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 | { |
||
81 | set { Rotate.Angle = value; } |
||
82 | get { return Rotate.Angle; } |
||
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": |
||
94 | icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterRed.png", System.UriKind.Relative)); |
||
95 | break; |
||
96 | case "green": |
||
97 | icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterGreen.png", System.UriKind.Relative)); |
||
98 | break; |
||
99 | case "blue": |
||
100 | icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterBlue.png", System.UriKind.Relative)); |
||
101 | break; |
||
102 | case "yellow": |
||
103 | icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterYellow.png", System.UriKind.Relative)); |
||
104 | break; |
||
105 | case "pink": |
||
106 | icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterPink.png", System.UriKind.Relative)); |
||
107 | break; |
||
2287 | - | 108 | |
2319 | - | 109 | default: |
110 | icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterRed.png", System.UriKind.Relative)); |
||
111 | break; |
||
112 | } |
||
113 | } |
||
2388 | - | 114 | public void setHeadingColor(string sColor) |
115 | { |
||
116 | switch (sColor) |
||
117 | { |
||
118 | case "red": |
||
119 | heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingRed.png", System.UriKind.Relative)); |
||
120 | break; |
||
121 | case "green": |
||
122 | heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingGreen.png", System.UriKind.Relative)); |
||
123 | break; |
||
124 | case "blue": |
||
125 | heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingBlue.png", System.UriKind.Relative)); |
||
126 | break; |
||
127 | case "yellow": |
||
128 | heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingYellow.png", System.UriKind.Relative)); |
||
129 | break; |
||
130 | case "pink": |
||
131 | heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingPink.png", System.UriKind.Relative)); |
||
132 | break; |
||
133 | |||
134 | default: |
||
135 | heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingRed.png", System.UriKind.Relative)); |
||
136 | break; |
||
137 | } |
||
138 | } |
||
2287 | - | 139 | void CustomMarkerCopter_SizeChanged(object sender, SizeChangedEventArgs e) |
140 | { |
||
141 | // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2); |
||
142 | } |
||
143 | |||
144 | void CustomMarkerCopter_MouseMove(object sender, MouseEventArgs e) |
||
145 | { |
||
146 | if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) |
||
147 | { |
||
148 | Point p = e.GetPosition(MainWindow.MainMap); |
||
149 | Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y)); |
||
150 | } |
||
151 | } |
||
152 | |||
153 | void CustomMarkerCopter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
154 | { |
||
155 | if (!IsMouseCaptured) |
||
156 | { |
||
157 | Mouse.Capture(this); |
||
158 | } |
||
159 | } |
||
160 | |||
161 | void CustomMarkerCopter_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
||
162 | { |
||
163 | if (IsMouseCaptured) |
||
164 | { |
||
165 | Mouse.Capture(null); |
||
166 | } |
||
167 | } |
||
168 | |||
169 | void MarkerControl_MouseLeave(object sender, MouseEventArgs e) |
||
170 | { |
||
171 | Marker.ZIndex -= 10000; |
||
172 | //Popup.IsOpen = false; |
||
173 | } |
||
174 | |||
175 | void MarkerControl_MouseEnter(object sender, MouseEventArgs e) |
||
176 | { |
||
177 | Marker.ZIndex += 10000; |
||
178 | //Popup.IsOpen = true; |
||
179 | } |
||
180 | |||
181 | } |
||
182 | } |