Subversion Repositories Projects

Rev

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

Rev 2435 Rev 2437
Line 17... Line 17...
17
///You should have received a copy of the GNU General Public License
17
///You should have received a copy of the GNU General Public License
18
///along with cssRcon.  If not, see <http://www.gnu.org/licenses/>.
18
///along with cssRcon.  If not, see <http://www.gnu.org/licenses/>.
19
///
19
///
20
///============================================================================
20
///============================================================================
21
///Credits:
21
///Credits:
22
 
-
 
23
/// radioman (http://www.codeplex.com/site/users/view/radioman)
22
/// radioman (http://www.codeplex.com/site/users/view/radioman)
24
/// for his really GreatMaps! (http://greatmaps.codeplex.com/)
23
/// for his really GreatMaps! (http://greatmaps.codeplex.com/)
25
///
24
///
26
/// I made some changes to the source, so You need all files from this project here in order to compile and run
25
/// I made some changes to the source, so You need all files from this project here in order to compile and run
27
///
26
///
Line 357... Line 356...
357
        /// </summary>
356
        /// </summary>
358
        byte blctrlInterval = 75;
357
        byte blctrlInterval = 75;
359
        /// <summary>
358
        /// <summary>
360
        /// interval for sending NAV-CTRL status (multiplied by 10ms)
359
        /// interval for sending NAV-CTRL status (multiplied by 10ms)
361
        /// </summary>
360
        /// </summary>
362
        byte navctrlInterval = 80;
361
        byte navctrlInterval = 20;
363
        /// <summary>
362
        /// <summary>
364
        /// interval for sending OSD page update (multiplied by 10ms)
363
        /// interval for sending OSD page update (multiplied by 10ms)
365
        /// </summary>
364
        /// </summary>
366
        byte OSDInterval = 85;
365
        byte OSDInterval = 85;
367
        /// <summary>
366
        /// <summary>
Line 377... Line 376...
377
        static volatile int _iWPCount = -1;
376
        static volatile int _iWPCount = -1;
378
        static volatile int _iWPIndex = -1;
377
        static volatile int _iWPIndex = -1;
379
        int _iWPTimeout = 1000;
378
        int _iWPTimeout = 1000;
380
        bool _bGetWP = false;
379
        bool _bGetWP = false;
381
        bool _bShowWPRoute = false;
380
        bool _bShowWPRoute = false;
-
 
381
        bool _bAutoWPEdit = true;
382
        static volatile bool _bGetWPCount = false;
382
        static volatile bool _bGetWPCount = false;
383
        DataTable dtGPX = new DataTable();
383
        DataTable dtGPX = new DataTable();
384
        DataRow drGPX;
384
        DataRow drGPX;
385
        bool _bAirborne = false;
385
        bool _bAirborne = false;
386
        int _wpIndex = -1, _wpCount = 0, _wpEdit = -1;
386
        int _wpIndex = -1, _wpCount = 0, _wpEdit = -1;
Line -... Line 387...
-
 
387
 
-
 
388
        string _wpDefPrefix = "P";
-
 
389
        int _wpDefAltitude = 20;
-
 
390
        int _wpDefHeading = 0;
-
 
391
        int _wpDefCBoxHeading = 0;
-
 
392
        int _wpDefSpeed = 10;
-
 
393
        int _wpDefCBoxSpeed = 0;
-
 
394
        int _wpDefClimb = 10;
-
 
395
        int _wpDefCBoxClimb = 0;
-
 
396
        int _wpDefRadius = 5;
-
 
397
        int _wpDefHoldtime = 5;
-
 
398
        int _wpDefAutotrig = 0;
-
 
399
        int _wpDefCamangle = 0;
-
 
400
        int _wpDefCBoxCamangle = 0;
-
 
401
        int _wpDefOut1 = 0;
-
 
402
 
-
 
403
        bool _wpAddCopterHeight = true;
-
 
404
        bool _wpAddCopterHeading = true;
387
 
405
       
Line 388... Line 406...
388
        DispatcherTimer timer = new DispatcherTimer();
406
        DispatcherTimer timer = new DispatcherTimer();
389
 
407
 
390
        /// <summary>
408
        /// <summary>
391
        /// stuff for enabeling touch zoom for the map
409
        /// stuff for enabeling touch zoom for the map
392
        /// </summary>
410
        /// </summary>
-
 
411
        Point pTouch1 = new Point(0, 0), pTouch2 = new Point(0, 0);
393
        Point pTouch1 = new Point(0, 0), pTouch2 = new Point(0, 0);
412
        int iFirstStylusID = -1;
394
        int iFirstStylusID = -1;
413
 
395
        public string connectButtonText
414
        public string connectButtonText
396
        {
415
        {
397
            get
416
            get
398
            {
417
            {
399
                return bReadContinously ? "stop polling data" + System.Environment.NewLine + "from copter" : "start polling data" + System.Environment.NewLine + "from copter";
418
                return bReadContinously ? "stop polling data" + System.Environment.NewLine + "from copter" : "start polling data" + System.Environment.NewLine + "from copter";
Line 400... Line 419...
400
            }
419
            }
-
 
420
        }
401
        }
421
 
402
 
422
        WinState winState = new WinState();
403
        WinState winState = new WinState();
423
 
404
        #endregion declarations
424
        #endregion declarations
405
        public MainWindow()
425
        public MainWindow()
Line 457... Line 477...
457
            cBoxTimingsOSD.SelectedItem = OSDInterval * 10;
477
            cBoxTimingsOSD.SelectedItem = OSDInterval * 10;
458
            checkBoxAutoSetHP.IsChecked = _bAutoHome;
478
            checkBoxAutoSetHP.IsChecked = _bAutoHome;
459
            checkBoxFollowCopter.IsChecked = _bFollowCopter;
479
            checkBoxFollowCopter.IsChecked = _bFollowCopter;
460
            checkBoxGPXLog.IsChecked = _bGPXLog;
480
            checkBoxGPXLog.IsChecked = _bGPXLog;
461
            checkBoxShowWPRoute.IsChecked = _bShowWPRoute;
481
            checkBoxShowWPRoute.IsChecked = _bShowWPRoute;
462
 
-
 
-
 
482
            checkBoxAutoShowWPEdit.IsChecked = _bAutoWPEdit;
-
 
483
            checkBoxWPAddUseCopterHeight.IsChecked = _wpAddCopterHeight;
-
 
484
            checkBoxWPAddUseCopterHeading.IsChecked = _wpAddCopterHeading;
463
            GridSettings.Visibility = Visibility.Visible;
485
            GridSettings.Visibility = Visibility.Visible;
464
            GridData.Visibility = GridWP.Visibility = Visibility.Collapsed;
486
            GridData.Visibility = GridWP.Visibility = GridWPEdit.Visibility = Visibility.Collapsed;
465
            _initSerialCtrl();
487
            _initSerialCtrl();
466
        }
488
        }
467
        /// <summary>
489
        /// <summary>
468
        /// initialize the datatables
490
        /// initialize the datatables
469
        /// with columnnames etc
491
        /// with columnnames etc
Line 629... Line 651...
629
        private void labelWaypoints_MouseDown(object sender, MouseButtonEventArgs e)
651
        private void labelWaypoints_MouseDown(object sender, MouseButtonEventArgs e)
630
        {
652
        {
631
            GridData.Visibility = GridSettings.Visibility = Visibility.Collapsed;
653
            GridData.Visibility = GridSettings.Visibility = Visibility.Collapsed;
632
            GridWP.Visibility = GridWP.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
654
            GridWP.Visibility = GridWP.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
633
        }
655
        }
-
 
656
        private void labelWPEdit_MouseDown(object sender, MouseButtonEventArgs e)
-
 
657
        {
-
 
658
            GridWPEdit.Visibility = GridWPEdit.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
-
 
659
        }
Line 634... Line 660...
634
 
660
 
635
        private void btnGetWP_Click(object sender, RoutedEventArgs e)
661
        private void btnGetWP_Click(object sender, RoutedEventArgs e)
636
        {
662
        {
637
            Thread t = new Thread(new ThreadStart(_getWP));
663
            Thread t = new Thread(new ThreadStart(_getWP));
Line 744... Line 770...
744
        Point pWPAdd;
770
        Point pWPAdd;
745
        private void GridGMapControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
771
        private void GridGMapControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
746
        {
772
        {
747
            if(e.ClickCount == 2)
773
            if(e.ClickCount == 2)
748
            {
774
            {
-
 
775
                double x = 0, y = 0;
-
 
776
                var titleHeight = SystemParameters.WindowCaptionHeight + SystemParameters.ResizeFrameHorizontalBorderHeight;
-
 
777
 
749
                pWPAdd = new Point(e.GetPosition(this).X, e.GetPosition(this).Y);
778
                pWPAdd = new Point(e.GetPosition(this).X, e.GetPosition(this).Y);
-
 
779
                if (pWPAdd.X + canvasAddPoint.Width > Width)
-
 
780
                    x = pWPAdd.X - canvasAddPoint.Width;
-
 
781
                else
-
 
782
                    x = pWPAdd.X;
-
 
783
                if (pWPAdd.Y + canvasAddPoint.Height > Height - titleHeight)
-
 
784
                    y = pWPAdd.Y - canvasAddPoint.Height;
-
 
785
                else
-
 
786
                    y = pWPAdd.Y;
-
 
787
 
750
                canvasAddPoint.Margin = new Thickness(pWPAdd.X, pWPAdd.Y, canvasAddPoint.Margin.Left, canvasAddPoint.Margin.Bottom);
788
                canvasAddPoint.Margin = new Thickness(x, y, canvasAddPoint.Margin.Left, canvasAddPoint.Margin.Bottom);
751
                canvasAddPoint.Visibility = Visibility.Visible;
789
                canvasAddPoint.Visibility = Visibility.Visible;
752
            }
790
            }
Line 753... Line 791...
753
 
791
 
754
        }
792
        }
Line 3529... Line 3567...
3529
                if(sVal != "") comboBoxLandingColor.SelectedIndex = Convert.ToInt32(sVal);
3567
                if(sVal != "") comboBoxLandingColor.SelectedIndex = Convert.ToInt32(sVal);
3530
                sVal = ini.IniReadValue("waypoints", "routecolor");
3568
                sVal = ini.IniReadValue("waypoints", "routecolor");
3531
                if(sVal != "") comboBoxRouteColor.SelectedIndex = Convert.ToInt32(sVal);
3569
                if(sVal != "") comboBoxRouteColor.SelectedIndex = Convert.ToInt32(sVal);
3532
                sVal = ini.IniReadValue("waypoints", "showWPRoute");
3570
                sVal = ini.IniReadValue("waypoints", "showWPRoute");
3533
                if(sVal != "") _bShowWPRoute = Convert.ToBoolean(sVal);
3571
                if(sVal != "") _bShowWPRoute = Convert.ToBoolean(sVal);
-
 
3572
                sVal = ini.IniReadValue("waypoints", "autoShowWPEdit");
-
 
3573
                if(sVal != "") _bAutoWPEdit = Convert.ToBoolean(sVal);
3534
                sVal = ini.IniReadValue("waypoints", "showWPMaxRange");
3574
                sVal = ini.IniReadValue("waypoints", "showWPMaxRange");
3535
                if(sVal != "") checkBoxShowWPMaxRange.IsChecked = Convert.ToBoolean(sVal);
3575
                if(sVal != "") checkBoxShowWPMaxRange.IsChecked = Convert.ToBoolean(sVal);
3536
                sVal = ini.IniReadValue("waypoints", "WPMaxRangecolor");
3576
                sVal = ini.IniReadValue("waypoints", "WPMaxRangecolor");
3537
                if(sVal != "") comboBoxWPMaxRangeColor.SelectedIndex = Convert.ToInt32(sVal);
3577
                if(sVal != "") comboBoxWPMaxRangeColor.SelectedIndex = Convert.ToInt32(sVal);
-
 
3578
                sVal = ini.IniReadValue("waypoints", "WPDefPrefix");
-
 
3579
                if(sVal != "") _wpDefPrefix = sVal;
-
 
3580
                sVal = ini.IniReadValue("waypoints", "WPDefAltitude");
-
 
3581
                if(sVal != "") _wpDefAltitude = Convert.ToInt32(sVal);
-
 
3582
                sVal = ini.IniReadValue("waypoints", "WPDefHeading");
-
 
3583
                if(sVal != "") _wpDefHeading = Convert.ToInt32(sVal);
-
 
3584
                sVal = ini.IniReadValue("waypoints", "WPDefCBoxHeading");
-
 
3585
                if(sVal != "") _wpDefCBoxHeading = Convert.ToInt32(sVal);
-
 
3586
                sVal = ini.IniReadValue("waypoints", "WPDefSpeed");
-
 
3587
                if(sVal != "") _wpDefSpeed = Convert.ToInt32(sVal);
-
 
3588
                sVal = ini.IniReadValue("waypoints", "WPDefCBoxSpeed");
-
 
3589
                if(sVal != "") _wpDefCBoxSpeed = Convert.ToInt32(sVal);
-
 
3590
                sVal = ini.IniReadValue("waypoints", "WPDefClimb");
-
 
3591
                if(sVal != "") _wpDefClimb = Convert.ToInt32(sVal);
-
 
3592
                sVal = ini.IniReadValue("waypoints", "WPDefCBoxClimb");
-
 
3593
                if(sVal != "") _wpDefCBoxClimb = Convert.ToInt32(sVal);
-
 
3594
                sVal = ini.IniReadValue("waypoints", "WPDefRadius");
-
 
3595
                if(sVal != "") _wpDefRadius = Convert.ToInt32(sVal);
-
 
3596
                sVal = ini.IniReadValue("waypoints", "WPDefHoldtime");
-
 
3597
                if(sVal != "") _wpDefHoldtime = Convert.ToInt32(sVal);
-
 
3598
                sVal = ini.IniReadValue("waypoints", "WPDefAutotrig");
-
 
3599
                if(sVal != "") _wpDefAutotrig = Convert.ToInt32(sVal);
-
 
3600
                sVal = ini.IniReadValue("waypoints", "WPDefCamangle");
-
 
3601
                if(sVal != "") _wpDefCamangle = Convert.ToInt32(sVal);
-
 
3602
                sVal = ini.IniReadValue("waypoints", "WPDefCBoxCamangle");
-
 
3603
                if(sVal != "") _wpDefCBoxCamangle = Convert.ToInt32(sVal);
-
 
3604
                sVal = ini.IniReadValue("waypoints", "WPDefOut1");
-
 
3605
                if(sVal != "") _wpDefOut1 = Convert.ToInt32(sVal);
-
 
3606
                sVal = ini.IniReadValue("waypoints", "WPAddCopterHeight");
-
 
3607
                if (sVal != "") _wpAddCopterHeight = Convert.ToBoolean(sVal);
-
 
3608
                sVal = ini.IniReadValue("waypoints", "WPAddCopterHeading");
-
 
3609
                if (sVal != "") _wpAddCopterHeading = Convert.ToBoolean(sVal);
Line 3538... Line 3610...
3538
 
3610
 
3539
                for (int i = 0; i < 12; i++)
3611
                for (int i = 0; i < 12; i++)
3540
                {
3612
                {
3541
                    sVal = ini.IniReadValue("serial", "ch" + i.ToString() + "Val");
3613
                    sVal = ini.IniReadValue("serial", "ch" + i.ToString() + "Val");
Line 3639... Line 3711...
3639
                ini.IniWriteValue("waypoints", "copterheadingcolor", comboBoxCopterHeadingColor.SelectedIndex.ToString());
3711
                ini.IniWriteValue("waypoints", "copterheadingcolor", comboBoxCopterHeadingColor.SelectedIndex.ToString());
3640
                ini.IniWriteValue("waypoints", "landingcolor", comboBoxLandingColor.SelectedIndex.ToString());
3712
                ini.IniWriteValue("waypoints", "landingcolor", comboBoxLandingColor.SelectedIndex.ToString());
3641
                ini.IniWriteValue("waypoints", "routecolor", comboBoxRouteColor.SelectedIndex.ToString());
3713
                ini.IniWriteValue("waypoints", "routecolor", comboBoxRouteColor.SelectedIndex.ToString());
3642
                ini.IniWriteValue("waypoints", "showWPRoute", _bShowWPRoute.ToString());
3714
                ini.IniWriteValue("waypoints", "showWPRoute", _bShowWPRoute.ToString());
3643
                ini.IniWriteValue("waypoints", "showWPMaxRange", ((bool)checkBoxShowWPMaxRange.IsChecked).ToString());
3715
                ini.IniWriteValue("waypoints", "showWPMaxRange", ((bool)checkBoxShowWPMaxRange.IsChecked).ToString());
-
 
3716
                ini.IniWriteValue("waypoints", "autoShowWPEdit", ((bool)checkBoxAutoShowWPEdit.IsChecked).ToString());
3644
                ini.IniWriteValue("waypoints", "WPMaxRangecolor", comboBoxWPMaxRangeColor.SelectedIndex.ToString());
3717
                ini.IniWriteValue("waypoints", "WPMaxRangecolor", comboBoxWPMaxRangeColor.SelectedIndex.ToString());
-
 
3718
                ini.IniWriteValue("waypoints", "WPDefPrefix", _wpDefPrefix);
-
 
3719
                ini.IniWriteValue("waypoints", "WPDefAltitude", _wpDefAltitude.ToString());
-
 
3720
                ini.IniWriteValue("waypoints", "WPDefHeading", _wpDefHeading.ToString());
-
 
3721
                ini.IniWriteValue("waypoints", "WPDefCBoxHeading", _wpDefCBoxHeading.ToString());
-
 
3722
                ini.IniWriteValue("waypoints", "WPDefSpeed", _wpDefSpeed.ToString());
-
 
3723
                ini.IniWriteValue("waypoints", "WPDefCBoxSpeed", _wpDefCBoxSpeed.ToString());
-
 
3724
                ini.IniWriteValue("waypoints", "WPDefClimb", _wpDefClimb.ToString());
-
 
3725
                ini.IniWriteValue("waypoints", "WPDefCBoxClimb", _wpDefCBoxClimb.ToString());
-
 
3726
                ini.IniWriteValue("waypoints", "WPDefRadius", _wpDefRadius.ToString());
-
 
3727
                ini.IniWriteValue("waypoints", "WPDefHoldtime", _wpDefHoldtime.ToString());
-
 
3728
                ini.IniWriteValue("waypoints", "WPDefAutotrig", _wpDefAutotrig.ToString());
-
 
3729
                ini.IniWriteValue("waypoints", "WPDefCamangle", _wpDefCamangle.ToString());
-
 
3730
                ini.IniWriteValue("waypoints", "WPDefCBoxCamangle", _wpDefCBoxCamangle.ToString());
-
 
3731
                ini.IniWriteValue("waypoints", "WPDefOut1", _wpDefOut1.ToString());
-
 
3732
                ini.IniWriteValue("waypoints", "WPAddCopterHeight", _wpAddCopterHeight.ToString());
-
 
3733
                ini.IniWriteValue("waypoints", "WPAddCopterHeading", _wpAddCopterHeading.ToString());
-
 
3734
 
Line 3645... Line 3735...
3645
 
3735
 
3646
                for (int i = 0; i < 12; i++)
3736
                for (int i = 0; i < 12; i++)
3647
                {
3737
                {
3648
                    ini.IniWriteValue("serial", "ch" + i.ToString() + "Val", serChan[i].ToString());
3738
                    ini.IniWriteValue("serial", "ch" + i.ToString() + "Val", serChan[i].ToString());
Line 4285... Line 4375...
4285
 
4375
 
4286
            o[0] = dgvWP.ItemContainerGenerator.Items.Count + 1;
4376
            o[0] = dgvWP.ItemContainerGenerator.Items.Count + 1;
4287
            o[1] = type;
4377
            o[1] = type;
4288
            //     cbWPEditType.SelectedIndex = 0;
4378
            //     cbWPEditType.SelectedIndex = 0;
4289
            //  tbWPEditPrefix.Text = "P";
4379
            //  tbWPEditPrefix.Text = "P";
4290
            o[2] = "P" + o[0].ToString();
4380
            o[2] = _wpDefPrefix + o[0].ToString();
4291
            //   tbWPEditLat.Text = copter.Position.Lat.ToString();
4381
            //   tbWPEditLat.Text = copter.Position.Lat.ToString();
4292
            o[3] = p.Lat;
4382
            o[3] = p.Lat;
4293
            //  tbWPEditLon.Text = copter.Position.Lng.ToString();
4383
            //  tbWPEditLon.Text = copter.Position.Lng.ToString();
4294
            o[4] = p.Lng;
4384
            o[4] = p.Lng;
4295
            //   tbWPEditAlt.Text = ((double)iAnalogData[4] / (double)10).ToString();
4385
            //   lblWPEditAlt.Content = ((double)iAnalogData[4] / (double)10).ToString();
Line 4296... Line 4386...
4296
            o[5] = iAnalogData[4].ToString();
4386
            o[5] = _wpAddCopterHeight ? iAnalogData[4].ToString(): _wpDefAltitude.ToString();
4297
 
4387
 
4298
            //    cbWPEditHeading.SelectedIndex = 2;
4388
            cbWPEditHeading.SelectedIndex = _wpDefCBoxHeading;
4299
            o[6] = iAnalogData[10].ToString();
4389
            o[6] = _wpAddCopterHeading ? iAnalogData[10].ToString(): _wpDefHeading.ToString();
Line 4300... Line 4390...
4300
            //tbWPEditHeading.Text = iAnalogData[10].ToString();
4390
            //lblWPEditHeading.Content = iAnalogData[10].ToString();
4301
            //    tbWPEditHeading.IsReadOnly = false;
4391
            //    tbWPEditHeading.IsReadOnly = false;
4302
 
4392
 
4303
            //     cbWPEditSpeed.SelectedIndex = 1;
4393
            cbWPEditSpeed.SelectedIndex = _wpDefCBoxSpeed;
Line 4304... Line 4394...
4304
            //     tbWPEditSpeed.Text = "5.0";
4394
            //     tbWPEditSpeed.Text = "5.0";
4305
            //     tbWPEditSpeed.IsReadOnly = false;
4395
            //     tbWPEditSpeed.IsReadOnly = false;
4306
            o[7] = "10";
4396
            o[7] = _wpDefSpeed.ToString();
4307
 
4397
 
Line 4308... Line 4398...
4308
            //      cbWPEditClimbrate.SelectedIndex = 1;
4398
            cbWPEditClimbrate.SelectedIndex = _wpDefCBoxClimb;
4309
            //       tbWPEditClimbrate.Text = "5.0";
4399
            //       lblWPEditClimbrate.Content = "5.0";
4310
            //       tbWPEditClimbrate.IsReadOnly = false;
4400
            //       tbWPEditClimbrate.IsReadOnly = false;
4311
            o[8] = "10";
4401
            o[8] = _wpDefClimb.ToString();
4312
 
4402
 
4313
            //       tbWPEditRadius.Text = "10";
4403
            //       lblWPEditRadius.Content = "10";
4314
            o[9] = "5";
4404
            o[9] = _wpDefRadius.ToString();
4315
            //       tbWPEditHoldtime.Text = "5";
4405
            //       lblWPEditHoldtime.Content = "5";
4316
            o[10] = "5";
4406
            o[10] = _wpDefHoldtime.ToString();
4317
            //      tbWPEditAutoTrigger.Text = "0";
4407
            //      lblWPEditAutoTrigger.Content = "0";
Line 4318... Line 4408...
4318
            o[11] = "0";
4408
            o[11] = _wpDefAutotrig.ToString();
4319
            //       cbWPEditCamAngle.SelectedIndex = 1;
4409
            cbWPEditCamAngle.SelectedIndex = _wpDefCBoxCamangle;
4320
            //       tbWPEditCamAngle.Text = "AUTO";
4410
            //       lblWPEditCamAngle.Content = "AUTO";
4321
            //       tbWPEditCamAngle.IsReadOnly = true;
4411
            //       tbWPEditCamAngle.IsReadOnly = true;
Line 4322... Line 4412...
4322
            o[12] = "255";
4412
            o[12] = _wpDefCamangle.ToString();
4323
 
4413
 
4324
            o[13] = "0";
4414
            o[13] = "0";
Line 4606... Line 4696...
4606
                o[0] = dgvWP.SelectedIndex + 1;
4696
                o[0] = dgvWP.SelectedIndex + 1;
4607
                o[1] = cbWPEditType.SelectedIndex;
4697
                o[1] = cbWPEditType.SelectedIndex;
4608
                o[2] = tbWPEditPrefix.Text + (dgvWP.SelectedIndex + 1).ToString();
4698
                o[2] = tbWPEditPrefix.Text + (dgvWP.SelectedIndex + 1).ToString();
4609
                o[3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ','));
4699
                o[3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ','));
4610
                o[4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ','));
4700
                o[4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ','));
4611
                o[5] = tbWPEditAlt.Text;
4701
                o[5] = lblWPEditAlt.Content;
4612
                switch (cbWPEditHeading.SelectedIndex)
4702
                switch (cbWPEditHeading.SelectedIndex)
4613
                {
4703
                {
4614
                    case 0:
4704
                    case 0:
4615
                        o[6] = "0";
4705
                        o[6] = "0";
4616
                        break;
4706
                        break;
4617
                    case 1:
4707
                    case 1:
4618
                        o[6] = "-" + tbWPEditHeading.Text;
4708
                        o[6] = "-" + lblWPEditHeading.Content;
4619
                        break;
4709
                        break;
4620
                    case 2:
4710
                    case 2:
4621
                        o[6] = tbWPEditHeading.Text;
4711
                        o[6] = lblWPEditHeading.Content;
4622
                        break;
4712
                        break;
4623
                }
4713
                }
4624
                switch (cbWPEditSpeed.SelectedIndex)
4714
                switch (cbWPEditSpeed.SelectedIndex)
4625
                {
4715
                {
4626
                    case 0:
4716
                    case 0:
4627
                        o[7] = "0";
4717
                        o[7] = "0";
4628
                        break;
4718
                        break;
4629
                    case 1:
4719
                    case 1:
4630
                        o[7] = (System.Convert.ToDouble(tbWPEditSpeed.Text.Replace('.', ',')) * 10).ToString("0");
4720
                        o[7] = (System.Convert.ToDouble(lblWPEditSpeed.Content.ToString().Replace('.', ',')) * 10).ToString("0");
4631
                        break;
4721
                        break;
4632
                    case 2:
4722
                    case 2:
4633
                        o[7] = (256 - Convert.ToInt16(tbWPEditSpeed.Text)).ToString();
4723
                        o[7] = (256 - Convert.ToInt16(lblWPEditSpeed.Content)).ToString();
4634
                        break;
4724
                        break;
4635
                }
4725
                }
4636
                switch (cbWPEditClimbrate.SelectedIndex)
4726
                switch (cbWPEditClimbrate.SelectedIndex)
4637
                {
4727
                {
4638
                    case 0:
4728
                    case 0:
4639
                        o[8] = "255";
4729
                        o[8] = "255";
4640
                        break;
4730
                        break;
4641
                    case 1:
4731
                    case 1:
4642
                        o[8] = (System.Convert.ToDouble(tbWPEditClimbrate.Text.Replace('.', ',')) * 10).ToString("0");
4732
                        o[8] = (System.Convert.ToDouble(lblWPEditClimbrate.Content.ToString().Replace('.', ',')) * 10).ToString("0");
4643
                        break;
4733
                        break;
4644
                }
4734
                }
4645
                o[9] = tbWPEditRadius.Text;
4735
                o[9] = lblWPEditRadius.Content;
4646
                o[10] = tbWPEditHoldtime.Text;
4736
                o[10] = lblWPEditHoldtime.Content;
4647
                o[11] = tbWPEditAutoTrigger.Text;
4737
                o[11] = lblWPEditAutoTrigger.Content;
4648
                switch (cbWPEditCamAngle.SelectedIndex)
4738
                switch (cbWPEditCamAngle.SelectedIndex)
4649
                {
4739
                {
4650
                    case 0:
4740
                    case 0:
4651
                        o[12] = "0";
4741
                        o[12] = "0";
4652
                        break;
4742
                        break;
4653
                    case 1:
4743
                    case 1:
4654
                        o[12] = "255";
4744
                        o[12] = "255";
4655
                        break;
4745
                        break;
4656
                    case 2:
4746
                    case 2:
4657
                        o[12] = tbWPEditCamAngle.Text;
4747
                        o[12] = lblWPEditCamAngle.Content;
4658
                        break;
4748
                        break;
4659
                }
4749
                }
4660
                o[13] = 0;
4750
                o[13] = 0;
4661
                o[14] = tbWPEditOut1.Text;
4751
                o[14] = lblWPEditOut1.Content;
4662
                DataRow dr = dtWaypoints.NewRow();
4752
                DataRow dr = dtWaypoints.NewRow();
4663
                dr.ItemArray = o;
4753
                dr.ItemArray = o;
Line 4664... Line 4754...
4664
 
4754
 
4665
                if (_wpCount > 0)
4755
                if (_wpCount > 0)
Line 4714... Line 4804...
4714
                   {
4804
                   {
4715
                       row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 100, 255));
4805
                       row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 100, 255));
4716
                       row.BorderBrush = new SolidColorBrush(Colors.Aqua);
4806
                       row.BorderBrush = new SolidColorBrush(Colors.Aqua);
4717
                       row.BorderThickness = new Thickness(2);
4807
                       row.BorderThickness = new Thickness(2);
4718
                       dgvWP.UpdateLayout();
4808
                       dgvWP.UpdateLayout();
-
 
4809
                        if (GridWPEdit.Visibility == Visibility.Collapsed && _bAutoWPEdit)
-
 
4810
                            GridWPEdit.Visibility = Visibility.Visible;
Line 4719... Line 4811...
4719
 
4811
 
4720
                       _setWPEditFields(_wpEdit);
4812
                       _setWPEditFields(_wpEdit);
4721
                   }
4813
                   }
4722
                });
4814
                });
Line 4728... Line 4820...
4728
            lblWPEditIndex.Content = dtWaypoints.Rows[index][0].ToString();
4820
            lblWPEditIndex.Content = dtWaypoints.Rows[index][0].ToString();
4729
            cbWPEditType.SelectedIndex = (int)dtWaypoints.Rows[index][1];
4821
            cbWPEditType.SelectedIndex = (int)dtWaypoints.Rows[index][1];
4730
            tbWPEditPrefix.Text = dtWaypoints.Rows[index][2].ToString().Substring(0,1);
4822
            tbWPEditPrefix.Text = dtWaypoints.Rows[index][2].ToString().Substring(0,1);
4731
            tbWPEditLat.Text = dtWaypoints.Rows[index][3].ToString();
4823
            tbWPEditLat.Text = dtWaypoints.Rows[index][3].ToString();
4732
            tbWPEditLon.Text = dtWaypoints.Rows[index][4].ToString();
4824
            tbWPEditLon.Text = dtWaypoints.Rows[index][4].ToString();
-
 
4825
 
4733
            tbWPEditAlt.Text = dtWaypoints.Rows[index][5].ToString();
4826
            SliderAlt.Value = Convert.ToInt16(dtWaypoints.Rows[index][5]);
-
 
4827
 
4734
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][6]);
4828
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][6]);
-
 
4829
            SliderHeading.Value = Math.Abs(iVal);
4735
            if (iVal == 0)
4830
            if (iVal == 0)
4736
            {
4831
            {
4737
                cbWPEditHeading.SelectedIndex = 0;
4832
                cbWPEditHeading.SelectedIndex = 0;
4738
                tbWPEditHeading.Text = " - - -";
4833
              //  lblWPEditHeading.Content = " - - -";
4739
                tbWPEditHeading.IsReadOnly = true;
-
 
4740
            }
4834
            }
4741
            if (iVal > 0 && iVal < 360)
4835
            if (iVal > 0 && iVal < 360)
4742
            {
4836
            {
4743
                cbWPEditHeading.SelectedIndex = 2;
4837
                cbWPEditHeading.SelectedIndex = 2;
4744
                tbWPEditHeading.Text = iVal.ToString();
4838
              //  lblWPEditHeading.Content = iVal.ToString();
4745
                tbWPEditHeading.IsReadOnly = false;
-
 
4746
            }
4839
            }
4747
            if (iVal < 0)
4840
            if (iVal < 0)
4748
            {
4841
            {
4749
                cbWPEditHeading.SelectedIndex = 1;
4842
                cbWPEditHeading.SelectedIndex = 1;
4750
                tbWPEditHeading.Text = (Math.Abs(iVal).ToString());
4843
             //   lblWPEditHeading.Content = (Math.Abs(iVal).ToString());
4751
                tbWPEditHeading.IsReadOnly = false;
-
 
4752
            }
4844
            }
4753
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][7]);
4845
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][7]);
-
 
4846
            SliderSpeed.Value = (double)iVal * 0.1;                                                  //------------!!!!!!!!
4754
            if (iVal == 0)
4847
            if (iVal == 0)
4755
            {
4848
            {
4756
                cbWPEditSpeed.SelectedIndex = 0;
4849
                cbWPEditSpeed.SelectedIndex = 0;
4757
                tbWPEditSpeed.Text = "MAX";
4850
              //  lblWPEditSpeed.Content = "MAX";
4758
                tbWPEditSpeed.IsReadOnly = true;
-
 
4759
            }
4851
            }
4760
            if (iVal > 0 && iVal < 248)
4852
            if (iVal > 0 && iVal < 248)
4761
            {
4853
            {
4762
                cbWPEditSpeed.SelectedIndex = 1;
4854
                cbWPEditSpeed.SelectedIndex = 1;
4763
                tbWPEditSpeed.Text = ((double)iVal * 0.1).ToString();
4855
              //  lblWPEditSpeed.Content = ((double)iVal * 0.1).ToString();
4764
                tbWPEditSpeed.IsReadOnly = false;
-
 
4765
            }
4856
            }
4766
            if (iVal > 247)
4857
            if (iVal > 247)
4767
            {
4858
            {
4768
                cbWPEditSpeed.SelectedIndex = 256 - iVal + 1;
4859
                cbWPEditSpeed.SelectedIndex = 256 - iVal + 1;
4769
                tbWPEditSpeed.Text = "";
4860
              //  lblWPEditSpeed.Content = "";
4770
                tbWPEditSpeed.IsReadOnly = true;
-
 
4771
            }
4861
            }
4772
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][8]);
4862
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][8]);
-
 
4863
            SliderClimbrate.Value = (System.Convert.ToDouble(iVal) / 10);                              //------------!!!!!!!!
4773
            if (iVal == 255)
4864
            if (iVal == 255)
4774
            {
4865
            {
4775
                cbWPEditClimbrate.SelectedIndex = 0;
4866
                cbWPEditClimbrate.SelectedIndex = 0;
4776
                tbWPEditClimbrate.Text = "AUTO";
4867
             //   lblWPEditClimbrate.Content = "AUTO";
4777
                tbWPEditClimbrate.IsReadOnly = true;
-
 
4778
            }
4868
            }
4779
            else
4869
            else
4780
            {
4870
            {
4781
                cbWPEditClimbrate.SelectedIndex = 1;
4871
                cbWPEditClimbrate.SelectedIndex = 1;
4782
                tbWPEditClimbrate.Text = (System.Convert.ToDouble(iVal) / 10).ToString("0.0");
4872
               // lblWPEditClimbrate.Content = (System.Convert.ToDouble(iVal) / 10).ToString("0.0");
4783
                tbWPEditClimbrate.IsReadOnly = false;
-
 
4784
            }
4873
            }
4785
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][9]);
4874
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][9]);
4786
            tbWPEditRadius.Text = iVal.ToString();
4875
            SliderRadius.Value = iVal;
4787
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][10]);
4876
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][10]);
4788
            tbWPEditHoldtime.Text = iVal.ToString();
4877
            SliderHoldTime.Value = iVal;
4789
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][11]);
4878
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][11]);
4790
            tbWPEditAutoTrigger.Text = iVal.ToString();
4879
            SliderAutoTrigger.Value = iVal;
4791
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][12]);
4880
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][12]);
-
 
4881
            SliderCamAngle.Value = iVal;
4792
            if (iVal == 0)
4882
            if (iVal == 0)
4793
            {
4883
            {
4794
                cbWPEditCamAngle.SelectedIndex = 0;
4884
                cbWPEditCamAngle.SelectedIndex = 0;
4795
                tbWPEditCamAngle.Text = " - - - ";
4885
              //  lblWPEditCamAngle.Content = " - - - ";
4796
                tbWPEditCamAngle.IsReadOnly = true;
-
 
4797
            }
4886
            }
4798
            if (iVal < 0 | iVal == 255)
4887
            if (iVal < 0 | iVal == 255)
4799
            {
4888
            {
4800
                cbWPEditCamAngle.SelectedIndex = 1;
4889
                cbWPEditCamAngle.SelectedIndex = 1;
4801
                tbWPEditCamAngle.Text = "AUTO";
4890
              //  lblWPEditCamAngle.Content = "AUTO";
4802
                tbWPEditCamAngle.IsReadOnly = true;
-
 
4803
            }
4891
            }
4804
            if (iVal > 0 & iVal < 255)
4892
            if (iVal > 0 & iVal < 255)
4805
            {
4893
            {
4806
                cbWPEditCamAngle.SelectedIndex = 2;
4894
                cbWPEditCamAngle.SelectedIndex = 2;
4807
                tbWPEditCamAngle.Text = iVal.ToString();
4895
             //   lblWPEditCamAngle.Content = iVal.ToString();
4808
                tbWPEditCamAngle.IsReadOnly = false;
-
 
4809
            }
4896
            }
4810
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][14]);
4897
            iVal = Convert.ToInt16(dtWaypoints.Rows[index][14]);
4811
            tbWPEditOut1.Text = iVal.ToString();
4898
            SliderOut1.Value = iVal;
4812
 
-
 
4813
        }
4899
        }
4814
        private void btnEditWPSave_Click(object sender, RoutedEventArgs e)
4900
        private void btnEditWPSave_Click(object sender, RoutedEventArgs e)
4815
        {
4901
        {
4816
            if(dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
4902
            if(dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
4817
            {
4903
            {
Line 4847... Line 4933...
4847
                        }
4933
                        }
4848
                        wpList.Insert(found, new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4]));
4934
                        wpList.Insert(found, new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4]));
4849
                        wpOffset.Insert(found, dgvWP.SelectedIndex);
4935
                        wpOffset.Insert(found, dgvWP.SelectedIndex);
4850
                    }
4936
                    }
4851
                }
4937
                }
4852
                dtWaypoints.Rows[dgvWP.SelectedIndex][5] = tbWPEditAlt.Text;
4938
                dtWaypoints.Rows[dgvWP.SelectedIndex][5] = lblWPEditAlt.Content;
4853
                switch (cbWPEditHeading.SelectedIndex)
4939
                switch (cbWPEditHeading.SelectedIndex)
4854
                {
4940
                {
4855
                    case 0:
4941
                    case 0:
4856
                        dtWaypoints.Rows[dgvWP.SelectedIndex][6] = "0";
4942
                        dtWaypoints.Rows[dgvWP.SelectedIndex][6] = "0";
4857
                        break;
4943
                        break;
4858
                    case 1:
4944
                    case 1:
4859
                        dtWaypoints.Rows[dgvWP.SelectedIndex][6] = "-" + tbWPEditHeading.Text;
4945
                        dtWaypoints.Rows[dgvWP.SelectedIndex][6] = "-" + lblWPEditHeading.Content;
4860
                        break;
4946
                        break;
4861
                    case 2:
4947
                    case 2:
4862
                        dtWaypoints.Rows[dgvWP.SelectedIndex][6] = tbWPEditHeading.Text;
4948
                        dtWaypoints.Rows[dgvWP.SelectedIndex][6] = lblWPEditHeading.Content;
4863
                        break;
4949
                        break;
4864
                }
4950
                }
4865
                switch (cbWPEditSpeed.SelectedIndex)
4951
                switch (cbWPEditSpeed.SelectedIndex)
4866
                {
4952
                {
4867
                    case 0:
4953
                    case 0:
4868
                        dtWaypoints.Rows[dgvWP.SelectedIndex][7] = "0";
4954
                        dtWaypoints.Rows[dgvWP.SelectedIndex][7] = "0";
4869
                        break;
4955
                        break;
4870
                    case 1:
4956
                    case 1:
4871
                        dtWaypoints.Rows[dgvWP.SelectedIndex][7] = (System.Convert.ToDouble(tbWPEditSpeed.Text.Replace('.', ',')) * 10).ToString("0");
4957
                        dtWaypoints.Rows[dgvWP.SelectedIndex][7] = (System.Convert.ToDouble(lblWPEditSpeed.Content.ToString().Replace('.', ',')) * 10).ToString("0");
4872
                        break;
4958
                        break;
4873
                    case 2:
4959
                    case 2:
4874
                        dtWaypoints.Rows[dgvWP.SelectedIndex][7] = (256 - Convert.ToInt16(tbWPEditSpeed.Text)).ToString();
4960
                        dtWaypoints.Rows[dgvWP.SelectedIndex][7] = (256 - Convert.ToInt16(lblWPEditSpeed.Content)).ToString();
4875
                        break;
4961
                        break;
4876
                }
4962
                }
4877
                switch (cbWPEditClimbrate.SelectedIndex)
4963
                switch (cbWPEditClimbrate.SelectedIndex)
4878
                {
4964
                {
4879
                    case 0:
4965
                    case 0:
4880
                        dtWaypoints.Rows[dgvWP.SelectedIndex][8] = "255";
4966
                        dtWaypoints.Rows[dgvWP.SelectedIndex][8] = "255";
4881
                        break;
4967
                        break;
4882
                    case 1:
4968
                    case 1:
4883
                        dtWaypoints.Rows[dgvWP.SelectedIndex][8] = (System.Convert.ToDouble(tbWPEditClimbrate.Text.Replace('.',',')) * 10).ToString("0");
4969
                        dtWaypoints.Rows[dgvWP.SelectedIndex][8] = (System.Convert.ToDouble(lblWPEditClimbrate.Content.ToString().Replace('.',',')) * 10).ToString("0");
4884
                        break;
4970
                        break;
4885
                }
4971
                }
4886
                dtWaypoints.Rows[dgvWP.SelectedIndex][9] = tbWPEditRadius.Text;
4972
                dtWaypoints.Rows[dgvWP.SelectedIndex][9] = lblWPEditRadius.Content;
4887
                dtWaypoints.Rows[dgvWP.SelectedIndex][10] = tbWPEditHoldtime.Text;
4973
                dtWaypoints.Rows[dgvWP.SelectedIndex][10] = lblWPEditHoldtime.Content;
4888
                dtWaypoints.Rows[dgvWP.SelectedIndex][11] = tbWPEditAutoTrigger.Text;
4974
                dtWaypoints.Rows[dgvWP.SelectedIndex][11] = lblWPEditAutoTrigger.Content;
4889
                switch (cbWPEditCamAngle.SelectedIndex)
4975
                switch (cbWPEditCamAngle.SelectedIndex)
4890
                {
4976
                {
4891
                    case 0:
4977
                    case 0:
4892
                        dtWaypoints.Rows[dgvWP.SelectedIndex][12] = "0";
4978
                        dtWaypoints.Rows[dgvWP.SelectedIndex][12] = "0";
4893
                        break;
4979
                        break;
4894
                    case 1:
4980
                    case 1:
4895
                        dtWaypoints.Rows[dgvWP.SelectedIndex][12] = "255";
4981
                        dtWaypoints.Rows[dgvWP.SelectedIndex][12] = "255";
4896
                        break;
4982
                        break;
4897
                    case 2:
4983
                    case 2:
4898
                        dtWaypoints.Rows[dgvWP.SelectedIndex][12] = tbWPEditCamAngle.Text;
4984
                        dtWaypoints.Rows[dgvWP.SelectedIndex][12] = lblWPEditCamAngle.Content;
4899
                        break;
4985
                        break;
4900
                }
4986
                }
4901
                dtWaypoints.Rows[dgvWP.SelectedIndex][14] = tbWPEditOut1.Text;
4987
                dtWaypoints.Rows[dgvWP.SelectedIndex][14] = lblWPEditOut1.Content;
Line 4902... Line 4988...
4902
 
4988
 
4903
                // _clearMapMarkers(typeof(CustomMarkerWP));
4989
                // _clearMapMarkers(typeof(CustomMarkerWP));
4904
                _repositionWPMarker(new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4]),oldName);
4990
                _repositionWPMarker(new PointLatLng((double)dtWaypoints.Rows[dgvWP.SelectedIndex][3], (double)dtWaypoints.Rows[dgvWP.SelectedIndex][4]),oldName);
4905
                _renameWPMarker(oldName, (string)dtWaypoints.Rows[dgvWP.SelectedIndex][2]);
4991
                _renameWPMarker(oldName, (string)dtWaypoints.Rows[dgvWP.SelectedIndex][2]);
Line 4926... Line 5012...
4926
            dr[0] = dtWaypoints.Rows.Count+1;
5012
            dr[0] = dtWaypoints.Rows.Count+1;
4927
            dr[1] = cbWPEditType.SelectedIndex;
5013
            dr[1] = cbWPEditType.SelectedIndex;
4928
            dr[2] = tbWPEditPrefix.Text + dr[0].ToString();
5014
            dr[2] = tbWPEditPrefix.Text + dr[0].ToString();
4929
            dr[3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ',')) + 0.00000001;
5015
            dr[3] = Convert.ToDouble(tbWPEditLat.Text.Replace('.', ',')) + 0.00000001;
4930
            dr[4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ',')) + 0.00000001;
5016
            dr[4] = Convert.ToDouble(tbWPEditLon.Text.Replace('.', ',')) + 0.00000001;
4931
            dr[5] = tbWPEditAlt.Text;
5017
            dr[5] = lblWPEditAlt.Content;
4932
            switch (cbWPEditHeading.SelectedIndex)
5018
            switch (cbWPEditHeading.SelectedIndex)
4933
            {
5019
            {
4934
                case 0:
5020
                case 0:
4935
                    dr[6] = "0";
5021
                    dr[6] = "0";
4936
                    break;
5022
                    break;
4937
                case 1:
5023
                case 1:
4938
                    dr[6] = "-" + tbWPEditHeading.Text;
5024
                    dr[6] = "-" + lblWPEditHeading.Content;
4939
                    break;
5025
                    break;
4940
                case 2:
5026
                case 2:
4941
                    dr[6] = tbWPEditHeading.Text;
5027
                    dr[6] = lblWPEditHeading.Content;
4942
                    break;
5028
                    break;
4943
            }
5029
            }
4944
            switch (cbWPEditSpeed.SelectedIndex)
5030
            switch (cbWPEditSpeed.SelectedIndex)
4945
            {
5031
            {
4946
                case 0:
5032
                case 0:
4947
                    dr[7] = "0";
5033
                    dr[7] = "0";
4948
                    break;
5034
                    break;
4949
                case 1:
5035
                case 1:
4950
                    dr[7] = (System.Convert.ToDouble(tbWPEditSpeed.Text.Replace('.', ',')) * 10).ToString("0");
5036
                    dr[7] = (System.Convert.ToDouble(lblWPEditSpeed.Content.ToString().Replace('.', ',')) * 10).ToString("0");
4951
                    break;
5037
                    break;
4952
                case 2:
5038
                case 2:
4953
                    dr[7] = (256 - Convert.ToInt16(tbWPEditSpeed.Text)).ToString();
5039
                    dr[7] = (256 - Convert.ToInt16(lblWPEditSpeed.Content)).ToString();
4954
                    break;
5040
                    break;
4955
            }
5041
            }
4956
            switch (cbWPEditClimbrate.SelectedIndex)
5042
            switch (cbWPEditClimbrate.SelectedIndex)
4957
            {
5043
            {
4958
                case 0:
5044
                case 0:
4959
                    dr[8] = "255";
5045
                    dr[8] = "255";
4960
                    break;
5046
                    break;
4961
                case 1:
5047
                case 1:
4962
                    dr[8] = (System.Convert.ToDouble(tbWPEditClimbrate.Text.Replace('.', ',')) * 10).ToString("0");
5048
                    dr[8] = (System.Convert.ToDouble(lblWPEditClimbrate.Content.ToString().Replace('.', ',')) * 10).ToString("0");
4963
                    break;
5049
                    break;
4964
            }
5050
            }
4965
            dr[9] = tbWPEditRadius.Text;
5051
            dr[9] = lblWPEditRadius.Content;
4966
            dr[10] = tbWPEditHoldtime.Text;
5052
            dr[10] = lblWPEditHoldtime.Content;
4967
            dr[11] = tbWPEditAutoTrigger.Text;
5053
            dr[11] = lblWPEditAutoTrigger.Content;
4968
            switch (cbWPEditCamAngle.SelectedIndex)
5054
            switch (cbWPEditCamAngle.SelectedIndex)
4969
            {
5055
            {
4970
                case 0:
5056
                case 0:
4971
                    dr[12] = "0";
5057
                    dr[12] = "0";
4972
                    break;
5058
                    break;
4973
                case 1:
5059
                case 1:
4974
                    dr[12] = "255";
5060
                    dr[12] = "255";
4975
                    break;
5061
                    break;
4976
                case 2:
5062
                case 2:
4977
                    dr[12] = tbWPEditCamAngle.Text;
5063
                    dr[12] = lblWPEditCamAngle.Content;
4978
                    break;
5064
                    break;
4979
            }
5065
            }
4980
            dr[13] = "";
5066
            dr[13] = "";
4981
            dr[14] = tbWPEditOut1.Text;
5067
            dr[14] = lblWPEditOut1.Content;
4982
            dr[15] = "";
5068
            dr[15] = "";
4983
            _createWP(new PointLatLng((double)dr[3], (double)dr[4]),(string) dr[2], (int)dr[1], (int)dr[0]);
5069
            _createWP(new PointLatLng((double)dr[3], (double)dr[4]),(string) dr[2], (int)dr[1], (int)dr[0]);
4984
            if (mRouteWP != null)
5070
            if (mRouteWP != null)
4985
                MainMap.Markers.Remove(mRouteWP);
5071
                MainMap.Markers.Remove(mRouteWP);
4986
            _routeUpdate();
5072
            _routeUpdate();
Line 5122... Line 5208...
5122
        }
5208
        }
5123
        private void btnWPAddCurrentPos_Click(object sender, RoutedEventArgs e)
5209
        private void btnWPAddCurrentPos_Click(object sender, RoutedEventArgs e)
5124
        {
5210
        {
5125
            _addWP(new PointLatLng(copter.Position.Lat, copter.Position.Lng),0);
5211
            _addWP(new PointLatLng(copter.Position.Lat, copter.Position.Lng),0);
5126
        }
5212
        }
-
 
5213
        private void checkBoxWPAddUseCopterHeading_Click(object sender, RoutedEventArgs e)
-
 
5214
        {
-
 
5215
            _wpAddCopterHeading = (bool)checkBoxWPAddUseCopterHeading.IsChecked;
-
 
5216
        }
-
 
5217
        private void checkBoxWPAddUseCopterHeight_Click(object sender, RoutedEventArgs e)
-
 
5218
        {
-
 
5219
            _wpAddCopterHeight = (bool)checkBoxWPAddUseCopterHeight.IsChecked;
-
 
5220
        }
-
 
5221
        private void btnSaveDefault_Click(object sender, RoutedEventArgs e)
-
 
5222
        {
-
 
5223
            _wpDefPrefix = tbWPEditPrefix.Text;
-
 
5224
            _wpDefAltitude = Convert.ToInt16(lblWPEditAlt.Content);
-
 
5225
            switch (cbWPEditHeading.SelectedIndex)
-
 
5226
            {
-
 
5227
                case 0:
-
 
5228
                    _wpDefHeading = 0;
-
 
5229
                    break;
-
 
5230
                case 1:
-
 
5231
                    _wpDefHeading = -Convert.ToInt16(lblWPEditHeading.Content);
-
 
5232
                    break;
-
 
5233
                case 2:
-
 
5234
                    _wpDefHeading = Convert.ToInt16(lblWPEditHeading.Content);
-
 
5235
                    break;
-
 
5236
            }            
-
 
5237
            _wpDefCBoxHeading = cbWPEditHeading.SelectedIndex;
-
 
5238
            switch (cbWPEditSpeed.SelectedIndex)
-
 
5239
            {
-
 
5240
                case 0:
-
 
5241
                    _wpDefSpeed = 0;
-
 
5242
                    break;
-
 
5243
                case 1:
-
 
5244
                    _wpDefSpeed = (int)(System.Convert.ToDouble(lblWPEditSpeed.Content.ToString().Replace('.', ',')) * 10);
-
 
5245
                    break;
-
 
5246
                case 2:
-
 
5247
                    _wpDefSpeed = 256 - Convert.ToInt16(lblWPEditSpeed.Content);
-
 
5248
                    break;
-
 
5249
            }
-
 
5250
            _wpDefCBoxSpeed = cbWPEditSpeed.SelectedIndex;
-
 
5251
            switch (cbWPEditClimbrate.SelectedIndex)
-
 
5252
            {
-
 
5253
                case 0:
-
 
5254
                    _wpDefClimb = 255;
-
 
5255
                    break;
-
 
5256
                case 1:
-
 
5257
                    _wpDefClimb = (int)(System.Convert.ToDouble(lblWPEditClimbrate.Content.ToString().Replace('.', ',')) * 10);
-
 
5258
                    break;
-
 
5259
            }
-
 
5260
            _wpDefCBoxClimb = cbWPEditClimbrate.SelectedIndex;
-
 
5261
            _wpDefRadius = Convert.ToInt16(lblWPEditRadius.Content);
-
 
5262
            _wpDefHoldtime = Convert.ToInt16(lblWPEditHoldtime.Content);
-
 
5263
            _wpDefAutotrig = Convert.ToInt16(lblWPEditAutoTrigger.Content);
-
 
5264
            switch (cbWPEditCamAngle.SelectedIndex)
-
 
5265
            {
-
 
5266
                case 0:
-
 
5267
                    _wpDefCamangle = 0;
-
 
5268
                    break;
-
 
5269
                case 1:
-
 
5270
                    _wpDefCamangle = 255;
-
 
5271
                    break;
-
 
5272
                case 2:
-
 
5273
                    _wpDefCamangle = Convert.ToInt16(lblWPEditCamAngle.Content);
-
 
5274
                    break;
-
 
5275
            }
-
 
5276
            _wpDefCBoxCamangle = cbWPEditCamAngle.SelectedIndex;
-
 
5277
            _wpDefOut1 = Convert.ToInt16(lblWPEditOut1.Content);
-
 
5278
        }
Line 5127... Line 5279...
5127
 
5279
 
5128
        private void btnWPEditmoveUp_Click(object sender, RoutedEventArgs e)
5280
        private void btnWPEditmoveUp_Click(object sender, RoutedEventArgs e)
5129
        {
5281
        {
5130
            if (dgvWP.SelectedIndex > 0 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
5282
            if (dgvWP.SelectedIndex > 0 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
Line 5264... Line 5416...
5264
            }
5416
            }
Line 5265... Line 5417...
5265
 
5417
 
5266
            if (checkBoxShowWPMaxRange.IsChecked == false && (cWPBound != null && cWPBound.Tag != null))
5418
            if (checkBoxShowWPMaxRange.IsChecked == false && (cWPBound != null && cWPBound.Tag != null))
5267
                MainMap.Markers.Remove(cWPBound.Tag as GMapMarker);
5419
                MainMap.Markers.Remove(cWPBound.Tag as GMapMarker);
-
 
5420
        }
-
 
5421
        private void checkBoxAutoShowWPEdit_Click(object sender, RoutedEventArgs e)
-
 
5422
        {
-
 
5423
             _bAutoWPEdit = (bool)checkBoxAutoShowWPEdit.IsChecked;
-
 
5424
        }
5268
        }
5425
 
5269
        #endregion WP
5426
        #endregion WP
5270
        #region GPX
5427
        #region GPX
5271
        private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e)
5428
        private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e)
5272
        {
5429
        {