mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-20 22:05:07 +00:00
WinUI animated Center
This commit is contained in:
parent
74f4e0176b
commit
5bc9c73fad
2 changed files with 12 additions and 9 deletions
|
|
@ -8,6 +8,7 @@ using Microsoft.UI.Xaml;
|
||||||
#else
|
#else
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
#endif
|
#endif
|
||||||
|
#pragma warning disable IDE0060 // Remove unused parameter
|
||||||
|
|
||||||
namespace MapControl
|
namespace MapControl
|
||||||
{
|
{
|
||||||
|
|
@ -16,7 +17,7 @@ namespace MapControl
|
||||||
public static DependencyProperty Register<TOwner, TValue>(
|
public static DependencyProperty Register<TOwner, TValue>(
|
||||||
string name,
|
string name,
|
||||||
TValue defaultValue = default,
|
TValue defaultValue = default,
|
||||||
bool bindTwoWayByDefault = false,
|
bool bindTwoWayByDefault = false, // unused in WinUI/UWP
|
||||||
Action<TOwner, TValue, TValue> changed = null)
|
Action<TOwner, TValue, TValue> changed = null)
|
||||||
where TOwner : DependencyObject
|
where TOwner : DependencyObject
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +31,7 @@ namespace MapControl
|
||||||
public static DependencyProperty RegisterAttached<TOwner, TValue>(
|
public static DependencyProperty RegisterAttached<TOwner, TValue>(
|
||||||
string name,
|
string name,
|
||||||
TValue defaultValue = default,
|
TValue defaultValue = default,
|
||||||
bool inherits = false,
|
bool inherits = false, // unused in WinUI/UWP
|
||||||
Action<FrameworkElement, TValue, TValue> changed = null)
|
Action<FrameworkElement, TValue, TValue> changed = null)
|
||||||
where TOwner : DependencyObject
|
where TOwner : DependencyObject
|
||||||
{
|
{
|
||||||
|
|
@ -42,3 +43,5 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning restore IDE0060
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,12 @@ namespace MapControl
|
||||||
public static readonly DependencyProperty ViewScaleProperty =
|
public static readonly DependencyProperty ViewScaleProperty =
|
||||||
DependencyPropertyHelper.Register<MapBase, double>(nameof(ViewScale), 0d);
|
DependencyPropertyHelper.Register<MapBase, double>(nameof(ViewScale), 0d);
|
||||||
|
|
||||||
|
private static readonly DependencyProperty AnimatedCenterProperty =
|
||||||
|
DependencyPropertyHelper.Register<MapBase, Windows.Foundation.Point>(nameof(AnimatedCenter),
|
||||||
|
new Windows.Foundation.Point(), false, (map, oldValue, newValue) => map.Center = new Location(newValue.Y, newValue.X));
|
||||||
|
|
||||||
|
private Windows.Foundation.Point AnimatedCenter => (Windows.Foundation.Point)GetValue(AnimatedCenterProperty);
|
||||||
|
|
||||||
private PointAnimation centerAnimation;
|
private PointAnimation centerAnimation;
|
||||||
private DoubleAnimation zoomLevelAnimation;
|
private DoubleAnimation zoomLevelAnimation;
|
||||||
private DoubleAnimation headingAnimation;
|
private DoubleAnimation headingAnimation;
|
||||||
|
|
@ -138,12 +144,6 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0052 // Remove unread private members
|
|
||||||
private static readonly DependencyProperty CenterPointProperty =
|
|
||||||
DependencyPropertyHelper.Register<MapBase, Windows.Foundation.Point>("CenterPoint",
|
|
||||||
new Windows.Foundation.Point(), false, (map, oldValue, newValue) => map.Center = new Location(newValue.Y, newValue.X));
|
|
||||||
#pragma warning restore IDE0052
|
|
||||||
|
|
||||||
private void TargetCenterPropertyChanged(Location value)
|
private void TargetCenterPropertyChanged(Location value)
|
||||||
{
|
{
|
||||||
if (!internalPropertyChange)
|
if (!internalPropertyChange)
|
||||||
|
|
@ -173,7 +173,7 @@ namespace MapControl
|
||||||
|
|
||||||
centerAnimation.Completed += CenterAnimationCompleted;
|
centerAnimation.Completed += CenterAnimationCompleted;
|
||||||
|
|
||||||
this.BeginAnimation("CenterPoint", centerAnimation);
|
this.BeginAnimation(nameof(AnimatedCenter), centerAnimation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue