Subversion Repositories Projects

Rev

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

Rev 2366 Rev 2368
Line 727... Line 727...
727
                else
727
                else
728
                    k++;
728
                    k++;
729
            }
729
            }
Line 730... Line 730...
730
 
730
 
-
 
731
        }
731
        }
732
        void _clearWPMarker(String text)
-
 
733
        {
-
 
734
            for (int k = 0; k < MainMap.Markers.Count;)
-
 
735
            {
-
 
736
                GMapMarker p = MainMap.Markers[k];
-
 
737
                if (p.GetType() == typeof(CustomMarkerWP) | (p.Shape != null && p.Shape.GetType() == typeof(CustomMarkerWP)))
-
 
738
                    if (((CustomMarkerWP)p.Shape).WPText == text)
-
 
739
                    { MainMap.Markers.Remove(p); break; }
-
 
740
                    else
-
 
741
                        k++;
-
 
742
                else
-
 
743
                    k++;
-
 
744
            }
-
 
745
        }
-
 
746
        void _renameWPMarker(string s1, string s2)
-
 
747
        {
-
 
748
            for (int k = 0; k < MainMap.Markers.Count;)
-
 
749
            {
-
 
750
                GMapMarker p = MainMap.Markers[k];
-
 
751
                if (p.GetType() == typeof(CustomMarkerWP) | (p.Shape != null && p.Shape.GetType() == typeof(CustomMarkerWP)))
-
 
752
                    if (((CustomMarkerWP)p.Shape).WPText == s1)
-
 
753
                    { ((CustomMarkerWP)p.Shape).WPText = s2; break; }
-
 
754
                    else
-
 
755
                        k++;
-
 
756
                else
-
 
757
                    k++;
-
 
758
            }
732
 
759
        }
733
        // access mode
760
        // access mode
734
        private void comboBoxMode_DropDownClosed(object sender, EventArgs e)
761
        private void comboBoxMode_DropDownClosed(object sender, EventArgs e)
735
        {
762
        {
736
            MainMap.Manager.Mode = (AccessMode)comboBoxMode.SelectedItem;
763
            MainMap.Manager.Mode = (AccessMode)comboBoxMode.SelectedItem;
Line 1738... Line 1765...
1738
                {
1765
                {
1739
                    Dispatcher.Invoke(() => MainMap.Markers.Remove(wpActiveMarker));
1766
                    Dispatcher.Invoke(() => MainMap.Markers.Remove(wpActiveMarker));
1740
                    Dispatcher.Invoke(() =>
1767
                    Dispatcher.Invoke(() =>
1741
                    {
1768
                    {
1742
                        DataGridRow row;
1769
                        DataGridRow row;
1743
                        if (_wpIndex > -1 && data[48] == 0)
1770
                        if (_wpIndex > -1 && data[48] == 0 && wpList.Count > _wpIndex)
1744
                        {
1771
                        {
1745
                            row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
1772
                            row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
1746
                            row.Background = new SolidColorBrush(Colors.Transparent);
1773
                            row.Background = new SolidColorBrush(Colors.Transparent);
1747
                            row.BorderBrush = new SolidColorBrush(Colors.Transparent);
1774
                            row.BorderBrush = new SolidColorBrush(Colors.Transparent);
1748
                            row.BorderThickness = new Thickness(0);
1775
                            row.BorderThickness = new Thickness(0);
Line 1890... Line 1917...
1890
                                MainMap.Markers.Remove(mRouteWP);
1917
                                MainMap.Markers.Remove(mRouteWP);
1891
                            if (wpActiveMarker != null)
1918
                            if (wpActiveMarker != null)
1892
                                MainMap.Markers.Remove(wpActiveMarker);
1919
                                MainMap.Markers.Remove(wpActiveMarker);
1893
                            lblWPRouteDistance.Content = "0 m";
1920
                            lblWPRouteDistance.Content = "0 m";
1894
                            dtWaypoints.Rows.Clear();
1921
                            dtWaypoints.Rows.Clear();
1895
                            _wpEdit = -1;
1922
                            _wpEdit = -1;_wpIndex = -1;
1896
                        });
1923
                        });
1897
                    }
1924
                    }
1898
                    DataRow dr = dtWaypoints.NewRow();
1925
                    DataRow dr = dtWaypoints.NewRow();
1899
                    dr = Waypoints.toDataRow(data, dr);
1926
                    dr = Waypoints.toDataRow(data, dr);
1900
                    dtWaypoints.Rows.Add(dr);
1927
                    dtWaypoints.Rows.Add(dr);
Line 1902... Line 1929...
1902
                    Dispatcher.Invoke(() => dgvWP.Items.Refresh());
1929
                    Dispatcher.Invoke(() => dgvWP.Items.Refresh());
1903
                    Dispatcher.Invoke(() => _iWPIndex = data[1]);
1930
                    Dispatcher.Invoke(() => _iWPIndex = data[1]);
1904
                    if (data[1] == data[0])
1931
                    if (data[1] == data[0])
1905
                    {
1932
                    {
1906
                        _bGetWP = false;
1933
                        _bGetWP = false;
1907
                        Dispatcher.Invoke(() => dgvWP.Items.Refresh());
-
 
1908
 
-
 
1909
                        Dispatcher.Invoke(() =>
-
 
1910
                        {
-
 
1911
                            if (comboBoxRouteColor.SelectionBoxItem != null)
-
 
1912
                            {
-
 
1913
                                string s = comboBoxRouteColor.SelectionBoxItem.ToString();
-
 
1914
                                mRouteWP = new GMapRoute(wpList, _getBrush(s));
-
 
1915
                            }
-
 
1916
                            else
1934
                        _routeUpdate();
1917
                                mRouteWP = new GMapRoute(wpList, null);
-
 
1918
 
-
 
1919
                            if (_bShowWPRoute)
-
 
1920
                                MainMap.Markers.Add(mRouteWP);
-
 
1921
                        });
-
 
1922
                        MapRoute mr = new MapRoute(wpList, "WPList");
-
 
1923
                        Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m"));
-
 
1924
                    }
1935
                    }
Line 1925... Line 1936...
1925
 
1936
 
1926
                }
1937
                }
1927
            }
1938
            }
Line 3168... Line 3179...
3168
                                string wp;
3179
                                string wp;
3169
                                int i;
3180
                                int i;
3170
                                NumberFormatInfo nfi = new NumberFormatInfo();
3181
                                NumberFormatInfo nfi = new NumberFormatInfo();
3171
                                nfi.NumberDecimalSeparator = ".";
3182
                                nfi.NumberDecimalSeparator = ".";
3172
                                dtWaypoints.Rows.Clear();
3183
                                dtWaypoints.Rows.Clear();
3173
                                _wpEdit = -1;
3184
                                _wpEdit = -1;_wpIndex = -1;
3174
                                _clearMapMarkers(typeof(CustomMarkerWP));
3185
                                _clearMapMarkers(typeof(CustomMarkerWP));
3175
                                _clearMapMarkers(typeof(CustomMarkerWPActive));
3186
                                _clearMapMarkers(typeof(CustomMarkerWPActive));
3176
                                wpList.Clear();
3187
                                wpList.Clear();
3177
                                if (mRouteWP != null)
3188
                                if (mRouteWP != null)
3178
                                    MainMap.Markers.Remove(mRouteWP);
3189
                                    MainMap.Markers.Remove(mRouteWP);
Line 3351... Line 3362...
3351
                }
3362
                }
3352
                else
3363
                else
3353
                    mRouteWP = new GMapRoute(wpList, null);
3364
                    mRouteWP = new GMapRoute(wpList, null);
Line 3354... Line 3365...
3354
 
3365
 
3355
                if (_bShowWPRoute)
3366
                if (_bShowWPRoute)
3356
                    Dispatcher.Invoke(() => MainMap.Markers.Add(mRouteWP));
3367
                    MainMap.Markers.Add(mRouteWP);
Line 3357... Line 3368...
3357
            });
3368
            });
3358
 
3369
 
3359
            MapRoute mr = new MapRoute(wpList, "WPList");
-
 
3360
            Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m"));
3370
            MapRoute mr = new MapRoute(wpList, "WPList");
3361
 
-
 
3362
        }
3371
            Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m"));
3363
 
3372
        }
3364
        GMapMarker _createWP(PointLatLng p, string name, int type)
3373
        GMapMarker _createWP(PointLatLng p, string name, int type)
3365
        {
3374
        {
3366
            GMapMarker wpMarker = new GMapMarker(p);
3375
            GMapMarker wpMarker = new GMapMarker(p);
Line 3530... Line 3539...
3530
                MainMap.Markers.Remove(mRouteWP);
3539
                MainMap.Markers.Remove(mRouteWP);
3531
            //if (wpActiveMarker != null)
3540
            //if (wpActiveMarker != null)
3532
            //    MainMap.Markers.Remove(wpActiveMarker);
3541
            //    MainMap.Markers.Remove(wpActiveMarker);
3533
            dtWaypoints.Rows.Clear();
3542
            dtWaypoints.Rows.Clear();
3534
            _wpEdit = -1;
3543
            _wpEdit = -1;
-
 
3544
            _wpIndex = -1;
3535
            Dispatcher.Invoke(() => dgvWP.Items.Refresh());
3545
            Dispatcher.Invoke(() => dgvWP.Items.Refresh());
3536
            Dispatcher.Invoke(() => lblWPIndex.Content = 0);
3546
            Dispatcher.Invoke(() => lblWPIndex.Content = 0);
3537
            Dispatcher.Invoke(() => lblWPCount.Content = 0);
3547
            Dispatcher.Invoke(() => lblWPCount.Content = 0);
3538
            Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m");
3548
            Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m");
3539
        }
3549
        }
Line 3555... Line 3565...
3555
                Thread t = new Thread(() => _sendWPList(index));
3565
                Thread t = new Thread(() => _sendWPList(index));
3556
                t.Start();
3566
                t.Start();
Line 3557... Line 3567...
3557
 
3567
 
3558
                Dispatcher.Invoke(() => {
3568
                Dispatcher.Invoke(() => {
3559
                    DataGridRow row;
3569
                    DataGridRow row;
3560
                    if (_wpIndex > -1 && _wpIndex < dgvWP.ItemContainerGenerator.Items.Count)
3570
                    if (_wpEdit > -1 && _wpEdit < dgvWP.ItemContainerGenerator.Items.Count)
3561
                    {
3571
                    {
3562
                        row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
3572
                        row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3563
                        row.Background = new SolidColorBrush(Colors.Transparent);
3573
                        row.Background = new SolidColorBrush(Colors.Transparent);
3564
                        row.BorderBrush = new SolidColorBrush(Colors.Transparent);
3574
                        row.BorderBrush = new SolidColorBrush(Colors.Transparent);
3565
                        row.BorderThickness = new Thickness(0);
3575
                        row.BorderThickness = new Thickness(0);
3566
                    }
3576
                    }
3567
                    _wpIndex = dgvWP.SelectedIndex;
3577
                    _wpEdit = dgvWP.SelectedIndex;
3568
                    row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpIndex);
3578
                    row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3569
                    row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 255, 100));
3579
                    row.Background = new SolidColorBrush(Color.FromArgb(80, 0, 255, 100));
3570
                    row.BorderBrush = new SolidColorBrush(Colors.SpringGreen);
3580
                    row.BorderBrush = new SolidColorBrush(Colors.SpringGreen);
3571
                    row.BorderThickness = new Thickness(2);
3581
                    row.BorderThickness = new Thickness(2);
3572
                    dgvWP.UpdateLayout();
3582
                    dgvWP.UpdateLayout();
Line 3582... Line 3592...
3582
        }
3592
        }
3583
        void _dgvWPselectEditRow()
3593
        void _dgvWPselectEditRow()
3584
        {
3594
        {
3585
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
3595
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
3586
            {
3596
            {
3587
                Dispatcher.Invoke(() => {
3597
               Dispatcher.Invoke(() => {
3588
                    DataGridRow row;
3598
                    DataGridRow row;
3589
                    if (_wpEdit > -1)
3599
                    if (_wpEdit > -1 && _wpEdit < dgvWP.ItemContainerGenerator.Items.Count)
3590
                    {
3600
                    {
3591
                        row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3601
                        row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
3592
                        row.Background = new SolidColorBrush(Colors.Transparent);
3602
                        row.Background = new SolidColorBrush(Colors.Transparent);
3593
                        row.BorderBrush = new SolidColorBrush(Colors.Transparent);
3603
                        row.BorderBrush = new SolidColorBrush(Colors.Transparent);
3594
                        row.BorderThickness = new Thickness(0);
3604
                        row.BorderThickness = new Thickness(0);
Line 3768... Line 3778...
3768
            }
3778
            }
Line 3769... Line 3779...
3769
 
3779
 
3770
        }
3780
        }
3771
        private void btnEditWPDel_Click(object sender, RoutedEventArgs e)
3781
        private void btnEditWPDel_Click(object sender, RoutedEventArgs e)
-
 
3782
        {
-
 
3783
            if (dgvWP.SelectedIndex > -1 && dgvWP.SelectedIndex < dtWaypoints.Rows.Count)
-
 
3784
            {
-
 
3785
                int index = dgvWP.SelectedIndex;
-
 
3786
                Dispatcher.Invoke(() => {
-
 
3787
                    DataGridRow row;
-
 
3788
                    if (_wpEdit > -1 && _wpEdit < dgvWP.ItemContainerGenerator.Items.Count)
-
 
3789
                    {
-
 
3790
                        row = (DataGridRow)dgvWP.ItemContainerGenerator.ContainerFromIndex(_wpEdit);
-
 
3791
                        row.Background = new SolidColorBrush(Colors.Transparent);
-
 
3792
                        row.BorderBrush = new SolidColorBrush(Colors.Transparent);
-
 
3793
                        row.BorderThickness = new Thickness(0);
-
 
3794
                    }
-
 
3795
                    if ((int)dtWaypoints.Rows[index][1] == 0)
-
 
3796
                        wpList.Remove(new PointLatLng((double)dtWaypoints.Rows[index][3], (double)dtWaypoints.Rows[index][4]));
-
 
3797
                    _clearWPMarker((string)dtWaypoints.Rows[index][2]);
-
 
3798
                    dtWaypoints.Rows[index].Delete();
-
 
3799
                    _wpIndex = -1;
-
 
3800
                    _wpEdit = -1;
-
 
3801
                    for (int i = index; i < dtWaypoints.Rows.Count; i++) //change the index of points behind deleted point + rename to new index
-
 
3802
                    {
-
 
3803
                        dtWaypoints.Rows[i][0] = i + 1;
-
 
3804
                        string s1 = (string)dtWaypoints.Rows[i][2]; //old name of WP (Prefix + index)
-
 
3805
                        string s2 = s1.Substring(0, 1) + (i + 1).ToString(); //new name of WP
-
 
3806
                        _renameWPMarker(s1, s2);
-
 
3807
                        dtWaypoints.Rows[i][2] = s2;
-
 
3808
                    }
-
 
3809
                    lblWPCount.Content = dtWaypoints.Rows.Count;
-
 
3810
                    if (mRouteWP != null)
-
 
3811
                        MainMap.Markers.Remove(mRouteWP);
Line -... Line 3812...
-
 
3812
                    _routeUpdate();
-
 
3813
 
-
 
3814
                    dgvWP.UpdateLayout();
3772
        {
3815
                });
3773
 
3816
            }
3774
        }
3817
        }
3775
        private void tbWPEdit_TouchDown(object sender, TouchEventArgs e)
3818
        private void tbWPEdit_TouchDown(object sender, TouchEventArgs e)
3776
        {
3819
        {
Line 3922... Line 3965...
3922
           //     tbWPEditOut1.Text = "0";
3965
           //     tbWPEditOut1.Text = "0";
3923
            o[14] = "0";
3966
            o[14] = "0";
3924
            o[15] = "0";
3967
            o[15] = "0";
Line 3925... Line 3968...
3925
 
3968
 
3926
            dtWaypoints.Rows.Add(o);
-
 
3927
            GMapMarker wpMarker = new GMapMarker(new PointLatLng((double)o[3], (double)o[4]));
-
 
3928
            wpMarker.Shape = new CustomMarkerWP(this, wpMarker, (string)o[2], (int)o[1]);
-
 
3929
            wpMarker.Offset = new System.Windows.Point(-11.5, -11.5);
-
 
3930
            wpMarker.ZIndex = 100;
-
 
3931
            _setMarkerColor(wpMarker, (int)o[1]);
-
 
3932
            MainMap.Markers.Add(wpMarker);
3969
            dtWaypoints.Rows.Add(o);
3933
            wpList.Add(new PointLatLng((double)o[3], (double)o[4]));
3970
            _createWP(new PointLatLng((double)o[3], (double)o[4]), (string)o[2], (int)o[1]);
3934
            Dispatcher.Invoke(() => lblWPCount.Content = o[0].ToString());
3971
            Dispatcher.Invoke(() => lblWPCount.Content = o[0].ToString());
3935
            if (mRouteWP != null)
3972
            if (mRouteWP != null)
3936
                MainMap.Markers.Remove(mRouteWP);
3973
                MainMap.Markers.Remove(mRouteWP);
3937
            _routeUpdate();
3974
            _routeUpdate();