// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control // Copyright © 2024 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using Avalonia.Collections; using Avalonia.Controls.Documents; using Avalonia.Controls.Shapes; using Avalonia.Media; namespace MapControl { public class MapOverlay : MapPanel { public static readonly StyledProperty FontFamilyProperty = DependencyPropertyHelper.AddOwner(TextElement.FontFamilyProperty); public static readonly StyledProperty FontSizeProperty = DependencyPropertyHelper.AddOwner(TextElement.FontSizeProperty); public static readonly StyledProperty FontStyleProperty = DependencyPropertyHelper.AddOwner(TextElement.FontStyleProperty); public static readonly StyledProperty FontStretchProperty = DependencyPropertyHelper.AddOwner(TextElement.FontStretchProperty); public static readonly StyledProperty FontWeightProperty = DependencyPropertyHelper.AddOwner(TextElement.FontWeightProperty); public static readonly StyledProperty ForegroundProperty = DependencyPropertyHelper.AddOwner(TextElement.ForegroundProperty); public static readonly StyledProperty StrokeProperty = DependencyPropertyHelper.AddOwner(Shape.StrokeProperty); public static readonly StyledProperty StrokeThicknessProperty = DependencyPropertyHelper.Register(nameof(StrokeThickness), 1d); public static readonly StyledProperty> StrokeDashArrayProperty = DependencyPropertyHelper.AddOwner>(Shape.StrokeDashArrayProperty); public static readonly StyledProperty StrokeDashOffsetProperty = DependencyPropertyHelper.AddOwner(Shape.StrokeDashOffsetProperty); public static readonly StyledProperty StrokeLineCapProperty = DependencyPropertyHelper.AddOwner(Shape.StrokeLineCapProperty); public static readonly StyledProperty StrokeLineJoinProperty = DependencyPropertyHelper.AddOwner(Shape.StrokeJoinProperty); public static readonly StyledProperty StrokeMiterLimitProperty = DependencyPropertyHelper.Register(nameof(StrokeMiterLimit)); public FontFamily FontFamily { get => GetValue(FontFamilyProperty); set => SetValue(FontFamilyProperty, value); } public double FontSize { get => GetValue(FontSizeProperty); set => SetValue(FontSizeProperty, value); } public FontStyle FontStyle { get => GetValue(FontStyleProperty); set => SetValue(FontStyleProperty, value); } public FontStretch FontStretch { get => GetValue(FontStretchProperty); set => SetValue(FontStretchProperty, value); } public FontWeight FontWeight { get => GetValue(FontWeightProperty); set => SetValue(FontWeightProperty, value); } public IBrush Foreground { get => GetValue(ForegroundProperty); set => SetValue(ForegroundProperty, value); } public IBrush Stroke { get => GetValue(StrokeProperty); set => SetValue(StrokeProperty, value); } public double StrokeThickness { get => GetValue(StrokeThicknessProperty); set => SetValue(StrokeThicknessProperty, value); } public AvaloniaList StrokeDashArray { get => GetValue(StrokeDashArrayProperty); set => SetValue(StrokeDashArrayProperty, value); } public double StrokeDashOffset { get => GetValue(StrokeDashOffsetProperty); set => SetValue(StrokeDashOffsetProperty, value); } public PenLineCap StrokeLineCap { get => GetValue(StrokeLineCapProperty); set => SetValue(StrokeLineCapProperty, value); } public PenLineJoin StrokeLineJoin { get => GetValue(StrokeLineJoinProperty); set => SetValue(StrokeLineJoinProperty, value); } public double StrokeMiterLimit { get => (double)GetValue(StrokeMiterLimitProperty); set => SetValue(StrokeMiterLimitProperty, value); } public Pen CreatePen() { return new Pen { Brush = Stroke, Thickness = StrokeThickness, LineJoin = StrokeLineJoin, MiterLimit = StrokeMiterLimit, LineCap = StrokeLineCap, DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset) }; } protected override void OnInitialized() { base.OnInitialized(); if (Stroke == null) { this.SetBinding(StrokeProperty, this.CreateBinding(nameof(Foreground))); } } } }