diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs index 18023a8b..f08e7e4a 100644 --- a/Caching/FileDbCache/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs index aa6991d0..8b70492c 100644 --- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] diff --git a/MapControl/LocationCollection.cs b/MapControl/LocationCollection.cs index 01509f7c..3fc513bf 100644 --- a/MapControl/LocationCollection.cs +++ b/MapControl/LocationCollection.cs @@ -19,7 +19,7 @@ namespace MapControl public LocationCollection(IEnumerable locations) { - foreach (Location location in locations) + foreach (var location in locations) { Add(location); } diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs index 754aae04..53d48465 100644 --- a/MapControl/MapBase.cs +++ b/MapControl/MapBase.cs @@ -575,16 +575,16 @@ namespace MapControl Location.NormalizeLongitude(location.Longitude)); } - private bool CoerceCenterProperty(DependencyProperty property, ref Location value) + private bool CoerceCenterProperty(DependencyProperty property, ref Location center) { - Location coercedValue = CoerceLocation(value); + Location coercedValue = CoerceLocation(center); - if (!coercedValue.Equals(value)) + if (!coercedValue.Equals(center)) { SetProperty(property, coercedValue); } - return coercedValue != value; + return coercedValue != center; } private void CenterPropertyChanged(Location center) @@ -672,7 +672,7 @@ namespace MapControl private void MaxZoomLevelPropertyChanged(double maxZoomLevel) { - var coercedValue = Math.Min(Math.Max(maxZoomLevel, MinZoomLevel), 20d); + var coercedValue = Math.Min(Math.Max(maxZoomLevel, MinZoomLevel), 22d); if (coercedValue != maxZoomLevel) { @@ -684,21 +684,21 @@ namespace MapControl } } - private double CoerceZoomLevel(double value) + private double CoerceZoomLevel(double zoomLevel) { - return Math.Min(Math.Max(value, MinZoomLevel), MaxZoomLevel); + return Math.Min(Math.Max(zoomLevel, MinZoomLevel), MaxZoomLevel); } - private bool CoerceZoomLevelProperty(DependencyProperty property, ref double value) + private bool CoerceZoomLevelProperty(DependencyProperty property, ref double zoomLevel) { - var coercedValue = CoerceZoomLevel(value); + var coercedValue = CoerceZoomLevel(zoomLevel); - if (coercedValue != value) + if (coercedValue != zoomLevel) { SetProperty(property, coercedValue); } - return coercedValue != value; + return coercedValue != zoomLevel; } private void ZoomLevelPropertyChanged(double zoomLevel) @@ -752,21 +752,21 @@ namespace MapControl } } - private double CoerceHeading(double value) + private double CoerceHeading(double heading) { - return (value >= -180d && value <= 360d) ? value : ((value + 360d) % 360d); + return (heading >= -180d && heading <= 360d) ? heading : ((heading + 360d) % 360d); } - private bool CoerceHeadingProperty(DependencyProperty property, ref double value) + private bool CoerceHeadingProperty(DependencyProperty property, ref double heading) { - var coercedValue = CoerceHeading(value); + var coercedValue = CoerceHeading(heading); - if (coercedValue != value) + if (coercedValue != heading) { SetProperty(property, coercedValue); } - return coercedValue != value; + return coercedValue != heading; } private void HeadingPropertyChanged(double heading) diff --git a/MapControl/MapPolyline.cs b/MapControl/MapPolyline.cs index e1fef135..ce9088ea 100644 --- a/MapControl/MapPolyline.cs +++ b/MapControl/MapPolyline.cs @@ -3,6 +3,8 @@ // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; +using System.Collections.Generic; +using System.Collections.Specialized; #if NETFX_CORE using Windows.UI.Xaml; using Windows.UI.Xaml.Media; @@ -16,21 +18,21 @@ namespace MapControl public partial class MapPolyline : IMapElement { public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register( - "Locations", typeof(LocationCollection), typeof(MapPolyline), - new PropertyMetadata(null, (o, e) => ((MapPolyline)o).UpdateGeometry())); + "Locations", typeof(IEnumerable), typeof(MapPolyline), + new PropertyMetadata(null, LocationsPropertyChanged)); public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register( "IsClosed", typeof(bool), typeof(MapPolyline), new PropertyMetadata(false, (o, e) => ((MapPolyline)o).UpdateGeometry())); - protected PathGeometry Geometry = new PathGeometry(); + protected readonly PathGeometry Geometry = new PathGeometry(); /// /// Gets or sets the locations that define the polyline points. /// - public LocationCollection Locations + public IEnumerable Locations { - get { return (LocationCollection)GetValue(LocationsProperty); } + get { return (IEnumerable)GetValue(LocationsProperty); } set { SetValue(LocationsProperty, value); } } @@ -43,40 +45,71 @@ namespace MapControl set { SetValue(IsClosedProperty, value); } } - protected virtual void UpdateGeometry() + private void UpdateGeometry() { var parentMap = MapPanel.GetParentMap(this); var locations = Locations; + Location first; - if (parentMap != null && locations != null && locations.Count > 0) + Geometry.Figures.Clear(); + + if (parentMap != null && locations != null && (first = locations.FirstOrDefault()) != null) { var figure = new PathFigure { - StartPoint = parentMap.MapTransform.Transform(locations[0]), + StartPoint = parentMap.MapTransform.Transform(first), IsClosed = IsClosed, IsFilled = IsClosed }; - if (locations.Count > 1) + var segment = new PolyLineSegment(); + + foreach (var location in locations.Skip(1)) { - var segment = new PolyLineSegment(); - - foreach (Location location in locations.Skip(1)) - { - segment.Points.Add(parentMap.MapTransform.Transform(location)); - } + segment.Points.Add(parentMap.MapTransform.Transform(location)); + } + if (segment.Points.Count > 0) + { figure.Segments.Add(segment); } Geometry.Figures.Add(figure); Geometry.Transform = parentMap.ViewportTransform; } + else + { + Geometry.Transform = null; + } } void IMapElement.ParentMapChanged(MapBase oldParentMap, MapBase newParentMap) { UpdateGeometry(); } + + private void LocationCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + UpdateGeometry(); + } + + private static void LocationsPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) + { + var mapPolyline = (MapPolyline)obj; + var oldNotifyCollectionChanged = e.OldValue as INotifyCollectionChanged; + var newNotifyCollectionChanged = e.NewValue as INotifyCollectionChanged; + + if (oldNotifyCollectionChanged != null) + { + oldNotifyCollectionChanged.CollectionChanged -= mapPolyline.LocationCollectionChanged; + } + + if (newNotifyCollectionChanged != null) + { + newNotifyCollectionChanged.CollectionChanged += mapPolyline.LocationCollectionChanged; + } + + mapPolyline.UpdateGeometry(); + } } } diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index b87df41a..ce422578 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -16,6 +16,6 @@ using System.Windows; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 55c24d77..026519b7 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index b5d5657b..bc33f0b6 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 7ad0ad1b..324a8784 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index aff8f083..8d072a6b 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] diff --git a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs index 0f6430db..806f104b 100644 --- a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Windows; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index a5b7e123..164e6a03 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Windows; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.3")] +[assembly: AssemblyFileVersion("1.1.3")] [assembly: ComVisible(false)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]