diff --git a/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs b/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs index 3cc08a6b..7c1f8d14 100644 --- a/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs +++ b/MapControl/Avalonia/DependencyPropertyHelper.Avalonia.cs @@ -46,5 +46,12 @@ namespace MapControl return property; } + + public static StyledProperty AddOwner( + StyledProperty property) + where TOwner : AvaloniaObject + { + return property.AddOwner(); + } } } diff --git a/MapControl/Avalonia/MapBase.Avalonia.cs b/MapControl/Avalonia/MapBase.Avalonia.cs index 58bdbd8b..0701ab72 100644 --- a/MapControl/Avalonia/MapBase.Avalonia.cs +++ b/MapControl/Avalonia/MapBase.Avalonia.cs @@ -6,6 +6,7 @@ global using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; using Avalonia.Controls; +using Avalonia.Controls.Documents; using Avalonia.Media; using Avalonia.Styling; using System.Threading; @@ -15,6 +16,9 @@ namespace MapControl { public partial class MapBase { + public static readonly StyledProperty ForegroundProperty = + DependencyPropertyHelper.AddOwner(TextElement.ForegroundProperty); + public static readonly StyledProperty AnimationEasingProperty = DependencyPropertyHelper.Register(nameof(AnimationEasing), new QuadraticEaseOut()); diff --git a/MapControl/Avalonia/MapControl.Avalonia.csproj b/MapControl/Avalonia/MapControl.Avalonia.csproj index 6b9376e6..3fce9dc8 100644 --- a/MapControl/Avalonia/MapControl.Avalonia.csproj +++ b/MapControl/Avalonia/MapControl.Avalonia.csproj @@ -17,6 +17,10 @@ AVALONIA + + + + @@ -33,10 +37,6 @@ - - - - diff --git a/MapControl/Shared/MapBase.cs b/MapControl/Shared/MapBase.cs index fc9ef2e1..f2be3866 100644 --- a/MapControl/Shared/MapBase.cs +++ b/MapControl/Shared/MapBase.cs @@ -7,15 +7,12 @@ using System; using System.Windows; using System.Windows.Media; #elif UWP -using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; #elif WINUI -using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media; #elif AVALONIA -using Avalonia.Media; using Brush = Avalonia.Media.IBrush; using DependencyProperty = Avalonia.AvaloniaProperty; using UIElement = Avalonia.Controls.Control; @@ -40,9 +37,6 @@ namespace MapControl { public static TimeSpan ImageFadeDuration { get; set; } = TimeSpan.FromSeconds(0.1); - public static readonly DependencyProperty ForegroundProperty = - DependencyPropertyHelper.Register(nameof(Foreground), new SolidColorBrush(Colors.Black)); - public static readonly DependencyProperty AnimationDurationProperty = DependencyPropertyHelper.Register(nameof(AnimationDuration), TimeSpan.FromSeconds(0.3)); diff --git a/MapControl/WPF/DependencyPropertyHelper.WPF.cs b/MapControl/WPF/DependencyPropertyHelper.WPF.cs index ed879683..811a28aa 100644 --- a/MapControl/WPF/DependencyPropertyHelper.WPF.cs +++ b/MapControl/WPF/DependencyPropertyHelper.WPF.cs @@ -73,24 +73,9 @@ namespace MapControl return DependencyProperty.RegisterReadOnly(name, typeof(TValue), typeof(TOwner), new PropertyMetadata(defaultValue)); } - public static DependencyProperty AddOwner( - DependencyProperty property, - FrameworkPropertyMetadataOptions options = FrameworkPropertyMetadataOptions.None) - where TOwner : DependencyObject - { - FrameworkPropertyMetadata metadata = null; - - if (options != FrameworkPropertyMetadataOptions.None) - { - metadata = new FrameworkPropertyMetadata(property.DefaultMetadata.DefaultValue, options); - } - - return property.AddOwner(typeof(TOwner), metadata); - } - public static DependencyProperty AddOwner( DependencyProperty property, - Action changed) + Action changed = null) where TOwner : DependencyObject { FrameworkPropertyMetadata metadata = null; diff --git a/MapControl/WPF/MapBase.WPF.cs b/MapControl/WPF/MapBase.WPF.cs index cf4a5422..f33c02e6 100644 --- a/MapControl/WPF/MapBase.WPF.cs +++ b/MapControl/WPF/MapBase.WPF.cs @@ -3,12 +3,17 @@ // Licensed under the Microsoft Public License (Ms-PL) using System.Windows; +using System.Windows.Documents; +using System.Windows.Media; using System.Windows.Media.Animation; namespace MapControl { public partial class MapBase { + public static readonly DependencyProperty ForegroundProperty = + DependencyPropertyHelper.AddOwner(TextElement.ForegroundProperty); + public static readonly DependencyProperty AnimationEasingFunctionProperty = DependencyPropertyHelper.Register(nameof(AnimationEasingFunction), new QuadraticEase { EasingMode = EasingMode.EaseOut }); diff --git a/MapControl/WPF/MapContentControl.WPF.cs b/MapControl/WPF/MapContentControl.WPF.cs index 055e93c5..9064ede8 100644 --- a/MapControl/WPF/MapContentControl.WPF.cs +++ b/MapControl/WPF/MapContentControl.WPF.cs @@ -13,10 +13,10 @@ namespace MapControl public class MapContentControl : ContentControl { public static readonly DependencyProperty AutoCollapseProperty = - DependencyPropertyHelper.AddOwner(MapPanel.AutoCollapseProperty); + DependencyPropertyHelper.AddOwner(MapPanel.AutoCollapseProperty); public static readonly DependencyProperty LocationProperty = - DependencyPropertyHelper.AddOwner(MapPanel.LocationProperty); + DependencyPropertyHelper.AddOwner(MapPanel.LocationProperty); static MapContentControl() { diff --git a/MapControl/WPF/MapItem.WPF.cs b/MapControl/WPF/MapItem.WPF.cs index 14e20460..4e8c5432 100644 --- a/MapControl/WPF/MapItem.WPF.cs +++ b/MapControl/WPF/MapItem.WPF.cs @@ -11,7 +11,7 @@ namespace MapControl public partial class MapItem { public static readonly DependencyProperty AutoCollapseProperty = - DependencyPropertyHelper.AddOwner(MapPanel.AutoCollapseProperty); + DependencyPropertyHelper.AddOwner(MapPanel.AutoCollapseProperty); public static readonly DependencyProperty LocationProperty = DependencyPropertyHelper.AddOwner(MapPanel.LocationProperty, diff --git a/MapControl/WPF/MapOverlay.WPF.cs b/MapControl/WPF/MapOverlay.WPF.cs index f82a219a..a7bfadee 100644 --- a/MapControl/WPF/MapOverlay.WPF.cs +++ b/MapControl/WPF/MapOverlay.WPF.cs @@ -13,64 +13,49 @@ namespace MapControl public partial class MapOverlay { public static readonly DependencyProperty FontFamilyProperty = - DependencyPropertyHelper.AddOwner(TextElement.FontFamilyProperty, - FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits); + DependencyPropertyHelper.AddOwner(TextElement.FontFamilyProperty); public static readonly DependencyProperty FontSizeProperty = - DependencyPropertyHelper.AddOwner(TextElement.FontSizeProperty, - FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits); + DependencyPropertyHelper.AddOwner(TextElement.FontSizeProperty); public static readonly DependencyProperty FontStyleProperty = - DependencyPropertyHelper.AddOwner(TextElement.FontStyleProperty, - FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits); + DependencyPropertyHelper.AddOwner(TextElement.FontStyleProperty); public static readonly DependencyProperty FontStretchProperty = - DependencyPropertyHelper.AddOwner(TextElement.FontStretchProperty, - FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits); + DependencyPropertyHelper.AddOwner(TextElement.FontStretchProperty); public static readonly DependencyProperty FontWeightProperty = - DependencyPropertyHelper.AddOwner(TextElement.FontWeightProperty, - FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits); + DependencyPropertyHelper.AddOwner(TextElement.FontWeightProperty); public static readonly DependencyProperty ForegroundProperty = - DependencyPropertyHelper.AddOwner(TextElement.ForegroundProperty, - FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits); + DependencyPropertyHelper.AddOwner(TextElement.ForegroundProperty); public static readonly DependencyProperty StrokeProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeProperty); public static readonly DependencyProperty StrokeThicknessProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeThicknessProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeThicknessProperty); public static readonly DependencyProperty StrokeDashArrayProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeDashArrayProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeDashArrayProperty); public static readonly DependencyProperty StrokeDashOffsetProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeDashOffsetProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeDashOffsetProperty); public static readonly DependencyProperty StrokeDashCapProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeDashCapProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeDashCapProperty); public static readonly DependencyProperty StrokeStartLineCapProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeStartLineCapProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeStartLineCapProperty); public static readonly DependencyProperty StrokeEndLineCapProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeEndLineCapProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeEndLineCapProperty); public static readonly DependencyProperty StrokeLineJoinProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeLineJoinProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeLineJoinProperty); public static readonly DependencyProperty StrokeMiterLimitProperty = - DependencyPropertyHelper.AddOwner(Shape.StrokeMiterLimitProperty, - FrameworkPropertyMetadataOptions.AffectsRender); + DependencyPropertyHelper.AddOwner(Shape.StrokeMiterLimitProperty); protected override void OnInitialized(EventArgs e) { diff --git a/MapControl/WinUI/MapBase.WinUI.cs b/MapControl/WinUI/MapBase.WinUI.cs index 61ca1747..a57b3bf8 100644 --- a/MapControl/WinUI/MapBase.WinUI.cs +++ b/MapControl/WinUI/MapBase.WinUI.cs @@ -18,6 +18,10 @@ namespace MapControl { public partial class MapBase { + public static readonly DependencyProperty ForegroundProperty = + DependencyPropertyHelper.Register(nameof(Foreground), + new SolidColorBrush(Colors.Black)); + public static readonly DependencyProperty AnimationEasingFunctionProperty = DependencyPropertyHelper.Register(nameof(AnimationEasingFunction), new QuadraticEase { EasingMode = EasingMode.EaseOut }); @@ -58,7 +62,8 @@ namespace MapControl DependencyPropertyHelper.Register(nameof(ViewScale), 0d); private static readonly DependencyProperty AnimatedCenterProperty = - DependencyPropertyHelper.Register(nameof(AnimatedCenter), new Windows.Foundation.Point(), + DependencyPropertyHelper.Register(nameof(AnimatedCenter), + new Windows.Foundation.Point(), (map, oldValue, newValue) => map.Center = new Location(newValue.Y, newValue.X)); private Windows.Foundation.Point AnimatedCenter => (Windows.Foundation.Point)GetValue(AnimatedCenterProperty);