mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update Tile class
This commit is contained in:
parent
6903c4a436
commit
7fa2e37266
|
|
@ -235,11 +235,11 @@ namespace MapControl
|
||||||
tile = new Tile(z, x, y);
|
tile = new Tile(z, x, y);
|
||||||
|
|
||||||
var equivalentTile = Tiles.FirstOrDefault(
|
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)
|
if (equivalentTile != null)
|
||||||
{
|
{
|
||||||
tile.SetImage(equivalentTile.Image.Source, false); // no fade-in animation
|
tile.SetImageSource(equivalentTile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,13 @@ namespace MapControl
|
||||||
|
|
||||||
public bool Pending { get; set; } = true;
|
public bool Pending { get; set; } = true;
|
||||||
|
|
||||||
|
public void SetImageSource(Tile tile)
|
||||||
|
{
|
||||||
|
Pending = false;
|
||||||
|
Image.Opacity = 1d;
|
||||||
|
Image.Source = tile.Image.Source;
|
||||||
|
}
|
||||||
|
|
||||||
private void FadeIn()
|
private void FadeIn()
|
||||||
{
|
{
|
||||||
Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation
|
Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tile.SetImage(await loadImageFunc());
|
tile.SetImageSource(await loadImageFunc());
|
||||||
tcs.TrySetResult(null);
|
tcs.TrySetResult(null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class Tile
|
public partial class Tile
|
||||||
{
|
{
|
||||||
public void SetImage(ImageSource image, bool fadeIn = true)
|
public void SetImageSource(ImageSource image)
|
||||||
{
|
{
|
||||||
Pending = false;
|
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)
|
if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
var image = await ImageLoader.LoadImageAsync(buffer).ConfigureAwait(false);
|
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);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class Tile
|
public partial class Tile
|
||||||
{
|
{
|
||||||
public void SetImage(ImageSource image, bool fadeIn = true)
|
public void SetImageSource(ImageSource image)
|
||||||
{
|
{
|
||||||
Pending = false;
|
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)
|
if (image is BitmapImage bitmap && bitmap.UriSource != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tile.SetImage(await loadImageFunc());
|
tile.SetImageSource(await loadImageFunc());
|
||||||
tcs.TrySetResult();
|
tcs.TrySetResult();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue