diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index 09f64d01..4c605f9e 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -235,11 +235,11 @@ namespace MapControl tile = new Tile(z, x, y); var equivalentTile = Tiles.FirstOrDefault( - t => t.ZoomLevel == z && t.XIndex == tile.XIndex && t.Y == y && !t.Pending); + t => !t.Pending && t.ZoomLevel == z && t.Y == y && t.XIndex == tile.XIndex); if (equivalentTile != null) { - tile.SetImage(equivalentTile.Image.Source, false); // no fade-in animation + tile.SetImageSource(equivalentTile); } } diff --git a/MapControl/Shared/Tile.cs b/MapControl/Shared/Tile.cs index 41277f3c..be9e028d 100644 --- a/MapControl/Shared/Tile.cs +++ b/MapControl/Shared/Tile.cs @@ -52,6 +52,13 @@ namespace MapControl public bool Pending { get; set; } = true; + public void SetImageSource(Tile tile) + { + Pending = false; + Image.Opacity = 1d; + Image.Source = tile.Image.Source; + } + private void FadeIn() { Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation diff --git a/MapControl/UWP/TileImageLoader.UWP.cs b/MapControl/UWP/TileImageLoader.UWP.cs index dab1a696..7d024018 100644 --- a/MapControl/UWP/TileImageLoader.UWP.cs +++ b/MapControl/UWP/TileImageLoader.UWP.cs @@ -70,7 +70,7 @@ namespace MapControl { try { - tile.SetImage(await loadImageFunc()); + tile.SetImageSource(await loadImageFunc()); tcs.TrySetResult(null); } catch (Exception ex) diff --git a/MapControl/WPF/Tile.WPF.cs b/MapControl/WPF/Tile.WPF.cs index 76dba25c..4da777e1 100644 --- a/MapControl/WPF/Tile.WPF.cs +++ b/MapControl/WPF/Tile.WPF.cs @@ -11,11 +11,11 @@ namespace MapControl { public partial class Tile { - public void SetImage(ImageSource image, bool fadeIn = true) + public void SetImageSource(ImageSource image) { Pending = false; - if (image != null && fadeIn && MapBase.ImageFadeDuration > TimeSpan.Zero) + if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero) { if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading) { diff --git a/MapControl/WPF/TileImageLoader.WPF.cs b/MapControl/WPF/TileImageLoader.WPF.cs index c2b1c63c..4f883be9 100644 --- a/MapControl/WPF/TileImageLoader.WPF.cs +++ b/MapControl/WPF/TileImageLoader.WPF.cs @@ -47,7 +47,7 @@ namespace MapControl { var image = await ImageLoader.LoadImageAsync(buffer).ConfigureAwait(false); - await tile.Image.Dispatcher.InvokeAsync(() => tile.SetImage(image)); + await tile.Image.Dispatcher.InvokeAsync(() => tile.SetImageSource(image)); } } @@ -55,7 +55,7 @@ namespace MapControl { var image = await tileSource.LoadImageAsync(tile.XIndex, tile.Y, tile.ZoomLevel).ConfigureAwait(false); - await tile.Image.Dispatcher.InvokeAsync(() => tile.SetImage(image)); + await tile.Image.Dispatcher.InvokeAsync(() => tile.SetImageSource(image)); } } } diff --git a/MapControl/WinUI/Tile.WinUI.cs b/MapControl/WinUI/Tile.WinUI.cs index 15622d06..138311f3 100644 --- a/MapControl/WinUI/Tile.WinUI.cs +++ b/MapControl/WinUI/Tile.WinUI.cs @@ -17,11 +17,11 @@ namespace MapControl { public partial class Tile { - public void SetImage(ImageSource image, bool fadeIn = true) + public void SetImageSource(ImageSource image) { Pending = false; - if (image != null && fadeIn && MapBase.ImageFadeDuration > TimeSpan.Zero) + if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero) { if (image is BitmapImage bitmap && bitmap.UriSource != null) { diff --git a/MapControl/WinUI/TileImageLoader.WinUI.cs b/MapControl/WinUI/TileImageLoader.WinUI.cs index d178b24c..6b7ed20e 100644 --- a/MapControl/WinUI/TileImageLoader.WinUI.cs +++ b/MapControl/WinUI/TileImageLoader.WinUI.cs @@ -71,7 +71,7 @@ namespace MapControl { try { - tile.SetImage(await loadImageFunc()); + tile.SetImageSource(await loadImageFunc()); tcs.TrySetResult(); } catch (Exception ex)