2025-02-27 18:46:32 +01:00
|
|
|
|
#if UWP
|
2021-07-02 21:18:39 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
2024-05-19 17:24:18 +02:00
|
|
|
|
using Windows.UI.Xaml.Media.Animation;
|
2021-07-02 21:18:39 +02:00
|
|
|
|
using Windows.UI.Xaml.Media.Imaging;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#else
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media.Animation;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media.Imaging;
|
2021-06-14 21:41:37 +02:00
|
|
|
|
#endif
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
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
|
2025-01-05 09:22:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
From = 0d,
|
|
|
|
|
|
Duration = MapBase.ImageFadeDuration,
|
|
|
|
|
|
FillBehavior = FillBehavior.Stop
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-01-05 10:31:15 +01:00
|
|
|
|
Storyboard.SetTarget(fadeInAnimation, Image);
|
2025-01-25 16:47:42 +01:00
|
|
|
|
Storyboard.SetTargetProperty(fadeInAnimation, nameof(UIElement.Opacity));
|
2025-01-05 09:22:50 +01:00
|
|
|
|
|
|
|
|
|
|
var storyboard = new Storyboard();
|
2025-01-05 10:31:15 +01:00
|
|
|
|
storyboard.Children.Add(fadeInAnimation);
|
2025-01-05 09:22:50 +01:00
|
|
|
|
storyboard.Begin();
|
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 BitmapImage bitmap && bitmap.UriSource != null)
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2022-11-19 18:00:26 +01:00
|
|
|
|
bitmap.ImageOpened += BitmapImageOpened;
|
|
|
|
|
|
bitmap.ImageFailed += BitmapImageFailed;
|
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 BitmapImageOpened(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2019-06-15 01:39:07 +02:00
|
|
|
|
var bitmap = (BitmapImage)sender;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
|
2019-06-15 01:39:07 +02:00
|
|
|
|
bitmap.ImageOpened -= BitmapImageOpened;
|
|
|
|
|
|
bitmap.ImageFailed -= BitmapImageFailed;
|
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 BitmapImageFailed(object sender, ExceptionRoutedEventArgs e)
|
|
|
|
|
|
{
|
2019-06-15 01:39:07 +02:00
|
|
|
|
var bitmap = (BitmapImage)sender;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
|
2019-06-15 01:39:07 +02:00
|
|
|
|
bitmap.ImageOpened -= BitmapImageOpened;
|
|
|
|
|
|
bitmap.ImageFailed -= BitmapImageFailed;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
|
2013-01-03 15:33:46 +01:00
|
|
|
|
Image.Source = null;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|