mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-01 22:30:14 +01:00
Improved BeginAnimation extension methods for UWP.
This commit is contained in:
parent
5011138446
commit
da684bff95
|
|
@ -3,6 +3,7 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
|
|
@ -26,38 +27,34 @@ namespace MapControl
|
|||
public static void BeginAnimation(this DependencyObject obj, DependencyProperty property, DoubleAnimation animation)
|
||||
{
|
||||
animation.EnableDependentAnimation = true;
|
||||
|
||||
if (property == UIElement.OpacityProperty)
|
||||
{
|
||||
BeginAnimation(obj, "Opacity", animation);
|
||||
}
|
||||
else if (property == MapBase.ZoomLevelProperty)
|
||||
{
|
||||
BeginAnimation(obj, "ZoomLevel", animation);
|
||||
}
|
||||
else if (property == MapBase.HeadingProperty)
|
||||
{
|
||||
BeginAnimation(obj, "Heading", animation);
|
||||
}
|
||||
BeginAnimation(obj, property, (Timeline)animation);
|
||||
}
|
||||
|
||||
public static void BeginAnimation(this DependencyObject obj, DependencyProperty property, PointAnimation animation)
|
||||
{
|
||||
animation.EnableDependentAnimation = true;
|
||||
|
||||
if (property == MapBase.CenterPointProperty)
|
||||
{
|
||||
BeginAnimation(obj, "CenterPoint", animation);
|
||||
}
|
||||
BeginAnimation(obj, property, (Timeline)animation);
|
||||
}
|
||||
|
||||
private static void BeginAnimation(DependencyObject obj, string property, Timeline animation)
|
||||
private static Dictionary<DependencyProperty, string> properties = new Dictionary<DependencyProperty, string>()
|
||||
{
|
||||
Storyboard.SetTargetProperty(animation, property);
|
||||
Storyboard.SetTarget(animation, obj);
|
||||
var storyboard = new Storyboard();
|
||||
storyboard.Children.Add(animation);
|
||||
storyboard.Begin();
|
||||
{ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -425,8 +425,8 @@ namespace MapControl
|
|||
{
|
||||
var p1 = mapTransform.Transform(southWest);
|
||||
var p2 = mapTransform.Transform(northEast);
|
||||
var lonScale = RenderSize.Width / (p2.X - p1.X) * 360d / (double)TileSource.TileSize;
|
||||
var latScale = RenderSize.Height / (p2.Y - p1.Y) * 360d / (double)TileSource.TileSize;
|
||||
var lonScale = RenderSize.Width / (p2.X - p1.X) * 360d / TileSource.TileSize;
|
||||
var latScale = RenderSize.Height / (p2.Y - p1.Y) * 360d / TileSource.TileSize;
|
||||
var lonZoom = Math.Log(lonScale, 2d);
|
||||
var latZoom = Math.Log(latScale, 2d);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue