From ba9edb14cc528630b87e79b663bfeb3178ae4019 Mon Sep 17 00:00:00 2001 From: ClemensF Date: Tue, 7 May 2013 18:12:25 +0200 Subject: [PATCH] Version 1.3.0: Added class MapImageLayer for WMS based map overlays. Plus plenty of cleanup. --- Caching/FileDbCache/FileDbCache.cs | 2 +- .../FileDbCache/Properties/AssemblyInfo.cs | 11 +- Caching/ImageFileCache/ImageFileCache.cs | 2 +- .../ImageFileCache/Properties/AssemblyInfo.cs | 11 +- MapControl/AnimationEx.Silverlight.cs | 2 +- MapControl/AnimationEx.WinRT.cs | 2 +- MapControl/ImageTileSource.cs | 2 +- MapControl/Int32Rect.cs | 2 +- MapControl/Location.cs | 2 +- MapControl/LocationCollection.cs | 2 +- MapControl/LocationCollectionConverter.cs | 2 +- MapControl/LocationConverter.cs | 2 +- ....Silverlight.WPF.cs => Map.Silverlight.cs} | 21 +- MapControl/Map.WPF.cs | 77 ++++++++ MapControl/Map.WinRT.cs | 29 +-- MapControl/Map.cs | 19 -- MapControl/MapBase.Silverlight.WinRT.cs | 4 +- MapControl/MapBase.WPF.cs | 4 +- MapControl/MapBase.cs | 34 ++-- MapControl/MapControl.Silverlight.csproj | 4 +- MapControl/MapControl.WPF.csproj | 5 +- MapControl/MapGraticule.Silverlight.WinRT.cs | 2 +- MapControl/MapGraticule.WPF.cs | 4 +- MapControl/MapGraticule.cs | 2 +- MapControl/MapImage.Silverlight.WinRT.cs | 49 ----- MapControl/MapImage.WPF.cs | 42 ---- MapControl/MapImage.cs | 36 +--- MapControl/MapImageLayer.cs | 187 ++++++++++++++++++ MapControl/MapItem.Silverlight.WinRT.cs | 2 +- MapControl/MapItem.WPF.cs | 2 +- .../MapItemsControl.Silverlight.WinRT.cs | 2 +- MapControl/MapItemsControl.WPF.cs | 2 +- MapControl/MapItemsControl.cs | 2 +- MapControl/MapOverlay.cs | 2 +- MapControl/MapPanel.Silverlight.WinRT.cs | 2 +- MapControl/MapPanel.WPF.cs | 2 +- MapControl/MapPanel.cs | 2 +- MapControl/MapPolyline.Silverlight.WinRT.cs | 2 +- MapControl/MapPolyline.WPF.cs | 2 +- MapControl/MapPolyline.cs | 2 +- MapControl/MapRectangle.cs | 22 +-- MapControl/MapScale.cs | 2 +- MapControl/MapShape.Silverlight.WinRT.cs | 2 +- MapControl/MapShape.WPF.cs | 2 +- MapControl/MapShape.cs | 2 +- MapControl/MapTransform.cs | 2 +- MapControl/MatrixEx.cs | 2 +- MapControl/MercatorTransform.cs | 4 +- MapControl/Properties/AssemblyInfo.cs | 19 +- MapControl/Pushpin.Silverlight.WinRT.cs | 2 +- MapControl/Pushpin.WPF.cs | 2 +- MapControl/Tile.Silverlight.WinRT.cs | 17 +- MapControl/Tile.WPF.cs | 18 +- MapControl/Tile.cs | 2 +- MapControl/TileContainer.Silverlight.WinRT.cs | 2 +- MapControl/TileContainer.WPF.cs | 2 +- MapControl/TileContainer.cs | 16 +- .../TileImageLoader.Silverlight.WinRT.cs | 2 +- MapControl/TileImageLoader.WPF.cs | 7 +- MapControl/TileLayer.Silverlight.WinRT.cs | 2 +- MapControl/TileLayer.WPF.cs | 9 +- MapControl/TileLayer.cs | 2 +- MapControl/TileLayerCollection.cs | 2 +- MapControl/TileSource.cs | 42 +++- MapControl/TileSourceConverter.cs | 2 +- MapControl/TransformEx.WinRT.cs | 2 +- MapControl/WinRT/MapControl.WinRT.csproj | 6 - MapControl/WinRT/Properties/AssemblyInfo.cs | 15 +- .../Properties/AssemblyInfo.cs | 15 +- SampleApps/SilverlightApplication/App.xaml.cs | 9 - .../SilverlightApplication/MainPage.xaml.cs | 4 +- .../Properties/AssemblyInfo.cs | 15 +- .../SilverlightApplication/SampleItems.cs | 4 +- SampleApps/StoreApplication/App.xaml.cs | 10 - SampleApps/StoreApplication/MainPage.xaml.cs | 4 +- .../Properties/AssemblyInfo.cs | 15 +- SampleApps/StoreApplication/SampleItems.cs | 4 +- .../Properties/AssemblyInfo.cs | 15 +- .../Properties/Resources.Designer.cs | 63 ------ .../Properties/Resources.resx | 117 ----------- .../Properties/Settings.Designer.cs | 26 --- .../Properties/Settings.settings | 7 - .../SurfaceApplication.csproj | 22 +-- .../LocationToVisibilityConverter.cs | 10 +- SampleApps/WpfApplication/MainWindow.xaml | 20 +- SampleApps/WpfApplication/MainWindow.xaml.cs | 6 +- .../WpfApplication/Properties/AssemblyInfo.cs | 17 +- .../Properties/Settings.Designer.cs | 2 +- SampleApps/WpfApplication/SampleItems.cs | 4 +- 89 files changed, 545 insertions(+), 638 deletions(-) rename MapControl/{Map.Silverlight.WPF.cs => Map.Silverlight.cs} (80%) create mode 100644 MapControl/Map.WPF.cs delete mode 100644 MapControl/Map.cs delete mode 100644 MapControl/MapImage.Silverlight.WinRT.cs delete mode 100644 MapControl/MapImage.WPF.cs create mode 100644 MapControl/MapImageLayer.cs delete mode 100644 SampleApps/SurfaceApplication/Properties/Resources.Designer.cs delete mode 100644 SampleApps/SurfaceApplication/Properties/Resources.resx delete mode 100644 SampleApps/SurfaceApplication/Properties/Settings.Designer.cs delete mode 100644 SampleApps/SurfaceApplication/Properties/Settings.settings diff --git a/Caching/FileDbCache/FileDbCache.cs b/Caching/FileDbCache/FileDbCache.cs index f99adbbf..b17eea40 100644 --- a/Caching/FileDbCache/FileDbCache.cs +++ b/Caching/FileDbCache/FileDbCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs index fff8b07d..5433b719 100644 --- a/Caching/FileDbCache/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs @@ -3,12 +3,13 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("FileDbCache")] [assembly: AssemblyDescription("ObjectCache implementation based on EzTools FileDb")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache/ImageFileCache.cs b/Caching/ImageFileCache/ImageFileCache.cs index a9cd62ff..2796a06d 100644 --- a/Caching/ImageFileCache/ImageFileCache.cs +++ b/Caching/ImageFileCache/ImageFileCache.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs index 2f880cbe..9503e6af 100644 --- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs @@ -3,12 +3,13 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("ImageFileCache")] [assembly: AssemblyDescription("ObjectCache implementation based on local image files")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] diff --git a/MapControl/AnimationEx.Silverlight.cs b/MapControl/AnimationEx.Silverlight.cs index 521a4612..0ec00673 100644 --- a/MapControl/AnimationEx.Silverlight.cs +++ b/MapControl/AnimationEx.Silverlight.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/AnimationEx.WinRT.cs b/MapControl/AnimationEx.WinRT.cs index 9238d27b..aa6c8885 100644 --- a/MapControl/AnimationEx.WinRT.cs +++ b/MapControl/AnimationEx.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using Windows.UI.Xaml; diff --git a/MapControl/ImageTileSource.cs b/MapControl/ImageTileSource.cs index 57a35b02..be3f7432 100644 --- a/MapControl/ImageTileSource.cs +++ b/MapControl/ImageTileSource.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows.Media; diff --git a/MapControl/Int32Rect.cs b/MapControl/Int32Rect.cs index fcceee72..0f32b0df 100644 --- a/MapControl/Int32Rect.cs +++ b/MapControl/Int32Rect.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) namespace MapControl diff --git a/MapControl/Location.cs b/MapControl/Location.cs index dee52207..d6d0bd27 100644 --- a/MapControl/Location.cs +++ b/MapControl/Location.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationCollection.cs b/MapControl/LocationCollection.cs index fb86fce9..791feaad 100644 --- a/MapControl/LocationCollection.cs +++ b/MapControl/LocationCollection.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationCollectionConverter.cs b/MapControl/LocationCollectionConverter.cs index 9e815b5e..696a3b96 100644 --- a/MapControl/LocationCollectionConverter.cs +++ b/MapControl/LocationCollectionConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/LocationConverter.cs b/MapControl/LocationConverter.cs index 387782dd..536b98c2 100644 --- a/MapControl/LocationConverter.cs +++ b/MapControl/LocationConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/Map.Silverlight.WPF.cs b/MapControl/Map.Silverlight.cs similarity index 80% rename from MapControl/Map.Silverlight.WPF.cs rename to MapControl/Map.Silverlight.cs index 2c5d05ff..c0be4951 100644 --- a/MapControl/Map.Silverlight.WPF.cs +++ b/MapControl/Map.Silverlight.cs @@ -1,14 +1,16 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) -using System; using System.Windows; using System.Windows.Input; namespace MapControl { - public partial class Map + /// + /// Default input event handling. + /// + public class Map : MapBase { private Point? mousePosition; @@ -19,17 +21,16 @@ namespace MapControl MouseLeftButtonDown += OnMouseLeftButtonDown; MouseLeftButtonUp += OnMouseLeftButtonUp; MouseMove += OnMouseMove; - -#if !SILVERLIGHT - ManipulationDelta += (o, e) => TransformMap( - e.ManipulationOrigin, (Point)e.DeltaManipulation.Translation, e.DeltaManipulation.Rotation, - (e.DeltaManipulation.Scale.X + e.DeltaManipulation.Scale.Y) / 2d); ; -#endif } + /// + /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event. + /// + public double MouseWheelZoomChange { get; set; } + private void OnMouseWheel(object sender, MouseWheelEventArgs e) { - var zoomChange = MouseWheelZoomChange * (double)e.Delta / MouseWheelDelta; + var zoomChange = MouseWheelZoomChange * (double)e.Delta / 120d; ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomChange); } diff --git a/MapControl/Map.WPF.cs b/MapControl/Map.WPF.cs new file mode 100644 index 00000000..ae2ce278 --- /dev/null +++ b/MapControl/Map.WPF.cs @@ -0,0 +1,77 @@ +// XAML Map Control - http://xamlmapcontrol.codeplex.com/ +// Copyright © Clemens Fischer 2012-2013 +// Licensed under the Microsoft Public License (Ms-PL) + +using System.Windows; +using System.Windows.Input; + +namespace MapControl +{ + /// + /// Default input event handling. + /// + public class Map : MapBase + { + private Point? mousePosition; + + public Map() + { + MouseWheelZoomChange = 1d; + } + + /// + /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event. + /// + public double MouseWheelZoomChange { get; set; } + + protected override void OnMouseWheel(MouseWheelEventArgs e) + { + base.OnMouseWheel(e); + + var zoomChange = MouseWheelZoomChange * (double)e.Delta / 120d; + ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomChange); + } + + protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) + { + base.OnMouseLeftButtonDown(e); + + if (CaptureMouse()) + { + mousePosition = e.GetPosition(this); + } + } + + protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) + { + base.OnMouseLeftButtonUp(e); + + if (mousePosition.HasValue) + { + mousePosition = null; + ReleaseMouseCapture(); + } + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (mousePosition.HasValue) + { + var position = e.GetPosition(this); + TranslateMap((Point)(position - mousePosition)); + mousePosition = position; + } + } + + protected override void OnManipulationDelta(ManipulationDeltaEventArgs e) + { + base.OnManipulationDelta(e); + + TransformMap(e.ManipulationOrigin, + (Point)e.DeltaManipulation.Translation, e.DeltaManipulation.Rotation, + (e.DeltaManipulation.Scale.X + e.DeltaManipulation.Scale.Y) / 2d); + } + } +} diff --git a/MapControl/Map.WinRT.cs b/MapControl/Map.WinRT.cs index 49af6d53..54324c23 100644 --- a/MapControl/Map.WinRT.cs +++ b/MapControl/Map.WinRT.cs @@ -1,15 +1,17 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) -using System; using Windows.Devices.Input; using Windows.Foundation; using Windows.UI.Xaml.Input; namespace MapControl { - public partial class Map + /// + /// Default input event handling. + /// + public class Map : MapBase { private Point? mousePosition; @@ -26,18 +28,15 @@ namespace MapControl PointerMoved += OnPointerMoved; } - private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) - { - if (e.PointerDeviceType != PointerDeviceType.Mouse) - { - TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale); - } - } + /// + /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event. + /// + public double MouseWheelZoomChange { get; set; } private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e) { var point = e.GetCurrentPoint(this); - var zoomChange = MouseWheelZoomChange * (double)point.Properties.MouseWheelDelta / MouseWheelDelta; + var zoomChange = MouseWheelZoomChange * (double)point.Properties.MouseWheelDelta / 120d; ZoomMap(point.Position, TargetZoomLevel + zoomChange); } @@ -68,5 +67,13 @@ namespace MapControl mousePosition = position; } } + + private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) + { + if (e.PointerDeviceType != PointerDeviceType.Mouse) + { + TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale); + } + } } } diff --git a/MapControl/Map.cs b/MapControl/Map.cs deleted file mode 100644 index 042fe7c2..00000000 --- a/MapControl/Map.cs +++ /dev/null @@ -1,19 +0,0 @@ -// XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer -// Licensed under the Microsoft Public License (Ms-PL) - -namespace MapControl -{ - /// - /// MapBase with input event handling. - /// - public partial class Map : MapBase - { - private const double MouseWheelDelta = 120; - - /// - /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event. - /// - public double MouseWheelZoomChange { get; set; } - } -} diff --git a/MapControl/MapBase.Silverlight.WinRT.cs b/MapControl/MapBase.Silverlight.WinRT.cs index 204327b5..85133f90 100644 --- a/MapControl/MapBase.Silverlight.WinRT.cs +++ b/MapControl/MapBase.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE @@ -20,7 +20,7 @@ namespace MapControl { // Set FillBehavior.HoldEnd to prevent animation from returning // to local value before invoking the Completed handler - private const FillBehavior AnimationFillBehavior = FillBehavior.HoldEnd; + private const FillBehavior animationFillBehavior = FillBehavior.HoldEnd; public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register( "Foreground", typeof(Brush), typeof(MapBase), new PropertyMetadata(new SolidColorBrush(Colors.Black))); diff --git a/MapControl/MapBase.WPF.cs b/MapControl/MapBase.WPF.cs index 85321e58..261b865a 100644 --- a/MapControl/MapBase.WPF.cs +++ b/MapControl/MapBase.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; @@ -12,7 +12,7 @@ namespace MapControl public partial class MapBase { // FillBehavior must be set to Stop to re-enable local property values - private const FillBehavior AnimationFillBehavior = FillBehavior.Stop; + private const FillBehavior animationFillBehavior = FillBehavior.Stop; public static readonly DependencyProperty ForegroundProperty = System.Windows.Controls.Control.ForegroundProperty.AddOwner(typeof(MapBase)); diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs index 73464796..d5369add 100644 --- a/MapControl/MapBase.cs +++ b/MapControl/MapBase.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -26,7 +26,6 @@ namespace MapControl /// public partial class MapBase : MapPanel { - public const double MeterPerDegree = 1852d * 60d; public static TimeSpan AnimationDuration = TimeSpan.FromSeconds(0.5); public static EasingFunctionBase AnimationEasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut }; @@ -272,12 +271,24 @@ namespace MapControl get { return scaleRotateTransform; } } + /// + /// Gets the conversion factor from longitude degrees to meters, at latitude = 0. + /// + public double MetersPerDegree + { + get + { + return (TileLayer != null && TileLayer.TileSource != null) ? + TileLayer.TileSource.MetersPerDegree : (TileSource.EarthRadius * Math.PI / 180d); + } + } + /// /// Gets the map scale at the specified location as viewport coordinate units (pixels) per meter. /// public double GetMapScale(Location location) { - return mapTransform.RelativeScale(location) * Math.Pow(2d, ZoomLevel) * 256d / (MeterPerDegree * 360d); + return mapTransform.RelativeScale(location) * Math.Pow(2d, ZoomLevel) * TileSource.TileSize / (MetersPerDegree * 360d); } /// @@ -591,8 +602,8 @@ namespace MapControl From = new Point(Center.Longitude, Center.Latitude), To = new Point(targetCenter.Longitude, targetCenter.Latitude), Duration = AnimationDuration, - FillBehavior = AnimationFillBehavior, - EasingFunction = AnimationEasingFunction + EasingFunction = AnimationEasingFunction, + FillBehavior = animationFillBehavior }; centerAnimation.Completed += CenterAnimationCompleted; @@ -695,8 +706,8 @@ namespace MapControl { To = targetZoomLevel, Duration = AnimationDuration, - FillBehavior = AnimationFillBehavior, - EasingFunction = AnimationEasingFunction + EasingFunction = AnimationEasingFunction, + FillBehavior = animationFillBehavior }; zoomLevelAnimation.Completed += ZoomLevelAnimationCompleted; @@ -719,7 +730,8 @@ namespace MapControl private void CoerceHeadingProperty(DependencyProperty property, ref double heading) { - var coercedValue = (heading >= -180d && heading <= 360d) ? heading : (((heading % 360d) + 360d) % 360d); + var coercedValue = (heading >= -180d && heading <= 360d) ? + heading : (((heading % 360d) + 360d) % 360d); if (coercedValue != heading) { @@ -769,8 +781,8 @@ namespace MapControl { By = delta, Duration = AnimationDuration, - FillBehavior = AnimationFillBehavior, - EasingFunction = AnimationEasingFunction + EasingFunction = AnimationEasingFunction, + FillBehavior = animationFillBehavior }; headingAnimation.Completed += HeadingAnimationCompleted; @@ -811,7 +823,7 @@ namespace MapControl } } - scale *= mapTransform.RelativeScale(center) / MeterPerDegree; // Pixels per meter at center latitude + scale *= mapTransform.RelativeScale(center) / MetersPerDegree; // Pixels per meter at center latitude CenterScale = scale; SetTransformMatrixes(scale); diff --git a/MapControl/MapControl.Silverlight.csproj b/MapControl/MapControl.Silverlight.csproj index ddee10b1..0183574d 100644 --- a/MapControl/MapControl.Silverlight.csproj +++ b/MapControl/MapControl.Silverlight.csproj @@ -69,14 +69,12 @@ - - + - diff --git a/MapControl/MapControl.WPF.csproj b/MapControl/MapControl.WPF.csproj index ecde4b8b..915e7c57 100644 --- a/MapControl/MapControl.WPF.csproj +++ b/MapControl/MapControl.WPF.csproj @@ -45,18 +45,17 @@ + - - Code - + diff --git a/MapControl/MapGraticule.Silverlight.WinRT.cs b/MapControl/MapGraticule.Silverlight.WinRT.cs index 878db841..50e0b5b7 100644 --- a/MapControl/MapGraticule.Silverlight.WinRT.cs +++ b/MapControl/MapGraticule.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapGraticule.WPF.cs b/MapControl/MapGraticule.WPF.cs index e876bc8f..9724dc59 100644 --- a/MapControl/MapGraticule.WPF.cs +++ b/MapControl/MapGraticule.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -32,7 +32,7 @@ namespace MapControl var bounds = ParentMap.ViewportTransform.Inverse.TransformBounds(new Rect(ParentMap.RenderSize)); var start = ParentMap.MapTransform.Transform(new Point(bounds.X, bounds.Y)); var end = ParentMap.MapTransform.Transform(new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height)); - var minSpacing = MinLineSpacing * 360d / (Math.Pow(2d, ParentMap.ZoomLevel) * 256d); + var minSpacing = MinLineSpacing * 360d / (Math.Pow(2d, ParentMap.ZoomLevel) * TileSource.TileSize); var spacing = LineSpacings[LineSpacings.Length - 1]; if (spacing >= minSpacing) diff --git a/MapControl/MapGraticule.cs b/MapControl/MapGraticule.cs index dd4e8953..5872a2da 100644 --- a/MapControl/MapGraticule.cs +++ b/MapControl/MapGraticule.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapImage.Silverlight.WinRT.cs b/MapControl/MapImage.Silverlight.WinRT.cs deleted file mode 100644 index a069f837..00000000 --- a/MapControl/MapImage.Silverlight.WinRT.cs +++ /dev/null @@ -1,49 +0,0 @@ -// XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer -// Licensed under the Microsoft Public License (Ms-PL) - -#if NETFX_CORE -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Media.Imaging; -#else -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Imaging; -#endif - -namespace MapControl -{ - public partial class MapImage - { - private void BeginOpacityAnimation(ImageSource image) - { - var bitmapImage = image as BitmapImage; - - if (bitmapImage != null) - { - bitmapImage.ImageOpened += BitmapImageOpened; - bitmapImage.ImageFailed += BitmapImageFailed; - } - else - { - BeginOpacityAnimation(); - } - } - - private void BitmapImageOpened(object sender, RoutedEventArgs e) - { - ((BitmapImage)sender).ImageOpened -= BitmapImageOpened; - ((BitmapImage)sender).ImageFailed -= BitmapImageFailed; - BeginOpacityAnimation(); - } - - private void BitmapImageFailed(object sender, ExceptionRoutedEventArgs e) - { - ((BitmapImage)sender).ImageOpened -= BitmapImageOpened; - ((BitmapImage)sender).ImageFailed -= BitmapImageFailed; - ((ImageBrush)Fill).ImageSource = null; - } - } -} diff --git a/MapControl/MapImage.WPF.cs b/MapControl/MapImage.WPF.cs deleted file mode 100644 index d6dd7fe4..00000000 --- a/MapControl/MapImage.WPF.cs +++ /dev/null @@ -1,42 +0,0 @@ -// XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer -// Licensed under the Microsoft Public License (Ms-PL) - -using System; -using System.Windows.Media; -using System.Windows.Media.Imaging; - -namespace MapControl -{ - public partial class MapImage - { - private void BeginOpacityAnimation(ImageSource image) - { - var bitmapImage = image as BitmapImage; - - if (bitmapImage != null && bitmapImage.IsDownloading) - { - bitmapImage.DownloadCompleted += BitmapDownloadCompleted; - bitmapImage.DownloadFailed += BitmapDownloadFailed; - } - else - { - BeginOpacityAnimation(); - } - } - - private void BitmapDownloadCompleted(object sender, EventArgs e) - { - ((BitmapImage)sender).DownloadCompleted -= BitmapDownloadCompleted; - ((BitmapImage)sender).DownloadFailed -= BitmapDownloadFailed; - BeginOpacityAnimation(); - } - - private void BitmapDownloadFailed(object sender, ExceptionEventArgs e) - { - ((BitmapImage)sender).DownloadCompleted -= BitmapDownloadCompleted; - ((BitmapImage)sender).DownloadFailed -= BitmapDownloadFailed; - ((ImageBrush)Fill).ImageSource = null; - } - } -} diff --git a/MapControl/MapImage.cs b/MapControl/MapImage.cs index 2fc47d2d..f6746720 100644 --- a/MapControl/MapImage.cs +++ b/MapControl/MapImage.cs @@ -1,24 +1,25 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE using Windows.UI.Xaml; using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Media.Animation; #else using System.Windows; using System.Windows.Media; -using System.Windows.Media.Animation; #endif namespace MapControl { - public partial class MapImage : MapRectangle + /// + /// Fills a rectangular area with an ImageBrush from the Source property. + /// + public class MapImage : MapRectangle { private static readonly Transform imageTransform = new MatrixTransform { - Matrix = new Matrix(1, 0, 0, -1, 0, 1) + Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d) }; public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( @@ -31,36 +32,13 @@ namespace MapControl set { SetValue(SourceProperty, value); } } - public bool AnimateOpacity { get; set; } - private void SourceChanged(ImageSource image) { Fill = new ImageBrush { ImageSource = image, - RelativeTransform = imageTransform, - Opacity = 0d + RelativeTransform = imageTransform }; - - if (AnimateOpacity) - { - BeginOpacityAnimation(image); - } - else - { - Fill.Opacity = 1d; - } - } - - private void BeginOpacityAnimation() - { - Fill.BeginAnimation(Brush.OpacityProperty, - new DoubleAnimation - { - To = 1d, - Duration = Tile.AnimationDuration, - FillBehavior = FillBehavior.HoldEnd - }); } } } diff --git a/MapControl/MapImageLayer.cs b/MapControl/MapImageLayer.cs new file mode 100644 index 00000000..1eece36c --- /dev/null +++ b/MapControl/MapImageLayer.cs @@ -0,0 +1,187 @@ +// XAML Map Control - http://xamlmapcontrol.codeplex.com/ +// Copyright © Clemens Fischer 2012-2013 +// Licensed under the Microsoft Public License (Ms-PL) + +using System; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Net; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Threading; + +namespace MapControl +{ + /// + /// Map image overlay. Fills the entire viewport with a map image from a web request, + /// for example from a Web Map Service (WMS). + /// The request Uri is specified by the UriFormat property, which has {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 for example EPSG:4326) or + /// {W},{S},{E},{N} for the bounding box in meters (like for example EPSG:3857) + /// + public class MapImageLayer : MapPanel + { + private readonly DispatcherTimer updateTimer; + private readonly WebClient webClient; + private string uriFormat; + private bool latLonBoundingBox; + private bool imageIsValid; + private bool updateInProgress; + private int currentImageIndex; + + public MapImageLayer() + { + Children.Add(new MapImage { Opacity = 0d }); + Children.Add(new MapImage { Opacity = 0d }); + + webClient = new WebClient(); + webClient.Headers.Add(HttpRequestHeader.UserAgent, "XAML Map Control"); + + updateTimer = new DispatcherTimer { Interval = TileContainer.UpdateInterval }; + updateTimer.Tick += UpdateImage; + } + + public string UriFormat + { + get { return uriFormat; } + set + { + if (value != null) + { + if (!(value.Contains("{X}") && value.Contains("{Y}"))) + { + throw new ArgumentException("UriFormat must specify the requested image size by {X} and {Y}."); + } + + if (value.Contains("{w}") && value.Contains("{s}") && value.Contains("{e}") && value.Contains("{n}")) + { + latLonBoundingBox = true; + } + else if (!(value.Contains("{W}") && value.Contains("{S}") && value.Contains("{E}") && value.Contains("{N}"))) + { + throw new ArgumentException("UriFormat must specify a bounding box in meters by {W},{S},{E},{N} or as lat/lon by {w},{s},{e},{n}."); + } + } + + uriFormat = value; + + if (ParentMap != null) + { + UpdateImage(this, EventArgs.Empty); + } + } + } + + protected override void OnViewportChanged() + { + base.OnViewportChanged(); + + imageIsValid = false; + updateTimer.Stop(); + updateTimer.Start(); + } + + private void UpdateImage(object sender, EventArgs e) + { + updateTimer.Stop(); + + if (updateInProgress || string.IsNullOrWhiteSpace(uriFormat)) + { + return; + } + + imageIsValid = true; + updateInProgress = true; + + var uri = uriFormat. + Replace("{X}", ActualWidth.ToString("F0", CultureInfo.InvariantCulture)). + Replace("{Y}", ActualHeight.ToString("F0", CultureInfo.InvariantCulture)); + + var loc1 = ParentMap.ViewportPointToLocation(new Point(0d, 0d)); + var loc2 = ParentMap.ViewportPointToLocation(new Point(ActualWidth, 0d)); + var loc3 = ParentMap.ViewportPointToLocation(new Point(0d, ActualHeight)); + var loc4 = ParentMap.ViewportPointToLocation(new Point(ActualWidth, ActualHeight)); + + ThreadPool.QueueUserWorkItem(o => + { + var west = Math.Min(loc1.Longitude, Math.Min(loc2.Longitude, Math.Min(loc3.Longitude, loc4.Longitude))); + var east = Math.Max(loc1.Longitude, Math.Max(loc2.Longitude, Math.Max(loc3.Longitude, loc4.Longitude))); + 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 (latLonBoundingBox) + { + 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)); + } + else + { + var p1 = ParentMap.MapTransform.Transform(new Location(south, west)); + var p2 = ParentMap.MapTransform.Transform(new Location(north, east)); + var arc = TileSource.EarthRadius * Math.PI / 180d; + + uri = uri. + Replace("{W}", (arc * p1.X).ToString(CultureInfo.InvariantCulture)). + Replace("{S}", (arc * p1.Y).ToString(CultureInfo.InvariantCulture)). + Replace("{E}", (arc * p2.X).ToString(CultureInfo.InvariantCulture)). + Replace("{N}", (arc * p2.Y).ToString(CultureInfo.InvariantCulture)); + } + + try + { + var buffer = webClient.DownloadData(uri); + var bitmap = new BitmapImage(); + + using (var stream = new MemoryStream(buffer)) + { + bitmap.BeginInit(); + bitmap.CacheOption = BitmapCacheOption.OnLoad; + bitmap.StreamSource = stream; + bitmap.EndInit(); + bitmap.Freeze(); + } + + Dispatcher.BeginInvoke((Action)(() => + { + var image = (MapImage)Children[currentImageIndex]; + image.BeginAnimation(Image.OpacityProperty, + new DoubleAnimation(0d, Tile.AnimationDuration) + { + BeginTime = Tile.AnimationDuration + }); + + currentImageIndex = (currentImageIndex + 1) % 2; + image = (MapImage)Children[currentImageIndex]; + image.Source = null; + image.North = double.NaN; // avoid frequent MapRectangle.UpdateGeometry() calls + image.West = west; + image.East = east; + image.South = south; + image.North = north; + image.Source = bitmap; + image.BeginAnimation(Image.OpacityProperty, new DoubleAnimation(1d, Tile.AnimationDuration)); + + if (!imageIsValid) + { + UpdateImage(this, EventArgs.Empty); + } + })); + } + catch (Exception ex) + { + Trace.TraceWarning("{0}: {1}", uri, ex.Message); + } + + updateInProgress = false; + }); + } + } +} diff --git a/MapControl/MapItem.Silverlight.WinRT.cs b/MapControl/MapItem.Silverlight.WinRT.cs index c239a87d..38715db7 100644 --- a/MapControl/MapItem.Silverlight.WinRT.cs +++ b/MapControl/MapItem.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapItem.WPF.cs b/MapControl/MapItem.WPF.cs index c40dd05e..a4be3eea 100644 --- a/MapControl/MapItem.WPF.cs +++ b/MapControl/MapItem.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // 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 31e1dc89..206ac8e7 100644 --- a/MapControl/MapItemsControl.Silverlight.WinRT.cs +++ b/MapControl/MapItemsControl.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) namespace MapControl diff --git a/MapControl/MapItemsControl.WPF.cs b/MapControl/MapItemsControl.WPF.cs index a935c154..25620a06 100644 --- a/MapControl/MapItemsControl.WPF.cs +++ b/MapControl/MapItemsControl.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapItemsControl.cs b/MapControl/MapItemsControl.cs index dc64a492..e31cd4e3 100644 --- a/MapControl/MapItemsControl.cs +++ b/MapControl/MapItemsControl.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapOverlay.cs b/MapControl/MapOverlay.cs index a3c37c9a..600f3cd5 100644 --- a/MapControl/MapOverlay.cs +++ b/MapControl/MapOverlay.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapPanel.Silverlight.WinRT.cs b/MapControl/MapPanel.Silverlight.WinRT.cs index 40dc0f46..1f9c3c8d 100644 --- a/MapControl/MapPanel.Silverlight.WinRT.cs +++ b/MapControl/MapPanel.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapPanel.WPF.cs b/MapControl/MapPanel.WPF.cs index 8de26358..1a6fbeaf 100644 --- a/MapControl/MapPanel.WPF.cs +++ b/MapControl/MapPanel.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs index 3d32536e..77f2ddba 100644 --- a/MapControl/MapPanel.cs +++ b/MapControl/MapPanel.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapPolyline.Silverlight.WinRT.cs b/MapControl/MapPolyline.Silverlight.WinRT.cs index 9be7b8dd..b00a0feb 100644 --- a/MapControl/MapPolyline.Silverlight.WinRT.cs +++ b/MapControl/MapPolyline.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; diff --git a/MapControl/MapPolyline.WPF.cs b/MapControl/MapPolyline.WPF.cs index ac53db55..a6aae403 100644 --- a/MapControl/MapPolyline.WPF.cs +++ b/MapControl/MapPolyline.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; diff --git a/MapControl/MapPolyline.cs b/MapControl/MapPolyline.cs index 99673c26..5ab1a6a9 100644 --- a/MapControl/MapPolyline.cs +++ b/MapControl/MapPolyline.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapRectangle.cs b/MapControl/MapRectangle.cs index 4833aa96..f161024d 100644 --- a/MapControl/MapRectangle.cs +++ b/MapControl/MapRectangle.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE @@ -13,11 +13,11 @@ using System.Windows.Media; namespace MapControl { - public partial class MapRectangle : MapShape + /// + /// Fills a rectangular area defined by South, North, West and East with a Brush. + /// + public class MapRectangle : MapShape { - private static Transform DefaultFillRelativeTransform = - Brush.RelativeTransformProperty.GetMetadata(typeof(Brush)).DefaultValue as Transform; - public static readonly DependencyProperty SouthProperty = DependencyProperty.Register( "South", typeof(double), typeof(MapRectangle), new PropertyMetadata(double.NaN, (o, e) => ((MapRectangle)o).UpdateGeometry())); @@ -84,17 +84,5 @@ namespace MapControl ClearValue(RenderTransformProperty); } } - -//#if !NETFX_CORE && !SILVERLIGHT -// protected override void OnRender(DrawingContext drawingContext) -// { -// if (ParentMap != null) -// { -// drawingContext.PushTransform(ParentMap.ViewportTransform); -// drawingContext.DrawRectangle(Fill, null, ((RectangleGeometry)Geometry).Rect); -// drawingContext.Pop(); -// } -// } -//#endif } } diff --git a/MapControl/MapScale.cs b/MapControl/MapScale.cs index bf7a10cb..e15575b4 100644 --- a/MapControl/MapScale.cs +++ b/MapControl/MapScale.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MapShape.Silverlight.WinRT.cs b/MapControl/MapShape.Silverlight.WinRT.cs index fc4c4d65..870b8248 100644 --- a/MapControl/MapShape.Silverlight.WinRT.cs +++ b/MapControl/MapShape.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapShape.WPF.cs b/MapControl/MapShape.WPF.cs index e9421707..6d944287 100644 --- a/MapControl/MapShape.WPF.cs +++ b/MapControl/MapShape.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows.Media; diff --git a/MapControl/MapShape.cs b/MapControl/MapShape.cs index e643d5d4..35e91cf4 100644 --- a/MapControl/MapShape.cs +++ b/MapControl/MapShape.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MapTransform.cs b/MapControl/MapTransform.cs index fd1eb2d7..e136229e 100644 --- a/MapControl/MapTransform.cs +++ b/MapControl/MapTransform.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/MatrixEx.cs b/MapControl/MatrixEx.cs index 44de2069..5eb6c872 100644 --- a/MapControl/MatrixEx.cs +++ b/MapControl/MatrixEx.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/MercatorTransform.cs b/MapControl/MercatorTransform.cs index f92d6f04..23d4f7a2 100644 --- a/MapControl/MercatorTransform.cs +++ b/MapControl/MercatorTransform.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -54,7 +54,7 @@ namespace MapControl else { var lat = location.Latitude * Math.PI / 180d; - location.Y = (Math.Log(Math.Tan(lat) + 1d / Math.Cos(lat))) / Math.PI * 180d; + location.Y = Math.Log(Math.Tan(lat) + 1d / Math.Cos(lat)) / Math.PI * 180d; } } diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 2fc12f4d..1c92f2d5 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -3,19 +3,20 @@ using System.Runtime.InteropServices; using System.Windows; #if SILVERLIGHT -[assembly: AssemblyTitle("MapControl.Silverlight")] -[assembly: AssemblyDescription("XAML Map Control for Silverlight")] +[assembly: AssemblyTitle("Silverlight Map Control")] +[assembly: AssemblyDescription("XAML Map Control Library for Silverlight")] #else -[assembly: AssemblyTitle("MapControl.WPF")] -[assembly: AssemblyDescription("XAML Map Control for WPF")] +[assembly: AssemblyTitle("WPF Map Control")] +[assembly: AssemblyDescription("XAML Map Control Library for WPF")] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] #endif -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] diff --git a/MapControl/Pushpin.Silverlight.WinRT.cs b/MapControl/Pushpin.Silverlight.WinRT.cs index b6340378..06cf1aa3 100644 --- a/MapControl/Pushpin.Silverlight.WinRT.cs +++ b/MapControl/Pushpin.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/Pushpin.WPF.cs b/MapControl/Pushpin.WPF.cs index 0edfb4f0..90e62d17 100644 --- a/MapControl/Pushpin.WPF.cs +++ b/MapControl/Pushpin.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // 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 f9f2060f..aaf9e6e5 100644 --- a/MapControl/Tile.Silverlight.WinRT.cs +++ b/MapControl/Tile.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE @@ -42,7 +42,7 @@ namespace MapControl } else { - BeginOpacityAnimation(); + Image.BeginAnimation(Image.OpacityProperty, new DoubleAnimation { To = 1d, Duration = AnimationDuration }); } } else @@ -59,7 +59,7 @@ namespace MapControl { ((BitmapImage)sender).ImageOpened -= BitmapImageOpened; ((BitmapImage)sender).ImageFailed -= BitmapImageFailed; - BeginOpacityAnimation(); + Image.BeginAnimation(Image.OpacityProperty, new DoubleAnimation { To = 1d, Duration = AnimationDuration }); } private void BitmapImageFailed(object sender, ExceptionRoutedEventArgs e) @@ -68,16 +68,5 @@ namespace MapControl ((BitmapImage)sender).ImageFailed -= BitmapImageFailed; Image.Source = null; } - - private void BeginOpacityAnimation() - { - Image.BeginAnimation(Image.OpacityProperty, - new DoubleAnimation - { - To = 1d, - Duration = AnimationDuration, - FillBehavior = FillBehavior.HoldEnd - }); - } } } diff --git a/MapControl/Tile.WPF.cs b/MapControl/Tile.WPF.cs index 4b1d6cb2..4b711038 100644 --- a/MapControl/Tile.WPF.cs +++ b/MapControl/Tile.WPF.cs @@ -1,12 +1,11 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; -using System.Windows.Threading; namespace MapControl { @@ -34,7 +33,7 @@ namespace MapControl } else { - BeginOpacityAnimation(); + Brush.BeginAnimation(ImageBrush.OpacityProperty, new DoubleAnimation(1d, AnimationDuration)); } } else @@ -51,7 +50,7 @@ namespace MapControl { ((BitmapImage)sender).DownloadCompleted -= BitmapDownloadCompleted; ((BitmapImage)sender).DownloadFailed -= BitmapDownloadFailed; - BeginOpacityAnimation(); + Brush.BeginAnimation(ImageBrush.OpacityProperty, new DoubleAnimation(1d, AnimationDuration)); } private void BitmapDownloadFailed(object sender, ExceptionEventArgs e) @@ -60,16 +59,5 @@ namespace MapControl ((BitmapImage)sender).DownloadFailed -= BitmapDownloadFailed; Brush.ImageSource = null; } - - private void BeginOpacityAnimation() - { - Brush.BeginAnimation(ImageBrush.OpacityProperty, - new DoubleAnimation - { - To = 1d, - Duration = AnimationDuration, - FillBehavior = FillBehavior.HoldEnd - }); - } } } diff --git a/MapControl/Tile.cs b/MapControl/Tile.cs index ac5dd719..14b39d6f 100644 --- a/MapControl/Tile.cs +++ b/MapControl/Tile.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileContainer.Silverlight.WinRT.cs b/MapControl/TileContainer.Silverlight.WinRT.cs index b322ab69..9d35af90 100644 --- a/MapControl/TileContainer.Silverlight.WinRT.cs +++ b/MapControl/TileContainer.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/TileContainer.WPF.cs b/MapControl/TileContainer.WPF.cs index 83c273eb..64e9378c 100644 --- a/MapControl/TileContainer.WPF.cs +++ b/MapControl/TileContainer.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows.Media; diff --git a/MapControl/TileContainer.cs b/MapControl/TileContainer.cs index 10f71863..965c2c25 100644 --- a/MapControl/TileContainer.cs +++ b/MapControl/TileContainer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -19,8 +19,11 @@ namespace MapControl internal partial class TileContainer { private const double maxScaledTileSize = 400d; // scaled tile size 200..400 units - private static double zoomLevelSwitchOffset = Math.Log(maxScaledTileSize / 256d, 2d); + private static double zoomLevelSwitchOffset = Math.Log(maxScaledTileSize / TileSource.TileSize, 2d); + internal static TimeSpan UpdateInterval = TimeSpan.FromSeconds(0.5); + + private readonly DispatcherTimer updateTimer; private Size size; private Point origin; private Point offset; @@ -28,13 +31,12 @@ namespace MapControl private double zoomLevel; private int tileZoomLevel; private Int32Rect tileGrid; - private readonly DispatcherTimer updateTimer; public readonly MatrixTransform ViewportTransform = new MatrixTransform(); public TileContainer() { - updateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.5) }; + updateTimer = new DispatcherTimer { Interval = UpdateInterval }; updateTimer.Tick += UpdateTiles; } @@ -80,13 +82,13 @@ namespace MapControl public double SetViewportTransform(double mapZoomLevel, double mapRotation, Point mapOrigin, Point viewportOrigin, Size viewportSize) { - var scale = Math.Pow(2d, zoomLevel) * 256d / 360d; + var scale = Math.Pow(2d, zoomLevel) * TileSource.TileSize / 360d; var oldMapOriginX = (origin.X - offset.X) / scale - 180d; if (zoomLevel != mapZoomLevel) { zoomLevel = mapZoomLevel; - scale = Math.Pow(2d, zoomLevel) * 256d / 360d; + scale = Math.Pow(2d, zoomLevel) * TileSource.TileSize / 360d; } rotation = mapRotation; @@ -124,7 +126,7 @@ namespace MapControl // with origin at tileGrid.X and tileGrid.Y to minimize rounding errors. return GetTransformMatrix( - new Matrix(1d, 0d, 0d, 1d, tileGrid.X * 256d, tileGrid.Y * 256d), + new Matrix(1d, 0d, 0d, 1d, tileGrid.X * TileSource.TileSize, tileGrid.Y * TileSource.TileSize), Math.Pow(2d, zoomLevel - tileZoomLevel)); } diff --git a/MapControl/TileImageLoader.Silverlight.WinRT.cs b/MapControl/TileImageLoader.Silverlight.WinRT.cs index 61d853d0..68036a7a 100644 --- a/MapControl/TileImageLoader.Silverlight.WinRT.cs +++ b/MapControl/TileImageLoader.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.Generic; diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index 1f910dff..08d98d38 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -121,7 +121,7 @@ namespace MapControl (Action)((t, i) => t.SetImageSource(i, true)), DispatcherPriority.Background, tile, image); - var creationTime = BitConverter.ToInt64(buffer, 0); + long creationTime = BitConverter.ToInt64(buffer, 0); if (DateTime.FromBinary(creationTime) + CacheUpdateAge < DateTime.UtcNow) { @@ -268,11 +268,12 @@ namespace MapControl using (var response = (HttpWebResponse)request.GetResponse()) using (var responseStream = response.GetResponseStream()) { - var creationTime = DateTime.UtcNow.ToBinary(); var length = (int)response.ContentLength; using (var memoryStream = length > 0 ? new MemoryStream(length + sizeof(long)) : new MemoryStream()) { + long creationTime = DateTime.UtcNow.ToBinary(); + memoryStream.Write(BitConverter.GetBytes(creationTime), 0, sizeof(long)); responseStream.CopyTo(memoryStream); diff --git a/MapControl/TileLayer.Silverlight.WinRT.cs b/MapControl/TileLayer.Silverlight.WinRT.cs index d67f4467..27bd6134 100644 --- a/MapControl/TileLayer.Silverlight.WinRT.cs +++ b/MapControl/TileLayer.Silverlight.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) #if NETFX_CORE diff --git a/MapControl/TileLayer.WPF.cs b/MapControl/TileLayer.WPF.cs index 94415fa1..5c00cf4a 100644 --- a/MapControl/TileLayer.WPF.cs +++ b/MapControl/TileLayer.WPF.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; @@ -26,8 +26,11 @@ namespace MapControl { foreach (var tile in tiles) { - var tileSize = 256 << (zoomLevel - tile.ZoomLevel); - var tileRect = new Rect(tileSize * tile.X - 256 * grid.X, tileSize * tile.Y - 256 * grid.Y, tileSize, tileSize); + var tileSize = TileSource.TileSize << (zoomLevel - tile.ZoomLevel); + var tileRect = new Rect( + tileSize * tile.X - TileSource.TileSize * grid.X, + tileSize * tile.Y - TileSource.TileSize * grid.Y, + tileSize, tileSize); drawingContext.DrawRectangle(tile.Brush, null, tileRect); diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 26adf885..27d1bce0 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TileLayerCollection.cs b/MapControl/TileLayerCollection.cs index 983b4dc0..33afbc48 100644 --- a/MapControl/TileLayerCollection.cs +++ b/MapControl/TileLayerCollection.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System.Collections.ObjectModel; diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs index a65beb43..38c72e52 100644 --- a/MapControl/TileSource.cs +++ b/MapControl/TileSource.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; @@ -18,6 +18,9 @@ namespace MapControl /// public partial class TileSource { + public const int TileSize = 256; + public const double EarthRadius = 6378137d; // WGS 84 semi major axis + private Func getUri; private string uriFormat = string.Empty; private int hostIndex = -1; @@ -31,6 +34,11 @@ namespace MapControl UriFormat = uriFormat; } + public virtual double MetersPerDegree + { + get { return EarthRadius * Math.PI / 180d; } + } + public string UriFormat { get { return uriFormat; } @@ -43,8 +51,6 @@ namespace MapControl uriFormat = value; - getUri = GetDefaultUri; - if (uriFormat.Contains("{x}") && uriFormat.Contains("{y}") && uriFormat.Contains("{z}")) { if (uriFormat.Contains("{c}")) @@ -59,15 +65,23 @@ namespace MapControl { getUri = GetMapQuestUri; } + else + { + getUri = GetBasicUri; + } } else if (uriFormat.Contains("{q}")) // {i} is optional { getUri = GetQuadKeyUri; } - else if (uriFormat.Contains("{w}") && uriFormat.Contains("{s}") && uriFormat.Contains("{e}") && uriFormat.Contains("{n}")) + else if (uriFormat.Contains("{W}") && uriFormat.Contains("{S}") && uriFormat.Contains("{E}") && uriFormat.Contains("{N}")) { getUri = GetBoundingBoxUri; } + else if (uriFormat.Contains("{w}") && uriFormat.Contains("{s}") && uriFormat.Contains("{e}") && uriFormat.Contains("{n}")) + { + getUri = GetLatLonBoundingBoxUri; + } else if (uriFormat.Contains("{x}") && uriFormat.Contains("{v}") && uriFormat.Contains("{z}")) { getUri = GetTmsUri; @@ -80,7 +94,7 @@ namespace MapControl return getUri != null ? getUri(x, y, zoomLevel) : null; } - private Uri GetDefaultUri(int x, int y, int zoomLevel) + private Uri GetBasicUri(int x, int y, int zoomLevel) { return new Uri(UriFormat. Replace("{x}", x.ToString()). @@ -147,12 +161,28 @@ namespace MapControl private Uri GetBoundingBoxUri(int x, int y, int zoomLevel) { - var t = new MercatorTransform(); + var n = (double)(1 << zoomLevel); + var x1 = MetersPerDegree * ((double)x * 360d / n - 180d); + var x2 = MetersPerDegree * ((double)(x + 1) * 360d / n - 180d); + var y1 = MetersPerDegree * (180d - (double)(y + 1) * 360d / n); + var y2 = MetersPerDegree * (180d - (double)y * 360d / n); + + return new Uri(UriFormat. + Replace("{W}", x1.ToString(CultureInfo.InvariantCulture)). + Replace("{S}", y1.ToString(CultureInfo.InvariantCulture)). + Replace("{E}", x2.ToString(CultureInfo.InvariantCulture)). + Replace("{N}", y2.ToString(CultureInfo.InvariantCulture))); + } + + private Uri GetLatLonBoundingBoxUri(int x, int y, int zoomLevel) + { var n = (double)(1 << zoomLevel); var x1 = (double)x * 360d / n - 180d; var x2 = (double)(x + 1) * 360d / n - 180d; var y1 = 180d - (double)(y + 1) * 360d / n; var y2 = 180d - (double)y * 360d / n; + + var t = new MercatorTransform(); var p1 = t.Transform(new Point(x1, y1)); var p2 = t.Transform(new Point(x2, y2)); diff --git a/MapControl/TileSourceConverter.cs b/MapControl/TileSourceConverter.cs index 7cfabc10..93ba07db 100644 --- a/MapControl/TileSourceConverter.cs +++ b/MapControl/TileSourceConverter.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using System; diff --git a/MapControl/TransformEx.WinRT.cs b/MapControl/TransformEx.WinRT.cs index 92961a85..c97ba6ec 100644 --- a/MapControl/TransformEx.WinRT.cs +++ b/MapControl/TransformEx.WinRT.cs @@ -1,5 +1,5 @@ // XAML Map Control - http://xamlmapcontrol.codeplex.com/ -// Copyright © 2013 Clemens Fischer +// Copyright © Clemens Fischer 2012-2013 // Licensed under the Microsoft Public License (Ms-PL) using Windows.Foundation; diff --git a/MapControl/WinRT/MapControl.WinRT.csproj b/MapControl/WinRT/MapControl.WinRT.csproj index 08618dec..1d801d08 100644 --- a/MapControl/WinRT/MapControl.WinRT.csproj +++ b/MapControl/WinRT/MapControl.WinRT.csproj @@ -45,9 +45,6 @@ LocationCollection.cs - - Map.cs - Map.WinRT.cs @@ -66,9 +63,6 @@ MapImage.cs - - MapImage.Silverlight.WinRT.cs - MapItem.Silverlight.WinRT.cs diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 25660087..1275606a 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -1,14 +1,15 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("MapControl.WinRT")] -[assembly: AssemblyDescription("XAML Map Control for Windows Runtime")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyTitle("WinRT Map Control")] +[assembly: AssemblyDescription("XAML Map Control Library for Windows Runtime")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index 7fa1888c..4717c493 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -1,14 +1,15 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("SilverlightApplication.Web")] -[assembly: AssemblyDescription("XAML Map Control Sample Application for Silverlight")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyTitle("Silverlight/Web Sample Application")] +[assembly: AssemblyDescription("XAML Map Control Silverlight/Web Sample Application")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/App.xaml.cs b/SampleApps/SilverlightApplication/App.xaml.cs index 16c1ecb2..c7d0a5d3 100644 --- a/SampleApps/SilverlightApplication/App.xaml.cs +++ b/SampleApps/SilverlightApplication/App.xaml.cs @@ -1,14 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; namespace SilverlightApplication { diff --git a/SampleApps/SilverlightApplication/MainPage.xaml.cs b/SampleApps/SilverlightApplication/MainPage.xaml.cs index f52de91f..e7b88774 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml.cs +++ b/SampleApps/SilverlightApplication/MainPage.xaml.cs @@ -1,11 +1,11 @@ -using MapControl; -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Threading; +using MapControl; namespace SilverlightApplication { diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 70d42da1..e2a62111 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -1,14 +1,15 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("SilverlightApplication")] -[assembly: AssemblyDescription("XAML Map Control Sample Application for Silverlight")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyTitle("Silverlight Sample Application")] +[assembly: AssemblyDescription("XAML Map Control Silverlight Sample Application")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/SampleItems.cs b/SampleApps/SilverlightApplication/SampleItems.cs index 322f3733..bbfe90dc 100644 --- a/SampleApps/SilverlightApplication/SampleItems.cs +++ b/SampleApps/SilverlightApplication/SampleItems.cs @@ -1,6 +1,6 @@ -using MapControl; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; +using MapControl; namespace SilverlightApplication { diff --git a/SampleApps/StoreApplication/App.xaml.cs b/SampleApps/StoreApplication/App.xaml.cs index 9663b8dc..2f35ebf1 100644 --- a/SampleApps/StoreApplication/App.xaml.cs +++ b/SampleApps/StoreApplication/App.xaml.cs @@ -1,18 +1,8 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; -using Windows.Foundation; -using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 diff --git a/SampleApps/StoreApplication/MainPage.xaml.cs b/SampleApps/StoreApplication/MainPage.xaml.cs index 0d968f54..36372cfb 100644 --- a/SampleApps/StoreApplication/MainPage.xaml.cs +++ b/SampleApps/StoreApplication/MainPage.xaml.cs @@ -1,6 +1,6 @@ -using MapControl; -using System; +using System; using System.Collections.Generic; +using MapControl; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index e0e994a3..98ca92f3 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -1,14 +1,15 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("StoreApplication")] -[assembly: AssemblyDescription("XAML Map Control Sample Application for Windows Runtime")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyTitle("Windows Runtime Sample Application")] +[assembly: AssemblyDescription("XAML Map Control Windows Runtime Sample Application")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/SampleItems.cs b/SampleApps/StoreApplication/SampleItems.cs index 46b7231e..04769ee2 100644 --- a/SampleApps/StoreApplication/SampleItems.cs +++ b/SampleApps/StoreApplication/SampleItems.cs @@ -1,6 +1,6 @@ -using MapControl; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; +using MapControl; namespace StoreApplication { diff --git a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs index fa10f8f0..397b7e02 100644 --- a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs @@ -1,16 +1,15 @@ using System.Reflection; using System.Runtime.InteropServices; -using System.Windows; -[assembly: AssemblyTitle("SurfaceApplication")] +[assembly: AssemblyTitle("Surface Sample Application")] [assembly: AssemblyDescription("XAML Map Control Sample Application for PixelSense (Surface 2)")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] -[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] diff --git a/SampleApps/SurfaceApplication/Properties/Resources.Designer.cs b/SampleApps/SurfaceApplication/Properties/Resources.Designer.cs deleted file mode 100644 index e2775e3b..00000000 --- a/SampleApps/SurfaceApplication/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18010 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SurfaceApplication.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SurfaceApplication.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/SampleApps/SurfaceApplication/Properties/Resources.resx b/SampleApps/SurfaceApplication/Properties/Resources.resx deleted file mode 100644 index af7dbebb..00000000 --- a/SampleApps/SurfaceApplication/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SampleApps/SurfaceApplication/Properties/Settings.Designer.cs b/SampleApps/SurfaceApplication/Properties/Settings.Designer.cs deleted file mode 100644 index 84e4668d..00000000 --- a/SampleApps/SurfaceApplication/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18010 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SurfaceApplication.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/SampleApps/SurfaceApplication/Properties/Settings.settings b/SampleApps/SurfaceApplication/Properties/Settings.settings deleted file mode 100644 index 9010101f..00000000 --- a/SampleApps/SurfaceApplication/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/SampleApps/SurfaceApplication/SurfaceApplication.csproj b/SampleApps/SurfaceApplication/SurfaceApplication.csproj index adf4a62e..b17e7def 100644 --- a/SampleApps/SurfaceApplication/SurfaceApplication.csproj +++ b/SampleApps/SurfaceApplication/SurfaceApplication.csproj @@ -71,25 +71,7 @@ Code - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - @@ -97,9 +79,7 @@ PreserveNewest - - - + {226f3575-b683-446d-a2f0-181291dc8787} diff --git a/SampleApps/WpfApplication/LocationToVisibilityConverter.cs b/SampleApps/WpfApplication/LocationToVisibilityConverter.cs index 8cd862d3..901f2d92 100644 --- a/SampleApps/WpfApplication/LocationToVisibilityConverter.cs +++ b/SampleApps/WpfApplication/LocationToVisibilityConverter.cs @@ -1,9 +1,9 @@ -using MapControl; -using System; +using System; using System.Globalization; using System.Windows; using System.Windows.Data; using System.Windows.Media; +using MapControl; namespace WpfApplication { @@ -11,12 +11,12 @@ namespace WpfApplication { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - Visibility visibility = Visibility.Hidden; + var visibility = Visibility.Hidden; if (values.Length == 2 && values[0] is Map && values[1] is Transform) { - Map parentMap = (Map)values[0]; - Matrix transform = ((Transform)values[1]).Value; + var parentMap = (Map)values[0]; + var transform = ((Transform)values[1]).Value; if (transform.OffsetX >= 0d && transform.OffsetX <= parentMap.ActualWidth && transform.OffsetY >= 0d && transform.OffsetY <= parentMap.ActualHeight) diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index 6afababd..c0c82dd6 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -17,9 +17,13 @@ - + + + + Hence the declarations shown below are for demonstration purpose only. --> - + - + @@ -154,7 +158,13 @@ MouseLeftButtonDown="MapMouseLeftButtonDown" MouseRightButtonDown="MapMouseRightButtonDown" MouseMove="MapMouseMove" MouseLeave="MapMouseLeave" ManipulationInertiaStarting="MapManipulationInertiaStarting"> - + + + + + diff --git a/SampleApps/WpfApplication/MainWindow.xaml.cs b/SampleApps/WpfApplication/MainWindow.xaml.cs index c4be346c..42b321ea 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml.cs +++ b/SampleApps/WpfApplication/MainWindow.xaml.cs @@ -1,12 +1,12 @@ -using Caching; -using MapControl; -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Threading; +using Caching; +using MapControl; namespace WpfApplication { diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index c95fe90c..c2c7a2e5 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -1,16 +1,15 @@ using System.Reflection; using System.Runtime.InteropServices; -using System.Windows; -[assembly: AssemblyTitle("WpfApplication")] -[assembly: AssemblyDescription("XAML Map Control Sample Application for WPF")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyTitle("WPF Sample Application")] +[assembly: AssemblyDescription("XAML Map Control WPF Sample Application")] + [assembly: AssemblyProduct("XAML Map Control")] -[assembly: AssemblyCopyright("Copyright © 2013 Clemens Fischer")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.2.2")] -[assembly: AssemblyFileVersion("1.2.2")] [assembly: ComVisible(false)] -[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] diff --git a/SampleApps/WpfApplication/Properties/Settings.Designer.cs b/SampleApps/WpfApplication/Properties/Settings.Designer.cs index 7ae79a04..b8c0153a 100644 --- a/SampleApps/WpfApplication/Properties/Settings.Designer.cs +++ b/SampleApps/WpfApplication/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18010 +// Runtime Version:4.0.30319.18033 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/SampleApps/WpfApplication/SampleItems.cs b/SampleApps/WpfApplication/SampleItems.cs index 69fb0050..a3bc5236 100644 --- a/SampleApps/WpfApplication/SampleItems.cs +++ b/SampleApps/WpfApplication/SampleItems.cs @@ -1,6 +1,6 @@ -using MapControl; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; +using MapControl; namespace WpfApplication {