diff --git a/FileDbCache/UWP/Properties/AssemblyInfo.cs b/FileDbCache/UWP/Properties/AssemblyInfo.cs index 9682ea56..1a9df272 100644 --- a/FileDbCache/UWP/Properties/AssemblyInfo.cs +++ b/FileDbCache/UWP/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2018 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("4.8.0")] -[assembly: AssemblyFileVersion("4.8.0")] +[assembly: AssemblyVersion("4.9.0")] +[assembly: AssemblyFileVersion("4.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/FileDbCache/WPF/Properties/AssemblyInfo.cs b/FileDbCache/WPF/Properties/AssemblyInfo.cs index 9f9ba6fe..1f8636b3 100644 --- a/FileDbCache/WPF/Properties/AssemblyInfo.cs +++ b/FileDbCache/WPF/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2018 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("4.8.0")] -[assembly: AssemblyFileVersion("4.8.0")] +[assembly: AssemblyVersion("4.9.0")] +[assembly: AssemblyFileVersion("4.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MBTiles/UWP/Properties/AssemblyInfo.cs b/MBTiles/UWP/Properties/AssemblyInfo.cs index 24a51997..1c77eafd 100644 --- a/MBTiles/UWP/Properties/AssemblyInfo.cs +++ b/MBTiles/UWP/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2018 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("4.8.0")] -[assembly: AssemblyFileVersion("4.8.0")] +[assembly: AssemblyVersion("4.9.0")] +[assembly: AssemblyFileVersion("4.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MBTiles/WPF/Properties/AssemblyInfo.cs b/MBTiles/WPF/Properties/AssemblyInfo.cs index 68cd7eb5..e91869a0 100644 --- a/MBTiles/WPF/Properties/AssemblyInfo.cs +++ b/MBTiles/WPF/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2018 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("4.8.0")] -[assembly: AssemblyFileVersion("4.8.0")] +[assembly: AssemblyVersion("4.9.0")] +[assembly: AssemblyFileVersion("4.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/Shared/HyperlinkText.cs b/MapControl/Shared/HyperlinkText.cs index eba21278..f448f994 100644 --- a/MapControl/Shared/HyperlinkText.cs +++ b/MapControl/Shared/HyperlinkText.cs @@ -62,12 +62,12 @@ namespace MapControl public static readonly DependencyProperty InlinesSourceProperty = DependencyProperty.RegisterAttached( "InlinesSource", typeof(string), typeof(HyperlinkText), new PropertyMetadata(null, InlinesSourcePropertyChanged)); - public static string GetInlinesSource(UIElement element) + public static string GetInlinesSource(DependencyObject element) { return (string)element.GetValue(InlinesSourceProperty); } - public static void SetInlinesSource(UIElement element, string value) + public static void SetInlinesSource(DependencyObject element, string value) { element.SetValue(InlinesSourceProperty, value); } diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index dfc1de39..f78637e4 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; +using System.Linq; using System.Threading.Tasks; #if WINDOWS_UWP using Windows.Foundation; @@ -295,7 +296,7 @@ namespace MapControl boundingBox.West += offset; boundingBox.East += offset; - foreach (UIElement element in Children) + foreach (var element in Children.OfType()) { var bbox = GetBoundingBox(element); @@ -309,7 +310,7 @@ namespace MapControl private void ClearImages() { - foreach (UIElement element in Children) + foreach (var element in Children.OfType()) { element.ClearValue(BoundingBoxProperty); element.ClearValue(Image.SourceProperty); diff --git a/MapControl/Shared/MapOverlay.cs b/MapControl/Shared/MapOverlay.cs index 745b4d9c..7f97991b 100644 --- a/MapControl/Shared/MapOverlay.cs +++ b/MapControl/Shared/MapOverlay.cs @@ -24,6 +24,16 @@ namespace MapControl { Loaded += (s, e) => { +#if WINDOWS_UWP + if (Foreground == null) + { + SetBinding(ForegroundProperty, new Binding + { + Source = this, + Path = new PropertyPath("ParentMap.Foreground") + }); + } +#endif if (Stroke == null) { SetBinding(StrokeProperty, new Binding diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs index a7b1878b..92c6ab45 100644 --- a/MapControl/Shared/MapPanel.cs +++ b/MapControl/Shared/MapPanel.cs @@ -3,6 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; +using System.Linq; #if WINDOWS_UWP using Windows.Foundation; using Windows.UI.Xaml; @@ -18,7 +19,6 @@ namespace MapControl { /// /// Optional interface to hold the value of the MapPanel.ParentMap attached property. - /// May be used to get notified when the property value changes. /// public interface IMapElement { @@ -28,8 +28,6 @@ namespace MapControl /// /// Arranges child elements on a Map at positions specified by the attached property Location, /// or in rectangles specified by the attached property BoundingBox. - /// An element's viewport position is assigned as TranslateTransform to its RenderTransform property, - /// either directly or as last child of a TransformGroup. /// public partial class MapPanel : Panel, IMapElement { @@ -46,37 +44,57 @@ namespace MapControl InitMapElement(this); } - public static Location GetLocation(UIElement element) + public static Location GetLocation(FrameworkElement element) { return (Location)element.GetValue(LocationProperty); } - public static void SetLocation(UIElement element, Location value) + public static void SetLocation(FrameworkElement element, Location value) { element.SetValue(LocationProperty, value); } - public static BoundingBox GetBoundingBox(UIElement element) + public static BoundingBox GetBoundingBox(FrameworkElement element) { return (BoundingBox)element.GetValue(BoundingBoxProperty); } - public static void SetBoundingBox(UIElement element, BoundingBox value) + public static void SetBoundingBox(FrameworkElement element, BoundingBox value) { element.SetValue(BoundingBoxProperty, value); } + public static Point? GetViewportPosition(FrameworkElement element) + { + return (Point?)element.GetValue(ViewportPositionProperty); + } + public MapBase ParentMap { get { return parentMap; } - set { SetParentMap(value); } + set + { + if (parentMap != null && parentMap != this) + { + parentMap.ViewportChanged -= OnViewportChanged; + } + + parentMap = value; + + if (parentMap != null && parentMap != this) + { + parentMap.ViewportChanged += OnViewportChanged; + + OnViewportChanged(new ViewportChangedEventArgs()); + } + } } protected override Size MeasureOverride(Size availableSize) { availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity); - foreach (UIElement element in Children) + foreach (var element in Children.OfType()) { element.Measure(availableSize); } @@ -86,62 +104,34 @@ namespace MapControl protected override Size ArrangeOverride(Size finalSize) { - foreach (UIElement element in Children) + foreach (var element in Children.OfType()) { - BoundingBox boundingBox; Location location; + BoundingBox boundingBox; + Point? viewportPosition = null; - if ((boundingBox = GetBoundingBox(element)) != null) + if ((location = GetLocation(element)) != null) { - ArrangeElementWithBoundingBox(element); - SetBoundingBoxRect(element, parentMap, boundingBox); + viewportPosition = ArrangeElementWithLocation(element, parentMap, location); } - else if ((location = GetLocation(element)) != null) + else if ((boundingBox = GetBoundingBox(element)) != null) { - ArrangeElementWithLocation(element); - SetViewportPosition(element, parentMap, location); + ArrangeElementWithBoundingBox(element, parentMap, boundingBox); } else { ArrangeElement(element, finalSize); } + + SetViewportPosition(element, viewportPosition); } return finalSize; } - protected virtual void SetParentMap(MapBase map) - { - if (parentMap != null && parentMap != this) - { - parentMap.ViewportChanged -= OnViewportChanged; - } - - parentMap = map; - - if (parentMap != null && parentMap != this) - { - parentMap.ViewportChanged += OnViewportChanged; - OnViewportChanged(new ViewportChangedEventArgs()); - } - } - protected virtual void OnViewportChanged(ViewportChangedEventArgs e) { - foreach (UIElement element in Children) - { - BoundingBox boundingBox; - Location location; - - if ((boundingBox = GetBoundingBox(element)) != null) - { - SetBoundingBoxRect(element, parentMap, boundingBox); - } - else if ((location = GetLocation(element)) != null) - { - SetViewportPosition(element, parentMap, location); - } - } + InvalidateArrange(); } private void OnViewportChanged(object sender, ViewportChangedEventArgs e) @@ -161,245 +151,201 @@ namespace MapControl private static void LocationPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var element = (UIElement)obj; - var map = GetParentMap(element); + var element = (FrameworkElement)obj; + var parentMap = GetParentMap(element); var location = (Location)e.NewValue; + Point? viewportPosition = null; - if (location == null) + if (location != null) { - ArrangeElement(element, map?.RenderSize ?? new Size()); + viewportPosition = ArrangeElementWithLocation(element, parentMap, location); } - else if (e.OldValue == null) + else { - ArrangeElementWithLocation(element); // arrange once when Location was null before + ArrangeElement(element, parentMap?.RenderSize ?? new Size()); } - SetViewportPosition(element, map, location); + SetViewportPosition(element, viewportPosition); } private static void BoundingBoxPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { var element = (FrameworkElement)obj; - var map = GetParentMap(element); + var parentMap = GetParentMap(element); var boundingBox = (BoundingBox)e.NewValue; - if (boundingBox == null) + if (boundingBox != null) { - ArrangeElement(element, map?.RenderSize ?? new Size()); + ArrangeElementWithBoundingBox(element, parentMap, boundingBox); } - else if (e.OldValue == null) + else { - ArrangeElementWithBoundingBox(element); // arrange once when BoundingBox was null before + ArrangeElement(element, parentMap?.RenderSize ?? new Size()); } - SetBoundingBoxRect(element, map, boundingBox); + SetViewportPosition(element, null); } - private static void SetViewportPosition(UIElement element, MapBase parentMap, Location location) + private static void ArrangeElement(FrameworkElement element, Size parentSize) { - var viewportPosition = new Point(); + var rect = new Rect(new Point(), element.DesiredSize); - if (parentMap != null && location != null) + switch (element.HorizontalAlignment) { - viewportPosition = parentMap.MapProjection.LocationToViewportPoint(location); + case HorizontalAlignment.Center: + rect.X = (parentSize.Width - rect.Width) / 2d; + break; + + case HorizontalAlignment.Right: + rect.X = parentSize.Width - rect.Width; + break; + + case HorizontalAlignment.Stretch: + rect.Width = parentSize.Width; + break; + + default: + break; + } + + switch (element.VerticalAlignment) + { + case VerticalAlignment.Center: + rect.Y = (parentSize.Height - rect.Height) / 2d; + break; + + case VerticalAlignment.Bottom: + rect.Y = parentSize.Height - rect.Height; + break; + + case VerticalAlignment.Stretch: + rect.Height = parentSize.Height; + break; + + default: + break; + } + + if (element.UseLayoutRounding) + { + rect.X = Math.Round(rect.X); + rect.Y = Math.Round(rect.Y); + } + + element.Arrange(rect); + } + + private static Point ArrangeElementWithLocation(FrameworkElement element, MapBase parentMap, Location location) + { + var pos = new Point(); + var rect = new Rect(pos, element.DesiredSize); + + if (parentMap != null) + { + pos = parentMap.MapProjection.LocationToViewportPoint(location); if (parentMap.MapProjection.IsContinuous && - (viewportPosition.X < 0d || viewportPosition.X > parentMap.RenderSize.Width || - viewportPosition.Y < 0d || viewportPosition.Y > parentMap.RenderSize.Height)) + (pos.X < 0d || pos.X > parentMap.RenderSize.Width || + pos.Y < 0d || pos.Y > parentMap.RenderSize.Height)) { - viewportPosition = parentMap.MapProjection.LocationToViewportPoint(new Location( + pos = parentMap.MapProjection.LocationToViewportPoint(new Location( location.Latitude, Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude))); } - if ((bool)element.GetValue(UseLayoutRoundingProperty)) - { - viewportPosition.X = Math.Round(viewportPosition.X); - viewportPosition.Y = Math.Round(viewportPosition.Y); - } + rect.X = pos.X; + rect.Y = pos.Y; } - var translateTransform = element.RenderTransform as TranslateTransform; - - if (translateTransform == null) + switch (element.HorizontalAlignment) { - var transformGroup = element.RenderTransform as TransformGroup; + case HorizontalAlignment.Center: + rect.X -= rect.Width / 2d; + break; - if (transformGroup == null) - { - translateTransform = new TranslateTransform(); - element.RenderTransform = translateTransform; - } - else - { - if (transformGroup.Children.Count > 0) - { - translateTransform = transformGroup.Children[transformGroup.Children.Count - 1] as TranslateTransform; - } + case HorizontalAlignment.Right: + rect.X -= rect.Width; + break; - if (translateTransform == null) - { - translateTransform = new TranslateTransform(); - transformGroup.Children.Add(translateTransform); - } - } + default: + break; } - translateTransform.X = viewportPosition.X; - translateTransform.Y = viewportPosition.Y; + switch (element.VerticalAlignment) + { + case VerticalAlignment.Center: + rect.Y -= rect.Height / 2d; + break; + + case VerticalAlignment.Bottom: + rect.Y -= rect.Height; + break; + + default: + break; + } + + if (element.UseLayoutRounding) + { + rect.X = Math.Round(rect.X); + rect.Y = Math.Round(rect.Y); + } + + element.Arrange(rect); + return pos; } - private static void SetBoundingBoxRect(UIElement element, MapBase parentMap, BoundingBox boundingBox) + private static void ArrangeElementWithBoundingBox(FrameworkElement element, MapBase parentMap, BoundingBox boundingBox) { + var rect = new Rect(); var rotation = 0d; - var viewportPosition = new Point(); - if (parentMap != null && boundingBox != null) + if (parentMap != null) { var projection = parentMap.MapProjection; - var rect = projection.BoundingBoxToRect(boundingBox); - var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d); + rect = projection.BoundingBoxToRect(boundingBox); - rotation = parentMap.Heading; - viewportPosition = projection.ViewportTransform.Transform(center); + var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d); + var pos = projection.ViewportTransform.Transform(center); if (parentMap.MapProjection.IsContinuous && - (viewportPosition.X < 0d || viewportPosition.X > parentMap.RenderSize.Width || - viewportPosition.Y < 0d || viewportPosition.Y > parentMap.RenderSize.Height)) + (pos.X < 0d || pos.X > parentMap.RenderSize.Width || + pos.Y < 0d || pos.Y > parentMap.RenderSize.Height)) { var location = projection.PointToLocation(center); location.Longitude = Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude); - viewportPosition = projection.LocationToViewportPoint(location); + pos = projection.LocationToViewportPoint(location); } - var width = rect.Width * projection.ViewportScale; - var height = rect.Height * projection.ViewportScale; + rect.Width *= projection.ViewportScale; + rect.Height *= projection.ViewportScale; + rect.X = pos.X - rect.Width / 2d; + rect.Y = pos.Y - rect.Height / 2d; - if (element is FrameworkElement) + if (element.UseLayoutRounding) { - ((FrameworkElement)element).Width = width; - ((FrameworkElement)element).Height = height; - } - else - { - element.Arrange(new Rect(-width / 2d, -height / 2d, width, height)); // ??? + rect.X = Math.Round(rect.X); + rect.Y = Math.Round(rect.Y); } + + rotation = parentMap.Heading; } - var transformGroup = element.RenderTransform as TransformGroup; - RotateTransform rotateTransform; - TranslateTransform translateTransform; + element.Width = rect.Width; + element.Height = rect.Height; + element.Arrange(rect); - if (transformGroup == null || - transformGroup.Children.Count != 2 || - (rotateTransform = transformGroup.Children[0] as RotateTransform) == null || - (translateTransform = transformGroup.Children[1] as TranslateTransform) == null) + var rotateTransform = element.RenderTransform as RotateTransform; + + if (rotateTransform == null) { - transformGroup = new TransformGroup(); rotateTransform = new RotateTransform(); - translateTransform = new TranslateTransform(); - transformGroup.Children.Add(rotateTransform); - transformGroup.Children.Add(translateTransform); - - element.RenderTransform = transformGroup; + element.RenderTransform = rotateTransform; element.RenderTransformOrigin = new Point(0.5, 0.5); } rotateTransform.Angle = rotation; - translateTransform.X = viewportPosition.X; - translateTransform.Y = viewportPosition.Y; - } - - private static void ArrangeElementWithBoundingBox(UIElement element) - { - var size = element.DesiredSize; - - element.Arrange(new Rect(-size.Width / 2d, -size.Height / 2d, size.Width, size.Height)); - } - - private static void ArrangeElementWithLocation(UIElement element) - { - var rect = new Rect(new Point(), element.DesiredSize); - - if (element is FrameworkElement) - { - switch (((FrameworkElement)element).HorizontalAlignment) - { - case HorizontalAlignment.Center: - rect.X = -rect.Width / 2d; - break; - - case HorizontalAlignment.Right: - rect.X = -rect.Width; - break; - - default: - break; - } - - switch (((FrameworkElement)element).VerticalAlignment) - { - case VerticalAlignment.Center: - rect.Y = -rect.Height / 2d; - break; - - case VerticalAlignment.Bottom: - rect.Y = -rect.Height; - break; - - default: - break; - } - } - - element.Arrange(rect); - } - - private static void ArrangeElement(UIElement element, Size parentSize) - { - var rect = new Rect(new Point(), element.DesiredSize); - - if (element is FrameworkElement) - { - switch (((FrameworkElement)element).HorizontalAlignment) - { - case HorizontalAlignment.Center: - rect.X = (parentSize.Width - rect.Width) / 2d; - break; - - case HorizontalAlignment.Right: - rect.X = parentSize.Width - rect.Width; - break; - - case HorizontalAlignment.Stretch: - rect.Width = parentSize.Width; - break; - - default: - break; - } - - switch (((FrameworkElement)element).VerticalAlignment) - { - case VerticalAlignment.Center: - rect.Y = (parentSize.Height - rect.Height) / 2d; - break; - - case VerticalAlignment.Bottom: - rect.Y = parentSize.Height - rect.Height; - break; - - case VerticalAlignment.Stretch: - rect.Height = parentSize.Height; - break; - - default: - break; - } - } - - element.Arrange(rect); } } } diff --git a/MapControl/Shared/MapScale.cs b/MapControl/Shared/MapScale.cs index 6cf35623..0c10c373 100644 --- a/MapControl/Shared/MapScale.cs +++ b/MapControl/Shared/MapScale.cs @@ -26,7 +26,7 @@ namespace MapControl public class MapScale : MapOverlay { public static readonly DependencyProperty PaddingProperty = DependencyProperty.Register( - nameof(Padding), typeof(Thickness), typeof(MapScale), null); + nameof(Padding), typeof(Thickness), typeof(MapScale), new PropertyMetadata(new Thickness(4))); private TextBlock label = new TextBlock(); private Polyline line = new Polyline(); @@ -34,11 +34,11 @@ namespace MapControl public MapScale() { IsHitTestVisible = false; +#if WINDOWS_UWP MinWidth = 100d; - Padding = new Thickness(4d); - HorizontalAlignment = HorizontalAlignment.Left; - VerticalAlignment = VerticalAlignment.Bottom; - +#else + SetCurrentValue(MinWidthProperty, 100d); +#endif label.HorizontalAlignment = HorizontalAlignment.Left; label.VerticalAlignment = VerticalAlignment.Top; label.TextAlignment = TextAlignment.Center; @@ -49,16 +49,12 @@ namespace MapControl Path = new PropertyPath("Foreground") }); - - line.SetBinding(Shape.StrokeProperty, new Binding { Source = this, Path = new PropertyPath("Stroke") }); - - line.SetBinding(Shape.StrokeThicknessProperty, new Binding { Source = this, diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index c079a501..2f5e880b 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -220,9 +220,9 @@ namespace MapControl { availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity); - foreach (UIElement element in Children) + foreach (var tile in Tiles) { - element.Measure(availableSize); + tile.Image.Measure(availableSize); } return new Size(); diff --git a/MapControl/UWP/MapGraticule.UWP.cs b/MapControl/UWP/MapGraticule.UWP.cs index 0f5dcfe3..bb8eab7a 100644 --- a/MapControl/UWP/MapGraticule.UWP.cs +++ b/MapControl/UWP/MapGraticule.UWP.cs @@ -35,18 +35,7 @@ namespace MapControl 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") - }); - + SetStrokeBindings(path); Children.Add(path); } diff --git a/MapControl/UWP/MapOverlay.UWP.cs b/MapControl/UWP/MapOverlay.UWP.cs index 02092e68..59ccfa9b 100644 --- a/MapControl/UWP/MapOverlay.UWP.cs +++ b/MapControl/UWP/MapOverlay.UWP.cs @@ -6,6 +6,7 @@ using Windows.UI.Text; using Windows.UI.Xaml; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Shapes; namespace MapControl { @@ -56,18 +57,61 @@ namespace MapControl public static readonly DependencyProperty StrokeMiterLimitProperty = DependencyProperty.Register( nameof(StrokeMiterLimit), typeof(double), typeof(MapOverlay), new PropertyMetadata(1d)); - protected override void SetParentMap(MapBase parentMap) + public void SetStrokeBindings(Shape shape) { - if (parentMap != null && Foreground == null) + shape.SetBinding(Shape.StrokeProperty, new Binding { - SetBinding(ForegroundProperty, new Binding - { - Source = parentMap, - Path = new PropertyPath("Foreground") - }); - } + Source = this, + Path = new PropertyPath("Stroke") + }); - base.SetParentMap(parentMap); + shape.SetBinding(Shape.StrokeThicknessProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeThickness") + }); + + shape.SetBinding(Shape.StrokeDashArrayProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeDashArray") + }); + + shape.SetBinding(Shape.StrokeDashOffsetProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeDashOffset") + }); + + shape.SetBinding(Shape.StrokeDashCapProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeDashCap") + }); + + shape.SetBinding(Shape.StrokeStartLineCapProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeStartLineCap") + }); + + shape.SetBinding(Shape.StrokeEndLineCapProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeEndLineCap") + }); + + shape.SetBinding(Shape.StrokeLineJoinProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeLineJoin") + }); + + shape.SetBinding(Shape.StrokeMiterLimitProperty, new Binding + { + Source = this, + Path = new PropertyPath("StrokeMiterLimit") + }); } } } diff --git a/MapControl/UWP/MapPanel.UWP.cs b/MapControl/UWP/MapPanel.UWP.cs index 7063f29d..74cd8ebf 100644 --- a/MapControl/UWP/MapPanel.UWP.cs +++ b/MapControl/UWP/MapPanel.UWP.cs @@ -12,6 +12,9 @@ namespace MapControl public static readonly DependencyProperty ParentMapProperty = DependencyProperty.RegisterAttached( "ParentMap", typeof(MapBase), typeof(MapPanel), new PropertyMetadata(null, ParentMapPropertyChanged)); + private static readonly DependencyProperty ViewportPositionProperty = DependencyProperty.RegisterAttached( + "ViewportPosition", typeof(Point?), typeof(MapPanel), new PropertyMetadata(null)); + public static void InitMapElement(FrameworkElement element) { if (element is MapBase) @@ -28,7 +31,7 @@ namespace MapControl } } - public static MapBase GetParentMap(UIElement element) + public static MapBase GetParentMap(FrameworkElement element) { var parentMap = (MapBase)element.GetValue(ParentMapProperty); @@ -40,14 +43,19 @@ namespace MapControl return parentMap; } - private static MapBase FindParentMap(UIElement element) + private static MapBase FindParentMap(FrameworkElement element) { - var parent = VisualTreeHelper.GetParent(element) as UIElement; + var parent = VisualTreeHelper.GetParent(element) as FrameworkElement; return parent == null ? null : ((parent as MapBase) ?? (MapBase)element.GetValue(ParentMapProperty) ?? FindParentMap(parent)); } + + private static void SetViewportPosition(FrameworkElement element, Point? viewportPosition) + { + element.SetValue(ViewportPositionProperty, viewportPosition); + } } } diff --git a/MapControl/UWP/Properties/AssemblyInfo.cs b/MapControl/UWP/Properties/AssemblyInfo.cs index 1903f2b0..a8d38dd1 100644 --- a/MapControl/UWP/Properties/AssemblyInfo.cs +++ b/MapControl/UWP/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2018 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("4.8.0")] -[assembly: AssemblyFileVersion("4.8.0")] +[assembly: AssemblyVersion("4.9.0")] +[assembly: AssemblyFileVersion("4.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/WPF/MapGraticule.WPF.cs b/MapControl/WPF/MapGraticule.WPF.cs index d776c3ee..1bb02a85 100644 --- a/MapControl/WPF/MapGraticule.WPF.cs +++ b/MapControl/WPF/MapGraticule.WPF.cs @@ -66,17 +66,7 @@ namespace MapControl var latLabels = new List