2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2016-02-23 20:07:30 +01:00
|
|
|
|
// © 2016 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2013-02-12 19:30:58 +01:00
|
|
|
|
using System.Linq;
|
2015-03-20 18:49:17 +01:00
|
|
|
|
using System.Windows;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2013-04-12 19:59:16 +02:00
|
|
|
|
public partial class MapPolyline
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2015-03-20 18:49:17 +01:00
|
|
|
|
public static readonly DependencyProperty FillRuleProperty = StreamGeometry.FillRuleProperty.AddOwner(
|
2015-11-11 19:48:50 +01:00
|
|
|
|
typeof(MapPolyline),
|
|
|
|
|
|
new FrameworkPropertyMetadata((o, e) => ((StreamGeometry)((MapPolyline)o).Data).FillRule = (FillRule)e.NewValue));
|
2015-03-20 18:49:17 +01:00
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
public MapPolyline()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2016-04-19 19:36:03 +02:00
|
|
|
|
Data = new StreamGeometry { Transform = ViewportTransform };
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
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 = (StreamGeometry)Data;
|
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
|
|
|
|
{
|
2013-04-12 19:59:16 +02:00
|
|
|
|
using (var context = geometry.Open())
|
2013-02-12 19:30:58 +01:00
|
|
|
|
{
|
2015-02-10 17:25:00 +01:00
|
|
|
|
var points = Locations.Select(l => ParentMap.MapTransform.Transform(l));
|
2013-02-12 19:30:58 +01:00
|
|
|
|
|
2015-02-10 17:25:00 +01:00
|
|
|
|
context.BeginFigure(points.First(), IsClosed, IsClosed);
|
|
|
|
|
|
context.PolyLineTo(points.Skip(1).ToList(), true, false);
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2013-04-12 19:59:16 +02:00
|
|
|
|
geometry.Clear();
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|