From 5bc9c73fad142df585f42e20eb9115169001c10e Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Tue, 21 May 2024 14:06:36 +0200 Subject: [PATCH] WinUI animated Center --- MapControl/WinUI/DependencyPropertyHelper.WinUI.cs | 7 +++++-- MapControl/WinUI/MapBase.WinUI.cs | 14 +++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/MapControl/WinUI/DependencyPropertyHelper.WinUI.cs b/MapControl/WinUI/DependencyPropertyHelper.WinUI.cs index b14a12a9..aef65d7d 100644 --- a/MapControl/WinUI/DependencyPropertyHelper.WinUI.cs +++ b/MapControl/WinUI/DependencyPropertyHelper.WinUI.cs @@ -8,6 +8,7 @@ using Microsoft.UI.Xaml; #else using Windows.UI.Xaml; #endif +#pragma warning disable IDE0060 // Remove unused parameter namespace MapControl { @@ -16,7 +17,7 @@ namespace MapControl public static DependencyProperty Register( string name, TValue defaultValue = default, - bool bindTwoWayByDefault = false, + bool bindTwoWayByDefault = false, // unused in WinUI/UWP Action changed = null) where TOwner : DependencyObject { @@ -30,7 +31,7 @@ namespace MapControl public static DependencyProperty RegisterAttached( string name, TValue defaultValue = default, - bool inherits = false, + bool inherits = false, // unused in WinUI/UWP Action changed = null) where TOwner : DependencyObject { @@ -42,3 +43,5 @@ namespace MapControl } } } + +#pragma warning restore IDE0060 diff --git a/MapControl/WinUI/MapBase.WinUI.cs b/MapControl/WinUI/MapBase.WinUI.cs index 55f74f6d..a86da6a0 100644 --- a/MapControl/WinUI/MapBase.WinUI.cs +++ b/MapControl/WinUI/MapBase.WinUI.cs @@ -57,6 +57,12 @@ namespace MapControl public static readonly DependencyProperty ViewScaleProperty = DependencyPropertyHelper.Register(nameof(ViewScale), 0d); + private static readonly DependencyProperty AnimatedCenterProperty = + DependencyPropertyHelper.Register(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 DoubleAnimation zoomLevelAnimation; private DoubleAnimation headingAnimation; @@ -138,12 +144,6 @@ namespace MapControl } } -#pragma warning disable IDE0052 // Remove unread private members - private static readonly DependencyProperty CenterPointProperty = - DependencyPropertyHelper.Register("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) { if (!internalPropertyChange) @@ -173,7 +173,7 @@ namespace MapControl centerAnimation.Completed += CenterAnimationCompleted; - this.BeginAnimation("CenterPoint", centerAnimation); + this.BeginAnimation(nameof(AnimatedCenter), centerAnimation); } } }