Rev 2327 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2327 | Rev 2328 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | GMapMarker copter; |
42 | GMapMarker copter; |
43 | GMapMarker home; |
43 | GMapMarker home; |
44 | PointLatLng start; |
44 | PointLatLng start; |
45 | PointLatLng end; |
45 | PointLatLng end; |
46 | PointLatLng pHome; |
46 | PointLatLng pHome; |
47 | - | ||
- | 47 | GMapRoute mRouteWP; |
|
- | 48 | List<PointLatLng> wpList = new List<PointLatLng>(); |
|
48 | #region NC-Errors |
49 | #region NC-Errors |
49 | String[] NC_Error = new string[44] |
50 | String[] NC_Error = new string[44] |
50 | { |
51 | { |
51 | "No Error", |
52 | "No Error", |
52 | "FC not compatible" + Environment.NewLine + "http://wiki.mikrokopter.de/ErrorCodes#A1_.22FC_not_compatible_.22", |
53 | "FC not compatible" + Environment.NewLine + "http://wiki.mikrokopter.de/ErrorCodes#A1_.22FC_not_compatible_.22", |
Line 269... | Line 270... | ||
269 | DataTable dtWaypoints = new DataTable(); |
270 | DataTable dtWaypoints = new DataTable(); |
270 | static volatile int _iWPCount = -1; |
271 | static volatile int _iWPCount = -1; |
271 | static volatile int _iWPIndex = -1; |
272 | static volatile int _iWPIndex = -1; |
272 | int _iWPTimeout = 1000; |
273 | int _iWPTimeout = 1000; |
273 | bool _bGetWP = false; |
274 | bool _bGetWP = false; |
- | 275 | bool _bShowWPRoute = false; |
|
274 | static volatile bool _bGetWPCount = false; |
276 | static volatile bool _bGetWPCount = false; |
275 | DataTable dtGPX = new DataTable(); |
277 | DataTable dtGPX = new DataTable(); |
276 | DataRow drGPX; |
278 | DataRow drGPX; |
277 | bool _bAirborne = false; |
279 | bool _bAirborne = false; |
278 | DispatcherTimer timer = new DispatcherTimer(); |
280 | DispatcherTimer timer = new DispatcherTimer(); |
Line 346... | Line 348... | ||
346 | cBoxTimingsBl.SelectedItem = blctrlInterval * 10; |
348 | cBoxTimingsBl.SelectedItem = blctrlInterval * 10; |
347 | cBoxTimingsOSD.SelectedItem = OSDInterval * 10; |
349 | cBoxTimingsOSD.SelectedItem = OSDInterval * 10; |
348 | checkBoxAutoSetHP.IsChecked = _bAutoHome; |
350 | checkBoxAutoSetHP.IsChecked = _bAutoHome; |
349 | checkBoxFollowCopter.IsChecked = _bFollowCopter; |
351 | checkBoxFollowCopter.IsChecked = _bFollowCopter; |
350 | checkBoxGPXLog.IsChecked = _bGPXLog; |
352 | checkBoxGPXLog.IsChecked = _bGPXLog; |
- | 353 | checkBoxShowWPRoute.IsChecked = _bShowWPRoute; |
|
Line 351... | Line 354... | ||
351 | 354 | ||
352 | } |
355 | } |
353 | /// <summary> |
356 | /// <summary> |
354 | /// initialize the datatables |
357 | /// initialize the datatables |
Line 1804... | Line 1807... | ||
1804 | Dispatcher.Invoke(() => lblWPCount.Content = data[0].ToString()); |
1807 | Dispatcher.Invoke(() => lblWPCount.Content = data[0].ToString()); |
1805 | if (_bGetWP) |
1808 | if (_bGetWP) |
1806 | { |
1809 | { |
1807 | if (data[1] == 1) |
1810 | if (data[1] == 1) |
1808 | { |
1811 | { |
- | 1812 | wpList.Clear(); |
|
- | 1813 | if(mRouteWP != null) |
|
- | 1814 | MainMap.Markers.Remove(mRouteWP); |
|
- | 1815 | ||
- | 1816 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m"); |
|
1809 | dtWaypoints.Rows.Clear(); |
1817 | dtWaypoints.Rows.Clear(); |
1810 | Dispatcher.Invoke(() => { |
1818 | Dispatcher.Invoke(() => { |
1811 | for (int k = 0; k < MainMap.Markers.Count;) |
1819 | for (int k = 0; k < MainMap.Markers.Count;) |
1812 | { |
1820 | { |
1813 | GMapMarker p = MainMap.Markers[k]; |
1821 | GMapMarker p = MainMap.Markers[k]; |
Line 1827... | Line 1835... | ||
1827 | _setMarkerColor(wp, (int)dr[1]); |
1835 | _setMarkerColor(wp, (int)dr[1]); |
1828 | MainMap.Markers.Add(wp); |
1836 | MainMap.Markers.Add(wp); |
1829 | }); |
1837 | }); |
1830 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
1838 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
1831 | Dispatcher.Invoke(() => _iWPIndex = data[1]); |
1839 | Dispatcher.Invoke(() => _iWPIndex = data[1]); |
- | 1840 | wpList.Add(new PointLatLng((double)dr[3], (double)dr[4])); |
|
1832 | if (data[1] == data[0]) |
1841 | if (data[1] == data[0]) |
1833 | { |
1842 | { |
1834 | _bGetWP = false; |
1843 | _bGetWP = false; |
1835 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
1844 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
- | 1845 | ||
- | 1846 | Dispatcher.Invoke(() => |
|
- | 1847 | { |
|
- | 1848 | if (comboBoxRouteColor.SelectionBoxItem != null) |
|
- | 1849 | { |
|
- | 1850 | string s = comboBoxRouteColor.SelectionBoxItem.ToString(); |
|
- | 1851 | mRouteWP = new GMapRoute(wpList, _getBrush(s)); |
|
- | 1852 | } |
|
- | 1853 | else |
|
- | 1854 | mRouteWP = new GMapRoute(wpList, null); |
|
- | 1855 | ||
- | 1856 | if (_bShowWPRoute) |
|
- | 1857 | MainMap.Markers.Add(mRouteWP); |
|
- | 1858 | }); |
|
- | 1859 | MapRoute mr = new MapRoute(wpList, "WPList"); |
|
- | 1860 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance / 1000).ToString("0 m")); |
|
1836 | } |
1861 | } |
Line 1837... | Line 1862... | ||
1837 | 1862 | ||
1838 | } |
1863 | } |
1839 | } |
1864 | } |
Line 2525... | Line 2550... | ||
2525 | if(sVal != "") comboBoxPOIColor.SelectedIndex = Convert.ToInt32(sVal); |
2550 | if(sVal != "") comboBoxPOIColor.SelectedIndex = Convert.ToInt32(sVal); |
2526 | sVal = ini.IniReadValue("waypoints", "fscolor"); |
2551 | sVal = ini.IniReadValue("waypoints", "fscolor"); |
2527 | if(sVal != "") comboBoxFSColor.SelectedIndex = Convert.ToInt32(sVal); |
2552 | if(sVal != "") comboBoxFSColor.SelectedIndex = Convert.ToInt32(sVal); |
2528 | sVal = ini.IniReadValue("waypoints", "coptercolor"); |
2553 | sVal = ini.IniReadValue("waypoints", "coptercolor"); |
2529 | if(sVal != "") comboBoxCopterColor.SelectedIndex = Convert.ToInt32(sVal); |
2554 | if(sVal != "") comboBoxCopterColor.SelectedIndex = Convert.ToInt32(sVal); |
- | 2555 | sVal = ini.IniReadValue("waypoints", "routecolor"); |
|
- | 2556 | if(sVal != "") comboBoxRouteColor.SelectedIndex = Convert.ToInt32(sVal); |
|
- | 2557 | sVal = ini.IniReadValue("waypoints", "showWPRoute"); |
|
- | 2558 | if(sVal != "") _bShowWPRoute = Convert.ToBoolean(sVal); |
|
2530 | } |
2559 | } |
2531 | catch (Exception e) |
2560 | catch (Exception e) |
2532 | { |
2561 | { |
Line 2533... | Line 2562... | ||
2533 | 2562 | ||
Line 2609... | Line 2638... | ||
2609 | 2638 | ||
2610 | ini.IniWriteValue("waypoints", "wpcolor", comboBoxWPColor.SelectedIndex.ToString()); |
2639 | ini.IniWriteValue("waypoints", "wpcolor", comboBoxWPColor.SelectedIndex.ToString()); |
2611 | ini.IniWriteValue("waypoints", "poicolor", comboBoxPOIColor.SelectedIndex.ToString()); |
2640 | ini.IniWriteValue("waypoints", "poicolor", comboBoxPOIColor.SelectedIndex.ToString()); |
2612 | ini.IniWriteValue("waypoints", "fscolor", comboBoxFSColor.SelectedIndex.ToString()); |
2641 | ini.IniWriteValue("waypoints", "fscolor", comboBoxFSColor.SelectedIndex.ToString()); |
- | 2642 | ini.IniWriteValue("waypoints", "coptercolor", comboBoxCopterColor.SelectedIndex.ToString()); |
|
- | 2643 | ini.IniWriteValue("waypoints", "routecolor", comboBoxRouteColor.SelectedIndex.ToString()); |
|
2613 | ini.IniWriteValue("waypoints", "coptercolor", comboBoxCopterColor.SelectedIndex.ToString()); |
2644 | ini.IniWriteValue("waypoints", "showWPRoute", _bShowWPRoute.ToString()); |
2614 | } |
2645 | } |
2615 | catch (Exception e) |
2646 | catch (Exception e) |
Line 2616... | Line 2647... | ||
2616 | { |
2647 | { |
Line 2660... | Line 2691... | ||
2660 | // MainMap.Markers.Remove(p); |
2691 | // MainMap.Markers.Remove(p); |
2661 | // else |
2692 | // else |
2662 | // k++; |
2693 | // k++; |
2663 | //} |
2694 | //} |
2664 | _clearMapMarkers(typeof(CustomMarkerWP)); |
2695 | _clearMapMarkers(typeof(CustomMarkerWP)); |
- | 2696 | wpList.Clear(); |
|
- | 2697 | if (mRouteWP != null) |
|
- | 2698 | MainMap.Markers.Remove(mRouteWP); |
|
- | 2699 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = "0 m"); |
|
- | 2700 | ||
2665 | for (int k = 1; k <= wpnum; k++) |
2701 | for (int k = 1; k <= wpnum; k++) |
2666 | { |
2702 | { |
2667 | DataRow dr = dtWaypoints.NewRow(); |
2703 | DataRow dr = dtWaypoints.NewRow(); |
2668 | dr.ItemArray = new object[16]; |
2704 | dr.ItemArray = new object[16]; |
2669 | object[] o = new object[16]; |
2705 | object[] o = new object[16]; |
Line 2729... | Line 2765... | ||
2729 | 2765 | ||
2730 | dr.ItemArray = o; |
2766 | dr.ItemArray = o; |
2731 | dtWaypoints.Rows.Add(dr); |
2767 | dtWaypoints.Rows.Add(dr); |
2732 | GMapMarker wpMarker = new GMapMarker(new PointLatLng((double)o[3], (double)o[4])); |
2768 | GMapMarker wpMarker = new GMapMarker(new PointLatLng((double)o[3], (double)o[4])); |
- | 2769 | wpMarker.Shape = new CustomMarkerWP(this, wpMarker, (string)dr[2], (int)o[1]); |
|
- | 2770 | wpMarker.Offset = new System.Windows.Point(-11.5, -11.5); |
|
2733 | wpMarker.Shape = new CustomMarkerWP(this, wpMarker, (string)dr[2], (int)o[1]); |
2771 | wpMarker.ZIndex = 100; |
2734 | _setMarkerColor(wpMarker, (int)o[1]); |
2772 | _setMarkerColor(wpMarker, (int)o[1]); |
- | 2773 | MainMap.Markers.Add(wpMarker); |
|
- | 2774 | if((int)o[1] == 0) |
|
Line 2735... | Line 2775... | ||
2735 | MainMap.Markers.Add(wpMarker); |
2775 | wpList.Add(new PointLatLng((double)o[3], (double)o[4])); |
2736 | 2776 | ||
2737 | Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString()); |
2777 | Dispatcher.Invoke(() => lblWPIndex.Content = k.ToString()); |
2738 | Dispatcher.Invoke(() => lblWPCount.Content = k.ToString()); |
2778 | Dispatcher.Invoke(() => lblWPCount.Content = k.ToString()); |
2739 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
2779 | Dispatcher.Invoke(() => dgvWP.Items.Refresh()); |
- | 2780 | Thread.Sleep(10); |
|
- | 2781 | } |
|
- | 2782 | Dispatcher.Invoke(() => |
|
- | 2783 | { |
|
- | 2784 | if (comboBoxRouteColor.SelectionBoxItem != null) |
|
- | 2785 | { |
|
- | 2786 | string s = comboBoxRouteColor.SelectionBoxItem.ToString(); |
|
- | 2787 | mRouteWP = new GMapRoute(wpList, _getBrush(s)); |
|
- | 2788 | } |
|
- | 2789 | else |
|
- | 2790 | mRouteWP = new GMapRoute(wpList, null); |
|
- | 2791 | ||
- | 2792 | if (_bShowWPRoute) |
|
- | 2793 | MainMap.Markers.Add(mRouteWP); |
|
- | 2794 | }); |
|
- | 2795 | ||
- | 2796 | MapRoute mr = new MapRoute(wpList, "WPList"); |
|
2740 | Thread.Sleep(10); |
2797 | Dispatcher.Invoke(() => lblWPRouteDistance.Content = (mr.Distance * 1000).ToString("0 m")); |
2741 | } |
2798 | |
2742 | } |
2799 | } |
Line 2743... | Line 2800... | ||
2743 | } |
2800 | } |
Line 2750... | Line 2807... | ||
2750 | MessageBox.Show("Error parsing wpl-file!" + Environment.NewLine + e.Message, "Read wpl-file", MessageBoxButton.OK, MessageBoxImage.Error); |
2807 | MessageBox.Show("Error parsing wpl-file!" + Environment.NewLine + e.Message, "Read wpl-file", MessageBoxButton.OK, MessageBoxImage.Error); |
2751 | } |
2808 | } |
Line 2752... | Line 2809... | ||
2752 | 2809 | ||
2753 | } |
2810 | } |
- | 2811 | } |
|
- | 2812 | Brush _getBrush(string color) |
|
- | 2813 | { |
|
- | 2814 | switch (color) |
|
- | 2815 | { |
|
- | 2816 | case "red": |
|
- | 2817 | return Brushes.Red; |
|
- | 2818 | case "green": |
|
- | 2819 | return Brushes.Lime; |
|
- | 2820 | case "blue": |
|
- | 2821 | return Brushes.Aqua; |
|
- | 2822 | case "pink": |
|
- | 2823 | return Brushes.Magenta; |
|
- | 2824 | case "yellow": |
|
- | 2825 | return Brushes.Yellow; |
|
- | 2826 | default: |
|
- | 2827 | return Brushes.Magenta; |
|
- | 2828 | } |
|
2754 | } |
2829 | } |
2755 | void _setMarkerColor(GMapMarker wpMarker,int iType) |
2830 | void _setMarkerColor(GMapMarker wpMarker,int iType) |
2756 | { |
2831 | { |
2757 | Dispatcher.Invoke(() => |
2832 | Dispatcher.Invoke(() => |
2758 | { |
2833 | { |
Line 2866... | Line 2941... | ||
2866 | } |
2941 | } |
2867 | else |
2942 | else |
2868 | ((CustomMarkerCopter)(copter.Shape)).setColor("red"); |
2943 | ((CustomMarkerCopter)(copter.Shape)).setColor("red"); |
2869 | }); |
2944 | }); |
2870 | } |
2945 | } |
- | 2946 | private void comboBoxRouteColor_DropDownClosed(object sender, EventArgs e) |
|
2871 | 2947 | { |
|
- | 2948 | Dispatcher.Invoke(() => |
|
- | 2949 | { |
|
- | 2950 | if (comboBoxRouteColor.SelectionBoxItem != null) |
|
- | 2951 | { |
|
- | 2952 | string s = comboBoxRouteColor.SelectionBoxItem.ToString(); |
|
- | 2953 | MainMap.Markers.Remove(mRouteWP); |
|
- | 2954 | mRouteWP = new GMapRoute(wpList, _getBrush(s)); |
|
- | 2955 | if (_bShowWPRoute) |
|
- | 2956 | MainMap.Markers.Add(mRouteWP); |
|
- | 2957 | } |
|
- | 2958 | }); |
|
- | 2959 | } |
|
- | 2960 | private void checkBoxShowWPRoute_Click(object sender, RoutedEventArgs e) |
|
- | 2961 | { |
|
- | 2962 | _bShowWPRoute = (bool)checkBoxShowWPRoute.IsChecked; |
|
- | 2963 | if (_bShowWPRoute) |
|
- | 2964 | { |
|
- | 2965 | if (mRouteWP != null) |
|
- | 2966 | MainMap.Markers.Add(mRouteWP); |
|
- | 2967 | } |
|
- | 2968 | else |
|
- | 2969 | { |
|
- | 2970 | if (mRouteWP != null) |
|
- | 2971 | MainMap.Markers.Remove(mRouteWP); |
|
- | 2972 | } |
|
- | 2973 | } |
|
2872 | private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
2974 | private void btnLoadWPLFile_Click(object sender, RoutedEventArgs e) |
2873 | { |
2975 | { |
2874 | _readWPLFile(); |
2976 | _readWPLFile(); |
2875 | } |
2977 | } |
2876 | #endregion WP |
2978 | #endregion WP |
Line 3019... | Line 3121... | ||
3019 | // MainMap.Markers.Remove(p); |
3121 | // MainMap.Markers.Remove(p); |
3020 | // else |
3122 | // else |
3021 | // k++; |
3123 | // k++; |
3022 | //} |
3124 | //} |
3023 | MapRoute mr = new MapRoute(wpl, "flying"); |
3125 | MapRoute mr = new MapRoute(wpl, "flying"); |
- | 3126 | Dispatcher.Invoke(() => |
|
- | 3127 | { |
|
- | 3128 | GMapRoute mRoute; |
|
- | 3129 | if (comboBoxRouteColor.SelectionBoxItem != null) |
|
- | 3130 | { |
|
- | 3131 | string s = comboBoxRouteColor.SelectionBoxItem.ToString(); |
|
- | 3132 | mRoute = new GMapRoute(wpList, _getBrush(s)); |
|
- | 3133 | } |
|
- | 3134 | else |
|
- | 3135 | mRoute = new GMapRoute(wpList, null); |
|
Line 3024... | Line 3136... | ||
3024 | 3136 | ||
3025 | GMapRoute mRoute = new GMapRoute(mr.Points); |
3137 | MainMap.Markers.Add(mRoute); |
3026 | MainMap.Markers.Add(mRoute); |
3138 | }); |
Line 3027... | Line 3139... | ||
3027 | } |
3139 | } |
3028 | 3140 | ||
3029 | } |
3141 | } |