mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
// © 2017 Clemens Fischer
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
using System.Linq;
|
|
#if NETFX_CORE
|
|
using Windows.UI.Xaml;
|
|
using Windows.UI.Xaml.Media;
|
|
#else
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
#endif
|
|
|
|
namespace MapControl
|
|
{
|
|
public partial class MapPolyline
|
|
{
|
|
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));
|
|
|
|
public MapPolyline()
|
|
{
|
|
Data = new PathGeometry();
|
|
}
|
|
|
|
protected override void UpdateData()
|
|
{
|
|
var geometry = (PathGeometry)Data;
|
|
geometry.Figures.Clear();
|
|
|
|
if (ParentMap != null && Locations != null && Locations.Any())
|
|
{
|
|
var points = Locations.Select(l => ParentMap.MapProjection.LocationToPoint(l));
|
|
|
|
var figure = new PathFigure
|
|
{
|
|
StartPoint = points.First(),
|
|
IsClosed = IsClosed,
|
|
IsFilled = IsClosed
|
|
};
|
|
|
|
var segment = new PolyLineSegment();
|
|
|
|
foreach (var point in points.Skip(1))
|
|
{
|
|
segment.Points.Add(point);
|
|
}
|
|
|
|
figure.Segments.Add(segment);
|
|
geometry.Figures.Add(figure);
|
|
}
|
|
}
|
|
}
|
|
}
|