SystemCommands.cs 1.1 KB

12345678910111213141516171819202122232425
  1. using System.Windows.Input;
  2. using Avalonia.Controls;
  3. using Avalonia.Interactivity;
  4. using CommunityToolkit.Mvvm.Input;
  5. namespace PixiEditor.AvaloniaUI.ViewModels;
  6. public static class SystemCommands
  7. {
  8. public static RoutedEvent<RoutedEventArgs> CloseWindowEvent { get; }
  9. = RoutedEvent.Register<Window, RoutedEventArgs>(nameof(CloseWindowEvent), RoutingStrategies.Bubble);
  10. public static RoutedEvent<RoutedEventArgs> MaximizeWindowEvent { get; }
  11. = RoutedEvent.Register<Window, RoutedEventArgs>(nameof(MaximizeWindowEvent), RoutingStrategies.Bubble);
  12. public static RoutedEvent<RoutedEventArgs> MinimizeWindowEvent { get; }
  13. = RoutedEvent.Register<Window, RoutedEventArgs>(nameof(MinimizeWindowEvent), RoutingStrategies.Bubble);
  14. public static RoutedEvent<RoutedEventArgs> RestoreWindowEvent { get; }
  15. = RoutedEvent.Register<Window, RoutedEventArgs>(nameof(RestoreWindowEvent), RoutingStrategies.Bubble);
  16. public static ICommand CloseWindowCommand { get; } = new RelayCommand<Window>(CloseWindow);
  17. public static void CloseWindow(Window? obj)
  18. {
  19. obj?.Close();
  20. }
  21. }