using System.ComponentModel; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Data; using Avalonia.Media; using Irihi.Avalonia.Shared.Helpers; namespace Ursa.Controls; [PseudoClasses(PC_Active)] public class TwoTonePathIcon: TemplatedControl { public const string PC_Active = ":active"; public static readonly StyledProperty StrokeBrushProperty = AvaloniaProperty.Register( nameof(StrokeBrush)); public IBrush? StrokeBrush { get => GetValue(StrokeBrushProperty); set => SetValue(StrokeBrushProperty, value); } public static readonly StyledProperty DataProperty = AvaloniaProperty.Register( nameof(Data)); public Geometry Data { get => GetValue(DataProperty); set => SetValue(DataProperty, value); } public static readonly StyledProperty IsActiveProperty = AvaloniaProperty.Register( nameof(IsActive), defaultBindingMode: BindingMode.TwoWay); public bool IsActive { get => GetValue(IsActiveProperty); set => SetValue(IsActiveProperty, value); } public static readonly StyledProperty ActiveForegroundProperty = AvaloniaProperty.Register( nameof(ActiveForeground)); public IBrush? ActiveForeground { get => GetValue(ActiveForegroundProperty); set => SetValue(ActiveForegroundProperty, value); } public static readonly StyledProperty ActiveStrokeBrushProperty = AvaloniaProperty.Register( nameof(ActiveStrokeBrush)); public IBrush? ActiveStrokeBrush { get => GetValue(ActiveStrokeBrushProperty); set => SetValue(ActiveStrokeBrushProperty, value); } public static readonly StyledProperty StrokeThicknessProperty = AvaloniaProperty.Register( nameof(StrokeThickness)); public double StrokeThickness { get => GetValue(StrokeThicknessProperty); set => SetValue(StrokeThicknessProperty, value); } static TwoTonePathIcon() { AffectsRender( DataProperty, StrokeBrushProperty, ForegroundProperty, ActiveForegroundProperty, ActiveStrokeBrushProperty); IsActiveProperty.AffectsPseudoClass(PC_Active); } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); PseudoClasses.Set(PC_Active, IsActive); } }