XAML-Map-Control/MapControl/WPF/TileImageLoader.WPF.cs
2024-02-08 23:02:25 +01:00

29 lines
950 B
C#

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// Copyright © 2024 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Media;
namespace MapControl
{
public partial class TileImageLoader
{
/// <summary>
/// Default folder where the Cache instance may save data, i.e. "C:\ProgramData\MapControl\TileCache".
/// </summary>
public static string DefaultCacheFolder =>
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "TileCache");
private static async Task LoadTileAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
{
var image = await loadImageFunc().ConfigureAwait(false);
await tile.Image.Dispatcher.InvokeAsync(() => tile.SetImageSource(image));
}
}
}