Subversion Repositories Projects

Rev

Rev 2265 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2265 Rev 2274
Line 204... Line 204...
204
        DataTable dtWaypoints = new DataTable();
204
        DataTable dtWaypoints = new DataTable();
Line 205... Line 205...
205
 
205
 
206
        public MainForm()
206
        public MainForm()
207
        {
207
        {
-
 
208
            InitializeComponent();
-
 
209
            _initForm();
-
 
210
        }
-
 
211
        void _initForm()
208
            InitializeComponent();
212
        {
Line 209... Line 213...
209
            serChanTitle.Initialize();
213
            serChanTitle.Initialize();
Line 210... Line 214...
210
 
214
 
Line 226... Line 230...
226
            labelTimingNAV.Text = (navctrlInterval * 10).ToString();
230
            labelTimingNAV.Text = (navctrlInterval * 10).ToString();
227
            labelTimingOSD.Text = (OSDInterval * 10).ToString();
231
            labelTimingOSD.Text = (OSDInterval * 10).ToString();
Line 228... Line 232...
228
 
232
 
229
            TabControl1.TabPages.Remove(tabPageTesting); //a testing page
233
            TabControl1.TabPages.Remove(tabPageTesting); //a testing page
230
        }
-
 
231
 
234
        }
232
        #region events
235
        #region events
233
        private void MainForm_Shown(object sender, EventArgs e)
236
        private void MainForm_Shown(object sender, EventArgs e)
234
        {
237
        {
235
            _loadLabelNames();
238
            _loadLabelNames();
Line 238... Line 241...
238
            splitContainer1.SplitterDistance = 510;
241
            splitContainer1.SplitterDistance = 510;
239
        }
242
        }
240
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
243
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
241
        {
244
        {
242
            _writeIni();
245
            _writeIni();
-
 
246
            // after adding a second language the programm didn't close properly anymore
-
 
247
            // so this is kinda workaround...
-
 
248
            Dispose(true);
-
 
249
            Environment.Exit(0);
243
        }
250
        }
244
        private void SimpleSerialPort_PortOpened()
251
        private void SimpleSerialPort_PortOpened()
245
        {
252
        {
246
            btnConn.Invoke((Action)(() => btnConn.BackColor = Color.FromArgb(192, 255, 192)));
253
            btnConn.Invoke((Action)(() => btnConn.BackColor = Color.FromArgb(192, 255, 192)));
-
 
254
            if(Thread.CurrentThread.CurrentUICulture.Name== "")
247
            btnConn.Invoke((Action)(() => btnConn.Text = "close" + Environment.NewLine + "serial port"));
255
                btnConn.Invoke((Action)(() => btnConn.Text = "close" + Environment.NewLine + "serial port"));
-
 
256
            else
-
 
257
                btnConn.Invoke((Action)(() => btnConn.Text = "COM-Port" + Environment.NewLine + "schliessen"));
248
            _getVersion();
258
            _getVersion();
249
            Thread.Sleep(100);
259
            Thread.Sleep(100);
250
            _OSDMenue(0);
260
            _OSDMenue(0);
251
            Thread.Sleep(200);
261
            Thread.Sleep(200);
252
            _sendSerialData();
262
            _sendSerialData();
253
           // _readCont(true);
263
           // _readCont(true);
254
        }
264
        }
255
        private void SimpleSerialPort_PortClosed()
265
        private void SimpleSerialPort_PortClosed()
256
        {
266
        {
257
            btnConn.Invoke((Action)(() => btnConn.BackColor = Color.FromArgb(224, 224, 224)));
267
            btnConn.Invoke((Action)(() => btnConn.BackColor = Color.FromArgb(224, 224, 224)));
-
 
268
            if (Thread.CurrentThread.CurrentUICulture.Name == "")
258
            btnConn.Invoke((Action)(() => btnConn.Text = "open" + Environment.NewLine + "serial port"));
269
                btnConn.Invoke((Action)(() => btnConn.Text = "open" + Environment.NewLine + "serial port"));
-
 
270
            else
-
 
271
                btnConn.Invoke((Action)(() => btnConn.Text = "COM-Port" + Environment.NewLine + "öffnen"));
259
            _readCont(false);
272
            _readCont(false);
260
        }
273
        }
261
        /// <summary>
274
        /// <summary>
262
        /// timer for refreshing subscription of subscribed data
275
        /// timer for refreshing subscription of subscribed data
263
        /// query lifecounter for connection failure
276
        /// query lifecounter for connection failure
Line 342... Line 355...
342
        }
355
        }
343
        private void rtfError_LinkClicked(object sender, LinkClickedEventArgs e)
356
        private void rtfError_LinkClicked(object sender, LinkClickedEventArgs e)
344
        {
357
        {
345
            System.Diagnostics.Process.Start(e.LinkText);
358
            System.Diagnostics.Process.Start(e.LinkText);
346
        }
359
        }
-
 
360
        /// <summary>
-
 
361
        /// Combobox for selecting UI language
-
 
362
        /// </summary>
-
 
363
        /// <param name="sender"></param>
-
 
364
        /// <param name="e"></param>
-
 
365
        private void cbLanguage_SelectedIndexChanged(object sender, EventArgs e)
-
 
366
        {
-
 
367
            if (cbLanguage.SelectedIndex == 1)
-
 
368
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");
-
 
369
            else
-
 
370
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("");
-
 
371
            updateStringRessource();
-
 
372
        }
-
 
373
        /// <summary>
-
 
374
        /// the form has to be recreated when changing the language of the UI
-
 
375
        /// </summary>
-
 
376
        private void updateStringRessource()
-
 
377
        {
-
 
378
            try
-
 
379
            {
-
 
380
                Point pt = this.Location;// memorize location of form
-
 
381
                Size sz = this.Size;// memorize size of form
-
 
382
 
-
 
383
                if (simpleSerialPort.Port.IsOpen)
-
 
384
                {
-
 
385
                    simpleSerialPort.Port.Close();
-
 
386
                    Thread.Sleep(200);
-
 
387
                    _readCont(false);
-
 
388
                    Thread.Sleep(100);
-
 
389
                    while (simpleSerialPort.Port.IsOpen | bReadContinously)
-
 
390
                        Thread.Sleep(100);
-
 
391
                }
-
 
392
 
-
 
393
                this.Controls.Clear();// clear all controls of form
-
 
394
                components.Dispose();// dispose all components and release resources
-
 
395
                // delete all events to avoid double instances when calling  InitializeComponent(); 
-
 
396
                this.Events.Dispose();
-
 
397
                if (timer1 != null)
-
 
398
                {
-
 
399
                    timer1.Dispose();
-
 
400
                    timer1 = null;
-
 
401
                }
-
 
402
                _init = true;
-
 
403
                timer1 = new System.Windows.Forms.Timer();
-
 
404
 
-
 
405
                dtAnalog = new DataTable();
-
 
406
                dtMotors1 = new DataTable();
-
 
407
                dtMotors2 = new DataTable();
-
 
408
                dtWaypoints = new DataTable();
-
 
409
 
-
 
410
                InitializeComponent(); // reload UI
-
 
411
 
-
 
412
                _dataTablesInit();
-
 
413
 
-
 
414
                simpleSerialPort.PortClosed += SimpleSerialPort_PortClosed;
-
 
415
                simpleSerialPort.PortOpened += SimpleSerialPort_PortOpened;
-
 
416
                simpleSerialPort.DataReceived += processMessage;
-
 
417
 
-
 
418
                chkbAutoBL.Checked = _blctrlDataAutorefresh;
-
 
419
                chkbAutoDbg.Checked = _debugDataAutorefresh;
-
 
420
                chkbAutoNav.Checked = _navCtrlDataAutorefresh;
-
 
421
                chkbAutoOSD.Checked = _OSDAutorefresh;
-
 
422
 
-
 
423
                labelTimingDebug.Text = (debugInterval * 10).ToString();
-
 
424
                labelTimingBLCTRL.Text = (blctrlInterval * 10).ToString();
-
 
425
                labelTimingNAV.Text = (navctrlInterval * 10).ToString();
-
 
426
                labelTimingOSD.Text = (OSDInterval * 10).ToString();
-
 
427
 
-
 
428
                TabControl1.TabPages.Remove(tabPageTesting); //a testing page
-
 
429
 
-
 
430
                this.Size = sz;// set size
-
 
431
                this.Location = pt;// position form
-
 
432
                _loadLabelNames();
-
 
433
                _initSerialCtrl();
-
 
434
                _init = false;
-
 
435
 
-
 
436
            }
-
 
437
            catch (Exception ex)
-
 
438
            {
-
 
439
                MessageBox.Show(ex.Message);
-
 
440
            }
-
 
441
        }
347
 
442
 
348
        #endregion events
443
        #endregion events
Line 349... Line 444...
349
 
444
 
350
        /// <summary> Log data to the terminal window. </summary>
445
        /// <summary> Log data to the terminal window. </summary>
351
        /// <param name="msgtype"> The type of message to be written. </param>
446
        /// <param name="msgtype"> The type of message to be written. </param>
Line 1157... Line 1252...
1157
        /// </summary>
1252
        /// </summary>
1158
        /// <param name="b">start/stop switch</param>
1253
        /// <param name="b">start/stop switch</param>
1159
        void _readCont(bool b)
1254
        void _readCont(bool b)
1160
        {
1255
        {
1161
            bReadContinously = b;
1256
            bReadContinously = b;
-
 
1257
 
-
 
1258
            if (Thread.CurrentThread.CurrentUICulture.Name == "")
1162
            btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.Text = bReadContinously ? "stop automatic" + Environment.NewLine + "data refresh" : "start automatic" + Environment.NewLine + "data refresh"));
1259
                btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.Text = bReadContinously ? "stop automatic" + Environment.NewLine + "data refresh" : "start automatic" + Environment.NewLine + "data refresh"));
-
 
1260
            else
-
 
1261
                btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.Text = bReadContinously ? "Aktualisierung" + Environment.NewLine + "beenden" : "Aktualisierung" + Environment.NewLine + "starten"));
1163
            btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.BackColor = bReadContinously ? Color.FromArgb(192, 255, 192) : Color.FromArgb(224, 224, 224)));
1262
            btnReadDebugCont.Invoke((Action)(() => btnReadDebugCont.BackColor = bReadContinously ? Color.FromArgb(192, 255, 192) : Color.FromArgb(224, 224, 224)));
1164
            if (bReadContinously)
1263
            if (bReadContinously)
1165
            {
1264
            {
1166
                if (_debugDataAutorefresh) { _readDebugData(true); Thread.Sleep(10); }
1265
                if (_debugDataAutorefresh) { _readDebugData(true); Thread.Sleep(10); }
1167
                if (_blctrlDataAutorefresh) { _readBLCtrl(true); Thread.Sleep(10); }
1266
                if (_blctrlDataAutorefresh) { _readBLCtrl(true); Thread.Sleep(10); }
Line 1254... Line 1353...
1254
            dtAnalog.Columns.Add("ID");
1353
            dtAnalog.Columns.Add("ID");
1255
            dtAnalog.Columns.Add("Value");
1354
            dtAnalog.Columns.Add("Value");
1256
            dataGridView1.DataSource = dtAnalog;
1355
            dataGridView1.DataSource = dtAnalog;
Line 1257... Line 1356...
1257
 
1356
 
-
 
1357
            dtMotors1.Columns.Add("#");
1258
            dtMotors1.Columns.Add("#");
1358
            if (Thread.CurrentThread.CurrentUICulture.Name == "")
-
 
1359
                dtMotors1.Columns.Add("Current");
-
 
1360
            else
1259
            dtMotors1.Columns.Add("Current");
1361
                dtMotors1.Columns.Add("Strom");
1260
            dtMotors1.Columns.Add("Temp");
1362
            dtMotors1.Columns.Add("Temp");
-
 
1363
            dtMotors2.Columns.Add("#");
1261
            dtMotors2.Columns.Add("#");
1364
            if (Thread.CurrentThread.CurrentUICulture.Name == "")
-
 
1365
                dtMotors2.Columns.Add("Current");
-
 
1366
            else
1262
            dtMotors2.Columns.Add("Current");
1367
                dtMotors2.Columns.Add("Strom");
1263
            dtMotors2.Columns.Add("Temp");
1368
            dtMotors2.Columns.Add("Temp");
1264
            dgvMotors1.DataSource = dtMotors1;
1369
            dgvMotors1.DataSource = dtMotors1;
1265
            dgvMotors2.DataSource = dtMotors2;
1370
            dgvMotors2.DataSource = dtMotors2;
1266
            _initDTMotors();
1371
            _initDTMotors();