mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Moved asynchronous image loading to Tile class
This commit is contained in:
parent
2f9c50fb47
commit
f4d43eeb44
10 changed files with 114 additions and 184 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
#if WPF
|
||||
#if WPF
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
#elif UWP
|
||||
|
|
@ -25,25 +24,12 @@ namespace MapControl
|
|||
Column = ((x % columnCount) + columnCount) % columnCount;
|
||||
}
|
||||
|
||||
public Image Image { get; } = new Image { Stretch = Stretch.Fill };
|
||||
public int ZoomLevel { get; }
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
public int Column { get; }
|
||||
public int Row => Y;
|
||||
|
||||
public Image Image { get; } = new Image { Stretch = Stretch.Fill };
|
||||
|
||||
public bool IsPending { get; set; } = true;
|
||||
|
||||
public void SetImageSource(ImageSource image)
|
||||
{
|
||||
IsPending = false;
|
||||
Image.Source = image;
|
||||
|
||||
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
||||
{
|
||||
FadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,6 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if WPF
|
||||
using System.Windows.Media;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml.Media;
|
||||
#elif WINUI
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
|
|
@ -27,7 +20,7 @@ namespace MapControl
|
|||
void CancelLoadTiles();
|
||||
}
|
||||
|
||||
public partial class TileImageLoader : ITileImageLoader
|
||||
public class TileImageLoader : ITileImageLoader
|
||||
{
|
||||
private static ILogger logger;
|
||||
private static ILogger Logger => logger ?? (logger = ImageLoader.LoggerFactory?.CreateLogger<TileImageLoader>());
|
||||
|
|
@ -161,9 +154,7 @@ namespace MapControl
|
|||
|
||||
if (string.IsNullOrEmpty(cacheName))
|
||||
{
|
||||
Task<ImageSource> LoadImage() => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel);
|
||||
|
||||
await LoadTileImage(tile, LoadImage).ConfigureAwait(false);
|
||||
await tile.LoadImageAsync(() => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel)).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -175,9 +166,7 @@ namespace MapControl
|
|||
|
||||
if (buffer?.Length > 0)
|
||||
{
|
||||
Task<ImageSource> LoadImage() => tileSource.LoadImageAsync(buffer);
|
||||
|
||||
await LoadTileImage(tile, LoadImage).ConfigureAwait(false);
|
||||
await tile.LoadImageAsync(() => tileSource.LoadImageAsync(buffer)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue