2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2014-01-10 20:11:39 +01:00
|
|
|
|
// Copyright © 2014 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2014-07-01 18:57:44 +02:00
|
|
|
|
#if WINDOWS_RUNTIME
|
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;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register(
|
2013-04-12 19:59:16 +02:00
|
|
|
|
"Foreground", typeof(Brush), typeof(MapBase), 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(
|
|
|
|
|
|
"Center", typeof(Location), typeof(MapBase), new PropertyMetadata(new Location(),
|
|
|
|
|
|
(o, e) => ((MapBase)o).CenterPropertyChanged((Location)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetCenterProperty = DependencyProperty.Register(
|
|
|
|
|
|
"TargetCenter", typeof(Location), typeof(MapBase), new PropertyMetadata(new Location(),
|
|
|
|
|
|
(o, e) => ((MapBase)o).TargetCenterPropertyChanged((Location)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty ZoomLevelProperty = DependencyProperty.Register(
|
|
|
|
|
|
"ZoomLevel", typeof(double), typeof(MapBase), new PropertyMetadata(1d,
|
|
|
|
|
|
(o, e) => ((MapBase)o).ZoomLevelPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetZoomLevelProperty = DependencyProperty.Register(
|
|
|
|
|
|
"TargetZoomLevel", typeof(double), typeof(MapBase), new PropertyMetadata(1d,
|
|
|
|
|
|
(o, e) => ((MapBase)o).TargetZoomLevelPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty HeadingProperty = DependencyProperty.Register(
|
|
|
|
|
|
"Heading", typeof(double), typeof(MapBase), new PropertyMetadata(0d,
|
|
|
|
|
|
(o, e) => ((MapBase)o).HeadingPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetHeadingProperty = DependencyProperty.Register(
|
|
|
|
|
|
"TargetHeading", typeof(double), typeof(MapBase), new PropertyMetadata(0d,
|
|
|
|
|
|
(o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
partial void Initialize()
|
|
|
|
|
|
{
|
2013-05-13 23:49:48 +02:00
|
|
|
|
Background = new SolidColorBrush(Colors.Transparent);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
Clip = new RectangleGeometry();
|
|
|
|
|
|
|
|
|
|
|
|
SizeChanged += OnRenderSizeChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnRenderSizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
|
|
{
|
2014-06-11 23:03:13 +02:00
|
|
|
|
((RectangleGeometry)Clip).Rect = new Rect(new Point(), e.NewSize);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
ResetTransformOrigin();
|
|
|
|
|
|
UpdateTransform();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-12-20 17:05:10 +01:00
|
|
|
|
private void SetTransformMatrixes()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2013-12-20 17:05:10 +01:00
|
|
|
|
scaleTransform.Matrix = new Matrix(CenterScale, 0d, 0d, CenterScale, 0d, 0d);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
rotateTransform.Matrix = Matrix.Identity.Rotate(Heading);
|
|
|
|
|
|
scaleRotateTransform.Matrix = scaleTransform.Matrix.Multiply(rotateTransform.Matrix);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|