Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2273 → Rev 2274

/MKLiveView/Source/MainForm.cs
206,6 → 206,10
public MainForm()
{
InitializeComponent();
_initForm();
}
void _initForm()
{
serChanTitle.Initialize();
 
_readIni();
228,7 → 232,6
 
TabControl1.TabPages.Remove(tabPageTesting); //a testing page
}
 
#region events
private void MainForm_Shown(object sender, EventArgs e)
{
240,11 → 243,18
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
_writeIni();
// after adding a second language the programm didn't close properly anymore
// so this is kinda workaround...
Dispose(true);
Environment.Exit(0);
}
private void SimpleSerialPort_PortOpened()
{
btnConn.Invoke((Action)(() => btnConn.BackColor = Color.FromArgb(192, 255, 192)));
btnConn.Invoke((Action)(() => btnConn.Text = "close" + Environment.NewLine + "serial port"));
if(Thread.CurrentThread.CurrentUICulture.Name== "")
btnConn.Invoke((Action)(() => btnConn.Text = "close" + Environment.NewLine + "serial port"));
else
btnConn.Invoke((Action)(() => btnConn.Text = "COM-Port" + Environment.NewLine + "schliessen"));
_getVersion();
Thread.Sleep(100);
_OSDMenue(0);
255,7 → 265,10
private void SimpleSerialPort_PortClosed()
{
btnConn.Invoke((Action)(() => btnConn.BackColor = Color.FromArgb(224, 224, 224)));
btnConn.Invoke((Action)(() => btnConn.Text = "open" + Environment.NewLine + "serial port"));
if (Thread.CurrentThread.CurrentUICulture.Name == "")
btnConn.Invoke((Action)(() => btnConn.Text = "open" + Environment.NewLine + "serial port"));
else
btnConn.Invoke((Action)(() => btnConn.Text = "COM-Port" + Environment.NewLine + "öffnen"));
_readCont(false);
}
/// <summary>
344,7 → 357,89
{
System.Diagnostics.Process.Start(e.LinkText);
}
/// <summary>
/// Combobox for selecting UI language
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cbLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbLanguage.SelectedIndex == 1)
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");
else
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("");
updateStringRessource();
}
/// <summary>
/// the form has to be recreated when changing the language of the UI
/// </summary>
private void updateStringRessource()
{
try
{
Point pt = this.Location;// memorize location of form
Size sz = this.Size;// memorize size of form
 
if (simpleSerialPort.Port.IsOpen)
{
simpleSerialPort.Port.Close();
Thread.Sleep(200);
_readCont(false);
Thread.Sleep(100);
while (simpleSerialPort.Port.IsOpen | bReadContinously)
Thread.Sleep(100);
}
 
this.Controls.Clear();// clear all controls of form
components.Dispose();// dispose all components and release resources
// delete all events to avoid double instances when calling InitializeComponent();
this.Events.Dispose();
if (timer1 != null)
{
timer1.Dispose();
timer1 = null;
}
_init = true;
timer1 = new System.Windows.Forms.Timer();
 
dtAnalog = new DataTable();
dtMotors1 = new DataTable();
dtMotors2 = new DataTable();
dtWaypoints = new DataTable();
 
InitializeComponent(); // reload UI
 
_dataTablesInit();
 
simpleSerialPort.PortClosed += SimpleSerialPort_PortClosed;
simpleSerialPort.PortOpened += SimpleSerialPort_PortOpened;
simpleSerialPort.DataReceived += processMessage;
 
chkbAutoBL.Checked = _blctrlDataAutorefresh;
chkbAutoDbg.Checked = _debugDataAutorefresh;
chkbAutoNav.Checked = _navCtrlDataAutorefresh;
chkbAutoOSD.Checked = _OSDAutorefresh;
 
labelTimingDebug.Text = (debugInterval * 10).ToString();
labelTimingBLCTRL.Text = (blctrlInterval * 10).ToString();
labelTimingNAV.Text = (navctrlInterval * 10).ToString();
labelTimingOSD.Text = (OSDInterval * 10).ToString();
 
TabControl1.TabPages.Remove(tabPageTesting); //a testing page
 
this.Size = sz;// set size
this.Location = pt;// position form
_loadLabelNames();
_initSerialCtrl();
_init = false;
 
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
 
#endregion events
 
/// <summary> Log data to the terminal window. </summary>
1159,7 → 1254,11
void _readCont(bool b)
{
bReadContinously = b;
btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.Text = bReadContinously ? "stop automatic" + Environment.NewLine + "data refresh" : "start automatic" + Environment.NewLine + "data refresh"));
 
if (Thread.CurrentThread.CurrentUICulture.Name == "")
btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.Text = bReadContinously ? "stop automatic" + Environment.NewLine + "data refresh" : "start automatic" + Environment.NewLine + "data refresh"));
else
btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.Text = bReadContinously ? "Aktualisierung" + Environment.NewLine + "beenden" : "Aktualisierung" + Environment.NewLine + "starten"));
btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.BackColor = bReadContinously ? Color.FromArgb(192, 255, 192) : Color.FromArgb(224, 224, 224)));
if (bReadContinously)
{
1256,10 → 1355,16
dataGridView1.DataSource = dtAnalog;
 
dtMotors1.Columns.Add("#");
dtMotors1.Columns.Add("Current");
if (Thread.CurrentThread.CurrentUICulture.Name == "")
dtMotors1.Columns.Add("Current");
else
dtMotors1.Columns.Add("Strom");
dtMotors1.Columns.Add("Temp");
dtMotors2.Columns.Add("#");
dtMotors2.Columns.Add("Current");
if (Thread.CurrentThread.CurrentUICulture.Name == "")
dtMotors2.Columns.Add("Current");
else
dtMotors2.Columns.Add("Strom");
dtMotors2.Columns.Add("Temp");
dgvMotors1.DataSource = dtMotors1;
dgvMotors2.DataSource = dtMotors2;