Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2500 - 1
///============================================================================
2
/// MKLiveView 
3
/// Copyright © 2016 Steph
4
/// 
5
///This file is part of MKLiveView.
6
///
7
///MKLiveView is free software: you can redistribute it and/or modify
8
///it under the terms of the GNU General Public License as published by
9
///the Free Software Foundation, either version 3 of the License, or
10
///(at your option) any later version.
11
///
12
///MKLiveView is distributed in the hope that it will be useful,
13
///but WITHOUT ANY WARRANTY; without even the implied warranty of
14
///MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
///GNU General Public License for more details.
16
///
17
///You should have received a copy of the GNU General Public License
18
///along with cssRcon.  If not, see <http://www.gnu.org/licenses/>.
19
///
20
///============================================================================
21
///Credits:
22
 
23
/// radioman (http://www.codeplex.com/site/users/view/radioman)
24
/// for his really GreatMaps! (http://greatmaps.codeplex.com/)
25
///
26
/// I made some changes to the source, so You need all files from this project here in order to compile and run
27
///
28
/// JOHN C. MACDONALD at Ira A. Fulton College of Engineering and Technology
29
/// for his MIKROKOPTER SERIAL CONTROL TUTORIAL (http://hdl.lib.byu.edu/1877/2747)
30
/// and the sourcecode (http://hdl.lib.byu.edu/1877/2748)
31
/// By his work I finally managed to get the communication with the Mikrokopter controllers to run
32
/// Some of his code was used in this programm like the SimpelSerialPort class (with lots of changes)
33
/// and the FilghtControllerMessage class
34
/// 
35
///============================================================================
36
/// DISCLAIMER
37
/// ===========
38
/// 
39
/// I created this software with my best knowledge and belief.
40
/// 
41
/// IN NO EVENT, UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, 
42
/// SHALL I, OR ANY PERSON BE LIABLE FOR ANY LOSS, EXPENSE OR DAMAGE, 
43
/// OF ANY TYPE OR NATURE ARISING OUT OF THE USE OF, 
44
/// OR INABILITY TO USE THIS SOFTWARE OR PROGRAM, 
45
/// INCLUDING, BUT NOT LIMITED TO, CLAIMS, SUITS OR CAUSES OF ACTION 
46
/// INVOLVING ALLEGED INFRINGEMENT OF COPYRIGHTS, 
47
/// PATENTS, TRADEMARKS, TRADE SECRETS, OR UNFAIR COMPETITION.
48
/// 
49
/// This means: use it & have fun (but @ Your own risk...)
50
/// ===========================================================================
51
using System.Windows;
52
using System.Windows.Controls;
53
using System.Windows.Controls.Primitives;
54
using System.Windows.Input;
55
using System.Windows.Media;
56
using GMap.NET.WindowsPresentation;
57
using System.Diagnostics;
58
 
59
namespace MKLiveView.GMapCustomMarkers
60
{
61
    /// <summary>
62
    /// Interaction logic for CustomMarkerCopter.xaml
63
    /// </summary>
64
    public partial class CustomMarkerHome
65
    {
66
        //Popup Popup;
67
        //Label Label;
68
        GMapMarker Marker;
69
        MainWindow MainWindow;
70
 
71
        public CustomMarkerHome(MainWindow window, GMapMarker marker, string title)
72
        {
73
            this.InitializeComponent();
74
 
75
            this.MainWindow = window;
76
            this.Marker = marker;
77
 
78
            //Popup = new Popup();
79
            //Label = new Label();
80
 
81
            this.Unloaded += new RoutedEventHandler(CustomMarkerHome_Unloaded);
82
            this.Loaded += new RoutedEventHandler(CustomMarkerHome_Loaded);
83
            this.SizeChanged += new SizeChangedEventHandler(CustomMarkerHome_SizeChanged);
84
            //this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter);
85
            //this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave);
86
            //this.MouseMove += new MouseEventHandler(CustomMarkerCopter_MouseMove);
87
            //this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonUp);
88
            //this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonDown);
89
 
90
            //Popup.Placement = PlacementMode.Mouse;
91
            //{
92
            //   Label.Background = Brushes.Blue;
93
            //   Label.Foreground = Brushes.White;
94
            //   Label.BorderBrush = Brushes.WhiteSmoke;
95
            //   Label.BorderThickness = new Thickness(2);
96
            //   Label.Padding = new Thickness(5);
97
            //   Label.FontSize = 22;
98
            //   Label.Content = title;
99
            //}
100
            //Popup.Child = Label;
101
            lbl.Content = title;
102
        }
103
 
104
        void CustomMarkerHome_Loaded(object sender, RoutedEventArgs e)
105
        {
106
            if (icon.Source.CanFreeze)
107
            {
108
                icon.Source.Freeze();
109
            }
110
        }
111
 
112
        void CustomMarkerHome_Unloaded(object sender, RoutedEventArgs e)
113
        {
114
            this.Unloaded -= new RoutedEventHandler(CustomMarkerHome_Unloaded);
115
            this.Loaded -= new RoutedEventHandler(CustomMarkerHome_Loaded);
116
            this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerHome_SizeChanged);
117
            //this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter);
118
            //this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave);
119
            //this.MouseMove -= new MouseEventHandler(CustomMarkerCopter_MouseMove);
120
            //this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonUp);
121
            //this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonDown);
122
 
123
            Marker.Shape = null;
124
            icon.Source = null;
125
            icon = null;
126
            //Popup = null;
127
            //Label = null;         
128
        }
129
        public void setText(string s)
130
        {
131
            lbl.Content = s;
132
        }
133
 
134
        void CustomMarkerHome_SizeChanged(object sender, SizeChangedEventArgs e)
135
        {
136
           // Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2);
137
        }
138
 
139
        void CustomMarkerHome_MouseMove(object sender, MouseEventArgs e)
140
        {
141
            if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured)
142
            {
143
                Point p = e.GetPosition(MainWindow.MainMap);
144
                Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y));
145
            }
146
        }
147
 
148
        void CustomMarkerHome_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
149
        {
150
            if (!IsMouseCaptured)
151
            {
152
                Mouse.Capture(this);
153
            }
154
        }
155
 
156
        void CustomMarkerHome_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
157
        {
158
            if (IsMouseCaptured)
159
            {
160
                Mouse.Capture(null);
161
            }
162
        }
163
 
164
        void MarkerControl_MouseLeave(object sender, MouseEventArgs e)
165
        {
166
            Marker.ZIndex -= 10000;
167
            //Popup.IsOpen = false;
168
        }
169
 
170
        void MarkerControl_MouseEnter(object sender, MouseEventArgs e)
171
        {
172
            Marker.ZIndex += 10000;
173
            //Popup.IsOpen = true;
174
        }
175
 
176
    }
177
}