MapTileLayerBase.TileImageLoader property

This commit is contained in:
ClemensFischer 2023-08-22 18:16:24 +02:00
parent ebdbc012f2
commit b32755e29e
7 changed files with 13 additions and 33 deletions

View file

@ -30,12 +30,6 @@ namespace MapControl
}
public BingMapsTileLayer()
: this(new TileImageLoader())
{
}
public BingMapsTileLayer(ITileImageLoader tileImageLoader)
: base(tileImageLoader)
{
MinZoomLevel = 1;
MaxZoomLevel = 21;

View file

@ -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();

View file

@ -61,14 +61,13 @@ namespace MapControl
private readonly Progress<double> 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<double>(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;
}
/// <summary>
/// Provides map tile URIs or images.

View file

@ -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()

View file

@ -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;
}

View file

@ -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;

View file

@ -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;