2025-02-27 18:46:32 +01:00
|
|
|
|
using System.Windows;
|
2018-02-09 17:43:47 +01:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
2026-04-13 17:14:49 +02:00
|
|
|
|
namespace MapControl;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class MapPath : Shape
|
2018-02-09 17:43:47 +01:00
|
|
|
|
{
|
2026-04-13 17:14:49 +02:00
|
|
|
|
public static readonly DependencyProperty DataProperty =
|
|
|
|
|
|
DependencyPropertyHelper.AddOwner<MapPath, Geometry>(Path.DataProperty,
|
|
|
|
|
|
(path, oldValue, newValue) => path.DataPropertyChanged(oldValue, newValue));
|
2020-03-28 21:53:38 +01:00
|
|
|
|
|
2026-04-13 17:14:49 +02:00
|
|
|
|
public Geometry Data
|
|
|
|
|
|
{
|
|
|
|
|
|
get => (Geometry)GetValue(DataProperty);
|
|
|
|
|
|
set => SetValue(DataProperty, value);
|
|
|
|
|
|
}
|
2018-02-09 17:43:47 +01:00
|
|
|
|
|
2026-04-13 17:14:49 +02:00
|
|
|
|
protected override Geometry DefiningGeometry => Data;
|
2018-02-09 17:43:47 +01:00
|
|
|
|
|
2026-04-13 17:14:49 +02:00
|
|
|
|
private void DataPropertyChanged(Geometry oldValue, Geometry newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Check if Data is actually a new Geometry.
|
|
|
|
|
|
//
|
|
|
|
|
|
if (newValue != null && !ReferenceEquals(newValue, oldValue))
|
2022-11-03 20:10:17 +01:00
|
|
|
|
{
|
2026-04-13 17:14:49 +02:00
|
|
|
|
if (newValue.IsFrozen)
|
|
|
|
|
|
{
|
|
|
|
|
|
Data = newValue.Clone(); // DataPropertyChanged called again
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2022-11-03 20:10:17 +01:00
|
|
|
|
{
|
2026-04-13 17:14:49 +02:00
|
|
|
|
UpdateData();
|
2022-11-03 20:10:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-09 17:43:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|