mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Media.Animation;
|
|
|
|
namespace MapControl
|
|
{
|
|
public class LocationAnimation : AnimationTimeline
|
|
{
|
|
public override Type TargetPropertyType => typeof(Location);
|
|
|
|
public Location To { get; set; }
|
|
|
|
public IEasingFunction EasingFunction { get; set; }
|
|
|
|
protected override Freezable CreateInstanceCore()
|
|
{
|
|
return new LocationAnimation
|
|
{
|
|
To = To,
|
|
EasingFunction = EasingFunction
|
|
};
|
|
}
|
|
|
|
public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
|
|
{
|
|
var from = (Location)defaultOriginValue;
|
|
var progress = animationClock.CurrentProgress ?? 1d;
|
|
|
|
if (EasingFunction != null)
|
|
{
|
|
progress = EasingFunction.Ease(progress);
|
|
}
|
|
|
|
return new Location(
|
|
(1d - progress) * from.Latitude + progress * To.Latitude,
|
|
(1d - progress) * from.Longitude + progress * To.Longitude);
|
|
}
|
|
}
|
|
}
|