2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
|
|
|
|
// © 2017 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2015-08-09 20:04:44 +02:00
|
|
|
|
#if NETFX_CORE
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using Windows.Foundation;
|
2013-04-21 23:56:08 +02:00
|
|
|
|
using Windows.UI;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using Windows.UI.Xaml;
|
2015-08-09 20:04:44 +02:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
#else
|
|
|
|
|
|
using System.Windows;
|
2015-08-09 20:04:44 +02:00
|
|
|
|
using System.Windows.Media;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(Foreground), typeof(Brush), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(new SolidColorBrush(Colors.Black)));
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
2013-12-05 17:56:04 +01:00
|
|
|
|
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(Center), typeof(Location), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(new Location(), (o, e) => ((MapBase)o).CenterPropertyChanged((Location)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetCenterProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(TargetCenter), typeof(Location), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(new Location(), (o, e) => ((MapBase)o).TargetCenterPropertyChanged((Location)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty ZoomLevelProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(ZoomLevel), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(1d, (o, e) => ((MapBase)o).ZoomLevelPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetZoomLevelProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(TargetZoomLevel), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(1d, (o, e) => ((MapBase)o).TargetZoomLevelPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty HeadingProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(Heading), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(0d, (o, e) => ((MapBase)o).HeadingPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetHeadingProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(TargetHeading), typeof(double), typeof(MapBase),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(0d, (o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue)));
|
2013-12-05 17:56:04 +01:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
partial void Initialize()
|
|
|
|
|
|
{
|
2017-06-25 23:05:48 +02:00
|
|
|
|
// set Background by Style to enable resetting by ClearValue in MapLayerPropertyChanged
|
2014-11-19 21:11:14 +01:00
|
|
|
|
var style = new Style(typeof(MapBase));
|
2016-08-08 20:36:02 +02:00
|
|
|
|
style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
|
2014-11-19 21:11:14 +01:00
|
|
|
|
Style = style;
|
|
|
|
|
|
|
2015-08-25 20:04:33 +02:00
|
|
|
|
var clip = new RectangleGeometry();
|
|
|
|
|
|
Clip = clip;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
2015-08-25 20:04:33 +02:00
|
|
|
|
SizeChanged += (s, e) =>
|
|
|
|
|
|
{
|
2016-08-08 20:36:02 +02:00
|
|
|
|
if (clip.Rect.Width != e.NewSize.Width || clip.Rect.Height != e.NewSize.Height)
|
|
|
|
|
|
{
|
|
|
|
|
|
clip.Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height);
|
|
|
|
|
|
|
2017-06-25 23:05:48 +02:00
|
|
|
|
ResetTransformCenter();
|
2016-08-08 20:36:02 +02:00
|
|
|
|
UpdateTransform();
|
|
|
|
|
|
}
|
2015-08-25 20:04:33 +02:00
|
|
|
|
};
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|