Rev 2401 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2401 | Rev 2405 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | /// Interaktionslogik für MainWindow.xaml |
36 | /// Interaktionslogik für MainWindow.xaml |
37 | /// </summary> |
37 | /// </summary> |
38 | public partial class MainWindow : Window |
38 | public partial class MainWindow : Window |
39 | { |
39 | { |
40 | #region declarations |
40 | #region declarations |
- | 41 | object lockObj = new Object(); |
|
- | 42 | MediaPlayer.MediaPlayer mediaPlayer = new MediaPlayer.MediaPlayer(); |
|
Line 41... | Line 43... | ||
41 | 43 | ||
42 | GMapMarker copter; |
44 | GMapMarker copter; |
43 | GMapMarker home; |
45 | GMapMarker home; |
44 | PointLatLng start; |
46 | PointLatLng start; |
45 | PointLatLng end; |
47 | PointLatLng end; |
46 | PointLatLng pHome; |
48 | PointLatLng pHome; |
47 | GMapRoute mRouteWP; |
49 | GMapRoute mRouteWP; |
48 | GMapMarker wpActiveMarker; |
50 | GMapMarker wpActiveMarker; |
- | 51 | List<PointLatLng> wpList = new List<PointLatLng>(); |
|
- | 52 | Circle cWPBound = new Circle(); |
|
- | 53 | double dWPMaxRange = 0; |
|
49 | List<PointLatLng> wpList = new List<PointLatLng>(); |
54 | |
50 | #region NC-Errors |
55 | #region NC-Errors |
51 | String[] NC_Error = new string[44] |
56 | String[] NC_Error = new string[44] |
52 | { |
57 | { |
53 | "No Error", |
58 | "No Error", |
Line 737... | Line 742... | ||
737 | { |
742 | { |
738 | string s = comboBoxCopterHeadingColor.SelectionBoxItem.ToString(); |
743 | string s = comboBoxCopterHeadingColor.SelectionBoxItem.ToString(); |
739 | ((CustomMarkerCopter)(copter.Shape)).setHeadingColor(s); |
744 | ((CustomMarkerCopter)(copter.Shape)).setHeadingColor(s); |
740 | } |
745 | } |
741 | }); |
746 | }); |
742 | copter.Offset = new System.Windows.Point(-28, -28); |
747 | copter.Offset = new System.Windows.Point(-26, -26); |
743 | copter.ZIndex = int.MaxValue; |
748 | copter.ZIndex = int.MaxValue; |
744 | MainMap.Markers.Add(copter); |
749 | MainMap.Markers.Add(copter); |
745 | copter.Position = MainMap.Position; |
750 | copter.Position = MainMap.Position; |
746 | } |
751 | } |
747 | void _setHomePos() |
752 | void _setHomePos() |
Line 749... | Line 754... | ||
749 | pHome = MainMap.Position; |
754 | pHome = MainMap.Position; |
750 | if (!MainMap.Markers.Contains(home)) |
755 | if (!MainMap.Markers.Contains(home)) |
751 | { |
756 | { |
752 | home = new GMapMarker(MainMap.Position); |
757 | home = new GMapMarker(MainMap.Position); |
753 | home.Shape = new CustomMarkerHome(this, home, MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°")); |
758 | home.Shape = new CustomMarkerHome(this, home, MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°")); |
754 | home.Offset = new System.Windows.Point(-18, -18); |
759 | home.Offset = new System.Windows.Point(-16.5, -16.5); |
755 | // home.ZIndex = int.MaxValue; |
760 | // home.ZIndex = int.MaxValue; |
756 | MainMap.Markers.Add(home); |
761 | MainMap.Markers.Add(home); |
757 | } |
762 | } |
758 | home.Position = MainMap.Position; |
763 | home.Position = MainMap.Position; |
759 | ((CustomMarkerHome)(home.Shape)).setText(MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°")); |
764 | ((CustomMarkerHome)(home.Shape)).setText(MainMap.Position.Lat.ToString("0.#######°") + System.Environment.NewLine + MainMap.Position.Lng.ToString("0.#######°")); |
- | 765 | ||
- | 766 | if (checkBoxShowWPMaxRange.IsChecked == true) |
|
- | 767 | { |
|
- | 768 | if (cWPBound != null && cWPBound.Tag != null) |
|
- | 769 | MainMap.Markers.Remove(cWPBound.Tag as GMapMarker); |
|
- | 770 | ||
- | 771 | createCircle(home.Position, dWPMaxRange); |
|
- | 772 | } |
|
- | 773 | ||
760 | } |
774 | } |
761 | void _setActiveWP(int iIndex) |
775 | void _setActiveWP(int iIndex) |
762 | { |
776 | { |
763 | if (wpActiveMarker == null || !MainMap.Markers.Contains(wpActiveMarker)) |
777 | if (wpActiveMarker == null || !MainMap.Markers.Contains(wpActiveMarker)) |
764 | { |
778 | { |
Line 776... | Line 790... | ||
776 | Dispatcher.Invoke(() => tbWPStatusHeight.Text = dtWaypoints.Rows[iIndex][5].ToString() + " m"); |
790 | Dispatcher.Invoke(() => tbWPStatusHeight.Text = dtWaypoints.Rows[iIndex][5].ToString() + " m"); |
777 | } |
791 | } |
778 | void _clearHomePos() |
792 | void _clearHomePos() |
779 | { |
793 | { |
780 | MainMap.Markers.Remove(home); |
794 | MainMap.Markers.Remove(home); |
- | 795 | if (cWPBound != null && cWPBound.Tag != null) |
|
- | 796 | MainMap.Markers.Remove(cWPBound.Tag as GMapMarker); |
|
781 | } |
797 | } |
782 | void _clearMapMarkers(Type markerType) |
798 | void _clearMapMarkers(Type markerType) |
783 | { |
799 | { |
784 | for (int k = 0; k < MainMap.Markers.Count;) |
800 | for (int k = 0; k < MainMap.Markers.Count;) |
785 | { |
801 | { |
Line 830... | Line 846... | ||
830 | GMapMarker p = _findWPMarker(name); |
846 | GMapMarker p = _findWPMarker(name); |
831 | if (p != null) |
847 | if (p != null) |
832 | p.Position = point; |
848 | p.Position = point; |
833 | } |
849 | } |
Line -... | Line 850... | ||
- | 850 | ||
- | 851 | void createCircle(PointLatLng center, double distance) |
|
- | 852 | { |
|
- | 853 | ||
- | 854 | GMapMarker it = new GMapMarker(center); |
|
- | 855 | it.ZIndex = -1; |
|
- | 856 | ||
- | 857 | cWPBound.Center = center; |
|
- | 858 | cWPBound.Bound = GMap.NET.PureProjection.GetPointFromDistance(center, distance); |
|
- | 859 | cWPBound.Tag = it; |
|
- | 860 | cWPBound.IsHitTestVisible = false; |
|
- | 861 | UpdateCircle(cWPBound); |
|
- | 862 | it.Shape = cWPBound; |
|
- | 863 | MainMap.Markers.Add(it); |
|
- | 864 | } |
|
- | 865 | // calculates circle radius |
|
- | 866 | void UpdateCircle(Circle c) |
|
- | 867 | { |
|
- | 868 | var pxCenter = MainMap.FromLatLngToLocal(c.Center); |
|
- | 869 | var pxBounds = MainMap.FromLatLngToLocal(c.Bound); |
|
- | 870 | ||
- | 871 | double a = (double)(pxBounds.X - pxCenter.X); |
|
- | 872 | double b = (double)(pxBounds.Y - pxCenter.Y); |
|
- | 873 | var pxCircleRadius = Math.Sqrt(a * a + b * b); |
|
- | 874 | ||
- | 875 | c.Width = c.Height = pxCircleRadius * 2; |
|
- | 876 | //c.Width = 55 + pxCircleRadius * 2; |
|
- | 877 | //c.Height = 55 + pxCircleRadius * 2; |
|
- | 878 | (c.Tag as GMapMarker).Offset = new System.Windows.Point(-c.Width / 2, -c.Height / 2); |
|
- | 879 | } |
|
834 | 880 | ||
835 | // access mode |
881 | // access mode |
836 | private void comboBoxMode_DropDownClosed(object sender, EventArgs e) |
882 | private void comboBoxMode_DropDownClosed(object sender, EventArgs e) |
837 | { |
883 | { |
838 | MainMap.Manager.Mode = (AccessMode)comboBoxMode.SelectedItem; |
884 | MainMap.Manager.Mode = (AccessMode)comboBoxMode.SelectedItem; |
Line 933... | Line 979... | ||
933 | { |
979 | { |
934 | if (_bFollowCopter) |
980 | if (_bFollowCopter) |
935 | _setCopterData(MainMap.Position); |
981 | _setCopterData(MainMap.Position); |
936 | if((int)sliderMapZoom.Value != MainMap.Zoom) |
982 | if((int)sliderMapZoom.Value != MainMap.Zoom) |
937 | sliderMapZoom.Value = MainMap.Zoom; |
983 | sliderMapZoom.Value = MainMap.Zoom; |
- | 984 | if(cWPBound != null && cWPBound.Tag != null) |
|
- | 985 | UpdateCircle(cWPBound); |
|
938 | } |
986 | } |
Line 939... | Line 987... | ||
939 | 987 | ||
940 | void _setCopterData(PointLatLng p) |
988 | void _setCopterData(PointLatLng p) |
941 | { |
989 | { |
Line 1817... | Line 1865... | ||
1817 | Dispatcher.Invoke(() => stbSatFixLostAnim.Begin()); |
1865 | Dispatcher.Invoke(() => stbSatFixLostAnim.Begin()); |
1818 | _bAnimSatFixActive = true; |
1866 | _bAnimSatFixActive = true; |
1819 | } |
1867 | } |
1820 | if (_bVoiceSatFixPlay && !_bVoiceSatFixActive) |
1868 | if (_bVoiceSatFixPlay && !_bVoiceSatFixActive) |
1821 | { |
1869 | { |
- | 1870 | _bVoiceSatFixActive = true; |
|
1822 | ThreadPool.QueueUserWorkItem(new WaitCallback(_mediaPlayer), "Voice\\SatFixLost.mp3"); |
1871 | ThreadPool.QueueUserWorkItem(new WaitCallback(_mediaPlayer), "Voice\\SatFixLost.mp3"); |
1823 | //Thread th = new Thread(() => _mediaPlayer("Voice\\SatFixLost.mp3")); |
1872 | //Thread th = new Thread(() => _mediaPlayer("Voice\\SatFixLost.mp3")); |
1824 | //th.Start(); |
1873 | //th.Start(); |
1825 | _bVoiceSatFixActive = true; |
- | |
1826 | } |
1874 | } |
Line 1827... | Line 1875... | ||
1827 | 1875 | ||
1828 | _bSatFix = false; |
1876 | _bSatFix = false; |
1829 | } |
1877 | } |
Line 1959... | Line 2007... | ||
1959 | Dispatcher.Invoke(() => stbRCLevelAnim.Begin()); |
2007 | Dispatcher.Invoke(() => stbRCLevelAnim.Begin()); |
1960 | _bAnimRCLevelActive = true; |
2008 | _bAnimRCLevelActive = true; |
1961 | } |
2009 | } |
1962 | if (_bVoiceRCLevelPlay && !_bVoiceRCLevelActive) |
2010 | if (_bVoiceRCLevelPlay && !_bVoiceRCLevelActive) |
1963 | { |
2011 | { |
- | 2012 | _bVoiceRCLevelActive = true; |
|
1964 | ThreadPool.QueueUserWorkItem(new WaitCallback(_mediaPlayer), "Voice\\MagneticField.mp3"); |
2013 | ThreadPool.QueueUserWorkItem(new WaitCallback(_mediaPlayer), "Voice\\MagneticField.mp3"); |
1965 | //Thread th = new Thread(() => _mediaPlayer("Voice\\RCLevel.mp3")); |
2014 | //Thread th = new Thread(() => _mediaPlayer("Voice\\RCLevel.mp3")); |
1966 | //th.Start(); |
2015 | //th.Start(); |
1967 | _bVoiceRCLevelActive = true; |
- | |
1968 | } |
2016 | } |
1969 | _iRCLevelJitter++; |
2017 | _iRCLevelJitter++; |
1970 | } |
2018 | } |
1971 | } |
2019 | } |
Line -... | Line 2020... | ||
- | 2020 | ||
- | 2021 | //Waypoint max range (by license) |
|
- | 2022 | if(dWPMaxRange != (double)data[70]) |
|
- | 2023 | { |
|
- | 2024 | dWPMaxRange = (double)data[70]; |
|
- | 2025 | if (home != null && checkBoxShowWPMaxRange.IsChecked == true) |
|
- | 2026 | { |
|
- | 2027 | if (cWPBound != null && cWPBound.Tag != null) |
|
- | 2028 | MainMap.Markers.Remove(cWPBound.Tag as GMapMarker); |
|
- | 2029 | ||
- | 2030 | createCircle(home.Position, dWPMaxRange); |
|
- | 2031 | } |
|
- | 2032 | Dispatcher.Invoke((Action)(() => tbWPMaxRange.Text = data[70].ToString() + " m")); |
|
1972 | 2033 | } |
|
1973 | //Target hold time |
2034 | //Target hold time |
1974 | Dispatcher.Invoke((Action)(() => lblWPHoldTime.Content = data[73].ToString()+ " s")); |
2035 | Dispatcher.Invoke((Action)(() => lblWPHoldTime.Content = data[73].ToString()+ " s")); |
Line 1975... | Line 2036... | ||
1975 | Dispatcher.Invoke((Action)(() => tbWPStatusHoldTime.Text = data[73].ToString()+ " s")); |
2036 | Dispatcher.Invoke((Action)(() => tbWPStatusHoldTime.Text = data[73].ToString()+ " s")); |
Line 2592... | Line 2653... | ||
2592 | 2653 | ||
Line 2593... | Line 2654... | ||
2593 | #endregion controller messages |
2654 | #endregion controller messages |
2594 | 2655 | ||
- | 2656 | void _mediaPlayer(object file) |
|
- | 2657 | { |
|
- | 2658 | Monitor.TryEnter(lockObj); |
|
2595 | void _mediaPlayer(object file) |
2659 | try |
- | 2660 | { |
|
- | 2661 | if (File.Exists((string)file)) |
|
- | 2662 | { |
|
- | 2663 | ||
- | 2664 | mediaPlayer.Open((string)file); |
|
- | 2665 | mediaPlayer.Play(); |
|
- | 2666 | } |
|
- | 2667 | ||
2596 | { |
2668 | } |
2597 | if (File.Exists((string)file)) |
- | |
2598 | { |
2669 | finally |
2599 | MediaPlayer.MediaPlayer mp = new MediaPlayer.MediaPlayer(); |
- | |
2600 | mp.Open((string)file); |
2670 | { |
2601 | mp.Play(); |
2671 | Monitor.Exit(lockObj); |
Line 2602... | Line 2672... | ||
2602 | } |
2672 | } |
2603 | } |
2673 | } |
Line 4231... | Line 4301... | ||
4231 | dgvWP.SelectedIndex = (int)o[0] -1; |
4301 | dgvWP.SelectedIndex = (int)o[0] -1; |
4232 | dgvWP.UpdateLayout(); |
4302 | dgvWP.UpdateLayout(); |
4233 | _dgvWPselectEditRow(); |
4303 | _dgvWPselectEditRow(); |
4234 | }); |
4304 | }); |
4235 | } |
4305 | } |
- | 4306 | private void checkBoxShowWPStatus_Click(object sender, RoutedEventArgs e) |
|
- | 4307 | { |
|
- | 4308 | if (WPStatus.Visibility == Visibility.Visible) |
|
- | 4309 | GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value + 36, GridOSD.Margin.Right, GridOSD.Margin.Bottom); |
|
- | 4310 | else |
|
- | 4311 | GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value, GridOSD.Margin.Right, GridOSD.Margin.Bottom); |
|
- | 4312 | } |
|
- | 4313 | private void checkBoxShowWPMaxRange_click(object sender, RoutedEventArgs e) |
|
- | 4314 | { |
|
- | 4315 | if (home != null && checkBoxShowWPMaxRange.IsChecked == true && dWPMaxRange > 0) |
|
- | 4316 | { |
|
- | 4317 | if (cWPBound != null && cWPBound.Tag != null) |
|
- | 4318 | MainMap.Markers.Remove(cWPBound.Tag as GMapMarker); |
|
Line -... | Line 4319... | ||
- | 4319 | ||
- | 4320 | createCircle(home.Position, dWPMaxRange); |
|
- | 4321 | } |
|
- | 4322 | if (checkBoxShowWPMaxRange.IsChecked == false && (cWPBound != null && cWPBound.Tag != null)) |
|
- | 4323 | MainMap.Markers.Remove(cWPBound.Tag as GMapMarker); |
|
4236 | 4324 | } |
|
4237 | #endregion WP |
4325 | #endregion WP |
4238 | #region GPX |
4326 | #region GPX |
4239 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
4327 | private void checkBoxGPXLog_Click(object sender, RoutedEventArgs e) |
4240 | { |
4328 | { |
Line 4302... | Line 4390... | ||
4302 | myXmlTextWriter.Close(); |
4390 | myXmlTextWriter.Close(); |
4303 | } |
4391 | } |
4304 | } |
4392 | } |
4305 | } |
4393 | } |
Line 4306... | Line -... | ||
4306 | - | ||
4307 | private void checkBoxShowWPStatus_Click(object sender, RoutedEventArgs e) |
- | |
4308 | { |
- | |
4309 | if (WPStatus.Visibility == Visibility.Visible) |
- | |
4310 | GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value + 36, GridOSD.Margin.Right, GridOSD.Margin.Bottom); |
- | |
4311 | else |
- | |
4312 | GridOSD.Margin = new Thickness(GridOSD.Margin.Left, 36 * UIScaleTopSlider.Value, GridOSD.Margin.Right, GridOSD.Margin.Bottom); |
- | |
Line 4313... | Line 4394... | ||
4313 | } |
4394 | |
4314 | 4395 | ||
4315 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
4396 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
4316 | { |
4397 | { |