using System; using System.Linq; using System.Windows.Input; using Avalonia.Automation.Peers; using Avalonia.Controls.Metadata; using Avalonia.Controls.Platform; using Avalonia.Controls.Primitives; using Avalonia.Data; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.LogicalTree; using Avalonia.VisualTree; namespace Avalonia.Controls { /// /// Defines how a reacts to clicks. /// public enum ClickMode { /// /// The event is raised when the pointer is released. /// Release, /// /// The event is raised when the pointer is pressed. /// Press, } /// /// A standard button control. /// [PseudoClasses(pcFlyoutOpen, pcPressed)] public class Button : ContentControl, ICommandSource, IClickableControl { private const string pcPressed = ":pressed"; private const string pcFlyoutOpen = ":flyout-open"; private EventHandler? _canExecuteChangeHandler = default; private EventHandler CanExecuteChangedHandler => _canExecuteChangeHandler ??= new(CanExecuteChanged); /// /// Defines the property. /// public static readonly StyledProperty ClickModeProperty = AvaloniaProperty.Register(nameof(ClickMode)); /// /// Defines the property. /// public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register(nameof(Command), enableDataValidation: true); /// /// Defines the property. /// public static readonly StyledProperty HotKeyProperty = HotKeyManager.HotKeyProperty.AddOwner