Subversion Repositories Projects

Rev

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

Rev 2408 Rev 2419
Line 811... Line 811...
811
                if (p.GetType() == markerType | (p.Shape != null && p.Shape.GetType() == markerType))
811
                if (p.GetType() == markerType | (p.Shape != null && p.Shape.GetType() == markerType))
812
                    MainMap.Markers.Remove(p);
812
                    MainMap.Markers.Remove(p);
813
                else
813
                else
814
                    k++;
814
                    k++;
815
            }
815
            }
816
 
-
 
-
 
816
            _WPisMouseCaptured = false;
817
        }
817
        }
Line 818... Line 818...
818
 
818
 
819
        GMapMarker _findWPMarker(string name)
819
        GMapMarker _findWPMarker(string name)
820
        {
820
        {
Line 1058... Line 1058...
1058
        bool bFirstAccess = true;
1058
        bool bFirstAccess = true;
1059
        double dDistance = 0;
1059
        double dDistance = 0;
1060
        int iZoom;
1060
        int iZoom;
1061
        private void MainMap_StylusDown(object sender, StylusDownEventArgs e)
1061
        private void MainMap_StylusDown(object sender, StylusDownEventArgs e)
1062
        {
1062
        {
1063
            var id = e.StylusDevice.Id;
-
 
1064
            e.StylusDevice.Capture(MainMap);
-
 
1065
            if (iFirstStylusID == -1)
1063
            if (!_WPisMouseCaptured)
1066
            {
-
 
1067
                iFirstStylusID = id;
-
 
1068
            }
-
 
1069
            else
-
 
1070
            {
1064
            {
-
 
1065
                var id = e.StylusDevice.Id;
-
 
1066
                e.StylusDevice.Capture(MainMap);
-
 
1067
                if (iFirstStylusID == -1)
-
 
1068
                {
-
 
1069
                    iFirstStylusID = id;
-
 
1070
                }
-
 
1071
                else
-
 
1072
                {
Line 1071... Line 1073...
1071
 
1073
 
-
 
1074
                    MainMap.CanDragMap = false;
1072
                MainMap.CanDragMap = false;
1075
                }
1073
            }
1076
            }
1074
        }
1077
        }
1075
        private void MainMap_StylusUp(object sender, StylusEventArgs e)
1078
        private void MainMap_StylusUp(object sender, StylusEventArgs e)
1076
        {
1079
        {
Line 2398... Line 2401...
2398
                {
2401
                {
2399
                    Thread.Sleep(1);
2402
                    Thread.Sleep(1);
2400
                    iTimeout++;
2403
                    iTimeout++;
2401
                }
2404
                }
2402
            }
2405
            }
-
 
2406
            Dispatcher.Invoke(() =>
-
 
2407
            {
-
 
2408
               // MainMap.ZoomAndCenterMarkers(null);
-
 
2409
                MainMap.Position = new PointLatLng((double)dtWaypoints.Rows[0][3], (double)dtWaypoints.Rows[0][4]);
-
 
2410
                MainMap.Zoom = 19;
-
 
2411
            });
2403
        }
2412
        }
2404
        /// <summary>
2413
        /// <summary>
2405
        /// Wrapper for _clearCopterWPList()
2414
        /// Wrapper for _clearCopterWPList()
2406
        /// necessary, cause it is called by threadnew which does not like return values...
2415
        /// necessary, cause it is called by threadnew which does not like return values...
2407
        /// </summary>
2416
        /// </summary>
Line 2755... Line 2764...
2755
            if (GridData != null)
2764
            if (GridData != null)
2756
                GridData.Margin = new Thickness(GridData.Margin.Left, 36 * UIScaleTopSlider.Value, GridData.Margin.Right, GridData.Margin.Bottom);
2765
                GridData.Margin = new Thickness(GridData.Margin.Left, 36 * UIScaleTopSlider.Value, GridData.Margin.Right, GridData.Margin.Bottom);
2757
            if (GridWP != null)
2766
            if (GridWP != null)
2758
                GridWP.Margin = new Thickness(GridWP.Margin.Left, 36 * UIScaleTopSlider.Value, GridWP.Margin.Right, GridWP.Margin.Bottom);
2767
                GridWP.Margin = new Thickness(GridWP.Margin.Left, 36 * UIScaleTopSlider.Value, GridWP.Margin.Right, GridWP.Margin.Bottom);
2759
        }
2768
        }
-
 
2769
        private void UIScaleOSDSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
-
 
2770
        {
-
 
2771
            if (!_init)
-
 
2772
            {
-
 
2773
                if (WPStatus != null && (WPStatus.Visibility == Visibility.Visible))
-
 
2774
                    GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value + 36, GridOSD.Margin.Right, GridOSD.Margin.Bottom);
-
 
2775
                else
-
 
2776
                    GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value, GridOSD.Margin.Right, GridOSD.Margin.Bottom);
-
 
2777
            }
-
 
2778
        }
-
 
2779
 
2760
        /// <summary>
2780
        /// <summary>
2761
        /// restore the saved scalings for the fullscreen/normal window mode
2781
        /// restore the saved scalings for the fullscreen/normal window mode
2762
        /// </summary>
2782
        /// </summary>
2763
        /// <param name="bFull">the mode the window is set to</param>
2783
        /// <param name="bFull">the mode the window is set to</param>
2764
        void _setScaleSliders(bool bFull)
2784
        void _setScaleSliders(bool bFull)
Line 3510... Line 3530...
3510
                                    _createWP(new PointLatLng((double)o[3], (double)o[4]), (string)dr[2], (int)o[1]);
3530
                                    _createWP(new PointLatLng((double)o[3], (double)o[4]), (string)dr[2], (int)o[1]);
Line 3511... Line 3531...
3511
 
3531
 
3512
                                    Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString());
3532
                                    Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString());
3513
                                    Dispatcher.Invoke(() => lblWPCount.Content = k.ToString());
3533
                                    Dispatcher.Invoke(() => lblWPCount.Content = k.ToString());
3514
                                    Dispatcher.Invoke(() => dgvWP.Items.Refresh());
3534
                                    Dispatcher.Invoke(() => dgvWP.Items.Refresh());
3515
                                    Thread.Sleep(10);
3535
                                    Thread.Sleep(1);
-
 
3536
                                }
-
 
3537
                                Dispatcher.Invoke(() => MainMap.Position = new PointLatLng((double)dtWaypoints.Rows[0][3], (double)dtWaypoints.Rows[0][4]));
-
 
3538
                                Dispatcher.Invoke(() => MainMap.Zoom = 19);
3516
                                }
3539
                             //   Dispatcher.Invoke(() => MainMap.ZoomAndCenterMarkers(null));
3517
                                _routeUpdate();
3540
                                Dispatcher.Invoke(() => _routeUpdate());
3518
                            }
3541
                            }
3519
                        }
3542
                        }
Line 3520... Line 3543...
3520
                    }
3543
                    }
Line 3622... Line 3645...
3622
        {
3645
        {
3623
            GMapMarker wpMarker = new GMapMarker(p);
3646
            GMapMarker wpMarker = new GMapMarker(p);
3624
            Dispatcher.Invoke(()=>
3647
            Dispatcher.Invoke(()=>
3625
            {
3648
            {
3626
                wpMarker.Shape = new CustomMarkerWP(this, wpMarker, name, type);
3649
                wpMarker.Shape = new CustomMarkerWP(this, wpMarker, name, type);
-
 
3650
                wpMarker.Tag = name;
3627
                wpMarker.Offset = new System.Windows.Point(-11.5, -11.5);
3651
                wpMarker.Offset = new System.Windows.Point(-11.5, -11.5);
3628
                wpMarker.ZIndex = 100;
3652
                wpMarker.ZIndex = 100;
3629
                _setMarkerColor(wpMarker, type);
3653
                _setMarkerColor(wpMarker, type);
3630
                MainMap.Markers.Add(wpMarker);
3654
                MainMap.Markers.Add(wpMarker);
3631
                if (type == 0 || type == 3)
3655
                if (type == 0 || type == 3)
3632
                    wpList.Add(p);
3656
                    wpList.Add(p);
-
 
3657
                ((CustomMarkerWP)wpMarker.Shape).positionChanged += _updateDTWPPos;
-
 
3658
                ((CustomMarkerWP)wpMarker.Shape).newPosition += _updateDTWPPosFin;
-
 
3659
                ((CustomMarkerWP)wpMarker.Shape).mouseCaptured += _WPMouseCatured;
3633
            });
3660
            });
3634
            return wpMarker;
3661
            return wpMarker;
3635
        }
3662
        }
-
 
3663
        bool _WPisMouseCaptured = false;
-
 
3664
        void _WPMouseCatured(bool isCaptured)
-
 
3665
        {
-
 
3666
            _WPisMouseCaptured = isCaptured;
-
 
3667
            MainMap.CanDragMap = !isCaptured;
-
 
3668
        }
-
 
3669
        void _updateDTWPPos(CustomMarkerWP wp)
-
 
3670
        {
-
 
3671
            string sIndex = wp.WPText.Substring(1, wp.WPText.Length - 1);
-
 
3672
            int index = Convert.ToInt16(sIndex) -1;
-
 
3673
            GMapMarker p = ((GMapMarker)wp.DataContext);
-
 
3674
            if (p != null && index < dtWaypoints.Rows.Count)
-
 
3675
            {
-
 
3676
                //dtWaypoints.Rows[index][3] = p.Position.Lat;
-
 
3677
                //dtWaypoints.Rows[index][4] = p.Position.Lng;
-
 
3678
                //Dispatcher.Invoke(() => dgvWP.Items.Refresh());
-
 
3679
                if(wp.WPType == 0 | wp.WPType == 3)
-
 
3680
                {
-
 
3681
                    wpList[index] = p.Position;
-
 
3682
                    MainMap.Markers.Remove(mRouteWP);
-
 
3683
                    _routeUpdate();
-
 
3684
                }
-
 
3685
            }
-
 
3686
        }
-
 
3687
        void _updateDTWPPosFin(CustomMarkerWP wp)
-
 
3688
        {
-
 
3689
            string sIndex = wp.WPText.Substring(1, wp.WPText.Length - 1);
-
 
3690
            int index = Convert.ToInt16(sIndex) -1;
-
 
3691
            GMapMarker p = ((GMapMarker)wp.DataContext);
-
 
3692
            if (p != null && index < dtWaypoints.Rows.Count)
-
 
3693
            {
-
 
3694
                dtWaypoints.Rows[index][3] = p.Position.Lat;
-
 
3695
                dtWaypoints.Rows[index][4] = p.Position.Lng;
-
 
3696
                Dispatcher.Invoke(() => dgvWP.Items.Refresh());
-
 
3697
            }
-
 
3698
 
-
 
3699
        }
-
 
3700
 
3636
        void _setMarkerColor(GMapMarker wpMarker,int iType)
3701
        void _setMarkerColor(GMapMarker wpMarker,int iType)
3637
        {
3702
        {
3638
            if(wpMarker != null)
3703
            if(wpMarker != null)
3639
            Dispatcher.Invoke(() =>
3704
            Dispatcher.Invoke(() =>
3640
            {
3705
            {
Line 4358... Line 4423...
4358
            {
4423
            {
4359
                if (cWPBound != null && cWPBound.Tag != null)
4424
                if (cWPBound != null && cWPBound.Tag != null)
4360
                    MainMap.Markers.Remove(cWPBound.Tag as GMapMarker);
4425
                    MainMap.Markers.Remove(cWPBound.Tag as GMapMarker);
Line 4361... Line 4426...
4361
 
4426
 
-
 
4427
                createCircle(home.Position, dWPMaxRange);
-
 
4428
                if (comboBoxWPMaxRangeColor.SelectionBoxItem != null)
4362
                createCircle(home.Position, dWPMaxRange);
4429
                {
4363
                string s = comboBoxWPMaxRangeColor.SelectionBoxItem.ToString();
4430
                    string s = comboBoxWPMaxRangeColor.SelectionBoxItem.ToString();
4364
                cWPBound.setColor(s);
-
 
-
 
4431
                    cWPBound.setColor(s);
4365
 
4432
                }
Line 4366... Line 4433...
4366
            }
4433
            }
4367
 
4434
 
4368
            if (checkBoxShowWPMaxRange.IsChecked == false && (cWPBound != null && cWPBound.Tag != null))
4435
            if (checkBoxShowWPMaxRange.IsChecked == false && (cWPBound != null && cWPBound.Tag != null))