using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Interactivity; using Irihi.Avalonia.Shared.Contracts; using Irihi.Avalonia.Shared.Helpers; using Ursa.Common; using Ursa.EventArgs; namespace Ursa.Controls; [TemplatePart(PART_YesButton, typeof(Button))] [TemplatePart(PART_NoButton, typeof(Button))] [TemplatePart(PART_OKButton, typeof(Button))] [TemplatePart(PART_CancelButton, typeof(Button))] public class DefaultDrawerControl: DrawerControlBase { public const string PART_YesButton = "PART_YesButton"; public const string PART_NoButton = "PART_NoButton"; public const string PART_OKButton = "PART_OKButton"; public const string PART_CancelButton = "PART_CancelButton"; private Button? _yesButton; private Button? _noButton; private Button? _okButton; private Button? _cancelButton; public static readonly StyledProperty ButtonsProperty = AvaloniaProperty.Register( nameof(Buttons), DialogButton.OKCancel); public DialogButton Buttons { get => GetValue(ButtonsProperty); set => SetValue(ButtonsProperty, value); } public static readonly StyledProperty ModeProperty = AvaloniaProperty.Register( nameof(Mode), DialogMode.None); public DialogMode Mode { get => GetValue(ModeProperty); set => SetValue(ModeProperty, value); } public static readonly StyledProperty TitleProperty = AvaloniaProperty.Register( nameof(Title)); public string? Title { get => GetValue(TitleProperty); set => SetValue(TitleProperty, value); } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); Button.ClickEvent.RemoveHandler(OnDefaultButtonClick, _yesButton, _noButton, _okButton, _cancelButton); _yesButton = e.NameScope.Find