2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2015-01-20 17:52:02 +01:00
|
|
|
|
// © 2015 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;
|
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
|
|
|
|
{
|
2013-04-12 19:59:16 +02:00
|
|
|
|
public MapPolyline()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2013-05-25 08:53:50 +02:00
|
|
|
|
Data = new StreamGeometry();
|
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
|
|
|
|
}
|
|
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
geometry.Transform = ParentMap.ViewportTransform;
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2013-04-12 19:59:16 +02:00
|
|
|
|
geometry.Clear();
|
|
|
|
|
|
geometry.ClearValue(Geometry.TransformProperty);
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|