Version 4.9.0: Reworked MapPanel child arrangement.

This commit is contained in:
ClemensF 2018-04-30 23:13:50 +02:00
parent 0a7d0fccd2
commit 56d376c4d0
24 changed files with 326 additions and 322 deletions

View file

@ -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);
}

View file

@ -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")
});
}
}
}

View file

@ -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);
}
}
}

View file

@ -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)]