mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-02 03:28:06 +02:00
Simplified Tile class
This commit is contained in:
parent
7b404446d2
commit
7d78d2587e
|
|
@ -40,26 +40,22 @@ namespace MapControl
|
||||||
|
|
||||||
public Image Image { get; } = new Image
|
public Image Image { get; } = new Image
|
||||||
{
|
{
|
||||||
Opacity = 0d,
|
|
||||||
Stretch = Stretch.Fill,
|
Stretch = Stretch.Fill,
|
||||||
IsHitTestVisible = false // avoid touch capture issues
|
IsHitTestVisible = false // avoid touch capture issues
|
||||||
};
|
};
|
||||||
|
|
||||||
public bool IsPending { get; set; } = true;
|
public bool IsPending { get; set; } = true;
|
||||||
|
|
||||||
public void SetImageSource(ImageSource image, bool animateOpacity = true)
|
public void SetImageSource(ImageSource image)
|
||||||
{
|
{
|
||||||
IsPending = false;
|
IsPending = false;
|
||||||
Image.Source = image;
|
|
||||||
|
|
||||||
if (image != null && animateOpacity && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
AnimateImageOpacity();
|
AnimateImageOpacity(image);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Image.Opacity = 1d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image.Source = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BeginOpacityAnimation()
|
private void BeginOpacityAnimation()
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ namespace MapControl
|
||||||
|
|
||||||
if (equivalentTile != null)
|
if (equivalentTile != null)
|
||||||
{
|
{
|
||||||
tile.SetImageSource(equivalentTile.Image.Source, false); // no opacity animation
|
tile.IsPending = false;
|
||||||
|
tile.Image.Source = equivalentTile.Image.Source; // no opacity animation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class Tile
|
public partial class Tile
|
||||||
{
|
{
|
||||||
private void AnimateImageOpacity()
|
private void AnimateImageOpacity(ImageSource image)
|
||||||
{
|
{
|
||||||
if (Image.Source is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
|
if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
|
||||||
{
|
{
|
||||||
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
||||||
bitmap.DownloadFailed += BitmapDownloadFailed;
|
bitmap.DownloadFailed += BitmapDownloadFailed;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
#if WINUI
|
#if WINUI
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Media;
|
||||||
using Microsoft.UI.Xaml.Media.Imaging;
|
using Microsoft.UI.Xaml.Media.Imaging;
|
||||||
#else
|
#else
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Media;
|
||||||
using Windows.UI.Xaml.Media.Imaging;
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -14,9 +16,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class Tile
|
public partial class Tile
|
||||||
{
|
{
|
||||||
private void AnimateImageOpacity()
|
private void AnimateImageOpacity(ImageSource image)
|
||||||
{
|
{
|
||||||
if (Image.Source is BitmapImage bitmap && bitmap.UriSource != null)
|
if (image is BitmapImage bitmap && bitmap.UriSource != null)
|
||||||
{
|
{
|
||||||
bitmap.ImageOpened += BitmapImageOpened;
|
bitmap.ImageOpened += BitmapImageOpened;
|
||||||
bitmap.ImageFailed += BitmapImageFailed;
|
bitmap.ImageFailed += BitmapImageFailed;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue