DependencyPropertyHelper

This commit is contained in:
ClemensFischer 2024-05-23 18:08:14 +02:00
parent c74c2b1fed
commit 8e82e0bcbd
25 changed files with 224 additions and 176 deletions

View file

@ -51,9 +51,9 @@ namespace MapControl
private static string QueryString(ushort tag) => $"/ifd/{{ushort={tag}}}";
public static readonly DependencyProperty SourcePathProperty = DependencyProperty.Register(
nameof(SourcePath), typeof(string), typeof(GeoImage),
new PropertyMetadata(null, async (o, e) => await ((GeoImage)o).SourcePathPropertyChanged((string)e.NewValue)));
public static readonly DependencyProperty SourcePathProperty =
DependencyPropertyHelper.Register<GeoImage, string>(nameof(SourcePath), null, false,
async (image, oldValue, newValue) => await image.SourcePathPropertyChanged(newValue));
public GeoImage()
{

View file

@ -44,8 +44,8 @@ namespace MapControl
private const double LineInterpolationResolution = 2d;
public static readonly DependencyProperty MinLineDistanceProperty = DependencyProperty.Register(
nameof(MinLineDistance), typeof(double), typeof(MapGraticule), new PropertyMetadata(150d));
public static readonly DependencyProperty MinLineDistanceProperty =
DependencyPropertyHelper.Register<MapGraticule, double>(nameof(MinLineDistance), 150d);
private double lineDistance;
private string labelFormat;

View file

@ -24,8 +24,8 @@ namespace MapControl
/// </summary>
public partial class MapItemsControl : ListBox
{
public static readonly DependencyProperty LocationMemberPathProperty = DependencyProperty.Register(
nameof(LocationMemberPath), typeof(string), typeof(MapItemsControl), new PropertyMetadata(null));
public static readonly DependencyProperty LocationMemberPathProperty =
DependencyPropertyHelper.Register<MapItemsControl, string>(nameof(LocationMemberPath));
/// <summary>
/// Path to a source property for binding the Location property of MapItem containers.

View file

@ -23,9 +23,9 @@ namespace MapControl
/// </summary>
public partial class MapPath : IMapElement
{
public static readonly DependencyProperty LocationProperty = DependencyProperty.Register(
nameof(Location), typeof(Location), typeof(MapPath),
new PropertyMetadata(null, (o, e) => ((MapPath)o).UpdateData()));
public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapPath, Location>(nameof(Location), null, false,
(path, oldValue, newValue) => path.UpdateData());
private MapBase parentMap;

View file

@ -21,13 +21,13 @@ namespace MapControl
/// </summary>
public class MapPolygon : MapPath
{
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
nameof(Locations), typeof(IEnumerable<Location>), typeof(MapPolygon),
new PropertyMetadata(null, (o, e) => ((MapPolygon)o).DataCollectionPropertyChanged(e)));
public static readonly DependencyProperty LocationsProperty =
DependencyPropertyHelper.Register<MapPolygon, IEnumerable<Location>>(nameof(Locations), null, false,
(polygon, oldValue, newValue) => polygon.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register(
nameof(FillRule), typeof(FillRule), typeof(MapPolygon),
new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapPolygon)o).Data).FillRule = (FillRule)e.NewValue));
public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd, false,
(polygon, oldValue, newValue) => ((PathGeometry)polygon.Data).FillRule = newValue);
/// <summary>
/// Gets or sets the Locations that define the polygon points.

View file

@ -21,13 +21,13 @@ namespace MapControl
/// </summary>
public class MapPolyline : MapPath
{
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
nameof(Locations), typeof(IEnumerable<Location>), typeof(MapPolyline),
new PropertyMetadata(null, (o, e) => ((MapPolyline)o).DataCollectionPropertyChanged(e)));
public static readonly DependencyProperty LocationsProperty =
DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null, false,
(polyline, oldValue, newValue) => polyline.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register(
nameof(FillRule), typeof(FillRule), typeof(MapPolyline),
new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapPolyline)o).Data).FillRule = (FillRule)e.NewValue));
public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapPolyline, FillRule>(nameof(FillRule), FillRule.EvenOdd, false,
(polyline, oldValue, newValue) => ((PathGeometry)polyline.Data).FillRule = newValue);
/// <summary>
/// Gets or sets the Locations that define the polyline points.

View file

@ -30,8 +30,8 @@ namespace MapControl
/// </summary>
public class MapScale : MapOverlay
{
public static readonly DependencyProperty PaddingProperty = DependencyProperty.Register(
nameof(Padding), typeof(Thickness), typeof(MapScale), new PropertyMetadata(new Thickness(4)));
public static readonly DependencyProperty PaddingProperty =
DependencyPropertyHelper.Register<MapScale, Thickness>(nameof(Padding), new Thickness(4));
private readonly Polyline line = new Polyline();