mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
LocationAnimation.WPF
This commit is contained in:
parent
8f01f63b99
commit
c95df3b81b
1 changed files with 0 additions and 0 deletions
43
MapControl/WPF/LocationAnimation.WPF.cs
Normal file
43
MapControl/WPF/LocationAnimation.WPF.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue