Version 4.12.2 Reverted to previous ITileImageLoader

This commit is contained in:
ClemensF 2019-07-11 18:00:21 +02:00
parent 5a7e93f577
commit 014f57ee1a
3 changed files with 11 additions and 11 deletions

View file

@ -38,8 +38,8 @@ namespace MapControl
public static TimeSpan DefaultCacheExpiration { get; set; } = TimeSpan.FromDays(1); public static TimeSpan DefaultCacheExpiration { get; set; } = TimeSpan.FromDays(1);
/// <summary> /// <summary>
/// Format string for creating cache keys from the SourceName property and the /// Format string for creating cache keys from the sourceName argument passed to LoadTilesAsync,
/// ZoomLevel, XIndex, and Y properties of a Tile and the image file extension. /// the ZoomLevel, XIndex, and Y properties of a Tile, and the image file extension.
/// The default value is "{0}/{1}/{2}/{3}{4}". /// The default value is "{0}/{1}/{2}/{3}{4}".
/// </summary> /// </summary>
public static string CacheKeyFormat { get; set; } = "{0}/{1}/{2}/{3}{4}"; public static string CacheKeyFormat { get; set; } = "{0}/{1}/{2}/{3}{4}";
@ -50,7 +50,7 @@ namespace MapControl
/// <summary> /// <summary>
/// Loads all pending tiles from the tiles collection in up to MaxLoadTasks parallel Tasks. /// Loads all pending tiles from the tiles collection in up to MaxLoadTasks parallel Tasks.
/// If the UriFormat of the TileSource starts with "http" and sourceName is a non-empty string, /// If tileSource.UriFormat starts with "http" and sourceName is a non-empty string,
/// tile images will be cached in the TileImageLoader's Cache. /// tile images will be cached in the TileImageLoader's Cache.
/// </summary> /// </summary>
public void LoadTilesAsync(IEnumerable<Tile> tiles, TileSource tileSource, string sourceName) public void LoadTilesAsync(IEnumerable<Tile> tiles, TileSource tileSource, string sourceName)
@ -94,7 +94,7 @@ namespace MapControl
Interlocked.Decrement(ref taskCount); Interlocked.Decrement(ref taskCount);
} }
private async Task LoadTileImageAsync(Tile tile, TileSource tileSource, string sourceName) private static async Task LoadTileImageAsync(Tile tile, TileSource tileSource, string sourceName)
{ {
if (Cache != null && if (Cache != null &&
tileSource.UriFormat != null && tileSource.UriFormat != null &&

View file

@ -28,7 +28,7 @@ namespace MapControl
public static Caching.IImageCache Cache { get; set; } public static Caching.IImageCache Cache { get; set; }
private async Task LoadCachedTileImageAsync(Tile tile, Uri uri, string cacheKey) private static async Task LoadCachedTileImageAsync(Tile tile, Uri uri, string cacheKey)
{ {
var cacheItem = await Cache.GetAsync(cacheKey).ConfigureAwait(false); var cacheItem = await Cache.GetAsync(cacheKey).ConfigureAwait(false);
var cacheBuffer = cacheItem?.Buffer; var cacheBuffer = cacheItem?.Buffer;
@ -55,7 +55,7 @@ namespace MapControl
} }
} }
private async Task LoadTileImageAsync(Tile tile, IBuffer buffer) private static async Task LoadTileImageAsync(Tile tile, IBuffer buffer)
{ {
using (var stream = new InMemoryRandomAccessStream()) using (var stream = new InMemoryRandomAccessStream())
{ {
@ -66,12 +66,12 @@ namespace MapControl
} }
} }
private Task LoadTileImageAsync(Tile tile, TileSource tileSource) private static Task LoadTileImageAsync(Tile tile, TileSource tileSource)
{ {
return SetTileImageAsync(tile, () => tileSource.LoadImageAsync(tile.XIndex, tile.Y, tile.ZoomLevel)); return SetTileImageAsync(tile, () => tileSource.LoadImageAsync(tile.XIndex, tile.Y, tile.ZoomLevel));
} }
private async Task SetTileImageAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc) private static async Task SetTileImageAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
{ {
var tcs = new TaskCompletionSource<object>(); var tcs = new TaskCompletionSource<object>();

View file

@ -28,7 +28,7 @@ namespace MapControl
public static ObjectCache Cache { get; set; } = MemoryCache.Default; public static ObjectCache Cache { get; set; } = MemoryCache.Default;
private async Task LoadCachedTileImageAsync(Tile tile, Uri uri, string cacheKey) private static async Task LoadCachedTileImageAsync(Tile tile, Uri uri, string cacheKey)
{ {
ImageSource image = null; ImageSource image = null;
DateTime expiration; DateTime expiration;
@ -64,7 +64,7 @@ namespace MapControl
} }
} }
private async Task LoadTileImageAsync(Tile tile, TileSource tileSource) private static async Task LoadTileImageAsync(Tile tile, TileSource tileSource)
{ {
var image = await tileSource.LoadImageAsync(tile.XIndex, tile.Y, tile.ZoomLevel).ConfigureAwait(false); var image = await tileSource.LoadImageAsync(tile.XIndex, tile.Y, tile.ZoomLevel).ConfigureAwait(false);
@ -74,7 +74,7 @@ namespace MapControl
} }
} }
private void SetTileImage(Tile tile, ImageSource image) private static void SetTileImage(Tile tile, ImageSource image)
{ {
tile.Image.Dispatcher.InvokeAsync(() => tile.SetImage(image)); tile.Image.Dispatcher.InvokeAsync(() => tile.SetImage(image));
} }