XAML-Map-Control/MapControl/UWP/Extensions.UWP.cs

57 lines
1.9 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2020 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Windows.UI.Xaml;
2020-03-20 18:12:56 +01:00
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
namespace MapControl
{
2014-10-30 16:27:36 +01:00
internal static class Extensions
{
2020-03-20 18:12:56 +01:00
public static Point Transform(this GeneralTransform transform, Point point)
{
return transform.TransformPoint(point);
}
2017-11-10 17:26:15 +01:00
public static void BeginAnimation(this DependencyObject obj, DependencyProperty property, Timeline animation)
{
2017-11-10 17:26:15 +01:00
if (animation != null)
{
string propertyName = null;
2017-11-10 17:26:15 +01:00
if (property == MapBase.CenterPointProperty)
{
propertyName = "CenterPoint";
((PointAnimation)animation).EnableDependentAnimation = true;
}
else if (property == MapBase.ZoomLevelProperty)
{
propertyName = "ZoomLevel";
((DoubleAnimation)animation).EnableDependentAnimation = true;
}
else if (property == MapBase.HeadingProperty)
{
propertyName = "Heading";
((DoubleAnimation)animation).EnableDependentAnimation = true;
}
else if (property == UIElement.OpacityProperty)
{
propertyName = "Opacity";
}
2017-11-10 17:26:15 +01:00
if (propertyName != null)
{
Storyboard.SetTargetProperty(animation, propertyName);
Storyboard.SetTarget(animation, obj);
2017-08-04 21:38:58 +02:00
2017-11-10 17:26:15 +01:00
var storyboard = new Storyboard();
storyboard.Children.Add(animation);
storyboard.Begin();
}
}
}
}
}