2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2024-02-03 21:01:53 +01:00
|
|
|
|
// Copyright © 2024 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2021-07-02 21:18:39 +02:00
|
|
|
|
#if WINUI
|
2021-06-28 23:35:03 +02:00
|
|
|
|
using Microsoft.UI.Xaml;
|
2024-05-19 17:24:18 +02:00
|
|
|
|
using Microsoft.UI.Xaml.Media.Animation;
|
2021-06-28 23:35:03 +02:00
|
|
|
|
using Microsoft.UI.Xaml.Media.Imaging;
|
2021-07-02 21:18:39 +02:00
|
|
|
|
#else
|
|
|
|
|
|
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;
|
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
|
|
|
|
{
|
2024-05-19 17:24:18 +02:00
|
|
|
|
private void BeginOpacityAnimation()
|
|
|
|
|
|
{
|
2024-05-21 22:05:01 +02:00
|
|
|
|
OpacityHelper.BeginOpacityAnimation(Image,
|
2024-05-19 17:24:18 +02:00
|
|
|
|
new DoubleAnimation
|
|
|
|
|
|
{
|
|
|
|
|
|
From = 0d,
|
|
|
|
|
|
Duration = MapBase.ImageFadeDuration,
|
|
|
|
|
|
FillBehavior = FillBehavior.Stop
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-22 18:16:24 +02:00
|
|
|
|
private void AnimateImageOpacity()
|
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
|
|
|
|
|
|
{
|
2022-11-19 18:00:26 +01:00
|
|
|
|
BeginOpacityAnimation();
|
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
|
|
|
|
|
2022-11-19 18:00:26 +01:00
|
|
|
|
BeginOpacityAnimation();
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|