///============================================================================
/// 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 CustomMarkerHome
{
//Popup Popup;
//Label Label;
GMapMarker Marker
;
MainWindow MainWindow
;
public CustomMarkerHome
(MainWindow window, GMapMarker marker,
string title
)
{
this.InitializeComponent();
this.MainWindow = window
;
this.Marker = marker
;
//Popup = new Popup();
//Label = new Label();
this.Unloaded += new RoutedEventHandler
(CustomMarkerHome_Unloaded
);
this.Loaded += new RoutedEventHandler
(CustomMarkerHome_Loaded
);
this.SizeChanged += new SizeChangedEventHandler
(CustomMarkerHome_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 CustomMarkerHome_Loaded
(object sender, RoutedEventArgs e
)
{
if (icon
.Source.CanFreeze)
{
icon
.Source.Freeze();
}
}
void CustomMarkerHome_Unloaded
(object sender, RoutedEventArgs e
)
{
this.Unloaded -= new RoutedEventHandler
(CustomMarkerHome_Unloaded
);
this.Loaded -= new RoutedEventHandler
(CustomMarkerHome_Loaded
);
this.SizeChanged -= new SizeChangedEventHandler
(CustomMarkerHome_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 void setText
(string s
)
{
lbl
.Content = s
;
}
void CustomMarkerHome_SizeChanged
(object sender, SizeChangedEventArgs e
)
{
// Marker.Offset = new Point(-e.NewSize.Width / 4, -e.NewSize.Height /2);
}
void CustomMarkerHome_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 CustomMarkerHome_MouseLeftButtonDown
(object sender, MouseButtonEventArgs e
)
{
if (!IsMouseCaptured
)
{
Mouse
.Capture(this);
}
}
void CustomMarkerHome_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;
}
}
}