Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2316 | - | 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 | public partial class CustomMarkerWP |
||
12 | { |
||
13 | //Popup Popup; |
||
14 | //Label Label; |
||
15 | GMapMarker Marker; |
||
16 | MainWindow MainWindow; |
||
17 | int _type = 0; |
||
18 | |||
19 | public CustomMarkerWP(MainWindow window, GMapMarker marker, string title, int type) |
||
20 | { |
||
21 | this.InitializeComponent(); |
||
22 | |||
23 | this.MainWindow = window; |
||
24 | this.Marker = marker; |
||
25 | _type = type; |
||
26 | |||
27 | //Popup = new Popup(); |
||
28 | //Label = new Label(); |
||
29 | |||
30 | //this.Unloaded += new RoutedEventHandler(CustomMarkerWP_Unloaded); |
||
31 | //this.Loaded += new RoutedEventHandler(CustomMarkerWP_Loaded); |
||
32 | //this.SizeChanged += new SizeChangedEventHandler(CustomMarkerWP_SizeChanged); |
||
33 | //this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); |
||
34 | //this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); |
||
35 | //this.MouseMove += new MouseEventHandler(CustomMarkerWP_MouseMove); |
||
36 | //this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonUp); |
||
37 | //this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonDown); |
||
38 | |||
39 | //Popup.Placement = PlacementMode.Mouse; |
||
40 | //{ |
||
41 | // Label.Background = Brushes.Blue; |
||
42 | // Label.Foreground = Brushes.White; |
||
43 | // Label.BorderBrush = Brushes.WhiteSmoke; |
||
44 | // Label.BorderThickness = new Thickness(2); |
||
45 | // Label.Padding = new Thickness(5); |
||
46 | // Label.FontSize = 22; |
||
47 | // Label.Content = title; |
||
48 | //} |
||
49 | //Popup.Child = Label; |
||
50 | text.Text = title; |
||
2373 | - | 51 | setType(); |
2316 | - | 52 | } |
53 | |||
2373 | - | 54 | void setType() |
55 | { |
||
56 | if (_type == 0) |
||
57 | { |
||
58 | gLanding.Visibility = Visibility.Hidden; |
||
59 | rect.Visibility = Visibility.Hidden; |
||
60 | ellipse.Visibility = Visibility.Visible; |
||
61 | } |
||
62 | if (_type == 1 | _type == 2) |
||
63 | { |
||
64 | gLanding.Visibility = Visibility.Hidden; |
||
65 | ellipse.Visibility = Visibility.Hidden; |
||
66 | rect.Visibility = Visibility.Visible; |
||
67 | } |
||
68 | if (_type == 3) |
||
69 | { |
||
70 | gLanding.Visibility = Visibility.Visible; |
||
71 | ellipse.Visibility = Visibility.Hidden; |
||
72 | rect.Visibility = Visibility.Hidden; |
||
73 | } |
||
74 | |||
75 | } |
||
2316 | - | 76 | void CustomMarkerWP_Loaded(object sender, RoutedEventArgs e) |
77 | { |
||
78 | //if (icon.Source.CanFreeze) |
||
79 | //{ |
||
80 | // icon.Source.Freeze(); |
||
81 | //} |
||
82 | } |
||
83 | |||
84 | void CustomMarkerWP_Unloaded(object sender, RoutedEventArgs e) |
||
85 | { |
||
86 | //this.Unloaded -= new RoutedEventHandler(CustomMarkerWP_Unloaded); |
||
87 | //this.Loaded -= new RoutedEventHandler(CustomMarkerWP_Loaded); |
||
88 | //this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerWP_SizeChanged); |
||
89 | //this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter); |
||
90 | //this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave); |
||
91 | //this.MouseMove -= new MouseEventHandler(CustomMarkerWP_MouseMove); |
||
92 | //this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonUp); |
||
93 | //this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonDown); |
||
94 | |||
95 | Marker.Shape = null; |
||
96 | //icon.Source = null; |
||
97 | //icon = null; |
||
98 | //Popup = null; |
||
99 | //Label = null; |
||
100 | } |
||
101 | public string WPText |
||
102 | { |
||
103 | get { return text.Text; } |
||
104 | set { text.Text = value; } |
||
105 | } |
||
106 | public int WPType |
||
107 | { |
||
108 | get { return _type; } |
||
2373 | - | 109 | set |
110 | { |
||
111 | _type = value; |
||
112 | setType(); |
||
113 | } |
||
2316 | - | 114 | } |
115 | |||
116 | public void setColor(string sColor) |
||
117 | { |
||
118 | RadialGradientBrush rgb = new RadialGradientBrush(); |
||
119 | GradientStop gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0x00, 0x00),0), gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x1B, 0x1B),1); |
||
120 | switch (sColor) |
||
121 | { |
||
122 | case "red": |
||
123 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x3A, 0x00)); |
||
2373 | - | 124 | rect.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x3A, 0x00)); |
125 | landing.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x3A, 0x00)); |
||
2316 | - | 126 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0x00, 0x00),0); |
127 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x1B, 0x1B),1); |
||
128 | break; |
||
129 | case "green": |
||
130 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0x00)); |
||
2373 | - | 131 | rect.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0x00)); |
132 | landing.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0x00)); |
||
2316 | - | 133 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0x00, 0xFD, 0x50),0); |
134 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x2F, 0x1B),1); |
||
135 | break; |
||
136 | case "yellow": |
||
137 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x00)); |
||
2373 | - | 138 | rect.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x00)); |
139 | landing.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x00)); |
||
2316 | - | 140 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0xFD, 0x00),0); |
141 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x5F, 0x1B),1); |
||
142 | break; |
||
143 | case "blue": |
||
144 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0xFF)); |
||
2373 | - | 145 | rect.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0xFF)); |
146 | landing.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0xFF)); |
||
2316 | - | 147 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0x00, 0xDB, 0xFD),0); |
148 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x00, 0x66, 0x5C),1); |
||
149 | break; |
||
150 | case "pink": |
||
151 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0xFF)); |
||
2373 | - | 152 | rect.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0xFF)); |
153 | landing.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0xFF)); |
||
2316 | - | 154 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0x00, 0xCF),0); |
155 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x00, 0x66),1); |
||
156 | break; |
||
157 | } |
||
158 | rgb.GradientStops.Add(gs0); |
||
159 | rgb.GradientStops.Add(gs1); |
||
160 | ellipse.Fill = rgb; |
||
2373 | - | 161 | rect.Fill = rgb; |
162 | landing.Fill = rgb; |
||
163 | |||
2316 | - | 164 | } |
165 | |||
166 | void CustomMarkerWP_SizeChanged(object sender, SizeChangedEventArgs e) |
||
167 | { |
||
168 | // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2); |
||
169 | } |
||
170 | |||
171 | void CustomMarkerWP_MouseMove(object sender, MouseEventArgs e) |
||
172 | { |
||
173 | //if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) |
||
174 | //{ |
||
175 | // Point p = e.GetPosition(MainWindow.MainMap); |
||
176 | // Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y)); |
||
177 | //} |
||
178 | } |
||
179 | |||
180 | void CustomMarkerWP_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
181 | { |
||
182 | //if (!IsMouseCaptured) |
||
183 | //{ |
||
184 | // Mouse.Capture(this); |
||
185 | //} |
||
186 | } |
||
187 | |||
188 | void CustomMarkerWP_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
||
189 | { |
||
190 | //if (IsMouseCaptured) |
||
191 | //{ |
||
192 | // Mouse.Capture(null); |
||
193 | //} |
||
194 | } |
||
195 | |||
196 | void MarkerControl_MouseLeave(object sender, MouseEventArgs e) |
||
197 | { |
||
198 | Marker.ZIndex -= 10000; |
||
199 | //Popup.IsOpen = false; |
||
200 | } |
||
201 | |||
202 | void MarkerControl_MouseEnter(object sender, MouseEventArgs e) |
||
203 | { |
||
204 | Marker.ZIndex += 10000; |
||
205 | //Popup.IsOpen = true; |
||
206 | } |
||
207 | |||
208 | } |
||
209 | } |