mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-02-13 03:04:13 +01: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
|
||||
{
|
||||
Opacity = 0d,
|
||||
Stretch = Stretch.Fill,
|
||||
IsHitTestVisible = false // avoid touch capture issues
|
||||
};
|
||||
|
||||
public bool IsPending { get; set; } = true;
|
||||
|
||||
public void SetImageSource(ImageSource image, bool animateOpacity = true)
|
||||
public void SetImageSource(ImageSource image)
|
||||
{
|
||||
IsPending = false;
|
||||
Image.Source = image;
|
||||
|
||||
if (image != null && animateOpacity && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
||||
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
||||
{
|
||||
AnimateImageOpacity();
|
||||
}
|
||||
else
|
||||
{
|
||||
Image.Opacity = 1d;
|
||||
AnimateImageOpacity(image);
|
||||
}
|
||||
|
||||
Image.Source = image;
|
||||
}
|
||||
|
||||
private void BeginOpacityAnimation()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ namespace MapControl
|
|||
|
||||
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
|
||||
{
|
||||
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.DownloadFailed += BitmapDownloadFailed;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
#if WINUI
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
#else
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
#endif
|
||||
|
||||
|
|
@ -14,9 +16,9 @@ namespace MapControl
|
|||
{
|
||||
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.ImageFailed += BitmapImageFailed;
|
||||
|
|
|
|||
Loading…
Reference in a new issue