2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
|
|
|
|
// © 2017 Clemens Fischer
|
2013-02-12 19:30:58 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
2015-08-09 20:04:44 +02:00
|
|
|
|
#if NETFX_CORE
|
2015-03-20 18:49:17 +01:00
|
|
|
|
using Windows.UI.Xaml;
|
2013-02-12 19:30:58 +01:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
2015-03-20 18:49:17 +01:00
|
|
|
|
using System.Windows;
|
2013-02-12 19:30:58 +01:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2013-04-12 19:59:16 +02:00
|
|
|
|
public partial class MapPolyline
|
2013-02-12 19:30:58 +01:00
|
|
|
|
{
|
2015-03-20 18:49:17 +01:00
|
|
|
|
public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register(
|
2017-06-25 23:05:48 +02:00
|
|
|
|
nameof(FillRule), typeof(FillRule), typeof(MapPolyline),
|
2015-11-11 19:48:50 +01:00
|
|
|
|
new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapPolyline)o).Data).FillRule = (FillRule)e.NewValue));
|
2015-03-20 18:49:17 +01:00
|
|
|
|
|
2013-02-12 19:30:58 +01:00
|
|
|
|
public MapPolyline()
|
|
|
|
|
|
{
|
2017-06-25 23:05:48 +02:00
|
|
|
|
Data = new PathGeometry();
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-05-25 08:53:50 +02:00
|
|
|
|
protected override void UpdateData()
|
2013-02-12 19:30:58 +01:00
|
|
|
|
{
|
2013-05-25 08:53:50 +02:00
|
|
|
|
var geometry = (PathGeometry)Data;
|
2015-02-10 17:25:00 +01:00
|
|
|
|
geometry.Figures.Clear();
|
2013-02-12 19:30:58 +01:00
|
|
|
|
|
2015-02-10 17:25:00 +01:00
|
|
|
|
if (ParentMap != null && Locations != null && Locations.Any())
|
2013-02-12 19:30:58 +01:00
|
|
|
|
{
|
2017-06-25 23:05:48 +02:00
|
|
|
|
var points = Locations.Select(l => ParentMap.MapProjection.LocationToPoint(l));
|
2015-02-10 17:25:00 +01:00
|
|
|
|
|
2013-02-12 19:30:58 +01:00
|
|
|
|
var figure = new PathFigure
|
|
|
|
|
|
{
|
2015-02-10 17:25:00 +01:00
|
|
|
|
StartPoint = points.First(),
|
2013-02-12 19:30:58 +01:00
|
|
|
|
IsClosed = IsClosed,
|
|
|
|
|
|
IsFilled = IsClosed
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var segment = new PolyLineSegment();
|
|
|
|
|
|
|
2015-02-10 17:25:00 +01:00
|
|
|
|
foreach (var point in points.Skip(1))
|
2013-02-12 19:30:58 +01:00
|
|
|
|
{
|
2015-02-10 17:25:00 +01:00
|
|
|
|
segment.Points.Add(point);
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-02-10 17:25:00 +01:00
|
|
|
|
figure.Segments.Add(segment);
|
2013-04-12 19:59:16 +02:00
|
|
|
|
geometry.Figures.Add(figure);
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|