using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; using Avalonia.Controls.Notifications; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; using Avalonia.Interactivity; using Avalonia.Metadata; namespace Ursa.Controls; [PseudoClasses(PC_Icon)] [TemplatePart(PART_CloseButton, typeof(Button))] public class Banner: HeaderedContentControl { public const string PC_Icon = ":icon"; public const string PART_CloseButton = "PART_CloseButton"; private Button? _closeButton; public static readonly StyledProperty CanCloseProperty = AvaloniaProperty.Register( nameof(CanClose)); public bool CanClose { get => GetValue(CanCloseProperty); set => SetValue(CanCloseProperty, value); } public static readonly StyledProperty ShowIconProperty = AvaloniaProperty.Register( nameof(ShowIcon), true); public bool ShowIcon { get => GetValue(ShowIconProperty); set => SetValue(ShowIconProperty, value); } public static readonly StyledProperty IconProperty = AvaloniaProperty.Register( nameof(Icon)); public object? Icon { get => GetValue(IconProperty); set => SetValue(IconProperty, value); } public static readonly StyledProperty TypeProperty = AvaloniaProperty.Register( nameof(Type)); public NotificationType Type { get => GetValue(TypeProperty); set => SetValue(TypeProperty, value); } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); if (_closeButton != null) { _closeButton.Click -= OnCloseClick; } _closeButton = e.NameScope.Find