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; |
||
51 | } |
||
52 | |||
53 | void CustomMarkerWP_Loaded(object sender, RoutedEventArgs e) |
||
54 | { |
||
55 | //if (icon.Source.CanFreeze) |
||
56 | //{ |
||
57 | // icon.Source.Freeze(); |
||
58 | //} |
||
59 | } |
||
60 | |||
61 | void CustomMarkerWP_Unloaded(object sender, RoutedEventArgs e) |
||
62 | { |
||
63 | //this.Unloaded -= new RoutedEventHandler(CustomMarkerWP_Unloaded); |
||
64 | //this.Loaded -= new RoutedEventHandler(CustomMarkerWP_Loaded); |
||
65 | //this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerWP_SizeChanged); |
||
66 | //this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter); |
||
67 | //this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave); |
||
68 | //this.MouseMove -= new MouseEventHandler(CustomMarkerWP_MouseMove); |
||
69 | //this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonUp); |
||
70 | //this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonDown); |
||
71 | |||
72 | Marker.Shape = null; |
||
73 | //icon.Source = null; |
||
74 | //icon = null; |
||
75 | //Popup = null; |
||
76 | //Label = null; |
||
77 | } |
||
78 | public string WPText |
||
79 | { |
||
80 | get { return text.Text; } |
||
81 | set { text.Text = value; } |
||
82 | } |
||
83 | public int WPType |
||
84 | { |
||
85 | get { return _type; } |
||
86 | set { _type = value; } |
||
87 | } |
||
88 | |||
89 | public void setColor(string sColor) |
||
90 | { |
||
91 | RadialGradientBrush rgb = new RadialGradientBrush(); |
||
92 | GradientStop gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0x00, 0x00),0), gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x1B, 0x1B),1); |
||
93 | switch (sColor) |
||
94 | { |
||
95 | case "red": |
||
96 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x3A, 0x00)); |
||
97 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0x00, 0x00),0); |
||
98 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x1B, 0x1B),1); |
||
99 | break; |
||
100 | case "green": |
||
101 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0x00)); |
||
102 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0x00, 0xFD, 0x50),0); |
||
103 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x2F, 0x1B),1); |
||
104 | break; |
||
105 | case "yellow": |
||
106 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0x00)); |
||
107 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0xFD, 0x00),0); |
||
108 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x5F, 0x1B),1); |
||
109 | break; |
||
110 | case "blue": |
||
111 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0xFF)); |
||
112 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0x00, 0xDB, 0xFD),0); |
||
113 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x00, 0x66, 0x5C),1); |
||
114 | break; |
||
115 | case "pink": |
||
116 | ellipse.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0xFF)); |
||
117 | gs0 = new GradientStop(Color.FromArgb(0xFF, 0xFD, 0x00, 0xCF),0); |
||
118 | gs1 = new GradientStop(Color.FromArgb(0xFF, 0x66, 0x00, 0x66),1); |
||
119 | break; |
||
120 | } |
||
121 | rgb.GradientStops.Add(gs0); |
||
122 | rgb.GradientStops.Add(gs1); |
||
123 | ellipse.Fill = rgb; |
||
124 | } |
||
125 | |||
126 | void CustomMarkerWP_SizeChanged(object sender, SizeChangedEventArgs e) |
||
127 | { |
||
128 | // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2); |
||
129 | } |
||
130 | |||
131 | void CustomMarkerWP_MouseMove(object sender, MouseEventArgs e) |
||
132 | { |
||
133 | //if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) |
||
134 | //{ |
||
135 | // Point p = e.GetPosition(MainWindow.MainMap); |
||
136 | // Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y)); |
||
137 | //} |
||
138 | } |
||
139 | |||
140 | void CustomMarkerWP_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
141 | { |
||
142 | //if (!IsMouseCaptured) |
||
143 | //{ |
||
144 | // Mouse.Capture(this); |
||
145 | //} |
||
146 | } |
||
147 | |||
148 | void CustomMarkerWP_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
||
149 | { |
||
150 | //if (IsMouseCaptured) |
||
151 | //{ |
||
152 | // Mouse.Capture(null); |
||
153 | //} |
||
154 | } |
||
155 | |||
156 | void MarkerControl_MouseLeave(object sender, MouseEventArgs e) |
||
157 | { |
||
158 | Marker.ZIndex -= 10000; |
||
159 | //Popup.IsOpen = false; |
||
160 | } |
||
161 | |||
162 | void MarkerControl_MouseEnter(object sender, MouseEventArgs e) |
||
163 | { |
||
164 | Marker.ZIndex += 10000; |
||
165 | //Popup.IsOpen = true; |
||
166 | } |
||
167 | |||
168 | } |
||
169 | } |