diff --git a/Caching/FileDbCache.WPF/FileDbCache.cs b/Caching/FileDbCache.WPF/FileDbCache.cs index 20e9dcbc..d7f21209 100644 --- a/Caching/FileDbCache.WPF/FileDbCache.cs +++ b/Caching/FileDbCache.WPF/FileDbCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs index f9580c29..5c1138f8 100644 --- a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("ObjectCache implementation based on EzTools FileDb")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/FileDbCache.WinRT/FileDbCache.cs b/Caching/FileDbCache.WinRT/FileDbCache.cs index 0289ad02..c3dcf9cb 100644 --- a/Caching/FileDbCache.WinRT/FileDbCache.cs +++ b/Caching/FileDbCache.WinRT/FileDbCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs index bcc41ef3..a1729790 100644 --- a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("IImageCache implementation based on EzTools FileDb")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WPF/ImageFileCache.cs b/Caching/ImageFileCache.WPF/ImageFileCache.cs index 04109a25..1486eceb 100644 --- a/Caching/ImageFileCache.WPF/ImageFileCache.cs +++ b/Caching/ImageFileCache.WPF/ImageFileCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs index 19ae587d..842a3ab4 100644 --- a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("ObjectCache implementation based on local image files")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WinRT/ImageFileCache.cs b/Caching/ImageFileCache.WinRT/ImageFileCache.cs index 844f87da..0e5b99c6 100644 --- a/Caching/ImageFileCache.WinRT/ImageFileCache.cs +++ b/Caching/ImageFileCache.WinRT/ImageFileCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs index 075639f7..9e9b3d47 100644 --- a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("IImageCache implementation based on local image files")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl VS2015.sln b/MapControl VS2015.sln index d4fcf46f..61d9852b 100644 --- a/MapControl VS2015.sln +++ b/MapControl VS2015.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileDbCache.WinRT", "Caching\FileDbCache.WinRT\FileDbCache.WinRT.csproj", "{C7BF2B18-CC74-430B-BCB2-600304EFA3D8}" EndProject @@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapControl.WinRT", "MapCont EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapControl.WPF", "MapControl\MapControl.WPF.csproj", "{226F3575-B683-446D-A2F0-181291DC8787}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhoneApplication", "SampleApps\PhoneApplication\PhoneApplication.csproj", "{8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightApplication", "SampleApps\SilverlightApplication\SilverlightApplication.csproj", "{CBA8C535-CCA3-4F60-8D3E-0E25791CBD21}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SilverlightApplication.Web", "SampleApps\SilverlightApplication.Web\SilverlightApplication.Web.csproj", "{177C4EF8-0B0A-426E-BDCC-168DC10AC1C1}" @@ -155,30 +153,6 @@ Global {226F3575-B683-446D-A2F0-181291DC8787}.Release|x64.Build.0 = Release|Any CPU {226F3575-B683-446D-A2F0-181291DC8787}.Release|x86.ActiveCfg = Release|Any CPU {226F3575-B683-446D-A2F0-181291DC8787}.Release|x86.Build.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|ARM.ActiveCfg = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|ARM.Build.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|ARM.Deploy.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|x64.ActiveCfg = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|x64.Build.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|x64.Deploy.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|x86.ActiveCfg = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|x86.Build.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Debug|x86.Deploy.0 = Debug|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|Any CPU.Build.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|Any CPU.Deploy.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|ARM.ActiveCfg = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|ARM.Build.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|ARM.Deploy.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|x64.ActiveCfg = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|x64.Build.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|x64.Deploy.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|x86.ActiveCfg = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|x86.Build.0 = Release|Any CPU - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}.Release|x86.Deploy.0 = Release|Any CPU {CBA8C535-CCA3-4F60-8D3E-0E25791CBD21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CBA8C535-CCA3-4F60-8D3E-0E25791CBD21}.Debug|Any CPU.Build.0 = Debug|Any CPU {CBA8C535-CCA3-4F60-8D3E-0E25791CBD21}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -256,7 +230,6 @@ Global {EF44F661-B98A-4676-927F-85D138F82300} = {AE8A7E02-0F7D-41B0-AB23-15394150ED17} {F789647E-96F7-43E3-A895-FA3FE8D01260} = {AE8A7E02-0F7D-41B0-AB23-15394150ED17} {86470440-FEE2-4120-AF5A-3762FB9C536F} = {AE8A7E02-0F7D-41B0-AB23-15394150ED17} - {8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9} = {100879CC-8910-459E-856E-253D629E45DE} {CBA8C535-CCA3-4F60-8D3E-0E25791CBD21} = {100879CC-8910-459E-856E-253D629E45DE} {177C4EF8-0B0A-426E-BDCC-168DC10AC1C1} = {100879CC-8910-459E-856E-253D629E45DE} {9949326E-9261-4F95-89B1-151F60498951} = {100879CC-8910-459E-856E-253D629E45DE} diff --git a/MapControl/BingMapsTileLayer.cs b/MapControl/BingMapsTileLayer.cs index ba7a45b9..c1bc6f27 100644 --- a/MapControl/BingMapsTileLayer.cs +++ b/MapControl/BingMapsTileLayer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -56,7 +56,7 @@ namespace MapControl } var uri = string.Format("http://dev.virtualearth.net/REST/V1/Imagery/Metadata/{0}?output=xml&key={1}", Mode, ApiKey); - var request = HttpWebRequest.CreateHttp(uri); + var request = WebRequest.CreateHttp(uri); request.BeginGetResponse(HandleImageryMetadataResponse, request); } @@ -122,7 +122,7 @@ namespace MapControl if (!string.IsNullOrEmpty(imageUrl) && imageUrlSubdomains != null && imageUrlSubdomains.Length > 0) { - Dispatcher.BeginInvoke(new Action(() => + var _ = Dispatcher.BeginInvoke(new Action(() => { if (string.IsNullOrEmpty(Culture)) { diff --git a/MapControl/BingMapsTileSource.cs b/MapControl/BingMapsTileSource.cs index 6cd8044a..44df45ee 100644 --- a/MapControl/BingMapsTileSource.cs +++ b/MapControl/BingMapsTileSource.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/Extensions.Silverlight.cs b/MapControl/Extensions.Silverlight.cs index b9fb1793..f633eeee 100644 --- a/MapControl/Extensions.Silverlight.cs +++ b/MapControl/Extensions.Silverlight.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Extensions.WinRT.cs b/MapControl/Extensions.WinRT.cs index a1118ff4..4359f74c 100644 --- a/MapControl/Extensions.WinRT.cs +++ b/MapControl/Extensions.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -13,9 +13,9 @@ namespace MapControl { internal static class Extensions { - public static void BeginInvoke(this CoreDispatcher dispatcher, Action action) + public static IAsyncAction BeginInvoke(this CoreDispatcher dispatcher, Action action) { - var asyncAction = dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(action)); + return dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(action)); } public static Point Transform(this GeneralTransform transform, Point point) diff --git a/MapControl/HyperlinkText.cs b/MapControl/HyperlinkText.cs index 32aabbbd..dac1d07e 100644 --- a/MapControl/HyperlinkText.cs +++ b/MapControl/HyperlinkText.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/IMapElement.cs b/MapControl/IMapElement.cs index cd583703..4ac2d67e 100644 --- a/MapControl/IMapElement.cs +++ b/MapControl/IMapElement.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) namespace MapControl diff --git a/MapControl/ITileImageLoader.cs b/MapControl/ITileImageLoader.cs index 88bf0f76..3b3404f0 100644 --- a/MapControl/ITileImageLoader.cs +++ b/MapControl/ITileImageLoader.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.Generic; diff --git a/MapControl/ImageCache.WinRT.cs b/MapControl/ImageCache.WinRT.cs index 55cb3959..56a77b42 100644 --- a/MapControl/ImageCache.WinRT.cs +++ b/MapControl/ImageCache.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/ImageLoader.cs b/MapControl/ImageLoader.cs new file mode 100644 index 00000000..75c579b8 --- /dev/null +++ b/MapControl/ImageLoader.cs @@ -0,0 +1,53 @@ +// XAML Map Control - http://xamlmapcontrol.codeplex.com/ +// © 2016 Clemens Fischer +// Licensed under the Microsoft Public License (Ms-PL) + +using System; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Windows.Media.Imaging; + +namespace MapControl +{ + internal static class ImageLoader + { + public static BitmapSource FromStream(Stream stream) + { + var bitmap = new BitmapImage(); + + bitmap.BeginInit(); + bitmap.CacheOption = BitmapCacheOption.OnLoad; + bitmap.StreamSource = stream; + bitmap.EndInit(); + bitmap.Freeze(); + + return bitmap; + } + + public static BitmapSource FromUri(Uri uri) + { + BitmapSource bitmap = null; + + try + { + var request = WebRequest.Create(uri); + + using (var response = request.GetResponse()) + using (var responseStream = response.GetResponseStream()) + using (var memoryStream = new MemoryStream()) + { + responseStream.CopyTo(memoryStream); + memoryStream.Seek(0, SeekOrigin.Begin); + bitmap = FromStream(memoryStream); + } + } + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + } + + return bitmap; + } + } +} diff --git a/MapControl/ImageTileSource.Silverlight.WinRT.cs b/MapControl/ImageTileSource.Silverlight.WinRT.cs index 7caac0d7..b979f3ee 100644 --- a/MapControl/ImageTileSource.Silverlight.WinRT.cs +++ b/MapControl/ImageTileSource.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/ImageTileSource.WPF.cs b/MapControl/ImageTileSource.WPF.cs index 5fa0df05..b49e0ced 100644 --- a/MapControl/ImageTileSource.WPF.cs +++ b/MapControl/ImageTileSource.WPF.cs @@ -1,9 +1,7 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) -using System.IO; -using System.Net; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -30,20 +28,11 @@ namespace MapControl { if (IsAsync) { - var request = HttpWebRequest.CreateHttp(uri); - - using (var response = (HttpWebResponse)request.GetResponse()) - using (var responseStream = response.GetResponseStream()) - using (var memoryStream = new MemoryStream()) - { - responseStream.CopyTo(memoryStream); - memoryStream.Position = 0; - image = BitmapFrame.Create(memoryStream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); - } + image = ImageLoader.FromUri(uri); } else { - image = BitmapFrame.Create(uri); + image = new BitmapImage(uri); } } diff --git a/MapControl/Location.cs b/MapControl/Location.cs index ee846bae..eb8ba689 100644 --- a/MapControl/Location.cs +++ b/MapControl/Location.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationCollection.cs b/MapControl/LocationCollection.cs index 8b3f2599..6fd0cfd0 100644 --- a/MapControl/LocationCollection.cs +++ b/MapControl/LocationCollection.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationCollectionConverter.cs b/MapControl/LocationCollectionConverter.cs index 24069b9f..54682618 100644 --- a/MapControl/LocationCollectionConverter.cs +++ b/MapControl/LocationCollectionConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationConverter.cs b/MapControl/LocationConverter.cs index 2037d812..35cd1545 100644 --- a/MapControl/LocationConverter.cs +++ b/MapControl/LocationConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/Map.Silverlight.cs b/MapControl/Map.Silverlight.cs index a260c941..470d190c 100644 --- a/MapControl/Map.Silverlight.cs +++ b/MapControl/Map.Silverlight.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Map.WPF.cs b/MapControl/Map.WPF.cs index 485698b5..bd7bdfaa 100644 --- a/MapControl/Map.WPF.cs +++ b/MapControl/Map.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Map.WinRT.cs b/MapControl/Map.WinRT.cs index 6d1f1d79..46317124 100644 --- a/MapControl/Map.WinRT.cs +++ b/MapControl/Map.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using Windows.UI.Xaml; diff --git a/MapControl/MapBase.Silverlight.WinRT.cs b/MapControl/MapBase.Silverlight.WinRT.cs index 75f119f5..9dcf1821 100644 --- a/MapControl/MapBase.Silverlight.WinRT.cs +++ b/MapControl/MapBase.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapBase.WPF.cs b/MapControl/MapBase.WPF.cs index 7c178000..4a704b00 100644 --- a/MapControl/MapBase.WPF.cs +++ b/MapControl/MapBase.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -53,6 +53,11 @@ namespace MapControl typeof(MapBase), new FrameworkPropertyMetadata(Brushes.Transparent)); } + partial void RemoveAnimation(DependencyProperty property) + { + BeginAnimation(property, null); + } + /// /// Changes the Center property according to the specified translation in viewport coordinates. /// @@ -71,11 +76,6 @@ namespace MapControl TransformMap(origin, (Point)translation, rotation, scale); } - partial void RemoveAnimation(DependencyProperty property) - { - BeginAnimation(property, null); - } - protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { base.OnRenderSizeChanged(sizeInfo); diff --git a/MapControl/MapControl.WPF.csproj b/MapControl/MapControl.WPF.csproj index 5b4e26a0..8b4fb464 100644 --- a/MapControl/MapControl.WPF.csproj +++ b/MapControl/MapControl.WPF.csproj @@ -54,6 +54,7 @@ + diff --git a/MapControl/MapGraticule.Silverlight.WinRT.cs b/MapControl/MapGraticule.Silverlight.WinRT.cs index 5abe923e..21b5d130 100644 --- a/MapControl/MapGraticule.Silverlight.WinRT.cs +++ b/MapControl/MapGraticule.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapGraticule.WPF.cs b/MapControl/MapGraticule.WPF.cs index be1e6afd..1da4fc30 100644 --- a/MapControl/MapGraticule.WPF.cs +++ b/MapControl/MapGraticule.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapGraticule.cs b/MapControl/MapGraticule.cs index bd5a4f29..30e8bfb3 100644 --- a/MapControl/MapGraticule.cs +++ b/MapControl/MapGraticule.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapImage.cs b/MapControl/MapImage.cs index 0ac524a1..7cefb1ec 100644 --- a/MapControl/MapImage.cs +++ b/MapControl/MapImage.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapImageLayer.Silverlight.WinRT.cs b/MapControl/MapImageLayer.Silverlight.WinRT.cs index 85762b06..cfc16c99 100644 --- a/MapControl/MapImageLayer.Silverlight.WinRT.cs +++ b/MapControl/MapImageLayer.Silverlight.WinRT.cs @@ -1,7 +1,8 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +using System; #if NETFX_CORE using Windows.UI.Xaml; using Windows.UI.Xaml.Media.Imaging; @@ -14,8 +15,15 @@ namespace MapControl { public partial class MapImageLayer { - private void ImageUpdated(BitmapSource bitmap) + protected virtual void UpdateImage(BoundingBox boundingBox, Uri uri) { + UpdateImage(boundingBox, new BitmapImage(uri)); + } + + protected void UpdateImage(BoundingBox boundingBox, BitmapSource bitmap) + { + SetTopImage(boundingBox, bitmap); + var bitmapImage = bitmap as BitmapImage; if (bitmapImage != null) diff --git a/MapControl/MapImageLayer.WPF.cs b/MapControl/MapImageLayer.WPF.cs index 7e15f89d..e7b22029 100644 --- a/MapControl/MapImageLayer.WPF.cs +++ b/MapControl/MapImageLayer.WPF.cs @@ -1,8 +1,9 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; +using System.Threading.Tasks; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -10,8 +11,19 @@ namespace MapControl { public partial class MapImageLayer { - private void ImageUpdated(BitmapSource bitmap) + protected virtual void UpdateImage(BoundingBox boundingBox, Uri uri) { + Task.Run(() => + { + var image = ImageLoader.FromUri(uri); + Dispatcher.BeginInvoke(new Action(() => UpdateImage(boundingBox, image))); + }); + } + + protected void UpdateImage(BoundingBox boundingBox, BitmapSource bitmap) + { + SetTopImage(boundingBox, bitmap); + if (bitmap != null && !bitmap.IsFrozen && bitmap.IsDownloading) { bitmap.DownloadCompleted += BitmapDownloadCompleted; diff --git a/MapControl/MapImageLayer.cs b/MapControl/MapImageLayer.cs index 560ef667..3649b0d6 100644 --- a/MapControl/MapImageLayer.cs +++ b/MapControl/MapImageLayer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -26,10 +26,38 @@ namespace MapControl /// public partial class MapImageLayer : MapPanel { + public struct BoundingBox + { + public readonly double West; + public readonly double East; + public readonly double South; + public readonly double North; + + public BoundingBox(double west, double east, double south, double north) + { + West = west; + East = east; + South = south; + North = north; + } + } + public static readonly DependencyProperty UriFormatProperty = DependencyProperty.Register( "UriFormat", typeof(string), typeof(MapImageLayer), new PropertyMetadata(null, (o, e) => ((MapImageLayer)o).UpdateImage())); + public static readonly DependencyProperty MinLongitudeProperty = DependencyProperty.Register( + "MinLongitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN)); + + public static readonly DependencyProperty MaxLongitudeProperty = DependencyProperty.Register( + "MaxLongitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN)); + + public static readonly DependencyProperty MinLatitudeProperty = DependencyProperty.Register( + "MinLatitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN)); + + public static readonly DependencyProperty MaxLatitudeProperty = DependencyProperty.Register( + "MaxLatitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN)); + public static readonly DependencyProperty RelativeImageSizeProperty = DependencyProperty.Register( "RelativeImageSize", typeof(double), typeof(MapImageLayer), new PropertyMetadata(1d)); @@ -53,8 +81,8 @@ namespace MapControl /// /// The format string of the image request Uri. The format must contain /// {X} and {Y} format specifiers for the map width and height in pixels and either - /// {w},{s},{e},{n} for the bounding box in lat/lon (like EPSG:4326) or - /// {W},{S},{E},{N} for the bounding box in meters (like EPSG:3857). + /// {w},{s},{e},{n} for a latitude/longitude bounding box (like EPSG:4326) or + /// {W},{S},{E},{N} for a projected bounding box (e.g. in meters like EPSG:3857). /// public string UriFormat { @@ -62,6 +90,42 @@ namespace MapControl set { SetValue(UriFormatProperty, value); } } + /// + /// Optional minimum longitude value. Default is NaN. + /// + public double MinLongitude + { + get { return (double)GetValue(MinLongitudeProperty); } + set { SetValue(MinLongitudeProperty, value); } + } + + /// + /// Optional maximum longitude value. Default is NaN. + /// + public double MaxLongitude + { + get { return (double)GetValue(MaxLongitudeProperty); } + set { SetValue(MaxLongitudeProperty, value); } + } + + /// + /// Optional minimum latitude value. Default is NaN. + /// + public double MinLatitude + { + get { return (double)GetValue(MinLatitudeProperty); } + set { SetValue(MinLatitudeProperty, value); } + } + + /// + /// Optional maximum latitude value. Default is NaN. + /// + public double MaxLatitude + { + get { return (double)GetValue(MaxLatitudeProperty); } + set { SetValue(MaxLatitudeProperty, value); } + } + /// /// Relative size of the map images in relation to the current viewport size. /// Setting a value greater than one will let MapImageLayer request images that @@ -82,6 +146,16 @@ namespace MapControl set { SetValue(UpdateIntervalProperty, value); } } + protected virtual BoundingBox ProjectBoundingBox(BoundingBox boundingBox) + { + var p1 = ParentMap.MapTransform.Transform(new Location(boundingBox.South, boundingBox.West)); + var p2 = ParentMap.MapTransform.Transform(new Location(boundingBox.North, boundingBox.East)); + + return new BoundingBox( + TileSource.MetersPerDegree * p1.X, TileSource.MetersPerDegree * p2.X, + TileSource.MetersPerDegree * p1.Y, TileSource.MetersPerDegree * p2.Y); + } + protected override void OnViewportChanged() { base.OnViewportChanged(); @@ -98,15 +172,15 @@ namespace MapControl { updateTimer.Start(); // update image on next timer tick } - else if (ParentMap != null && RenderSize.Width > 0 && RenderSize.Height > 0) + else if (ParentMap != null && ParentMap.RenderSize.Width > 0 && ParentMap.RenderSize.Height > 0) { updateInProgress = true; var relativeSize = Math.Max(RelativeImageSize, 1d); - var width = RenderSize.Width * relativeSize; - var height = RenderSize.Height * relativeSize; - var dx = (RenderSize.Width - width) / 2d; - var dy = (RenderSize.Height - height) / 2d; + var width = ParentMap.RenderSize.Width * relativeSize; + var height = ParentMap.RenderSize.Height * relativeSize; + var dx = (ParentMap.RenderSize.Width - width) / 2d; + var dy = (ParentMap.RenderSize.Height - height) / 2d; var loc1 = ParentMap.ViewportPointToLocation(new Point(dx, dy)); var loc2 = ParentMap.ViewportPointToLocation(new Point(dx + width, dy)); @@ -118,17 +192,36 @@ namespace MapControl var south = Math.Min(loc1.Latitude, Math.Min(loc2.Latitude, Math.Min(loc3.Latitude, loc4.Latitude))); var north = Math.Max(loc1.Latitude, Math.Max(loc2.Latitude, Math.Max(loc3.Latitude, loc4.Latitude))); + if (!double.IsNaN(MinLongitude) && west < MinLongitude) + { + west = MinLongitude; + } + + if (!double.IsNaN(MaxLongitude) && east > MaxLongitude) + { + east = MaxLongitude; + } + + if (!double.IsNaN(MinLatitude) && south < MinLatitude) + { + south = MinLatitude; + } + + if (!double.IsNaN(MaxLatitude) && north > MaxLatitude) + { + north = MaxLatitude; + } + var p1 = ParentMap.MapTransform.Transform(new Location(south, west)); var p2 = ParentMap.MapTransform.Transform(new Location(north, east)); - width = Math.Round((p2.X - p1.X) * ParentMap.ViewportScale); - height = Math.Round((p2.Y - p1.Y) * ParentMap.ViewportScale); - - UpdateImage(west, east, south, north, (int)width, (int)height); + UpdateImage(new BoundingBox(west, east, south, north), + (int)Math.Round((p2.X - p1.X) * ParentMap.ViewportScale), + (int)Math.Round((p2.Y - p1.Y) * ParentMap.ViewportScale)); } } - protected virtual void UpdateImage(double west, double east, double south, double north, int width, int height) + protected virtual void UpdateImage(BoundingBox boundingBox, int width, int height) { if (UriFormat != null && width > 0 && height > 0) { @@ -136,48 +229,40 @@ namespace MapControl .Replace("{X}", width.ToString()) .Replace("{Y}", height.ToString()); - if (uri.Contains("{W}") && uri.Contains("{S}") && uri.Contains("{E}") && uri.Contains("{N}")) + if (uri.Contains("{W}") && uri.Contains("{E}") && uri.Contains("{S}") && uri.Contains("{N}")) { - var p1 = ParentMap.MapTransform.Transform(new Location(south, west)); - var p2 = ParentMap.MapTransform.Transform(new Location(north, east)); + var projectedBoundingBox = ProjectBoundingBox(boundingBox); uri = uri - .Replace("{W}", (TileSource.MetersPerDegree * p1.X).ToString(CultureInfo.InvariantCulture)) - .Replace("{S}", (TileSource.MetersPerDegree * p1.Y).ToString(CultureInfo.InvariantCulture)) - .Replace("{E}", (TileSource.MetersPerDegree * p2.X).ToString(CultureInfo.InvariantCulture)) - .Replace("{N}", (TileSource.MetersPerDegree * p2.Y).ToString(CultureInfo.InvariantCulture)); + .Replace("{W}", projectedBoundingBox.West.ToString(CultureInfo.InvariantCulture)) + .Replace("{S}", projectedBoundingBox.South.ToString(CultureInfo.InvariantCulture)) + .Replace("{E}", projectedBoundingBox.East.ToString(CultureInfo.InvariantCulture)) + .Replace("{N}", projectedBoundingBox.North.ToString(CultureInfo.InvariantCulture)); } else { uri = uri - .Replace("{w}", west.ToString(CultureInfo.InvariantCulture)) - .Replace("{s}", south.ToString(CultureInfo.InvariantCulture)) - .Replace("{e}", east.ToString(CultureInfo.InvariantCulture)) - .Replace("{n}", north.ToString(CultureInfo.InvariantCulture)); + .Replace("{w}", boundingBox.West.ToString(CultureInfo.InvariantCulture)) + .Replace("{s}", boundingBox.South.ToString(CultureInfo.InvariantCulture)) + .Replace("{e}", boundingBox.East.ToString(CultureInfo.InvariantCulture)) + .Replace("{n}", boundingBox.North.ToString(CultureInfo.InvariantCulture)); } - UpdateImage(west, east, south, north, new Uri(uri)); + UpdateImage(boundingBox, new Uri(uri)); } else { - UpdateImage(west, east, south, north, (BitmapSource)null); + UpdateImage(boundingBox, (BitmapSource)null); } } - protected virtual void UpdateImage(double west, double east, double south, double north, Uri uri) - { - UpdateImage(west, east, south, north, new BitmapImage(uri)); - } - - protected void UpdateImage(double west, double east, double south, double north, BitmapSource bitmap) + private void SetTopImage(BoundingBox boundingBox, BitmapSource bitmap) { currentImageIndex = (currentImageIndex + 1) % 2; - var mapImage = (MapImage)Children[currentImageIndex]; + var topImage = (MapImage)Children[currentImageIndex]; - mapImage.SetBoundingBox(west, east, south, north); - mapImage.Source = bitmap; - - ImageUpdated(bitmap); + topImage.SetBoundingBox(boundingBox.West, boundingBox.East, boundingBox.South, boundingBox.North); + topImage.Source = bitmap; } private void SwapImages() @@ -198,7 +283,11 @@ namespace MapControl FillBehavior = FillBehavior.Stop }; - fadeAnimation.Completed += (s, e) => bottomImage.Opacity = 0d; + fadeAnimation.Completed += (s, e) => + { + bottomImage.Opacity = 0d; + bottomImage.Source = null; + }; topImage.BeginAnimation(UIElement.OpacityProperty, fadeAnimation); topImage.Opacity = 1d; @@ -207,6 +296,7 @@ namespace MapControl { topImage.Opacity = 0d; bottomImage.Opacity = 0d; + bottomImage.Source = null; } updateInProgress = false; diff --git a/MapControl/MapItem.Silverlight.WinRT.cs b/MapControl/MapItem.Silverlight.WinRT.cs index 740d97fe..abaabb3a 100644 --- a/MapControl/MapItem.Silverlight.WinRT.cs +++ b/MapControl/MapItem.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapItem.WPF.cs b/MapControl/MapItem.WPF.cs index dcaf6490..e3653ded 100644 --- a/MapControl/MapItem.WPF.cs +++ b/MapControl/MapItem.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapItemsControl.Silverlight.WinRT.cs b/MapControl/MapItemsControl.Silverlight.WinRT.cs index 9dc30ac2..a4e0594b 100644 --- a/MapControl/MapItemsControl.Silverlight.WinRT.cs +++ b/MapControl/MapItemsControl.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapItemsControl.WPF.cs b/MapControl/MapItemsControl.WPF.cs index 889d9370..8d22e270 100644 --- a/MapControl/MapItemsControl.WPF.cs +++ b/MapControl/MapItemsControl.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapOverlay.Silverlight.WinRT.cs b/MapControl/MapOverlay.Silverlight.WinRT.cs index f0e381a5..1192081e 100644 --- a/MapControl/MapOverlay.Silverlight.WinRT.cs +++ b/MapControl/MapOverlay.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if !NETFX_CORE diff --git a/MapControl/MapOverlay.WPF.cs b/MapControl/MapOverlay.WPF.cs index 3cafd706..2b6bdac0 100644 --- a/MapControl/MapOverlay.WPF.cs +++ b/MapControl/MapOverlay.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapOverlay.cs b/MapControl/MapOverlay.cs index f66de93e..0a9d67f0 100644 --- a/MapControl/MapOverlay.cs +++ b/MapControl/MapOverlay.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapPanel.Silverlight.WinRT.cs b/MapControl/MapPanel.Silverlight.WinRT.cs index 9d723f98..fc8b83c7 100644 --- a/MapControl/MapPanel.Silverlight.WinRT.cs +++ b/MapControl/MapPanel.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapPanel.WPF.cs b/MapControl/MapPanel.WPF.cs index d146bb07..49dccaa3 100644 --- a/MapControl/MapPanel.WPF.cs +++ b/MapControl/MapPanel.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs index 65ec9dc6..e811f092 100644 --- a/MapControl/MapPanel.cs +++ b/MapControl/MapPanel.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapPath.Silverlight.WinRT.cs b/MapControl/MapPath.Silverlight.WinRT.cs index 1ce65ac7..c9ba15d0 100644 --- a/MapControl/MapPath.Silverlight.WinRT.cs +++ b/MapControl/MapPath.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapPath.WPF.cs b/MapControl/MapPath.WPF.cs index af6a86d4..6a93c85d 100644 --- a/MapControl/MapPath.WPF.cs +++ b/MapControl/MapPath.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapPath.cs b/MapControl/MapPath.cs index 00b89f97..c4ff55e0 100644 --- a/MapControl/MapPath.cs +++ b/MapControl/MapPath.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapPolyline.Silverlight.WinRT.cs b/MapControl/MapPolyline.Silverlight.WinRT.cs index 1be26ada..cecaf207 100644 --- a/MapControl/MapPolyline.Silverlight.WinRT.cs +++ b/MapControl/MapPolyline.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; diff --git a/MapControl/MapPolyline.WPF.cs b/MapControl/MapPolyline.WPF.cs index 020d93e3..c788c107 100644 --- a/MapControl/MapPolyline.WPF.cs +++ b/MapControl/MapPolyline.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; diff --git a/MapControl/MapPolyline.cs b/MapControl/MapPolyline.cs index 8527a17b..3ee675ee 100644 --- a/MapControl/MapPolyline.cs +++ b/MapControl/MapPolyline.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.Generic; diff --git a/MapControl/MapRectangle.WPF.cs b/MapControl/MapRectangle.WPF.cs index 7ee45fe6..873ddb50 100644 --- a/MapControl/MapRectangle.WPF.cs +++ b/MapControl/MapRectangle.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapRectangle.cs b/MapControl/MapRectangle.cs index 207322fd..bf30ee55 100644 --- a/MapControl/MapRectangle.cs +++ b/MapControl/MapRectangle.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapScale.cs b/MapControl/MapScale.cs index d61ee5d5..d92c2d52 100644 --- a/MapControl/MapScale.cs +++ b/MapControl/MapScale.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapTransform.cs b/MapControl/MapTransform.cs index 9be6c379..b812ae2e 100644 --- a/MapControl/MapTransform.cs +++ b/MapControl/MapTransform.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MatrixEx.cs b/MapControl/MatrixEx.cs index dd39fc20..0608fe4a 100644 --- a/MapControl/MatrixEx.cs +++ b/MapControl/MatrixEx.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MercatorTransform.cs b/MapControl/MercatorTransform.cs index 10f7ddeb..3835a02e 100644 --- a/MapControl/MercatorTransform.cs +++ b/MapControl/MercatorTransform.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/PanelBase.cs b/MapControl/PanelBase.cs index 69fc860b..af80183a 100644 --- a/MapControl/PanelBase.cs +++ b/MapControl/PanelBase.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index ba943b26..36ae684b 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -12,10 +12,10 @@ using System.Windows; #endif [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/Pushpin.Silverlight.WinRT.cs b/MapControl/Pushpin.Silverlight.WinRT.cs index 60ea1cf4..b684c37d 100644 --- a/MapControl/Pushpin.Silverlight.WinRT.cs +++ b/MapControl/Pushpin.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/Pushpin.WPF.cs b/MapControl/Pushpin.WPF.cs index 7a66b4a5..dae75d2a 100644 --- a/MapControl/Pushpin.WPF.cs +++ b/MapControl/Pushpin.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/Tile.Silverlight.WinRT.cs b/MapControl/Tile.Silverlight.WinRT.cs index 294c6ba0..10771bdf 100644 --- a/MapControl/Tile.Silverlight.WinRT.cs +++ b/MapControl/Tile.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/Tile.WPF.cs b/MapControl/Tile.WPF.cs index f0266015..8bf70830 100644 --- a/MapControl/Tile.WPF.cs +++ b/MapControl/Tile.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/Tile.cs b/MapControl/Tile.cs index a3a8cd70..54132d92 100644 --- a/MapControl/Tile.cs +++ b/MapControl/Tile.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileGrid.cs b/MapControl/TileGrid.cs index 54ab6219..280f182c 100644 --- a/MapControl/TileGrid.cs +++ b/MapControl/TileGrid.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileImageLoader.Silverlight.cs b/MapControl/TileImageLoader.Silverlight.cs index 46be5dcf..7e83db83 100644 --- a/MapControl/TileImageLoader.Silverlight.cs +++ b/MapControl/TileImageLoader.Silverlight.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index 0a38a748..158971d1 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -14,7 +14,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Media; -using System.Windows.Media.Imaging; using System.Windows.Threading; namespace MapControl @@ -122,7 +121,7 @@ namespace MapControl foreach (var tile in tiles) { - BitmapSource cachedImage = null; + ImageSource cachedImage = null; if (useCache && GetCachedImage(CacheKey(sourceName, tile), out cachedImage)) { @@ -219,7 +218,7 @@ namespace MapControl { using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { - image = BitmapFrame.Create(fileStream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + image = ImageLoader.FromStream(fileStream); } } catch (Exception ex) @@ -233,11 +232,11 @@ namespace MapControl private static ImageSource DownloadImage(Uri uri, string cacheKey) { - BitmapSource image = null; + ImageSource image = null; try { - var request = HttpWebRequest.CreateHttp(uri); + var request = WebRequest.CreateHttp(uri); if (HttpUserAgent != null) { @@ -251,8 +250,7 @@ namespace MapControl { responseStream.CopyTo(memoryStream); memoryStream.Seek(0, SeekOrigin.Begin); - - image = BitmapFrame.Create(memoryStream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + image = ImageLoader.FromStream(memoryStream); if (cacheKey != null) { @@ -283,7 +281,7 @@ namespace MapControl return string.IsNullOrEmpty(sourceName) ? null : string.Format("{0}/{1}/{2}/{3}", sourceName, tile.ZoomLevel, tile.XIndex, tile.Y); } - private static bool GetCachedImage(string cacheKey, out BitmapSource image) + private static bool GetCachedImage(string cacheKey, out ImageSource image) { image = null; @@ -295,7 +293,7 @@ namespace MapControl { using (var memoryStream = new MemoryStream(buffer)) { - image = BitmapFrame.Create(memoryStream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + image = ImageLoader.FromStream(memoryStream); } DateTime expiration = DateTime.MinValue; diff --git a/MapControl/TileImageLoader.WinRT.cs b/MapControl/TileImageLoader.WinRT.cs index b5a13451..ef8dd5ce 100644 --- a/MapControl/TileImageLoader.WinRT.cs +++ b/MapControl/TileImageLoader.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileLayer.Silverlight.WinRT.cs b/MapControl/TileLayer.Silverlight.WinRT.cs index 9cef8906..c19b75aa 100644 --- a/MapControl/TileLayer.Silverlight.WinRT.cs +++ b/MapControl/TileLayer.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileLayer.WPF.cs b/MapControl/TileLayer.WPF.cs index a761ecde..a5b18adb 100644 --- a/MapControl/TileLayer.WPF.cs +++ b/MapControl/TileLayer.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 0f64f88f..8ae1299e 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileLayerCollection.cs b/MapControl/TileLayerCollection.cs index 5dbee361..78ed59dc 100644 --- a/MapControl/TileLayerCollection.cs +++ b/MapControl/TileLayerCollection.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.ObjectModel; diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs index 1d1ac2fe..178ad663 100644 --- a/MapControl/TileSource.cs +++ b/MapControl/TileSource.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileSourceConverter.cs b/MapControl/TileSourceConverter.cs index 8d4dc6f8..594aef95 100644 --- a/MapControl/TileSourceConverter.cs +++ b/MapControl/TileSourceConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// © 2015 Clemens Fischer +// © 2016 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 9350285f..2fa391c5 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Library for Windows Runtime")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs index 20cacb82..7e7d79dc 100644 --- a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Windows Phone Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index a4b1f45e..81d321e3 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Silverlight/Web Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 8be931ba..fcb38c12 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Silverlight Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index 30191bd7..9a6ecfee 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: ComVisible(false)] diff --git a/SampleApps/UniversalApp/MainPage.xaml b/SampleApps/UniversalApp/MainPage.xaml index 2c41e897..043bdd20 100644 --- a/SampleApps/UniversalApp/MainPage.xaml +++ b/SampleApps/UniversalApp/MainPage.xaml @@ -168,8 +168,10 @@ + + diff --git a/SampleApps/UniversalApp/Properties/AssemblyInfo.cs b/SampleApps/UniversalApp/Properties/AssemblyInfo.cs index fcac6855..bec13c68 100644 --- a/SampleApps/UniversalApp/Properties/AssemblyInfo.cs +++ b/SampleApps/UniversalApp/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control Universal Windows Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index 2ac8c533..4f299e8f 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -5,10 +5,10 @@ using System.Runtime.InteropServices; [assembly: AssemblyDescription("XAML Map Control WPF Sample Application")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] -[assembly: AssemblyCopyright("© 2015 Clemens Fischer")] +[assembly: AssemblyCopyright("© 2016 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.7.2")] -[assembly: AssemblyFileVersion("2.7.2")] +[assembly: AssemblyVersion("2.8.0")] +[assembly: AssemblyFileVersion("2.8.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)]