diff --git a/MapControl/Shared/BingMapsTileLayer.cs b/MapControl/Shared/BingMapsTileLayer.cs index 90bfb4a9..6eb59df8 100644 --- a/MapControl/Shared/BingMapsTileLayer.cs +++ b/MapControl/Shared/BingMapsTileLayer.cs @@ -30,12 +30,6 @@ namespace MapControl } public BingMapsTileLayer() - : this(new TileImageLoader()) - { - } - - public BingMapsTileLayer(ITileImageLoader tileImageLoader) - : base(tileImageLoader) { MinZoomLevel = 1; MaxZoomLevel = 21; diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index c0a7da83..a911a77a 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -48,16 +48,6 @@ namespace MapControl public static readonly DependencyProperty ZoomLevelOffsetProperty = DependencyProperty.Register( nameof(ZoomLevelOffset), typeof(double), typeof(MapTileLayer), new PropertyMetadata(0d)); - public MapTileLayer() - : this(new TileImageLoader()) - { - } - - public MapTileLayer(ITileImageLoader tileImageLoader) - : base(tileImageLoader) - { - } - public TileMatrix TileMatrix { get; private set; } public TileCollection Tiles { get; private set; } = new TileCollection(); diff --git a/MapControl/Shared/MapTileLayerBase.cs b/MapControl/Shared/MapTileLayerBase.cs index 4fcd173f..a0e03542 100644 --- a/MapControl/Shared/MapTileLayerBase.cs +++ b/MapControl/Shared/MapTileLayerBase.cs @@ -61,14 +61,13 @@ namespace MapControl private readonly Progress loadingProgress; private readonly DispatcherTimer updateTimer; + private ITileImageLoader tileImageLoader; private MapBase parentMap; - protected MapTileLayerBase(ITileImageLoader tileImageLoader) + protected MapTileLayerBase() { RenderTransform = new MatrixTransform(); - TileImageLoader = tileImageLoader; - loadingProgress = new Progress(p => LoadingProgress = p); updateTimer = this.CreateTimer(UpdateInterval); @@ -79,7 +78,11 @@ namespace MapControl #endif } - public ITileImageLoader TileImageLoader { get; } + public ITileImageLoader TileImageLoader + { + get => tileImageLoader ?? (tileImageLoader = new TileImageLoader()); + set => tileImageLoader = value; + } /// /// Provides map tile URIs or images. diff --git a/MapControl/Shared/Tile.cs b/MapControl/Shared/Tile.cs index fe736dbd..fafb2ce2 100644 --- a/MapControl/Shared/Tile.cs +++ b/MapControl/Shared/Tile.cs @@ -49,13 +49,12 @@ namespace MapControl public void SetImageSource(ImageSource image) { IsPending = false; + Image.Source = image; if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero) { - AnimateImageOpacity(image); + AnimateImageOpacity(); } - - Image.Source = image; } private void BeginOpacityAnimation() diff --git a/MapControl/Shared/WmtsTileLayer.cs b/MapControl/Shared/WmtsTileLayer.cs index 89451550..a53e9339 100644 --- a/MapControl/Shared/WmtsTileLayer.cs +++ b/MapControl/Shared/WmtsTileLayer.cs @@ -35,12 +35,6 @@ namespace MapControl nameof(PreferredTileMatrixSets), typeof(string[]), typeof(WmtsTileLayer), new PropertyMetadata(null)); public WmtsTileLayer() - : this(new TileImageLoader()) - { - } - - public WmtsTileLayer(ITileImageLoader tileImageLoader) - : base(tileImageLoader) { Loaded += OnLoaded; } diff --git a/MapControl/WPF/Tile.WPF.cs b/MapControl/WPF/Tile.WPF.cs index 03c5ff83..8378a311 100644 --- a/MapControl/WPF/Tile.WPF.cs +++ b/MapControl/WPF/Tile.WPF.cs @@ -11,9 +11,9 @@ namespace MapControl { public partial class Tile { - private void AnimateImageOpacity(ImageSource image) + private void AnimateImageOpacity() { - if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading) + if (Image.Source is BitmapSource bitmap && bitmap.IsDownloading && !bitmap.IsFrozen) { bitmap.DownloadCompleted += BitmapDownloadCompleted; bitmap.DownloadFailed += BitmapDownloadFailed; diff --git a/MapControl/WinUI/Tile.WinUI.cs b/MapControl/WinUI/Tile.WinUI.cs index e2b0a065..5f82a1e0 100644 --- a/MapControl/WinUI/Tile.WinUI.cs +++ b/MapControl/WinUI/Tile.WinUI.cs @@ -16,9 +16,9 @@ namespace MapControl { public partial class Tile { - private void AnimateImageOpacity(ImageSource image) + private void AnimateImageOpacity() { - if (image is BitmapImage bitmap && bitmap.UriSource != null) + if (Image.Source is BitmapImage bitmap && bitmap.UriSource != null) { bitmap.ImageOpened += BitmapImageOpened; bitmap.ImageFailed += BitmapImageFailed;