diff --git a/MapControl/Avalonia/MapImageLayer.Avalonia.cs b/MapControl/Avalonia/MapImageLayer.Avalonia.cs index e9566189..22feaa67 100644 --- a/MapControl/Avalonia/MapImageLayer.Avalonia.cs +++ b/MapControl/Avalonia/MapImageLayer.Avalonia.cs @@ -10,7 +10,7 @@ namespace MapControl { public static void FadeOver(Image topImage, Image bottomImage) { - var animation = new Animation + var fadeInAnimation = new Animation { FillMode = FillMode.Forward, Duration = MapBase.ImageFadeDuration, @@ -24,7 +24,7 @@ namespace MapControl } }; - _ = animation.RunAsync(topImage).ContinueWith( + _ = fadeInAnimation.RunAsync(topImage).ContinueWith( _ => bottomImage.Opacity = 0d, TaskScheduler.FromCurrentSynchronizationContext()); } diff --git a/MapControl/Avalonia/Tile.Avalonia.cs b/MapControl/Avalonia/Tile.Avalonia.cs index 6a1ebcc7..1e6be88e 100644 --- a/MapControl/Avalonia/Tile.Avalonia.cs +++ b/MapControl/Avalonia/Tile.Avalonia.cs @@ -8,9 +8,9 @@ namespace MapControl { public partial class Tile { - private void AnimateImageOpacity() + private void FadeIn() { - var animation = new Animation + var fadeInAnimation = new Animation { Duration = MapBase.ImageFadeDuration, Children = @@ -28,7 +28,7 @@ namespace MapControl } }; - _ = animation.RunAsync(Image); + _ = fadeInAnimation.RunAsync(Image); } } } diff --git a/MapControl/Shared/Tile.cs b/MapControl/Shared/Tile.cs index 6665a589..f3a1c3b1 100644 --- a/MapControl/Shared/Tile.cs +++ b/MapControl/Shared/Tile.cs @@ -43,7 +43,7 @@ namespace MapControl if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero) { - AnimateImageOpacity(); + FadeIn(); } } } diff --git a/MapControl/WPF/MapImageLayer.WPF.cs b/MapControl/WPF/MapImageLayer.WPF.cs index dd2d883c..a64ae88b 100644 --- a/MapControl/WPF/MapImageLayer.WPF.cs +++ b/MapControl/WPF/MapImageLayer.WPF.cs @@ -12,18 +12,22 @@ namespace MapControl { public static void FadeOver(Image topImage, Image bottomImage) { - topImage.BeginAnimation(OpacityProperty, new DoubleAnimation + var fadeInAnimation = new DoubleAnimation { To = 1d, Duration = MapBase.ImageFadeDuration - }); + }; - bottomImage.BeginAnimation(OpacityProperty, new DoubleAnimation + var fadeOutAnimation = new DoubleAnimation { To = 0d, BeginTime = MapBase.ImageFadeDuration, - Duration = TimeSpan.Zero - }); + Duration = TimeSpan.Zero, + FillBehavior = FillBehavior.Stop + }; + + topImage.BeginAnimation(OpacityProperty, fadeInAnimation); + bottomImage.BeginAnimation(OpacityProperty, fadeOutAnimation); } } } diff --git a/MapControl/WPF/Tile.WPF.cs b/MapControl/WPF/Tile.WPF.cs index ea38d65b..ad1f96a3 100644 --- a/MapControl/WPF/Tile.WPF.cs +++ b/MapControl/WPF/Tile.WPF.cs @@ -13,18 +13,19 @@ namespace MapControl { public partial class Tile { - private void BeginOpacityAnimation() + private void BeginFadeInAnimation() { - Image.BeginAnimation(UIElement.OpacityProperty, - new DoubleAnimation - { - From = 0d, - Duration = MapBase.ImageFadeDuration, - FillBehavior = FillBehavior.Stop - }); + var fadeInAnimation = new DoubleAnimation + { + From = 0d, + Duration = MapBase.ImageFadeDuration, + FillBehavior = FillBehavior.Stop + }; + + Image.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation); } - private void AnimateImageOpacity() + private void FadeIn() { if (Image.Source is BitmapSource bitmap && bitmap.IsDownloading && !bitmap.IsFrozen) { @@ -33,7 +34,7 @@ namespace MapControl } else { - BeginOpacityAnimation(); + BeginFadeInAnimation(); } } @@ -44,7 +45,7 @@ namespace MapControl bitmap.DownloadCompleted -= BitmapDownloadCompleted; bitmap.DownloadFailed -= BitmapDownloadFailed; - BeginOpacityAnimation(); + BeginFadeInAnimation(); } private void BitmapDownloadFailed(object sender, ExceptionEventArgs e) diff --git a/MapControl/WinUI/MapImageLayer.WinUI.cs b/MapControl/WinUI/MapImageLayer.WinUI.cs index 64da530b..d1d33299 100644 --- a/MapControl/WinUI/MapImageLayer.WinUI.cs +++ b/MapControl/WinUI/MapImageLayer.WinUI.cs @@ -17,28 +17,29 @@ namespace MapControl { public static void FadeOver(Image topImage, Image bottomImage) { - var topImageAnimation = new DoubleAnimation + var fadeInAnimation = new DoubleAnimation { To = 1d, Duration = MapBase.ImageFadeDuration }; - var bottomImageAnimation = new DoubleAnimation + var fadeOutAnimation = new DoubleAnimation { To = 0d, BeginTime = MapBase.ImageFadeDuration, - Duration = TimeSpan.Zero + Duration = TimeSpan.Zero, + FillBehavior = FillBehavior.Stop }; - Storyboard.SetTargetProperty(topImageAnimation, nameof(Opacity)); - Storyboard.SetTarget(topImageAnimation, topImage); + Storyboard.SetTargetProperty(fadeInAnimation, nameof(Opacity)); + Storyboard.SetTarget(fadeInAnimation, topImage); - Storyboard.SetTargetProperty(bottomImageAnimation, nameof(Opacity)); - Storyboard.SetTarget(bottomImageAnimation, bottomImage); + Storyboard.SetTargetProperty(fadeOutAnimation, nameof(Opacity)); + Storyboard.SetTarget(fadeOutAnimation, bottomImage); var storyboard = new Storyboard(); - storyboard.Children.Add(topImageAnimation); - storyboard.Children.Add(bottomImageAnimation); + storyboard.Children.Add(fadeInAnimation); + storyboard.Children.Add(fadeOutAnimation); storyboard.Begin(); } } diff --git a/MapControl/WinUI/Tile.WinUI.cs b/MapControl/WinUI/Tile.WinUI.cs index 66d6d7d3..13a63d9c 100644 --- a/MapControl/WinUI/Tile.WinUI.cs +++ b/MapControl/WinUI/Tile.WinUI.cs @@ -16,24 +16,24 @@ namespace MapControl { public partial class Tile { - private void BeginOpacityAnimation() + private void BeginFadeInAnimation() { - var animation = new DoubleAnimation + var fadeInAnimation = new DoubleAnimation { From = 0d, Duration = MapBase.ImageFadeDuration, FillBehavior = FillBehavior.Stop }; - Storyboard.SetTargetProperty(animation, nameof(UIElement.Opacity)); - Storyboard.SetTarget(animation, Image); + Storyboard.SetTargetProperty(fadeInAnimation, nameof(UIElement.Opacity)); + Storyboard.SetTarget(fadeInAnimation, Image); var storyboard = new Storyboard(); - storyboard.Children.Add(animation); + storyboard.Children.Add(fadeInAnimation); storyboard.Begin(); } - private void AnimateImageOpacity() + private void FadeIn() { if (Image.Source is BitmapImage bitmap && bitmap.UriSource != null) { @@ -42,7 +42,7 @@ namespace MapControl } else { - BeginOpacityAnimation(); + BeginFadeInAnimation(); } } @@ -53,7 +53,7 @@ namespace MapControl bitmap.ImageOpened -= BitmapImageOpened; bitmap.ImageFailed -= BitmapImageFailed; - BeginOpacityAnimation(); + BeginFadeInAnimation(); } private void BitmapImageFailed(object sender, ExceptionRoutedEventArgs e)