mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
Removed DependencyPropertyHelper.AddOwner
This commit is contained in:
parent
a516d12391
commit
d944058ab3
15 changed files with 72 additions and 125 deletions
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
#pragma warning disable AVP1001 // The same AvaloniaProperty should not be registered twice
|
||||
#pragma warning disable AVP1001
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
|
|
@ -52,27 +52,6 @@ namespace MapControl
|
|||
return property;
|
||||
}
|
||||
|
||||
public static StyledProperty<TValue> AddOwner<TOwner, TValue>(
|
||||
StyledProperty<TValue> property,
|
||||
TValue defaultValue = default,
|
||||
Action<TOwner, TValue, TValue> changed = null)
|
||||
where TOwner : AvaloniaObject
|
||||
{
|
||||
var newProperty = property.AddOwner<TOwner>();
|
||||
|
||||
if (!Equals(defaultValue, property.GetMetadata(typeof(TOwner)).DefaultValue))
|
||||
{
|
||||
newProperty.OverrideMetadata<TOwner>(new StyledPropertyMetadata<TValue>(defaultValue));
|
||||
}
|
||||
|
||||
if (changed != null)
|
||||
{
|
||||
newProperty.Changed.AddClassHandler<TOwner, TValue>((o, e) => changed(o, e.OldValue.Value, e.NewValue.Value));
|
||||
}
|
||||
|
||||
return newProperty;
|
||||
}
|
||||
|
||||
public static void SetBinding(this AvaloniaObject target, AvaloniaProperty property, Binding binding)
|
||||
{
|
||||
target.Bind(property, binding);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace MapControl
|
|||
public partial class MapBase
|
||||
{
|
||||
public static readonly StyledProperty<Brush> ForegroundProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapBase, Brush>(TextElement.ForegroundProperty, Brushes.Black);
|
||||
TextElement.ForegroundProperty.AddOwner<MapBase>(new StyledPropertyMetadata<Brush>(new Optional<Brush>(Brushes.Black)));
|
||||
|
||||
public static readonly StyledProperty<Easing> AnimationEasingProperty =
|
||||
DependencyPropertyHelper.Register<MapBase, Easing>(nameof(AnimationEasing), new QuadraticEaseOut());
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@
|
|||
public class MapContentControl : ContentControl
|
||||
{
|
||||
public static readonly StyledProperty<bool> AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapContentControl, bool>(MapPanel.AutoCollapseProperty);
|
||||
MapPanel.AutoCollapseProperty.AddOwner<MapContentControl>();
|
||||
|
||||
public static readonly StyledProperty<Location> LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapContentControl, Location>(MapPanel.LocationProperty);
|
||||
MapPanel.LocationProperty.AddOwner<MapContentControl>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets MapPanel.AutoCollapse.
|
||||
|
|
|
|||
|
|
@ -12,31 +12,13 @@ namespace MapControl
|
|||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> ForegroundProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapGraticule, IBrush>(TextElement.ForegroundProperty);
|
||||
TextElement.ForegroundProperty.AddOwner<MapGraticule>();
|
||||
|
||||
public static readonly StyledProperty<FontFamily> FontFamilyProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapGraticule, FontFamily>(TextElement.FontFamilyProperty);
|
||||
TextElement.FontFamilyProperty.AddOwner<MapGraticule>();
|
||||
|
||||
public static readonly StyledProperty<double> FontSizeProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapGraticule, double>(TextElement.FontSizeProperty, 12d);
|
||||
|
||||
public Brush Foreground
|
||||
{
|
||||
get => GetValue(ForegroundProperty);
|
||||
set => SetValue(ForegroundProperty, value);
|
||||
}
|
||||
|
||||
public FontFamily FontFamily
|
||||
{
|
||||
get => GetValue(FontFamilyProperty);
|
||||
set => SetValue(FontFamilyProperty, value);
|
||||
}
|
||||
|
||||
public double FontSize
|
||||
{
|
||||
get => GetValue(FontSizeProperty);
|
||||
set => SetValue(FontSizeProperty, value);
|
||||
}
|
||||
TextElement.FontSizeProperty.AddOwner<MapGraticule>(new StyledPropertyMetadata<double>(12d));
|
||||
|
||||
private MapBase parentMap;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,15 @@
|
|||
public partial class MapItem
|
||||
{
|
||||
public static readonly StyledProperty<bool> AutoCollapseProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, bool>(MapPanel.AutoCollapseProperty);
|
||||
MapPanel.AutoCollapseProperty.AddOwner<MapItem>();
|
||||
|
||||
public static readonly StyledProperty<Location> LocationProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapItem, Location>(MapPanel.LocationProperty, null,
|
||||
(item, oldValue, newValue) => item.UpdateMapTransform());
|
||||
MapPanel.LocationProperty.AddOwner<MapItem>();
|
||||
|
||||
static MapItem()
|
||||
{
|
||||
LocationProperty.Changed.AddClassHandler<MapItem, Location>((item, e) => item.UpdateMapTransform());
|
||||
}
|
||||
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@ namespace MapControl
|
|||
{
|
||||
public partial class MapPath : Shape
|
||||
{
|
||||
public MapPath()
|
||||
{
|
||||
Stretch = Stretch.None;
|
||||
}
|
||||
public static readonly StyledProperty<Geometry> DataProperty = Path.DataProperty.AddOwner<MapPath>();
|
||||
|
||||
public static readonly StyledProperty<Geometry> DataProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapPath, Geometry>(Path.DataProperty, null,
|
||||
(path, oldValue, newValue) => path.UpdateData());
|
||||
static MapPath()
|
||||
{
|
||||
DataProperty.Changed.AddClassHandler<MapPath, Geometry>((path, e) => path.UpdateData());
|
||||
}
|
||||
|
||||
public Geometry Data
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue