Subversion Repositories Projects

Rev

Rev 2373 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2373 Rev 2420
Line 13... Line 13...
13
        //Popup Popup;
13
        //Popup Popup;
14
        //Label Label;
14
        //Label Label;
15
        GMapMarker Marker;
15
        GMapMarker Marker;
16
        MainWindow MainWindow;
16
        MainWindow MainWindow;
17
        int _type = 0;
17
        int _type = 0;
-
 
18
        public event positionChangedEventHandler positionChanged;
-
 
19
        public delegate void positionChangedEventHandler(CustomMarkerWP wp);
-
 
20
        public event newPositionEventHandler newPosition;
-
 
21
        public delegate void newPositionEventHandler(CustomMarkerWP wp);
-
 
22
        public event mouseCapturedEventHandler mouseCaptured;
-
 
23
        public delegate void mouseCapturedEventHandler(bool isCaptured);
Line 18... Line 24...
18
 
24
 
19
        public CustomMarkerWP(MainWindow window, GMapMarker marker, string title, int type)
25
        public CustomMarkerWP(MainWindow window, GMapMarker marker, string title, int type)
20
        {
26
        {
Line 26... Line 32...
26
 
32
 
27
            //Popup = new Popup();
33
            //Popup = new Popup();
Line 28... Line 34...
28
            //Label = new Label();
34
            //Label = new Label();
29
 
35
 
30
            //this.Unloaded += new RoutedEventHandler(CustomMarkerWP_Unloaded);
36
            //this.Unloaded += new RoutedEventHandler(CustomMarkerWP_Unloaded);
31
            //this.Loaded += new RoutedEventHandler(CustomMarkerWP_Loaded);
37
            this.Loaded += new RoutedEventHandler(CustomMarkerWP_Loaded);
32
            //this.SizeChanged += new SizeChangedEventHandler(CustomMarkerWP_SizeChanged);
38
            //this.SizeChanged += new SizeChangedEventHandler(CustomMarkerWP_SizeChanged);
33
            //this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter);
39
            this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter);
34
            //this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave);
40
            this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave);
35
            //this.MouseMove += new MouseEventHandler(CustomMarkerWP_MouseMove);
41
            this.MouseMove += new MouseEventHandler(CustomMarkerWP_MouseMove);
-
 
42
            this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonUp);
-
 
43
            this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonDown);
-
 
44
            StylusEnter += CustomMarkerWP_StylusEnter;
-
 
45
            StylusLeave += CustomMarkerWP_StylusLeave;
-
 
46
            StylusDown += CustomMarkerWP_StylusDown;
Line 36... Line 47...
36
            //this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonUp);
47
            StylusMove += CustomMarkerWP_StylusMove;
37
            //this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonDown);
48
            StylusUp += CustomMarkerWP_StylusUp;
38
 
49
 
39
            //Popup.Placement = PlacementMode.Mouse;
50
            //Popup.Placement = PlacementMode.Mouse;
Line 49... Line 60...
49
            //Popup.Child = Label;
60
            //Popup.Child = Label;
50
            text.Text = title;
61
            text.Text = title;
51
            setType();
62
            setType();
52
        }
63
        }
Line -... Line 64...
-
 
64
 
-
 
65
        private void CustomMarkerWP_StylusUp(object sender, StylusEventArgs e)
-
 
66
        {
-
 
67
            if (IsStylusCaptured)
-
 
68
            {
-
 
69
                Stylus.Capture(null);
-
 
70
                newPosition(this);
-
 
71
                mouseCaptured(false);
-
 
72
            }
-
 
73
        }
-
 
74
 
-
 
75
        private void CustomMarkerWP_StylusMove(object sender, StylusEventArgs e)
-
 
76
        {
-
 
77
            if (IsStylusCaptured)
-
 
78
            {
-
 
79
                Point p = e.GetPosition(MainWindow.MainMap);
-
 
80
                Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y));
-
 
81
                if (positionChanged != null)
-
 
82
                    positionChanged(this);
-
 
83
            }
-
 
84
        }
-
 
85
 
-
 
86
        private void CustomMarkerWP_StylusDown(object sender, StylusDownEventArgs e)
-
 
87
        {
-
 
88
            if (!IsStylusCaptured)
-
 
89
            {
-
 
90
                Stylus.Capture(this);
-
 
91
                mouseCaptured(true);
-
 
92
            }
-
 
93
        }
-
 
94
 
-
 
95
        private void CustomMarkerWP_StylusLeave(object sender, StylusEventArgs e)
-
 
96
        {
-
 
97
            Marker.ZIndex -= 10000;
-
 
98
        }
-
 
99
 
-
 
100
        private void CustomMarkerWP_StylusEnter(object sender, StylusEventArgs e)
-
 
101
        {
-
 
102
            Marker.ZIndex += 10000;
-
 
103
        }
53
 
104
 
54
        void setType()
105
        void setType()
55
        {
106
        {
56
            if (_type == 0)
107
            if (_type == 0)
57
            {
108
            {
Line 84... Line 135...
84
        void CustomMarkerWP_Unloaded(object sender, RoutedEventArgs e)
135
        void CustomMarkerWP_Unloaded(object sender, RoutedEventArgs e)
85
        {
136
        {
86
            //this.Unloaded -= new RoutedEventHandler(CustomMarkerWP_Unloaded);
137
            //this.Unloaded -= new RoutedEventHandler(CustomMarkerWP_Unloaded);
87
            //this.Loaded -= new RoutedEventHandler(CustomMarkerWP_Loaded);
138
            //this.Loaded -= new RoutedEventHandler(CustomMarkerWP_Loaded);
88
            //this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerWP_SizeChanged);
139
            //this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerWP_SizeChanged);
89
            //this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter);
140
            this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter);
90
            //this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave);
141
            this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave);
91
            //this.MouseMove -= new MouseEventHandler(CustomMarkerWP_MouseMove);
142
            this.MouseMove -= new MouseEventHandler(CustomMarkerWP_MouseMove);
92
            //this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonUp);
143
            this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonUp);
93
            //this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonDown);
144
            this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerWP_MouseLeftButtonDown);
-
 
145
            StylusEnter -= CustomMarkerWP_StylusEnter;
-
 
146
            StylusLeave -= CustomMarkerWP_StylusLeave;
-
 
147
            StylusDown -= CustomMarkerWP_StylusDown;
-
 
148
            StylusMove -= CustomMarkerWP_StylusMove;
-
 
149
            StylusUp -= CustomMarkerWP_StylusUp;
Line 94... Line 150...
94
 
150
 
95
            Marker.Shape = null;
151
            Marker.Shape = null;
96
            //icon.Source = null;
152
            //icon.Source = null;
97
            //icon = null;
153
            //icon = null;
Line 168... Line 224...
168
            // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2);
224
            // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2);
169
        }
225
        }
Line 170... Line 226...
170
 
226
 
171
        void CustomMarkerWP_MouseMove(object sender, MouseEventArgs e)
227
        void CustomMarkerWP_MouseMove(object sender, MouseEventArgs e)
172
        {
228
        {
173
            //if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured)
229
            if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured)
174
            //{
230
            {
175
            //    Point p = e.GetPosition(MainWindow.MainMap);
231
                Point p = e.GetPosition(MainWindow.MainMap);
-
 
232
                Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y));
-
 
233
                if(positionChanged != null)
176
            //    Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y));
234
                    positionChanged(this);
177
            //}
235
            }
Line 178... Line 236...
178
        }
236
        }
179
 
237
 
180
        void CustomMarkerWP_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
238
        void CustomMarkerWP_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
181
        {
239
        {
182
            //if (!IsMouseCaptured)
240
            if (!IsMouseCaptured)
-
 
241
            {
183
            //{
242
                Mouse.Capture(this);
184
            //    Mouse.Capture(this);
243
                mouseCaptured(true);
Line 185... Line 244...
185
            //}
244
            }
186
        }
245
        }
187
 
246
 
188
        void CustomMarkerWP_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
247
        void CustomMarkerWP_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
189
        {
248
        {
-
 
249
            if (IsMouseCaptured)
-
 
250
            {
190
            //if (IsMouseCaptured)
251
                Mouse.Capture(null);
191
            //{
252
                newPosition(this);
Line 192... Line 253...
192
            //    Mouse.Capture(null);
253
                mouseCaptured(false);
193
            //}
254
            }
194
        }
255
        }