Update Tile class

This commit is contained in:
ClemensFischer 2022-11-19 18:00:26 +01:00
parent caf6a9c8a4
commit 5c17a1c36f
4 changed files with 26 additions and 42 deletions

View file

@ -11,28 +11,17 @@ namespace MapControl
{
public partial class Tile
{
public void SetImageSource(ImageSource image)
private void AnimateImageOpacity()
{
Pending = false;
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
if (Image.Source is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
{
if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
{
bitmap.DownloadCompleted += BitmapDownloadCompleted;
bitmap.DownloadFailed += BitmapDownloadFailed;
}
else
{
FadeIn();
}
bitmap.DownloadCompleted += BitmapDownloadCompleted;
bitmap.DownloadFailed += BitmapDownloadFailed;
}
else
{
Image.Opacity = 1d;
BeginOpacityAnimation();
}
Image.Source = image;
}
private void BitmapDownloadCompleted(object sender, EventArgs e)
@ -42,7 +31,7 @@ namespace MapControl
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
bitmap.DownloadFailed -= BitmapDownloadFailed;
FadeIn();
BeginOpacityAnimation();
}
private void BitmapDownloadFailed(object sender, ExceptionEventArgs e)