Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2287 | - | 1 | using System.Windows; |
2 | using System.Windows.Controls; |
||
3 | using System.Windows.Controls.Primitives; |
||
4 | using System.Windows.Input; |
||
5 | using System.Windows.Media; |
||
6 | using GMap.NET.WindowsPresentation; |
||
7 | using System.Diagnostics; |
||
8 | |||
9 | namespace MKLiveView.GMapCustomMarkers |
||
10 | { |
||
11 | /// <summary> |
||
12 | /// Interaction logic for CustomMarkerCopter.xaml |
||
13 | /// </summary> |
||
14 | public partial class CustomMarkerCopter |
||
15 | { |
||
16 | //Popup Popup; |
||
17 | //Label Label; |
||
18 | GMapMarker Marker; |
||
19 | MainWindow MainWindow; |
||
20 | |||
2319 | - | 21 | public CustomMarkerCopter(MainWindow window, GMapMarker marker, string title, string sColor) |
2287 | - | 22 | { |
23 | this.InitializeComponent(); |
||
24 | |||
25 | this.MainWindow = window; |
||
26 | this.Marker = marker; |
||
27 | |||
28 | //Popup = new Popup(); |
||
29 | //Label = new Label(); |
||
30 | |||
31 | this.Unloaded += new RoutedEventHandler(CustomMarkerCopter_Unloaded); |
||
32 | this.Loaded += new RoutedEventHandler(CustomMarkerCopter_Loaded); |
||
33 | this.SizeChanged += new SizeChangedEventHandler(CustomMarkerCopter_SizeChanged); |
||
34 | //this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); |
||
35 | //this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); |
||
36 | //this.MouseMove += new MouseEventHandler(CustomMarkerCopter_MouseMove); |
||
37 | //this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonUp); |
||
38 | //this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonDown); |
||
39 | |||
40 | //Popup.Placement = PlacementMode.Mouse; |
||
41 | //{ |
||
42 | // Label.Background = Brushes.Blue; |
||
43 | // Label.Foreground = Brushes.White; |
||
44 | // Label.BorderBrush = Brushes.WhiteSmoke; |
||
45 | // Label.BorderThickness = new Thickness(2); |
||
46 | // Label.Padding = new Thickness(5); |
||
47 | // Label.FontSize = 22; |
||
48 | // Label.Content = title; |
||
49 | //} |
||
50 | //Popup.Child = Label; |
||
51 | lbl.Content = title; |
||
52 | } |
||
53 | |||
54 | void CustomMarkerCopter_Loaded(object sender, RoutedEventArgs e) |
||
55 | { |
||
56 | if (icon.Source.CanFreeze) |
||
57 | { |
||
58 | icon.Source.Freeze(); |
||
59 | } |
||
60 | } |
||
61 | |||
62 | void CustomMarkerCopter_Unloaded(object sender, RoutedEventArgs e) |
||
63 | { |
||
64 | this.Unloaded -= new RoutedEventHandler(CustomMarkerCopter_Unloaded); |
||
65 | this.Loaded -= new RoutedEventHandler(CustomMarkerCopter_Loaded); |
||
66 | this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerCopter_SizeChanged); |
||
67 | //this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter); |
||
68 | //this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave); |
||
69 | //this.MouseMove -= new MouseEventHandler(CustomMarkerCopter_MouseMove); |
||
70 | //this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonUp); |
||
71 | //this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonDown); |
||
72 | |||
73 | Marker.Shape = null; |
||
74 | icon.Source = null; |
||
75 | icon = null; |
||
76 | //Popup = null; |
||
77 | //Label = null; |
||
78 | } |
||
2388 | - | 79 | public double rotate |
80 | { |
||
2390 | - | 81 | set { Rotate1.Angle = value; } |
82 | get { return Rotate1.Angle; } |
||
2388 | - | 83 | } |
84 | |||
2287 | - | 85 | public void setText(string s) |
86 | { |
||
87 | lbl.Content = s; |
||
88 | } |
||
2388 | - | 89 | public void setCopterColor(string sColor) |
2319 | - | 90 | { |
91 | switch (sColor) |
||
92 | { |
||
93 | case "red": |
||
2390 | - | 94 | s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
95 | f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Red); |
||
96 | // icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterRed.png", System.UriKind.Relative)); |
||
2319 | - | 97 | break; |
98 | case "green": |
||
2390 | - | 99 | s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
100 | f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.SpringGreen); |
||
101 | // icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterGreen.png", System.UriKind.Relative)); |
||
2319 | - | 102 | break; |
103 | case "blue": |
||
2390 | - | 104 | // icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterBlue.png", System.UriKind.Relative)); |
105 | s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
||
106 | f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Cyan); |
||
2319 | - | 107 | break; |
108 | case "yellow": |
||
2390 | - | 109 | // icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterYellow.png", System.UriKind.Relative)); |
110 | s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
||
111 | f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Yellow); |
||
2319 | - | 112 | break; |
113 | case "pink": |
||
2390 | - | 114 | // icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterPink.png", System.UriKind.Relative)); |
115 | s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
||
116 | f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Magenta); |
||
2319 | - | 117 | break; |
2287 | - | 118 | |
2319 | - | 119 | default: |
2390 | - | 120 | s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
121 | f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Red); |
||
122 | // icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterRed.png", System.UriKind.Relative)); |
||
2319 | - | 123 | break; |
124 | } |
||
125 | } |
||
2388 | - | 126 | public void setHeadingColor(string sColor) |
127 | { |
||
128 | switch (sColor) |
||
129 | { |
||
130 | case "red": |
||
2390 | - | 131 | f7.Fill = new SolidColorBrush(Colors.Red); |
132 | // heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingRed.png", System.UriKind.Relative)); |
||
2388 | - | 133 | break; |
134 | case "green": |
||
2390 | - | 135 | f7.Fill = new SolidColorBrush(Colors.SpringGreen); |
136 | // heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingGreen.png", System.UriKind.Relative)); |
||
2388 | - | 137 | break; |
138 | case "blue": |
||
2390 | - | 139 | f7.Fill = new SolidColorBrush(Colors.Cyan); |
140 | // heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingBlue.png", System.UriKind.Relative)); |
||
2388 | - | 141 | break; |
142 | case "yellow": |
||
2390 | - | 143 | f7.Fill = new SolidColorBrush(Colors.Yellow); |
144 | // heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingYellow.png", System.UriKind.Relative)); |
||
2388 | - | 145 | break; |
146 | case "pink": |
||
2390 | - | 147 | f7.Fill = new SolidColorBrush(Colors.Magenta); |
148 | // heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingPink.png", System.UriKind.Relative)); |
||
2388 | - | 149 | break; |
150 | |||
151 | default: |
||
2390 | - | 152 | f7.Fill = new SolidColorBrush(Colors.Red); |
153 | // heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingRed.png", System.UriKind.Relative)); |
||
2388 | - | 154 | break; |
155 | } |
||
156 | } |
||
2287 | - | 157 | void CustomMarkerCopter_SizeChanged(object sender, SizeChangedEventArgs e) |
158 | { |
||
159 | // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2); |
||
160 | } |
||
161 | |||
162 | void CustomMarkerCopter_MouseMove(object sender, MouseEventArgs e) |
||
163 | { |
||
164 | if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) |
||
165 | { |
||
166 | Point p = e.GetPosition(MainWindow.MainMap); |
||
167 | Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y)); |
||
168 | } |
||
169 | } |
||
170 | |||
171 | void CustomMarkerCopter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
172 | { |
||
173 | if (!IsMouseCaptured) |
||
174 | { |
||
175 | Mouse.Capture(this); |
||
176 | } |
||
177 | } |
||
178 | |||
179 | void CustomMarkerCopter_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
||
180 | { |
||
181 | if (IsMouseCaptured) |
||
182 | { |
||
183 | Mouse.Capture(null); |
||
184 | } |
||
185 | } |
||
186 | |||
187 | void MarkerControl_MouseLeave(object sender, MouseEventArgs e) |
||
188 | { |
||
189 | Marker.ZIndex -= 10000; |
||
190 | //Popup.IsOpen = false; |
||
191 | } |
||
192 | |||
193 | void MarkerControl_MouseEnter(object sender, MouseEventArgs e) |
||
194 | { |
||
195 | Marker.ZIndex += 10000; |
||
196 | //Popup.IsOpen = true; |
||
197 | } |
||
198 | |||
199 | } |
||
200 | } |