Version 4.12.2 Fixed local file handling for UWP. All relative paths relative to ms-appx:

This commit is contained in:
ClemensF 2019-06-15 01:39:07 +02:00
parent 26bf0b5005
commit c28387f87c
14 changed files with 172 additions and 192 deletions

View file

@ -31,28 +31,18 @@ namespace MapControl
{
await stream.WriteAsync(buffer.AsBuffer());
stream.Seek(0);
return await LoadImageAsync(stream);
}
}
private static async Task<ImageSource> LoadImageAsync(IHttpContent content)
{
using (var stream = new InMemoryRandomAccessStream())
{
await content.WriteToStreamAsync(stream);
stream.Seek(0);
return await LoadImageAsync(stream);
}
}
private static async Task<ImageSource> LoadLocalImageAsync(Uri uri)
public static async Task<ImageSource> LoadImageAsync(string path)
{
ImageSource image = null;
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
if (File.Exists(path))
{
var file = await StorageFile.GetFileFromPathAsync(path);
var file = await StorageFile.GetFileFromPathAsync(Path.GetFullPath(path));
using (var stream = await file.OpenReadAsync())
{
@ -63,6 +53,17 @@ namespace MapControl
return image;
}
private static async Task<ImageSource> LoadImageAsync(IHttpContent content)
{
using (var stream = new InMemoryRandomAccessStream())
{
await content.WriteToStreamAsync(stream);
stream.Seek(0);
return await LoadImageAsync(stream);
}
}
internal class HttpBufferResponse
{
public readonly IBuffer Buffer;