DependencyPropertyHelper

This commit is contained in:
ClemensFischer 2024-05-23 18:22:52 +02:00
parent 8e82e0bcbd
commit bc12b388de
20 changed files with 90 additions and 79 deletions

View file

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

View file

@ -62,7 +62,7 @@ namespace MapControl
}
public static readonly DependencyProperty SourcePathProperty =
DependencyPropertyHelper.Register<GroundOverlay, string>(nameof(SourcePath), null, false,
DependencyPropertyHelper.Register<GroundOverlay, string>(nameof(SourcePath), null,
async (overlay, oldValue, newValue) => await overlay.SourcePathPropertyChanged(newValue));
public string SourcePath

View file

@ -46,15 +46,15 @@ namespace MapControl
DependencyPropertyHelper.Register<MapBase, TimeSpan>(nameof(AnimationDuration), TimeSpan.FromSeconds(0.3));
public static readonly DependencyProperty MapLayerProperty =
DependencyPropertyHelper.Register<MapBase, UIElement>(nameof(MapLayer), null, false,
DependencyPropertyHelper.Register<MapBase, UIElement>(nameof(MapLayer), null,
(map, oldValue, newValue) => map.MapLayerPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty MapProjectionProperty =
DependencyPropertyHelper.Register<MapBase, MapProjection>(nameof(MapProjection), new WebMercatorProjection(), false,
DependencyPropertyHelper.Register<MapBase, MapProjection>(nameof(MapProjection), new WebMercatorProjection(),
(map, oldValue, newValue) => map.MapProjectionPropertyChanged(newValue));
public static readonly DependencyProperty ProjectionCenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(ProjectionCenter), null, false,
DependencyPropertyHelper.Register<MapBase, Location>(nameof(ProjectionCenter), null,
(map, oldValue, newValue) => map.ProjectionCenterPropertyChanged());
private Location transformCenter;

View file

@ -44,7 +44,7 @@ namespace MapControl
public static readonly DependencyProperty UpdateIntervalProperty =
DependencyPropertyHelper.Register<MapImageLayer, TimeSpan>(nameof(UpdateInterval), TimeSpan.FromSeconds(0.2),
false, (layer, oldValue, newValue) => layer.updateTimer.Interval = newValue);
(layer, oldValue, newValue) => layer.updateTimer.Interval = newValue);
public static readonly DependencyProperty UpdateWhileViewportChangingProperty =
DependencyPropertyHelper.Register<MapImageLayer, bool>(nameof(UpdateWhileViewportChanging));

View file

@ -24,7 +24,7 @@ namespace MapControl
public partial class MapPath : IMapElement
{
public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapPath, Location>(nameof(Location), null, false,
DependencyPropertyHelper.Register<MapPath, Location>(nameof(Location), null,
(path, oldValue, newValue) => path.UpdateData());
private MapBase parentMap;

View file

@ -22,11 +22,11 @@ namespace MapControl
public class MapPolygon : MapPath
{
public static readonly DependencyProperty LocationsProperty =
DependencyPropertyHelper.Register<MapPolygon, IEnumerable<Location>>(nameof(Locations), null, false,
DependencyPropertyHelper.Register<MapPolygon, IEnumerable<Location>>(nameof(Locations), null,
(polygon, oldValue, newValue) => polygon.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd, false,
DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd,
(polygon, oldValue, newValue) => ((PathGeometry)polygon.Data).FillRule = newValue);
/// <summary>

View file

@ -22,11 +22,11 @@ namespace MapControl
public class MapPolyline : MapPath
{
public static readonly DependencyProperty LocationsProperty =
DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null, false,
DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null,
(polyline, oldValue, newValue) => polyline.DataCollectionPropertyChanged(oldValue, newValue));
public static readonly DependencyProperty FillRuleProperty =
DependencyPropertyHelper.Register<MapPolyline, FillRule>(nameof(FillRule), FillRule.EvenOdd, false,
DependencyPropertyHelper.Register<MapPolyline, FillRule>(nameof(FillRule), FillRule.EvenOdd,
(polyline, oldValue, newValue) => ((PathGeometry)polyline.Data).FillRule = newValue);
/// <summary>

View file

@ -31,7 +31,7 @@ namespace MapControl
public abstract partial class MapTileLayerBase : Panel, IMapLayer
{
public static readonly DependencyProperty TileSourceProperty =
DependencyPropertyHelper.Register<MapTileLayerBase, TileSource>(nameof(TileSource), null, false,
DependencyPropertyHelper.Register<MapTileLayerBase, TileSource>(nameof(TileSource), null,
async (layer, oldValue, newValue) => await layer.Update(true));
public static readonly DependencyProperty SourceNameProperty =

View file

@ -30,11 +30,15 @@ namespace MapControl
public partial class WmsImageLayer : MapImageLayer
{
public static readonly DependencyProperty ServiceUriProperty =
DependencyPropertyHelper.Register<WmsImageLayer, Uri>(nameof(ServiceUri), null, false,
DependencyPropertyHelper.Register<WmsImageLayer, Uri>(nameof(ServiceUri), null,
async (layer, oldValue, newValue) => await layer.UpdateImageAsync());
public static readonly DependencyProperty WmsStylesProperty =
DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsStyles), string.Empty,
async (layer, oldValue, newValue) => await layer.UpdateImageAsync());
public static readonly DependencyProperty WmsLayersProperty =
DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsLayers), null, false,
DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsLayers), null,
async (layer, oldValue, newValue) =>
{
// Ignore property change from GetImageAsync when Layers was null.
@ -45,10 +49,6 @@ namespace MapControl
}
});
public static readonly DependencyProperty WmsStylesProperty =
DependencyPropertyHelper.Register<WmsImageLayer, string>(nameof(WmsStyles), string.Empty, false,
async (layer, oldValue, newValue) => await layer.UpdateImageAsync());
/// <summary>
/// The base request URL.
/// </summary>
@ -58,15 +58,6 @@ namespace MapControl
set => SetValue(ServiceUriProperty, value);
}
/// <summary>
/// Comma-separated sequence of WMS Layer names to be displayed. If not set, the first Layer is displayed.
/// </summary>
public string WmsLayers
{
get => (string)GetValue(WmsLayersProperty);
set => SetValue(WmsLayersProperty, value);
}
/// <summary>
/// Comma-separated sequence of requested WMS Styles. Default is an empty string.
/// </summary>
@ -76,6 +67,15 @@ namespace MapControl
set => SetValue(WmsStylesProperty, value);
}
/// <summary>
/// Comma-separated sequence of WMS Layer names to be displayed. If not set, the first Layer is displayed.
/// </summary>
public string WmsLayers
{
get => (string)GetValue(WmsLayersProperty);
set => SetValue(WmsLayersProperty, value);
}
/// <summary>
/// Gets a list of all layer names returned by a GetCapabilities response.
/// </summary>

View file

@ -28,7 +28,7 @@ namespace MapControl
public class WmtsTileLayer : MapTileLayerBase
{
public static readonly DependencyProperty CapabilitiesUriProperty =
DependencyPropertyHelper.Register<WmtsTileLayer, Uri>(nameof(CapabilitiesUri), null, false,
DependencyPropertyHelper.Register<WmtsTileLayer, Uri>(nameof(CapabilitiesUri), null,
(layer, oldValue, newValue) => layer.TileMatrixSets.Clear());
public static readonly DependencyProperty LayerProperty =