0,0 → 1,251 |
///============================================================================ |
/// MKLiveView |
/// Copyright © 2016 Steph |
/// |
///This file is part of MKLiveView. |
/// |
///MKLiveView is free software: you can redistribute it and/or modify |
///it under the terms of the GNU General Public License as published by |
///the Free Software Foundation, either version 3 of the License, or |
///(at your option) any later version. |
/// |
///MKLiveView is distributed in the hope that it will be useful, |
///but WITHOUT ANY WARRANTY; without even the implied warranty of |
///MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
///GNU General Public License for more details. |
/// |
///You should have received a copy of the GNU General Public License |
///along with cssRcon. If not, see <http://www.gnu.org/licenses/>. |
/// |
///============================================================================ |
///Credits: |
|
/// radioman (http://www.codeplex.com/site/users/view/radioman) |
/// for his really GreatMaps! (http://greatmaps.codeplex.com/) |
/// |
/// I made some changes to the source, so You need all files from this project here in order to compile and run |
/// |
/// JOHN C. MACDONALD at Ira A. Fulton College of Engineering and Technology |
/// for his MIKROKOPTER SERIAL CONTROL TUTORIAL (http://hdl.lib.byu.edu/1877/2747) |
/// and the sourcecode (http://hdl.lib.byu.edu/1877/2748) |
/// By his work I finally managed to get the communication with the Mikrokopter controllers to run |
/// Some of his code was used in this programm like the SimpelSerialPort class (with lots of changes) |
/// and the FilghtControllerMessage class |
/// |
///============================================================================ |
/// DISCLAIMER |
/// =========== |
/// |
/// I created this software with my best knowledge and belief. |
/// |
/// IN NO EVENT, UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, |
/// SHALL I, OR ANY PERSON BE LIABLE FOR ANY LOSS, EXPENSE OR DAMAGE, |
/// OF ANY TYPE OR NATURE ARISING OUT OF THE USE OF, |
/// OR INABILITY TO USE THIS SOFTWARE OR PROGRAM, |
/// INCLUDING, BUT NOT LIMITED TO, CLAIMS, SUITS OR CAUSES OF ACTION |
/// INVOLVING ALLEGED INFRINGEMENT OF COPYRIGHTS, |
/// PATENTS, TRADEMARKS, TRADE SECRETS, OR UNFAIR COMPETITION. |
/// |
/// This means: use it & have fun (but @ Your own risk...) |
/// =========================================================================== |
|
using System.Windows; |
using System.Windows.Controls; |
using System.Windows.Controls.Primitives; |
using System.Windows.Input; |
using System.Windows.Media; |
using GMap.NET.WindowsPresentation; |
using System.Diagnostics; |
|
namespace MKLiveView.GMapCustomMarkers |
{ |
/// <summary> |
/// Interaction logic for CustomMarkerCopter.xaml |
/// </summary> |
public partial class CustomMarkerCopter |
{ |
//Popup Popup; |
//Label Label; |
GMapMarker Marker; |
MainWindow MainWindow; |
|
public CustomMarkerCopter(MainWindow window, GMapMarker marker, string title, string sColor) |
{ |
this.InitializeComponent(); |
|
this.MainWindow = window; |
this.Marker = marker; |
|
//Popup = new Popup(); |
//Label = new Label(); |
|
this.Unloaded += new RoutedEventHandler(CustomMarkerCopter_Unloaded); |
this.Loaded += new RoutedEventHandler(CustomMarkerCopter_Loaded); |
this.SizeChanged += new SizeChangedEventHandler(CustomMarkerCopter_SizeChanged); |
//this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); |
//this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); |
//this.MouseMove += new MouseEventHandler(CustomMarkerCopter_MouseMove); |
//this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonUp); |
//this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonDown); |
|
//Popup.Placement = PlacementMode.Mouse; |
//{ |
// Label.Background = Brushes.Blue; |
// Label.Foreground = Brushes.White; |
// Label.BorderBrush = Brushes.WhiteSmoke; |
// Label.BorderThickness = new Thickness(2); |
// Label.Padding = new Thickness(5); |
// Label.FontSize = 22; |
// Label.Content = title; |
//} |
//Popup.Child = Label; |
lbl.Content = title; |
} |
|
void CustomMarkerCopter_Loaded(object sender, RoutedEventArgs e) |
{ |
//if (icon.Source.CanFreeze) |
//{ |
// icon.Source.Freeze(); |
//} |
} |
|
void CustomMarkerCopter_Unloaded(object sender, RoutedEventArgs e) |
{ |
this.Unloaded -= new RoutedEventHandler(CustomMarkerCopter_Unloaded); |
this.Loaded -= new RoutedEventHandler(CustomMarkerCopter_Loaded); |
this.SizeChanged -= new SizeChangedEventHandler(CustomMarkerCopter_SizeChanged); |
//this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter); |
//this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave); |
//this.MouseMove -= new MouseEventHandler(CustomMarkerCopter_MouseMove); |
//this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonUp); |
//this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerCopter_MouseLeftButtonDown); |
|
Marker.Shape = null; |
//icon.Source = null; |
//icon = null; |
//Popup = null; |
//Label = null; |
} |
public double rotate |
{ |
set { Rotate1.Angle = value; } |
get { return Rotate1.Angle; } |
} |
|
public void setText(string s) |
{ |
lbl.Content = s; |
} |
public void setCopterColor(string sColor) |
{ |
switch (sColor) |
{ |
case "red": |
s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Red); |
// icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterRed.png", System.UriKind.Relative)); |
break; |
case "green": |
s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.SpringGreen); |
// icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterGreen.png", System.UriKind.Relative)); |
break; |
case "blue": |
// icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterBlue.png", System.UriKind.Relative)); |
s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Cyan); |
break; |
case "yellow": |
// icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterYellow.png", System.UriKind.Relative)); |
s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Yellow); |
break; |
case "pink": |
// icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterPink.png", System.UriKind.Relative)); |
s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Magenta); |
break; |
|
default: |
s1.Stroke = s2.Stroke = s3.Stroke = s4.Stroke = s5.Stroke = s6.Stroke = s7.Stroke = s8.Stroke = |
f1.Fill = f2.Fill = f3.Fill = f4.Fill = f5.Fill = f6.Fill = new SolidColorBrush(Colors.Red); |
// icon.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterRed.png", System.UriKind.Relative)); |
break; |
} |
} |
public void setHeadingColor(string sColor) |
{ |
switch (sColor) |
{ |
case "red": |
f7.Fill = new SolidColorBrush(Colors.Red); |
// heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingRed.png", System.UriKind.Relative)); |
break; |
case "green": |
f7.Fill = new SolidColorBrush(Colors.SpringGreen); |
// heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingGreen.png", System.UriKind.Relative)); |
break; |
case "blue": |
f7.Fill = new SolidColorBrush(Colors.Cyan); |
// heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingBlue.png", System.UriKind.Relative)); |
break; |
case "yellow": |
f7.Fill = new SolidColorBrush(Colors.Yellow); |
// heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingYellow.png", System.UriKind.Relative)); |
break; |
case "pink": |
f7.Fill = new SolidColorBrush(Colors.Magenta); |
// heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingPink.png", System.UriKind.Relative)); |
break; |
|
default: |
f7.Fill = new SolidColorBrush(Colors.Red); |
// heading.Source = new System.Windows.Media.Imaging.BitmapImage(new System.Uri("CopterHeadingRed.png", System.UriKind.Relative)); |
break; |
} |
} |
void CustomMarkerCopter_SizeChanged(object sender, SizeChangedEventArgs e) |
{ |
// Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2); |
} |
|
void CustomMarkerCopter_MouseMove(object sender, MouseEventArgs e) |
{ |
if (e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) |
{ |
Point p = e.GetPosition(MainWindow.MainMap); |
Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int)(p.X), (int)(p.Y)); |
} |
} |
|
void CustomMarkerCopter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
{ |
if (!IsMouseCaptured) |
{ |
Mouse.Capture(this); |
} |
} |
|
void CustomMarkerCopter_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
{ |
if (IsMouseCaptured) |
{ |
Mouse.Capture(null); |
} |
} |
|
void MarkerControl_MouseLeave(object sender, MouseEventArgs e) |
{ |
Marker.ZIndex -= 10000; |
//Popup.IsOpen = false; |
} |
|
void MarkerControl_MouseEnter(object sender, MouseEventArgs e) |
{ |
Marker.ZIndex += 10000; |
//Popup.IsOpen = true; |
} |
|
} |
} |