mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-01 11:05:36 +02:00
Version 4.10.0: Updated target framework versions. Cleanup of TypeConverters, ImageLoader, MBTileSource.
This commit is contained in:
parent
bdcd2597a1
commit
25cc04e2f2
|
|
@ -63,7 +63,7 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
else if (IsTileAvailable(response.Headers))
|
else if (IsTileAvailable(response.Headers))
|
||||||
{
|
{
|
||||||
imageSource = await CreateImageSourceAsync(response.Content);
|
imageSource = await LoadImageAsync(response.Content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,30 +18,30 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public static partial class ImageLoader
|
public static partial class ImageLoader
|
||||||
{
|
{
|
||||||
public static async Task<ImageSource> CreateImageSourceAsync(IRandomAccessStream stream)
|
public static async Task<ImageSource> LoadImageAsync(IRandomAccessStream stream)
|
||||||
{
|
{
|
||||||
var bitmapImage = new BitmapImage();
|
var bitmapImage = new BitmapImage();
|
||||||
await bitmapImage.SetSourceAsync(stream);
|
await bitmapImage.SetSourceAsync(stream);
|
||||||
return bitmapImage;
|
return bitmapImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<ImageSource> CreateImageSourceAsync(byte[] buffer)
|
public static async Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||||
{
|
{
|
||||||
using (var stream = new InMemoryRandomAccessStream())
|
using (var stream = new InMemoryRandomAccessStream())
|
||||||
{
|
{
|
||||||
await stream.WriteAsync(buffer.AsBuffer());
|
await stream.WriteAsync(buffer.AsBuffer());
|
||||||
stream.Seek(0);
|
stream.Seek(0);
|
||||||
return await CreateImageSourceAsync(stream);
|
return await LoadImageAsync(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<ImageSource> CreateImageSourceAsync(IHttpContent content)
|
private static async Task<ImageSource> LoadImageAsync(IHttpContent content)
|
||||||
{
|
{
|
||||||
using (var stream = new InMemoryRandomAccessStream())
|
using (var stream = new InMemoryRandomAccessStream())
|
||||||
{
|
{
|
||||||
await content.WriteToStreamAsync(stream);
|
await content.WriteToStreamAsync(stream);
|
||||||
stream.Seek(0);
|
stream.Seek(0);
|
||||||
return await CreateImageSourceAsync(stream);
|
return await LoadImageAsync(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace MapControl
|
||||||
|
|
||||||
using (var stream = await file.OpenReadAsync())
|
using (var stream = await file.OpenReadAsync())
|
||||||
{
|
{
|
||||||
imageSource = await CreateImageSourceAsync(stream);
|
imageSource = await LoadImageAsync(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tile.SetImage(await ImageLoader.CreateImageSourceAsync(stream));
|
tile.SetImage(await ImageLoader.LoadImageAsync(stream));
|
||||||
tcs.SetResult(null);
|
tcs.SetResult(null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public static partial class ImageLoader
|
public static partial class ImageLoader
|
||||||
{
|
{
|
||||||
public static ImageSource CreateImageSource(Stream stream)
|
public static ImageSource LoadImage(Stream stream)
|
||||||
{
|
{
|
||||||
var bitmapImage = new BitmapImage();
|
var bitmapImage = new BitmapImage();
|
||||||
bitmapImage.BeginInit();
|
bitmapImage.BeginInit();
|
||||||
|
|
@ -28,31 +28,31 @@ namespace MapControl
|
||||||
return bitmapImage;
|
return bitmapImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task<ImageSource> CreateImageSourceAsync(Stream stream)
|
public static Task<ImageSource> LoadImageAsync(Stream stream)
|
||||||
{
|
{
|
||||||
return Task.Run(() => CreateImageSource(stream));
|
return Task.Run(() => LoadImage(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageSource CreateImageSource(byte[] buffer)
|
public static ImageSource LoadImage(byte[] buffer)
|
||||||
{
|
{
|
||||||
using (var stream = new MemoryStream(buffer))
|
using (var stream = new MemoryStream(buffer))
|
||||||
{
|
{
|
||||||
return CreateImageSource(stream);
|
return LoadImage(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task<ImageSource> CreateImageSourceAsync(byte[] buffer)
|
public static Task<ImageSource> LoadImageAsync(byte[] buffer)
|
||||||
{
|
{
|
||||||
return Task.Run(() => CreateImageSource(buffer));
|
return Task.Run(() => LoadImage(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<ImageSource> CreateImageSourceAsync(HttpContent content)
|
private static async Task<ImageSource> LoadImageAsync(HttpContent content)
|
||||||
{
|
{
|
||||||
using (var stream = new MemoryStream())
|
using (var stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
await content.CopyToAsync(stream);
|
await content.CopyToAsync(stream);
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
return await CreateImageSourceAsync(stream);
|
return await LoadImageAsync(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
using (var stream = File.OpenRead(path))
|
using (var stream = File.OpenRead(path))
|
||||||
{
|
{
|
||||||
imageSource = CreateImageSource(stream);
|
imageSource = LoadImage(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace MapControl
|
||||||
|
|
||||||
private void SetTileImage(Tile tile, Stream stream)
|
private void SetTileImage(Tile tile, Stream stream)
|
||||||
{
|
{
|
||||||
var imageSource = ImageLoader.CreateImageSource(stream);
|
var imageSource = ImageLoader.LoadImage(stream);
|
||||||
|
|
||||||
tile.Image.Dispatcher.InvokeAsync(() => tile.SetImage(imageSource));
|
tile.Image.Dispatcher.InvokeAsync(() => tile.SetImage(imageSource));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue