diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs
index 7d5d7032..2bffb890 100644
--- a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs
+++ b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs
index f516054d..2421817f 100644
--- a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs
+++ b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs
index f3dfec3a..bbabcab8 100644
--- a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs
+++ b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs
index 3010bdce..f6d77c81 100644
--- a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs
+++ b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/MapControl/IMapElement.cs b/MapControl/IMapElement.cs
index e356aae9..4ac2d67e 100644
--- a/MapControl/IMapElement.cs
+++ b/MapControl/IMapElement.cs
@@ -8,9 +8,4 @@ namespace MapControl
{
MapBase ParentMap { get; set; }
}
-
- public interface IMapShape : IMapElement
- {
- void LocationChanged(Location oldValue, Location newValue);
- }
}
diff --git a/MapControl/Map.WinRT.cs b/MapControl/Map.WinRT.cs
index 46317124..86a747bb 100644
--- a/MapControl/Map.WinRT.cs
+++ b/MapControl/Map.WinRT.cs
@@ -2,6 +2,8 @@
// © 2016 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
+using System;
+using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
@@ -15,6 +17,11 @@ namespace MapControl
public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
"MouseWheelZoomDelta", typeof(double), typeof(Map), new PropertyMetadata(1d));
+ private bool transformPending;
+ private Point transformTranslation;
+ private double transformRotation;
+ private double transformScale = 1d;
+
public Map()
{
ManipulationMode = ManipulationModes.Scale |
@@ -33,16 +40,36 @@ namespace MapControl
set { SetValue(MouseWheelZoomDeltaProperty, value); }
}
- private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
+ protected virtual void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
- var zoomChange = MouseWheelZoomDelta * (double)point.Properties.MouseWheelDelta / 120d;
+ var zoomChange = MouseWheelZoomDelta * point.Properties.MouseWheelDelta / 120d;
+
ZoomMap(point.Position, TargetZoomLevel + zoomChange);
}
- private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
+ protected virtual async void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
- TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale);
+ transformTranslation.X += e.Delta.Translation.X;
+ transformTranslation.Y += e.Delta.Translation.Y;
+ transformRotation += e.Delta.Rotation;
+ transformScale *= e.Delta.Scale;
+
+ if (!transformPending)
+ {
+ transformPending = true;
+
+ await Dispatcher.RunIdleAsync(a =>
+ {
+ TransformMap(e.Position, transformTranslation, transformRotation, transformScale);
+
+ transformPending = false;
+ transformTranslation.X = 0d;
+ transformTranslation.Y = 0d;
+ transformRotation = 0d;
+ transformScale = 1d;
+ });
+ }
}
}
}
diff --git a/MapControl/MapBase.Silverlight.WinRT.cs b/MapControl/MapBase.Silverlight.WinRT.cs
index 9dcf1821..7b958650 100644
--- a/MapControl/MapBase.Silverlight.WinRT.cs
+++ b/MapControl/MapBase.Silverlight.WinRT.cs
@@ -3,15 +3,14 @@
// Licensed under the Microsoft Public License (Ms-PL)
using System;
+using System.Linq;
#if NETFX_CORE
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
#else
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Media;
#endif
@@ -51,7 +50,7 @@ namespace MapControl
{
// set Background by Style to enable resetting by ClearValue in RemoveTileLayers
var style = new Style(typeof(MapBase));
- style.Setters.Add(new Setter(Panel.BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
+ style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
Style = style;
var clip = new RectangleGeometry();
@@ -59,9 +58,13 @@ namespace MapControl
SizeChanged += (s, e) =>
{
- clip.Rect = new Rect(new Point(), e.NewSize);
- ResetTransformOrigin();
- UpdateTransform();
+ if (clip.Rect.Width != e.NewSize.Width || clip.Rect.Height != e.NewSize.Height)
+ {
+ clip.Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height);
+
+ ResetTransformOrigin();
+ UpdateTransform();
+ }
};
}
diff --git a/MapControl/MapGraticule.Silverlight.WinRT.cs b/MapControl/MapGraticule.Silverlight.WinRT.cs
index 21b5d130..bff045a9 100644
--- a/MapControl/MapGraticule.Silverlight.WinRT.cs
+++ b/MapControl/MapGraticule.Silverlight.WinRT.cs
@@ -3,7 +3,6 @@
// Licensed under the Microsoft Public License (Ms-PL)
using System;
-using System.Linq;
#if NETFX_CORE
using Windows.Foundation;
using Windows.UI.Xaml;
@@ -23,7 +22,7 @@ namespace MapControl
{
public partial class MapGraticule
{
- private readonly Path path;
+ private Path path;
private Location graticuleStart;
private Location graticuleEnd;
@@ -31,29 +30,36 @@ namespace MapControl
{
IsHitTestVisible = false;
StrokeThickness = 0.5;
-
- path = new Path
- {
- Data = new PathGeometry()
- };
-
- path.SetBinding(Shape.StrokeProperty, new Binding
- {
- Source = this,
- Path = new PropertyPath("Stroke")
- });
-
- path.SetBinding(Shape.StrokeThicknessProperty, new Binding
- {
- Source = this,
- Path = new PropertyPath("StrokeThickness")
- });
-
- Children.Add(path);
}
protected override void OnViewportChanged()
{
+ if (path == null)
+ {
+ path = new Path
+ {
+ Data = new PathGeometry()
+ };
+
+ path.SetBinding(Shape.StrokeProperty,
+ GetBindingExpression(StrokeProperty)?.ParentBinding ??
+ new Binding
+ {
+ Source = this,
+ Path = new PropertyPath("Stroke")
+ });
+
+ path.SetBinding(Shape.StrokeThicknessProperty,
+ GetBindingExpression(StrokeThicknessProperty)?.ParentBinding ??
+ new Binding
+ {
+ Source = this,
+ Path = new PropertyPath("StrokeThickness")
+ });
+
+ Children.Add(path);
+ }
+
var bounds = ParentMap.ViewportTransform.Inverse.TransformBounds(new Rect(new Point(), 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));
@@ -143,11 +149,13 @@ namespace MapControl
RenderTransform = renderTransform
};
- label.SetBinding(TextBlock.ForegroundProperty, new Binding
- {
- Source = this,
- Path = new PropertyPath("Foreground")
- });
+ label.SetBinding(TextBlock.ForegroundProperty,
+ GetBindingExpression(ForegroundProperty)?.ParentBinding ??
+ new Binding
+ {
+ Source = this,
+ Path = new PropertyPath("Foreground")
+ });
Children.Add(label);
}
diff --git a/MapControl/MapItem.Silverlight.WinRT.cs b/MapControl/MapItem.Silverlight.WinRT.cs
index abaabb3a..66633f00 100644
--- a/MapControl/MapItem.Silverlight.WinRT.cs
+++ b/MapControl/MapItem.Silverlight.WinRT.cs
@@ -20,5 +20,11 @@ namespace MapControl
DefaultStyleKey = typeof(MapItem);
MapPanel.AddParentMapHandlers(this);
}
+
+ public Location Location
+ {
+ get { return (Location)GetValue(MapPanel.LocationProperty); }
+ set { SetValue(MapPanel.LocationProperty, value); }
+ }
}
}
diff --git a/MapControl/MapItem.WPF.cs b/MapControl/MapItem.WPF.cs
index e3653ded..93253f05 100644
--- a/MapControl/MapItem.WPF.cs
+++ b/MapControl/MapItem.WPF.cs
@@ -17,5 +17,14 @@ namespace MapControl
DefaultStyleKeyProperty.OverrideMetadata(
typeof(MapItem), new FrameworkPropertyMetadata(typeof(MapItem)));
}
+
+ public static readonly DependencyProperty LocationProperty =
+ MapPanel.LocationProperty.AddOwner(typeof(MapItem));
+
+ public Location Location
+ {
+ get { return (Location)GetValue(LocationProperty); }
+ set { SetValue(LocationProperty, value); }
+ }
}
}
diff --git a/MapControl/MapOverlay.Silverlight.WinRT.cs b/MapControl/MapOverlay.Silverlight.WinRT.cs
index 1192081e..3fa099aa 100644
--- a/MapControl/MapOverlay.Silverlight.WinRT.cs
+++ b/MapControl/MapOverlay.Silverlight.WinRT.cs
@@ -2,25 +2,24 @@
// © 2016 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
-#if !NETFX_CORE
-using System.Windows;
-using System.Windows.Data;
-using System.Windows.Media;
-#else
+#if NETFX_CORE
using Windows.UI.Text;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
-
-namespace MapControl
-{
- class FontStyles { public const FontStyle Normal = FontStyle.Normal; }
- class FontStretches { public const FontStretch Normal = FontStretch.Normal; }
-}
+#else
+using System.Windows;
+using System.Windows.Data;
+using System.Windows.Media;
#endif
namespace MapControl
{
+#if NETFX_CORE
+ class FontStyles { public const FontStyle Normal = FontStyle.Normal; }
+ class FontStretches { public const FontStretch Normal = FontStretch.Normal; }
+#endif
+
public partial class MapOverlay
{
public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register(
@@ -68,20 +67,15 @@ namespace MapControl
public static readonly DependencyProperty StrokeMiterLimitProperty = DependencyProperty.Register(
"StrokeMiterLimit", typeof(double), typeof(MapOverlay), new PropertyMetadata(1d));
- private Binding foregroundBinding;
- private Binding strokeBinding;
-
protected override void SetParentMapOverride(MapBase parentMap)
{
- if (foregroundBinding != null)
+ if (GetBindingExpression(ForegroundProperty) != null)
{
- foregroundBinding = null;
ClearValue(ForegroundProperty);
}
- if (strokeBinding != null)
+ if (GetBindingExpression(StrokeProperty) != null)
{
- strokeBinding = null;
ClearValue(StrokeProperty);
}
@@ -89,22 +83,20 @@ namespace MapControl
{
if (Foreground == null)
{
- foregroundBinding = new Binding
+ SetBinding(ForegroundProperty, new Binding
{
Source = parentMap,
Path = new PropertyPath("Foreground")
- };
- SetBinding(ForegroundProperty, foregroundBinding);
+ });
}
if (Stroke == null)
{
- strokeBinding = new Binding
+ SetBinding(StrokeProperty, new Binding
{
Source = parentMap,
Path = new PropertyPath("Foreground")
- };
- SetBinding(StrokeProperty, strokeBinding);
+ });
}
}
diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs
index 24dd7f5c..0d80aed9 100644
--- a/MapControl/MapPanel.cs
+++ b/MapControl/MapPanel.cs
@@ -46,9 +46,9 @@ namespace MapControl
{
foreach (UIElement element in Children)
{
- Location location;
+ var location = GetLocation(element);
- if (!(element is IMapShape) && (location = GetLocation(element)) != null)
+ if (location != null)
{
ArrangeElementWithLocation(element);
SetViewportPosition(element, parentMap, location);
@@ -82,9 +82,9 @@ namespace MapControl
{
foreach (UIElement element in Children)
{
- Location location;
+ var location = GetLocation(element);
- if (!(element is IMapShape) && (location = GetLocation(element)) != null)
+ if (location != null)
{
SetViewportPosition(element, parentMap, location);
}
@@ -109,25 +109,17 @@ namespace MapControl
private static void LocationPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var element = (UIElement)obj;
- var mapShape = element as IMapShape;
- if (mapShape != null)
+ if (e.NewValue == null)
{
- mapShape.LocationChanged((Location)e.OldValue, (Location)e.NewValue);
+ ArrangeElementWithoutLocation(element, Size.Empty);
}
- else
+ else if (e.OldValue == null)
{
- if (e.NewValue == null)
- {
- ArrangeElementWithoutLocation(element, Size.Empty);
- }
- else if (e.OldValue == null)
- {
- ArrangeElementWithLocation(element);
- }
+ ArrangeElementWithLocation(element);
+ }
- SetViewportPosition(element, GetParentMap(element), (Location)e.NewValue);
- }
+ SetViewportPosition(element, GetParentMap(element), (Location)e.NewValue);
}
private static void SetViewportPosition(UIElement element, MapBase parentMap, Location location)
@@ -146,13 +138,21 @@ namespace MapControl
Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude)));
}
- if ((bool)element.GetValue(FrameworkElement.UseLayoutRoundingProperty))
+ if ((bool)element.GetValue(UseLayoutRoundingProperty))
{
viewportPosition.X = Math.Round(viewportPosition.X);
viewportPosition.Y = Math.Round(viewportPosition.Y);
}
}
+ var translateTransform = GetTranslateTransform(element);
+
+ translateTransform.X = viewportPosition.X;
+ translateTransform.Y = viewportPosition.Y;
+ }
+
+ private static TranslateTransform GetTranslateTransform(UIElement element)
+ {
var translateTransform = element.RenderTransform as TranslateTransform;
if (translateTransform == null)
@@ -179,8 +179,7 @@ namespace MapControl
}
}
- translateTransform.X = viewportPosition.X;
- translateTransform.Y = viewportPosition.Y;
+ return translateTransform;
}
private static void ArrangeElementWithLocation(UIElement element)
@@ -232,7 +231,7 @@ namespace MapControl
if (parentSize.IsEmpty)
{
var parent = frameworkElement.Parent as UIElement;
- parentSize = parent != null ? parent.RenderSize : new Size();
+ parentSize = parent?.RenderSize ?? new Size();
}
switch (frameworkElement.HorizontalAlignment)
diff --git a/MapControl/MapPath.WPF.cs b/MapControl/MapPath.WPF.cs
index e3af4fe8..d9c64a34 100644
--- a/MapControl/MapPath.WPF.cs
+++ b/MapControl/MapPath.WPF.cs
@@ -12,8 +12,7 @@ namespace MapControl
{
public static readonly DependencyProperty DataProperty = DependencyProperty.Register(
"Data", typeof(Geometry), typeof(MapPath), new FrameworkPropertyMetadata(
- null, FrameworkPropertyMetadataOptions.AffectsRender,
- DataPropertyChanged, CoerceDataProperty));
+ null, FrameworkPropertyMetadataOptions.AffectsRender, DataPropertyChanged, CoerceDataProperty));
static MapPath()
{
@@ -40,7 +39,7 @@ namespace MapControl
private static void DataPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
- if (!object.ReferenceEquals(e.OldValue, e.NewValue))
+ if (!ReferenceEquals(e.OldValue, e.NewValue))
{
((MapPath)obj).UpdateData();
}
diff --git a/MapControl/MapPath.cs b/MapControl/MapPath.cs
index 6435d3d1..5e9716a9 100644
--- a/MapControl/MapPath.cs
+++ b/MapControl/MapPath.cs
@@ -16,15 +16,24 @@ namespace MapControl
///
/// Base class for map shapes. The shape geometry is given by the Data property,
/// which must contain a Geometry defined in cartesian (projected) map coordinates.
- /// The Stretch property is meaningless for MapPath, it will be reset to None.
- /// Optionally, the MapPanel.Location property can by set to move the viewport position
- /// to a longitude with minimal distance to the longitude of the current map center.
+ /// Optionally, the Location property can by set to adjust the viewport position to the
+ /// visible map viewport, as done for elements where the MapPanel.Location property is set.
///
- public partial class MapPath : IMapShape
+ public partial class MapPath : IMapElement
{
+ public static readonly DependencyProperty LocationProperty = DependencyProperty.Register(
+ "Location", typeof(Location), typeof(MapPath),
+ new PropertyMetadata(null, (o, e) => ((MapPath)o).LocationChanged((Location)e.OldValue, (Location)e.NewValue)));
+
private readonly TransformGroup viewportTransform = new TransformGroup();
private MapBase parentMap;
+ public Location Location
+ {
+ get { return (Location)GetValue(LocationProperty); }
+ set { SetValue(LocationProperty, value); }
+ }
+
public TransformGroup ViewportTransform
{
get { return viewportTransform; }
@@ -35,11 +44,9 @@ namespace MapControl
get { return parentMap; }
set
{
- var location = MapPanel.GetLocation(this);
-
- if (parentMap != null && location != null)
+ if (parentMap != null && Location != null)
{
- parentMap.ViewportChanged -= OnViewportChanged;
+ DetachViewportChanged();
}
viewportTransform.Children.Clear();
@@ -49,11 +56,9 @@ namespace MapControl
{
viewportTransform.Children.Add(parentMap.ViewportTransform);
- if (location != null)
+ if (Location != null)
{
- viewportTransform.Children.Insert(0, new TranslateTransform());
- parentMap.ViewportChanged += OnViewportChanged;
- OnViewportChanged(this, EventArgs.Empty);
+ AttachViewportChanged();
}
}
@@ -69,42 +74,46 @@ namespace MapControl
}
}
- void IMapShape.LocationChanged(Location oldValue, Location newValue)
+ private void LocationChanged(Location oldValue, Location newValue)
{
if (parentMap != null)
{
- if (newValue == null)
+ if (oldValue == null)
{
- parentMap.ViewportChanged -= OnViewportChanged;
- viewportTransform.Children.RemoveAt(0);
+ AttachViewportChanged();
}
- else if (oldValue == null)
+ else if (newValue == null)
{
- viewportTransform.Children.Insert(0, new TranslateTransform());
- parentMap.ViewportChanged += OnViewportChanged;
- OnViewportChanged(this, EventArgs.Empty);
+ DetachViewportChanged();
}
}
}
+ private void AttachViewportChanged()
+ {
+ viewportTransform.Children.Insert(0, new TranslateTransform());
+ parentMap.ViewportChanged += OnViewportChanged;
+ OnViewportChanged(parentMap, EventArgs.Empty);
+ }
+
+ private void DetachViewportChanged()
+ {
+ parentMap.ViewportChanged -= OnViewportChanged;
+ viewportTransform.Children.RemoveAt(0);
+ }
+
private void OnViewportChanged(object sender, EventArgs e)
{
- var location = MapPanel.GetLocation(this);
+ var viewportPosition = parentMap.LocationToViewportPoint(Location);
+ var longitudeOffset = 0d;
- if (parentMap != null && location != null)
+ if (viewportPosition.X < 0d || viewportPosition.X > parentMap.RenderSize.Width ||
+ viewportPosition.Y < 0d || viewportPosition.Y > parentMap.RenderSize.Height)
{
- var viewportPosition = parentMap.LocationToViewportPoint(location);
- var longitudeOffset = 0d;
-
- if (viewportPosition.X < 0d || viewportPosition.X > parentMap.RenderSize.Width ||
- viewportPosition.Y < 0d || viewportPosition.Y > parentMap.RenderSize.Height)
- {
- var longitude = Location.NormalizeLongitude(location.Longitude);
- longitudeOffset = Location.NearestLongitude(longitude, parentMap.Center.Longitude) - longitude;
- }
-
- ((TranslateTransform)viewportTransform.Children[0]).X = longitudeOffset;
+ longitudeOffset = Location.NearestLongitude(Location.Longitude, parentMap.Center.Longitude) - Location.Longitude;
}
+
+ ((TranslateTransform)viewportTransform.Children[0]).X = longitudeOffset;
}
}
}
diff --git a/MapControl/MapPolyline.cs b/MapControl/MapPolyline.cs
index 3ee675ee..23a117dc 100644
--- a/MapControl/MapPolyline.cs
+++ b/MapControl/MapPolyline.cs
@@ -22,14 +22,14 @@ namespace MapControl
public partial class MapPolyline : MapPath
{
#if NETFX_CORE
- // Binding fails on Windows Phone when property type is IEnumerable
+ // Binding fails on Windows Runtime when property type is IEnumerable
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
"Locations", typeof(IEnumerable), typeof(MapPolyline),
- new PropertyMetadata(null, LocationsPropertyChanged));
+ new PropertyMetadata(null, (o, e) => ((MapPolyline)o).LocationsChanged(e.OldValue as INotifyCollectionChanged, e.NewValue as INotifyCollectionChanged)));
#else
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
"Locations", typeof(IEnumerable), typeof(MapPolyline),
- new PropertyMetadata(null, LocationsPropertyChanged));
+ new PropertyMetadata(null, (o, e) => ((MapPolyline)o).LocationsChanged(e.OldValue as INotifyCollectionChanged, e.NewValue as INotifyCollectionChanged)));
#endif
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
"IsClosed", typeof(bool), typeof(MapPolyline),
@@ -65,28 +65,24 @@ namespace MapControl
set { SetValue(FillRuleProperty, value); }
}
- private void LocationCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ private void LocationsChanged(INotifyCollectionChanged oldCollection, INotifyCollectionChanged newCollection)
{
- UpdateData();
- }
-
- private static void LocationsPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
- {
- var mapPolyline = (MapPolyline)obj;
- var oldCollection = e.OldValue as INotifyCollectionChanged;
- var newCollection = e.NewValue as INotifyCollectionChanged;
-
if (oldCollection != null)
{
- oldCollection.CollectionChanged -= mapPolyline.LocationCollectionChanged;
+ oldCollection.CollectionChanged -= LocationCollectionChanged;
}
if (newCollection != null)
{
- newCollection.CollectionChanged += mapPolyline.LocationCollectionChanged;
+ newCollection.CollectionChanged += LocationCollectionChanged;
}
- mapPolyline.UpdateData();
+ UpdateData();
+ }
+
+ private void LocationCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ UpdateData();
}
}
}
diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs
index 17ca942b..a5f8acce 100644
--- a/MapControl/Properties/AssemblyInfo.cs
+++ b/MapControl/Properties/AssemblyInfo.cs
@@ -14,8 +14,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/MapControl/Pushpin.Silverlight.WinRT.cs b/MapControl/Pushpin.Silverlight.WinRT.cs
index b684c37d..342cf1d4 100644
--- a/MapControl/Pushpin.Silverlight.WinRT.cs
+++ b/MapControl/Pushpin.Silverlight.WinRT.cs
@@ -20,5 +20,11 @@ namespace MapControl
DefaultStyleKey = typeof(Pushpin);
MapPanel.AddParentMapHandlers(this);
}
+
+ public Location Location
+ {
+ get { return (Location)GetValue(MapPanel.LocationProperty); }
+ set { SetValue(MapPanel.LocationProperty, value); }
+ }
}
}
diff --git a/MapControl/Pushpin.WPF.cs b/MapControl/Pushpin.WPF.cs
index dae75d2a..47688dcb 100644
--- a/MapControl/Pushpin.WPF.cs
+++ b/MapControl/Pushpin.WPF.cs
@@ -17,5 +17,14 @@ namespace MapControl
DefaultStyleKeyProperty.OverrideMetadata(
typeof(Pushpin), new FrameworkPropertyMetadata(typeof(Pushpin)));
}
+
+ public static readonly DependencyProperty LocationProperty =
+ MapPanel.LocationProperty.AddOwner(typeof(Pushpin));
+
+ public Location Location
+ {
+ get { return (Location)GetValue(LocationProperty); }
+ set { SetValue(LocationProperty, value); }
+ }
}
}
diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs
index 178ad663..b484b1f2 100644
--- a/MapControl/TileSource.cs
+++ b/MapControl/TileSource.cs
@@ -79,7 +79,7 @@ namespace MapControl
public virtual Uri GetUri(int x, int y, int zoomLevel)
{
- return getUri != null ? getUri(x, y, zoomLevel) : null;
+ return getUri?.Invoke(x, y, zoomLevel);
}
private Uri GetBasicUri(int x, int y, int zoomLevel)
diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs
index 264a2138..d0aa7af7 100644
--- a/MapControl/WinRT/Properties/AssemblyInfo.cs
+++ b/MapControl/WinRT/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/Common/ViewModel.cs b/SampleApps/Common/ViewModel.cs
index f79871c4..edcd54ca 100644
--- a/SampleApps/Common/ViewModel.cs
+++ b/SampleApps/Common/ViewModel.cs
@@ -17,11 +17,7 @@ namespace ViewModel
protected void RaisePropertyChanged(string propertyName)
{
- var propertyChanged = PropertyChanged;
- if (propertyChanged != null)
- {
- propertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
diff --git a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs
index 54749dc0..b415f914 100644
--- a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/PhoneApplication/ViewModel.cs b/SampleApps/PhoneApplication/ViewModel.cs
index 69cb26aa..b7920176 100644
--- a/SampleApps/PhoneApplication/ViewModel.cs
+++ b/SampleApps/PhoneApplication/ViewModel.cs
@@ -51,11 +51,7 @@ namespace PhoneApplication
private void RaisePropertyChanged(string propertyName)
{
- var propertyChanged = PropertyChanged;
- if (propertyChanged != null)
- {
- propertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private async void GeoLocatorStatusChanged(Geolocator sender, StatusChangedEventArgs args)
diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
index e9b98af3..25c6ed32 100644
--- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
+++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
index 4d6693a7..31940e65 100644
--- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/UniversalApp/MainPage.xaml b/SampleApps/UniversalApp/MainPage.xaml
index 48e4e9f7..ba7550c6 100644
--- a/SampleApps/UniversalApp/MainPage.xaml
+++ b/SampleApps/UniversalApp/MainPage.xaml
@@ -88,37 +88,26 @@
-
-
-
-
-
-
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
-
+
diff --git a/SampleApps/UniversalApp/MainPage.xaml.cs b/SampleApps/UniversalApp/MainPage.xaml.cs
index 68929a4d..a78df1dc 100644
--- a/SampleApps/UniversalApp/MainPage.xaml.cs
+++ b/SampleApps/UniversalApp/MainPage.xaml.cs
@@ -12,7 +12,7 @@ namespace UniversalApp
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache();
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache();
- this.InitializeComponent();
+ InitializeComponent();
}
private void ImageOpacitySliderValueChanged(object sender, RangeBaseValueChangedEventArgs e)
diff --git a/SampleApps/UniversalApp/Properties/AssemblyInfo.cs b/SampleApps/UniversalApp/Properties/AssemblyInfo.cs
index fe1d8d46..b440cef0 100644
--- a/SampleApps/UniversalApp/Properties/AssemblyInfo.cs
+++ b/SampleApps/UniversalApp/Properties/AssemblyInfo.cs
@@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-[assembly: AssemblyVersion("2.11.0")]
-[assembly: AssemblyFileVersion("2.11.0")]
+[assembly: AssemblyVersion("2.12.0")]
+[assembly: AssemblyFileVersion("2.12.0")]
[assembly: AssemblyConfiguration("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml
index 804a0dd3..a10d6abc 100644
--- a/SampleApps/WpfApplication/MainWindow.xaml
+++ b/SampleApps/WpfApplication/MainWindow.xaml
@@ -96,7 +96,7 @@