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)
|
|
|
|
|
|
|
2014-10-19 21:50:23 +02:00
|
|
|
|
using System;
|
2016-07-03 00:32:11 +02:00
|
|
|
|
using System.Collections.Generic;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
using Windows.Foundation;
|
2014-10-19 21:50:23 +02:00
|
|
|
|
using Windows.UI.Core;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using Windows.UI.Xaml;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using Windows.UI.Xaml.Media.Animation;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2014-10-30 16:27:36 +01:00
|
|
|
|
internal static class Extensions
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2016-02-23 20:07:30 +01:00
|
|
|
|
public static IAsyncAction BeginInvoke(this CoreDispatcher dispatcher, Action action)
|
2014-10-19 21:50:23 +02:00
|
|
|
|
{
|
2016-02-23 20:07:30 +01:00
|
|
|
|
return dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(action));
|
2014-10-19 21:50:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-07-01 18:57:44 +02:00
|
|
|
|
public static Point Transform(this GeneralTransform transform, Point point)
|
|
|
|
|
|
{
|
|
|
|
|
|
return transform.TransformPoint(point);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public static void BeginAnimation(this DependencyObject obj, DependencyProperty property, DoubleAnimation animation)
|
|
|
|
|
|
{
|
|
|
|
|
|
animation.EnableDependentAnimation = true;
|
2016-07-03 00:32:11 +02:00
|
|
|
|
BeginAnimation(obj, property, (Timeline)animation);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void BeginAnimation(this DependencyObject obj, DependencyProperty property, PointAnimation animation)
|
|
|
|
|
|
{
|
|
|
|
|
|
animation.EnableDependentAnimation = true;
|
2016-07-03 00:32:11 +02:00
|
|
|
|
BeginAnimation(obj, property, (Timeline)animation);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-07-03 00:32:11 +02:00
|
|
|
|
private static Dictionary<DependencyProperty, string> properties = new Dictionary<DependencyProperty, string>()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2016-07-03 00:32:11 +02:00
|
|
|
|
{ UIElement.OpacityProperty, "Opacity" },
|
|
|
|
|
|
{ MapBase.ZoomLevelProperty, "ZoomLevel" },
|
|
|
|
|
|
{ MapBase.HeadingProperty, "Heading" },
|
|
|
|
|
|
{ MapBase.CenterPointProperty, "CenterPoint" }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private static void BeginAnimation(DependencyObject obj, DependencyProperty property, Timeline animation)
|
|
|
|
|
|
{
|
|
|
|
|
|
string propertyName;
|
|
|
|
|
|
if (properties.TryGetValue(property, out propertyName))
|
|
|
|
|
|
{
|
|
|
|
|
|
Storyboard.SetTargetProperty(animation, propertyName);
|
|
|
|
|
|
Storyboard.SetTarget(animation, obj);
|
|
|
|
|
|
var storyboard = new Storyboard();
|
|
|
|
|
|
storyboard.Children.Add(animation);
|
|
|
|
|
|
storyboard.Begin();
|
|
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|