diff --git a/MapControl/Shared/MapPolygon.cs b/MapControl/Shared/MapPolygon.cs index fb10d5a5..f5ac11b3 100644 --- a/MapControl/Shared/MapPolygon.cs +++ b/MapControl/Shared/MapPolygon.cs @@ -26,6 +26,10 @@ namespace MapControl nameof(Locations), typeof(IEnumerable), typeof(MapPolygon), new PropertyMetadata(null, (o, e) => ((MapPolygon)o).DataCollectionPropertyChanged(e))); + public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register( + nameof(FillRule), typeof(FillRule), typeof(MapPolygon), + new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapPolygon)o).Data).FillRule = (FillRule)e.NewValue)); + /// /// Gets or sets the Locations that define the polygon points. /// @@ -38,6 +42,12 @@ namespace MapControl set => SetValue(LocationsProperty, value); } + public FillRule FillRule + { + get => (FillRule)GetValue(FillRuleProperty); + set => SetValue(FillRuleProperty, value); + } + public MapPolygon() { Data = new PathGeometry(); diff --git a/MapControl/Shared/MapPolyline.cs b/MapControl/Shared/MapPolyline.cs index a51744b5..b592e91f 100644 --- a/MapControl/Shared/MapPolyline.cs +++ b/MapControl/Shared/MapPolyline.cs @@ -26,6 +26,10 @@ namespace MapControl nameof(Locations), typeof(IEnumerable), typeof(MapPolyline), new PropertyMetadata(null, (o, e) => ((MapPolyline)o).DataCollectionPropertyChanged(e))); + public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register( + nameof(FillRule), typeof(FillRule), typeof(MapPolyline), + new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapPolyline)o).Data).FillRule = (FillRule)e.NewValue)); + /// /// Gets or sets the Locations that define the polyline points. /// @@ -38,6 +42,12 @@ namespace MapControl set => SetValue(LocationsProperty, value); } + public FillRule FillRule + { + get => (FillRule)GetValue(FillRuleProperty); + set => SetValue(FillRuleProperty, value); + } + public MapPolyline() { Data = new PathGeometry(); diff --git a/MapControl/WPF/MapMultiPolygon.WPF.cs b/MapControl/WPF/MapMultiPolygon.WPF.cs index 9511b305..614b1951 100644 --- a/MapControl/WPF/MapMultiPolygon.WPF.cs +++ b/MapControl/WPF/MapMultiPolygon.WPF.cs @@ -14,7 +14,7 @@ namespace MapControl /// /// A PolygonCollection (with ObservableCollection of Location elements) may be used /// for the Polygons property if collection changes of the property itself and its - /// elements are both supposed to trigger a UI update. + /// elements are both supposed to trigger UI updates. /// public class MapMultiPolygon : MapPath { @@ -22,6 +22,10 @@ namespace MapControl nameof(Polygons), typeof(IEnumerable>), typeof(MapMultiPolygon), new PropertyMetadata(null, (o, e) => ((MapMultiPolygon)o).DataCollectionPropertyChanged(e))); + public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register( + nameof(FillRule), typeof(FillRule), typeof(MapMultiPolygon), + new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapMultiPolygon)o).Data).FillRule = (FillRule)e.NewValue)); + /// /// Gets or sets the Locations that define the multi-polygon points. /// @@ -31,6 +35,12 @@ namespace MapControl set => SetValue(PolygonsProperty, value); } + public FillRule FillRule + { + get => (FillRule)GetValue(FillRuleProperty); + set => SetValue(FillRuleProperty, value); + } + public MapMultiPolygon() { Data = new PathGeometry(); diff --git a/MapControl/WPF/MapPath.WPF.cs b/MapControl/WPF/MapPath.WPF.cs index 40a7a231..d748431c 100644 --- a/MapControl/WPF/MapPath.WPF.cs +++ b/MapControl/WPF/MapPath.WPF.cs @@ -14,6 +14,11 @@ namespace MapControl { public partial class MapPath : Shape, IWeakEventListener { + public MapPath() + { + Stretch = Stretch.None; + } + public static readonly DependencyProperty DataProperty = Path.DataProperty.AddOwner( typeof(MapPath), new PropertyMetadata(null, DataPropertyChanged)); @@ -25,11 +30,6 @@ namespace MapControl protected override Geometry DefiningGeometry => Data; - protected override Geometry GetLayoutClip(Size layoutSlotSize) - { - return ClipToBounds ? base.GetLayoutClip(layoutSlotSize) : null; - } - private static void DataPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { // Check if Data is actually a new Geometry. @@ -98,7 +98,7 @@ namespace MapControl { StartPoint = points.First(), IsClosed = closed, - IsFilled = closed + IsFilled = true }; figure.Segments.Add(new PolyLineSegment(points.Skip(1), true)); diff --git a/MapControl/WinUI/MapPath.WinUI.cs b/MapControl/WinUI/MapPath.WinUI.cs index cbd6a6df..40e975af 100644 --- a/MapControl/WinUI/MapPath.WinUI.cs +++ b/MapControl/WinUI/MapPath.WinUI.cs @@ -22,6 +22,7 @@ namespace MapControl { public MapPath() { + Stretch = Stretch.None; MapPanel.InitMapElement(this); } @@ -81,7 +82,7 @@ namespace MapControl { StartPoint = points.First(), IsClosed = closed, - IsFilled = closed + IsFilled = true }; figure.Segments.Add(segment); @@ -114,7 +115,7 @@ namespace MapControl { StartPoint = p1, IsClosed = false, - IsFilled = false + IsFilled = true }; segment = new PolyLineSegment();