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 CustomMarkerHome |
||
15 | { |
||
16 | //Popup Popup; |
||
17 | //Label Label; |
||
18 | GMapMarker Marker; |
||
19 | MainWindow MainWindow; |
||
20 | |||
21 | public CustomMarkerHome(MainWindow window, GMapMarker marker, string title) |
||
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(CustomMarkerHome_Unloaded); |
||
32 | this.Loaded += new RoutedEventHandler(CustomMarkerHome_Loaded); |
||
33 | this.SizeChanged += new SizeChangedEventHandler(CustomMarkerHome_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 CustomMarkerHome_Loaded(object sender, RoutedEventArgs e) |
||
55 | { |
||
56 | if (icon.Source.CanFreeze) |
||
57 | { |
||
58 | icon.Source.Freeze(); |
||
59 | } |
||
60 | } |
||
61 | |||
62 | void CustomMarkerHome_Unloaded(object sender, RoutedEventArgs e) |
||
63 | { |
||
64 | this.Unloaded -= new RoutedEventHandler(CustomMarkerHome_Unloaded); |
||
65 | this.Loaded -= new RoutedEventHandler(CustomMarkerHome_Loaded); |
||
66 | this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerHome_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 | } |
||
79 | public void setText(string s) |
||
80 | { |
||
81 | lbl.Content = s; |
||
82 | } |
||
83 | |||
84 | void CustomMarkerHome_SizeChanged(object sender, SizeChangedEventArgs e) |
||
85 | { |
||
86 | // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2); |
||
87 | } |
||
88 | |||
89 | void CustomMarkerHome_MouseMove(object sender, MouseEventArgs e) |
||
90 | { |
||
91 | if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) |
||
92 | { |
||
93 | Point p = e.GetPosition(MainWindow.MainMap); |
||
94 | Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y)); |
||
95 | } |
||
96 | } |
||
97 | |||
98 | void CustomMarkerHome_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
99 | { |
||
100 | if (!IsMouseCaptured) |
||
101 | { |
||
102 | Mouse.Capture(this); |
||
103 | } |
||
104 | } |
||
105 | |||
106 | void CustomMarkerHome_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
||
107 | { |
||
108 | if (IsMouseCaptured) |
||
109 | { |
||
110 | Mouse.Capture(null); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | void MarkerControl_MouseLeave(object sender, MouseEventArgs e) |
||
115 | { |
||
116 | Marker.ZIndex -= 10000; |
||
117 | //Popup.IsOpen = false; |
||
118 | } |
||
119 | |||
120 | void MarkerControl_MouseEnter(object sender, MouseEventArgs e) |
||
121 | { |
||
122 | Marker.ZIndex += 10000; |
||
123 | //Popup.IsOpen = true; |
||
124 | } |
||
125 | |||
126 | } |
||
127 | } |