mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
// Copyright © 2024 Clemens Fischer
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
using System;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace MapControl
|
|
{
|
|
public partial class Tile
|
|
{
|
|
private void AnimateImageOpacity()
|
|
{
|
|
if (Image.Source is BitmapSource bitmap && bitmap.IsDownloading && !bitmap.IsFrozen)
|
|
{
|
|
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
|
bitmap.DownloadFailed += BitmapDownloadFailed;
|
|
}
|
|
else
|
|
{
|
|
BeginOpacityAnimation();
|
|
}
|
|
}
|
|
|
|
private void BitmapDownloadCompleted(object sender, EventArgs e)
|
|
{
|
|
var bitmap = (BitmapSource)sender;
|
|
|
|
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
|
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
|
|
|
BeginOpacityAnimation();
|
|
}
|
|
|
|
private void BitmapDownloadFailed(object sender, ExceptionEventArgs e)
|
|
{
|
|
var bitmap = (BitmapSource)sender;
|
|
|
|
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
|
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
|
|
|
Image.Source = null;
|
|
}
|
|
}
|
|
}
|