mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 4.10.0: Updated target framework versions. Cleanup of TypeConverters, ImageLoader, MBTileSource.
This commit is contained in:
parent
acf43d70ea
commit
1359cea83c
|
|
@ -28,6 +28,8 @@ namespace MapControl
|
|||
{
|
||||
ImageSource imageSource = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (!uri.IsAbsoluteUri || uri.Scheme == "file")
|
||||
{
|
||||
imageSource = await LoadLocalImageAsync(uri);
|
||||
|
|
@ -40,6 +42,11 @@ namespace MapControl
|
|||
{
|
||||
imageSource = new BitmapImage(uri);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||
}
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
|
|
@ -48,6 +55,8 @@ namespace MapControl
|
|||
{
|
||||
ImageSource imageSource = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (var response = await HttpClient.GetAsync(uri))
|
||||
{
|
||||
if (!response.IsSuccessStatusCode)
|
||||
|
|
@ -58,9 +67,14 @@ namespace MapControl
|
|||
{
|
||||
imageSource = await CreateImageSourceAsync(response.Content);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||
}
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
#if WINDOWS_UWP
|
||||
|
|
@ -112,20 +111,12 @@ namespace MapControl
|
|||
public virtual async Task<ImageSource> LoadImageAsync(int x, int y, int zoomLevel)
|
||||
{
|
||||
ImageSource imageSource = null;
|
||||
|
||||
var uri = GetUri(x, y, zoomLevel);
|
||||
|
||||
if (uri != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
imageSource = await ImageLoader.LoadImageAsync(uri);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("TileSource: {0}: {1}", uri, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,15 +124,8 @@ namespace MapControl
|
|||
uri += "&FORMAT=" + Format;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
imageSource = await ImageLoader.LoadImageAsync(new Uri(uri.Replace(" ", "%20")));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("WmsImageLayer: {0}: {1}", uri, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ namespace MapControl
|
|||
public static async Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
||||
{
|
||||
ImageSource imageSource = null;
|
||||
|
||||
try
|
||||
{
|
||||
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
||||
|
||||
if (File.Exists(path))
|
||||
|
|
@ -31,6 +34,11 @@ namespace MapControl
|
|||
imageSource = await CreateImageSourceAsync(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||
}
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@ namespace MapControl
|
|||
{
|
||||
public static partial class ImageLoader
|
||||
{
|
||||
public static Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
public static ImageSource LoadLocalImage(Uri uri)
|
||||
{
|
||||
ImageSource imageSource = null;
|
||||
|
||||
try
|
||||
{
|
||||
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
||||
|
||||
if (File.Exists(path))
|
||||
|
|
@ -31,9 +32,18 @@ namespace MapControl
|
|||
imageSource = CreateImageSource(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||
}
|
||||
|
||||
return imageSource;
|
||||
});
|
||||
}
|
||||
|
||||
public static Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
||||
{
|
||||
return Task.Run(() => LoadLocalImage(uri));
|
||||
}
|
||||
|
||||
public static async Task<Tuple<MemoryStream, TimeSpan?>> LoadHttpStreamAsync(Uri uri)
|
||||
|
|
|
|||
Loading…
Reference in a new issue