Subversion Repositories Projects

Rev

Rev 2356 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2356 Rev 2359
Line 3249... Line 3249...
3249
                                    Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString());
3249
                                    Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString());
3250
                                    Dispatcher.Invoke(() => lblWPCount.Content = k.ToString());
3250
                                    Dispatcher.Invoke(() => lblWPCount.Content = k.ToString());
3251
                                    Dispatcher.Invoke(() => dgvWP.Items.Refresh());
3251
                                    Dispatcher.Invoke(() => dgvWP.Items.Refresh());
3252
                                    Thread.Sleep(10);
3252
                                    Thread.Sleep(10);
3253
                                }
3253
                                }
3254
                                Dispatcher.Invoke(() =>
-
 
3255
                                {
-
 
3256
                                    if (comboBoxRouteColor.SelectionBoxItem != null)
-
 
3257
                                    {
-
 
3258
                                        string s = comboBoxRouteColor.SelectionBoxItem.ToString();
-
 
3259
                                        mRouteWP = new GMapRoute(wpList, _getBrush(s));
-
 
3260
                                    }
-
 
3261
                                    else
3254
                                _routeUpdate();
3262
                                        mRouteWP = new GMapRoute(wpList, null);
-
 
3263
 
-
 
3264
                                    if (_bShowWPRoute)
-
 
3265
                                        MainMap.Markers.Add(mRouteWP);
-
 
3266
                                });
-
 
3267
 
-
 
3268
                                MapRoute mr = new MapRoute(wpList, "WPList");
-
 
3269
                                Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m"));
-
 
3270
 
-
 
3271
                            }
3255
                            }
3272
                        }
3256
                        }
3273
                    }
3257
                    }
Line 3274... Line 3258...
3274
 
3258
 
Line 3350... Line 3334...
3350
                    return Brushes.Yellow;
3334
                    return Brushes.Yellow;
3351
                default:
3335
                default:
3352
                    return Brushes.Magenta;
3336
                    return Brushes.Magenta;
3353
            }
3337
            }
3354
        }
3338
        }
-
 
3339
        void _routeUpdate()
-
 
3340
        {
-
 
3341
            Dispatcher.Invoke(() =>
-
 
3342
            {
-
 
3343
                if (comboBoxRouteColor.SelectionBoxItem != null)
-
 
3344
                {
-
 
3345
                    string s = comboBoxRouteColor.SelectionBoxItem.ToString();
-
 
3346
                    mRouteWP = new GMapRoute(wpList, _getBrush(s));
-
 
3347
                }
-
 
3348
                else
-
 
3349
                    mRouteWP = new GMapRoute(wpList, null);
-
 
3350
 
-
 
3351
                if (_bShowWPRoute)
-
 
3352
                    MainMap.Markers.Add(mRouteWP);
-
 
3353
            });
-
 
3354
 
-
 
3355
            MapRoute mr = new MapRoute(wpList, "WPList");
-
 
3356
            Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m"));
-
 
3357
 
-
 
3358
        }
3355
        void _setMarkerColor(GMapMarker wpMarker,int iType)
3359
        void _setMarkerColor(GMapMarker wpMarker,int iType)
3356
        {
3360
        {
3357
            Dispatcher.Invoke(() =>
3361
            Dispatcher.Invoke(() =>
3358
            {
3362
            {
3359
                switch (iType)
3363
                switch (iType)
Line 3575... Line 3579...
3575
                });
3579
                });
3576
            }
3580
            }
3577
        }
3581
        }
3578
        private void dgvWP_MouseUp(object sender, MouseButtonEventArgs e)
3582
        private void dgvWP_MouseUp(object sender, MouseButtonEventArgs e)
3579
        {
3583
        {
-
 
3584
            _dgvWPselectEditRow();
-
 
3585
        }
-
 
3586
        private void dgvWP_MouseDoubleClick(object sender, MouseButtonEventArgs e)
-
 
3587
        {
-
 
3588
        }
-
 
3589
        void _dgvWPselectEditRow()
-
 
3590
        {
3580
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
3591
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
3581
            {
3592
            {
3582
                Dispatcher.Invoke(() => {
3593
                Dispatcher.Invoke(() => {
3583
                    DataGridRow row;
3594
                    DataGridRow row;
3584
                    if (_wpEdit > -1)
3595
                    if (_wpEdit > -1)
Line 3597... Line 3608...
3597
 
3608
 
3598
                    _setWPEditFields(_wpEdit);
3609
                    _setWPEditFields(_wpEdit);
3599
                });
3610
                });
3600
            }
3611
            }
3601
        }
-
 
3602
        private void dgvWP_MouseDoubleClick(object sender, MouseButtonEventArgs e)
-
 
3603
        {
-
 
3604
        }
3612
        }
3605
        void _setWPEditFields(int index)
3613
        void _setWPEditFields(int index)
3606
        {
3614
        {
3607
            int iVal;
3615
            int iVal;
3608
            cbWPEditType.SelectedIndex = (int)dtWaypoints.Rows[index][1];
3616
            cbWPEditType.SelectedIndex = (int)dtWaypoints.Rows[index][1];
Line 3708... Line 3716...
3708
 
3716
 
3709
            }
3717
            }
3710
        }
3718
        }
3711
        private void btnWPEditAddCurrentPos_Click(object sender, RoutedEventArgs e)
3719
        private void btnWPEditAddCurrentPos_Click(object sender, RoutedEventArgs e)
3712
        {
-
 
3713
            cbWPEditType.SelectedIndex = dgvWP.ItemContainerGenerator.Items.Count;
-
 
3714
            tbWPEditPrefix.Text = "P";
-
 
3715
            tbWPEditLat.Text = copter.Position.Lat.ToString();
-
 
3716
            tbWPEditLon.Text = copter.Position.Lng.ToString();
-
 
3717
            tbWPEditAlt.Text = ((double)iAnalogData[4] / (double)10).ToString();
-
 
3718
 
-
 
3719
            cbWPEditHeading.SelectedIndex = 2;
-
 
3720
            tbWPEditHeading.Text = iAnalogData[10].ToString();
-
 
3721
            tbWPEditHeading.IsReadOnly = false;
-
 
3722
 
-
 
3723
            cbWPEditSpeed.SelectedIndex = 1;
-
 
3724
            tbWPEditSpeed.Text = "5.0";
-
 
3725
            tbWPEditSpeed.IsReadOnly = false;
-
 
3726
 
-
 
3727
            cbWPEditClimbrate.SelectedIndex = 1;
-
 
3728
            tbWPEditClimbrate.Text = "5.0";
-
 
3729
            tbWPEditClimbrate.IsReadOnly = false;
-
 
3730
 
-
 
3731
            tbWPEditRadius.Text = "10";
3720
        {
3732
            tbWPEditHoldtime.Text = "5";
-
 
3733
            tbWPEditAutoTrigger.Text = "0";
-
 
3734
 
-
 
3735
            cbWPEditCamAngle.SelectedIndex = 1;
-
 
3736
            tbWPEditCamAngle.Text = "AUTO";
-
 
Line -... Line 3721...
-
 
3721
            object[] o = new object[16];
-
 
3722
 
-
 
3723
            o[0] = dgvWP.ItemContainerGenerator.Items.Count+1;
-
 
3724
            o[1] = 0;
-
 
3725
           //     cbWPEditType.SelectedIndex = 0;
-
 
3726
          //  tbWPEditPrefix.Text = "P";
-
 
3727
            o[2] = "P" + o[0].ToString();
-
 
3728
         //   tbWPEditLat.Text = copter.Position.Lat.ToString();
-
 
3729
            o[3] = copter.Position.Lat;
-
 
3730
          //  tbWPEditLon.Text = copter.Position.Lng.ToString();
-
 
3731
            o[4] = copter.Position.Lng;            
-
 
3732
         //   tbWPEditAlt.Text = ((double)iAnalogData[4] / (double)10).ToString();
-
 
3733
            o[5] = iAnalogData[4].ToString();
-
 
3734
 
-
 
3735
        //    cbWPEditHeading.SelectedIndex = 2;
-
 
3736
            o[6] = tbWPEditHeading.Text = iAnalogData[10].ToString();
-
 
3737
        //    tbWPEditHeading.IsReadOnly = false;
-
 
3738
 
-
 
3739
       //     cbWPEditSpeed.SelectedIndex = 1;
-
 
3740
       //     tbWPEditSpeed.Text = "5.0";
-
 
3741
       //     tbWPEditSpeed.IsReadOnly = false;
-
 
3742
            o[7] = "50";
-
 
3743
 
-
 
3744
      //      cbWPEditClimbrate.SelectedIndex = 1;
-
 
3745
     //       tbWPEditClimbrate.Text = "5.0";
-
 
3746
     //       tbWPEditClimbrate.IsReadOnly = false;
-
 
3747
            o[8] = "50";
-
 
3748
 
-
 
3749
     //       tbWPEditRadius.Text = "10";
-
 
3750
            o[9] = "10";
-
 
3751
     //       tbWPEditHoldtime.Text = "5";
-
 
3752
            o[10] = "5";
-
 
3753
      //      tbWPEditAutoTrigger.Text = "0";
-
 
3754
            o[11] = "0";
-
 
3755
     //       cbWPEditCamAngle.SelectedIndex = 1;
-
 
3756
     //       tbWPEditCamAngle.Text = "AUTO";
-
 
3757
     //       tbWPEditCamAngle.IsReadOnly = true;
-
 
3758
            o[12] = "255";
3737
            tbWPEditCamAngle.IsReadOnly = true;
3759
 
-
 
3760
            o[13] = "0";
-
 
3761
           //     tbWPEditOut1.Text = "0";
-
 
3762
            o[14] = "0";
-
 
3763
            o[15] = "0";
-
 
3764
 
-
 
3765
            dtWaypoints.Rows.Add(o);
-
 
3766
            GMapMarker wpMarker = new GMapMarker(new PointLatLng((double)o[3], (double)o[4]));
-
 
3767
            wpMarker.Shape = new CustomMarkerWP(this, wpMarker, (string)o[2], (int)o[1]);
-
 
3768
            wpMarker.Offset = new System.Windows.Point(-11.5, -11.5);
-
 
3769
            wpMarker.ZIndex = 100;
-
 
3770
            _setMarkerColor(wpMarker, (int)o[1]);
-
 
3771
            MainMap.Markers.Add(wpMarker);
-
 
3772
            wpList.Add(new PointLatLng((double)o[3], (double)o[4]));
-
 
3773
            Dispatcher.Invoke(() => lblWPCount.Content = o[0].ToString());
-
 
3774
            if (mRouteWP != null)
-
 
3775
                MainMap.Markers.Remove(mRouteWP);
-
 
3776
            _routeUpdate();
-
 
3777
            Dispatcher.Invoke(() => {
-
 
3778
                dgvWP.Items.Refresh();
-
 
3779
                dgvWP.SelectedIndex = (int)o[0] -1;
-
 
3780
                dgvWP.UpdateLayout();
3738
 
3781
                _dgvWPselectEditRow();
Line 3739... Line 3782...
3739
            tbWPEditOut1.Text = "0";
3782
                });
3740
        }
3783
        }
3741
 
3784