Added MapPolypoint base class

This commit is contained in:
ClemensFischer 2024-05-26 09:49:00 +02:00
parent aeb3fd047f
commit 84890090f8
11 changed files with 357 additions and 317 deletions

View file

@ -5,15 +5,11 @@
using System.Collections.Generic;
#if WPF
using System.Windows;
using System.Windows.Media;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
#elif WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
#elif AVALONIA
using Avalonia.Media;
using DependencyProperty = Avalonia.AvaloniaProperty;
#endif
@ -22,16 +18,12 @@ namespace MapControl
/// <summary>
/// A polyline defined by a collection of Locations.
/// </summary>
public class MapPolyline : MapPath
public class MapPolyline : MapPolypoint
{
public static readonly DependencyProperty LocationsProperty =
DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null,
(polyline, oldValue, newValue) => polyline.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapPolyline, FillRule>(nameof(FillRule), FillRule.EvenOdd,
(polyline, oldValue, newValue) => ((PathGeometry)polyline.Data).FillRule = newValue);
/// <summary>
/// Gets or sets the Locations that define the polyline points.
/// </summary>
@ -44,20 +36,9 @@ namespace MapControl
set => SetValue(LocationsProperty, value);
}
public FillRule FillRule
{
get => (FillRule)GetValue(FillRuleProperty);
set => SetValue(FillRuleProperty, value);
}
public MapPolyline()
{
Data = new PathGeometry();
}
protected override void UpdateData()
{
SetPathFigures(GetPathFigures(Locations, true));
UpdateData(Locations, false);
}
}
}