2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2013-05-07 18:12:25 +02:00
|
|
|
|
// Copyright © Clemens Fischer 2012-2013
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty ForegroundProperty =
|
|
|
|
|
|
System.Windows.Controls.Control.ForegroundProperty.AddOwner(typeof(MapBase));
|
|
|
|
|
|
|
2013-12-05 17:56:04 +01:00
|
|
|
|
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register(
|
|
|
|
|
|
"Center", typeof(Location), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
|
|
|
|
new Location(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
|
|
|
|
(o, e) => ((MapBase)o).CenterPropertyChanged((Location)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetCenterProperty = DependencyProperty.Register(
|
|
|
|
|
|
"TargetCenter", typeof(Location), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
|
|
|
|
new Location(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
|
|
|
|
(o, e) => ((MapBase)o).TargetCenterPropertyChanged((Location)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty ZoomLevelProperty = DependencyProperty.Register(
|
|
|
|
|
|
"ZoomLevel", typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
|
|
|
|
1d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
|
|
|
|
(o, e) => ((MapBase)o).ZoomLevelPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetZoomLevelProperty = DependencyProperty.Register(
|
|
|
|
|
|
"TargetZoomLevel", typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
|
|
|
|
1d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
|
|
|
|
(o, e) => ((MapBase)o).TargetZoomLevelPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty HeadingProperty = DependencyProperty.Register(
|
|
|
|
|
|
"Heading", typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
|
|
|
|
0d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
|
|
|
|
(o, e) => ((MapBase)o).HeadingPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetHeadingProperty = DependencyProperty.Register(
|
|
|
|
|
|
"TargetHeading", typeof(double), typeof(MapBase), new FrameworkPropertyMetadata(
|
|
|
|
|
|
0d, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
|
|
|
|
|
(o, e) => ((MapBase)o).TargetHeadingPropertyChanged((double)e.NewValue)));
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
static MapBase()
|
|
|
|
|
|
{
|
|
|
|
|
|
UIElement.ClipToBoundsProperty.OverrideMetadata(
|
|
|
|
|
|
typeof(MapBase), new FrameworkPropertyMetadata(true));
|
|
|
|
|
|
|
|
|
|
|
|
Panel.BackgroundProperty.OverrideMetadata(
|
|
|
|
|
|
typeof(MapBase), new FrameworkPropertyMetadata(Brushes.Transparent));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partial void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
AddVisualChild(tileContainer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-30 18:23:13 +01:00
|
|
|
|
partial void RemoveAnimation(DependencyProperty property)
|
|
|
|
|
|
{
|
|
|
|
|
|
BeginAnimation(property, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-06-19 18:57:54 +02:00
|
|
|
|
protected override int VisualChildrenCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return base.VisualChildrenCount + 1; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override Visual GetVisualChild(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return tileContainer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return base.GetVisualChild(index - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-04-04 18:01:13 +02:00
|
|
|
|
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2013-04-04 18:01:13 +02:00
|
|
|
|
base.OnRenderSizeChanged(sizeInfo);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
ResetTransformOrigin();
|
|
|
|
|
|
UpdateTransform();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetTransformMatrixes(double scale)
|
|
|
|
|
|
{
|
|
|
|
|
|
Matrix rotateMatrix = Matrix.Identity;
|
|
|
|
|
|
rotateMatrix.Rotate(Heading);
|
|
|
|
|
|
rotateTransform.Matrix = rotateMatrix;
|
|
|
|
|
|
scaleTransform.Matrix = new Matrix(scale, 0d, 0d, scale, 0d, 0d);
|
|
|
|
|
|
scaleRotateTransform.Matrix = scaleTransform.Matrix * rotateMatrix;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|