2013-05-25 08:53:50 +02:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2016-02-23 20:07:30 +01:00
|
|
|
|
// © 2016 Clemens Fischer
|
2013-05-25 08:53:50 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapPath : Shape
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty DataProperty = DependencyProperty.Register(
|
2015-02-10 17:25:00 +01:00
|
|
|
|
"Data", typeof(Geometry), typeof(MapPath), new FrameworkPropertyMetadata(
|
2015-02-18 19:20:59 +01:00
|
|
|
|
null, FrameworkPropertyMetadataOptions.AffectsRender,
|
|
|
|
|
|
(o, e) => ((MapPath)o).UpdateData(), CoerceDataProperty));
|
|
|
|
|
|
|
|
|
|
|
|
static MapPath()
|
|
|
|
|
|
{
|
|
|
|
|
|
StretchProperty.OverrideMetadata(typeof(MapPath),
|
|
|
|
|
|
new FrameworkPropertyMetadata { CoerceValueCallback = (o, v) => Stretch.None });
|
|
|
|
|
|
}
|
2013-05-25 08:53:50 +02:00
|
|
|
|
|
|
|
|
|
|
public Geometry Data
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (Geometry)GetValue(DataProperty); }
|
|
|
|
|
|
set { SetValue(DataProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override Geometry DefiningGeometry
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return Data; }
|
|
|
|
|
|
}
|
2015-02-10 21:59:39 +01:00
|
|
|
|
|
|
|
|
|
|
protected override Size MeasureOverride(Size constraint)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Shape.MeasureOverride sometimes returns an empty Size.
|
|
|
|
|
|
return new Size(1, 1);
|
|
|
|
|
|
}
|
2015-02-18 19:20:59 +01:00
|
|
|
|
|
|
|
|
|
|
private static object CoerceDataProperty(DependencyObject obj, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = (Geometry)value;
|
|
|
|
|
|
return data != null && data.IsFrozen ? data.CloneCurrentValue() : data;
|
|
|
|
|
|
}
|
2013-05-25 08:53:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|