using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Interactivity; using Avalonia.Threading; using Ursa.Common; using Ursa.Controls.OverlayShared; using Ursa.EventArgs; namespace Ursa.Controls; [TemplatePart(PART_CloseButton, typeof(Button))] public abstract class DrawerControlBase: OverlayFeedbackElement { public const string PART_CloseButton = "PART_CloseButton"; internal bool CanClickOnMaskToClose { get; set; } protected internal Button? _closeButton; public static readonly StyledProperty PositionProperty = AvaloniaProperty.Register( nameof(Position), defaultValue: Position.Right); public Position Position { get => GetValue(PositionProperty); set => SetValue(PositionProperty, value); } public static readonly StyledProperty IsOpenProperty = AvaloniaProperty.Register( nameof(IsOpen)); public bool IsOpen { get => GetValue(IsOpenProperty); set => SetValue(IsOpenProperty, value); } public static readonly StyledProperty IsCloseButtonVisibleProperty = AvaloniaProperty.Register( nameof(IsCloseButtonVisible), defaultValue: true); public bool IsCloseButtonVisible { get => GetValue(IsCloseButtonVisibleProperty); set => SetValue(IsCloseButtonVisibleProperty, value); } protected internal bool ShowMask { get; set; } protected internal bool CanLightDismiss { get; set; } static DrawerControlBase() { DataContextProperty.Changed.AddClassHandler((o, e) => o.OnDataContextChange(e)); } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); EventHelper.UnregisterClickEvent(OnCloseButtonClick, _closeButton); _closeButton = e.NameScope.Find