2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2025-01-01 18:57:55 +01:00
|
|
|
|
// Copyright © Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2024-05-19 17:24:18 +02:00
|
|
|
|
using System.Windows;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
using System.Windows.Controls;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Windows.Media;
|
2024-05-19 17:24:18 +02:00
|
|
|
|
using System.Windows.Media.Animation;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2013-01-03 15:33:46 +01:00
|
|
|
|
public partial class Tile
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2025-01-05 10:31:15 +01:00
|
|
|
|
private void BeginFadeInAnimation()
|
2024-05-19 17:24:18 +02:00
|
|
|
|
{
|
2025-01-05 10:31:15 +01:00
|
|
|
|
var fadeInAnimation = new DoubleAnimation
|
|
|
|
|
|
{
|
|
|
|
|
|
From = 0d,
|
|
|
|
|
|
Duration = MapBase.ImageFadeDuration,
|
|
|
|
|
|
FillBehavior = FillBehavior.Stop
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Image.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation);
|
2024-05-19 17:24:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-05 10:31:15 +01:00
|
|
|
|
private void FadeIn()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2023-08-22 18:16:24 +02:00
|
|
|
|
if (Image.Source is BitmapSource bitmap && bitmap.IsDownloading && !bitmap.IsFrozen)
|
2017-07-17 21:31:09 +02:00
|
|
|
|
{
|
2022-11-19 18:00:26 +01:00
|
|
|
|
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
|
|
|
|
|
bitmap.DownloadFailed += BitmapDownloadFailed;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
2017-07-17 21:31:09 +02:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-01-05 10:31:15 +01:00
|
|
|
|
BeginFadeInAnimation();
|
2017-07-17 21:31:09 +02:00
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BitmapDownloadCompleted(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2019-06-15 01:39:07 +02:00
|
|
|
|
var bitmap = (BitmapSource)sender;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
|
2019-06-15 01:39:07 +02:00
|
|
|
|
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
|
|
|
|
|
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
|
2025-01-05 10:31:15 +01:00
|
|
|
|
BeginFadeInAnimation();
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BitmapDownloadFailed(object sender, ExceptionEventArgs e)
|
|
|
|
|
|
{
|
2019-06-15 01:39:07 +02:00
|
|
|
|
var bitmap = (BitmapSource)sender;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
|
2019-06-15 01:39:07 +02:00
|
|
|
|
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
|
|
|
|
|
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
|
2014-07-01 18:57:44 +02:00
|
|
|
|
Image.Source = null;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|