Browse Source

ShortcutPopup settings shortcut

CPKreuz 3 years ago
parent
commit
c66c76cbb6

+ 2 - 1
PixiEditor/Views/Dialogs/ShortcutPopup.xaml

@@ -13,7 +13,8 @@
         WindowStartupLocation="CenterScreen"
         WindowStartupLocation="CenterScreen"
         SizeToContent="Height"
         SizeToContent="Height"
         Title="ShortcutPopup" Width="1220" WindowStyle="None"
         Title="ShortcutPopup" Width="1220" WindowStyle="None"
-        MinHeight="780" MinWidth="620" Topmost="{Binding IsTopmost}">
+        MinHeight="780" MinWidth="620" Topmost="{Binding IsTopmost}"
+        KeyDown="ShortcutPopup_OnKeyDown">
     <Window.Resources>
     <Window.Resources>
         <BoolToVisibilityConverter x:Key="BoolToVisibility"/>
         <BoolToVisibilityConverter x:Key="BoolToVisibility"/>
 
 

+ 13 - 0
PixiEditor/Views/Dialogs/ShortcutPopup.xaml.cs

@@ -14,6 +14,8 @@ namespace PixiEditor.Views.Dialogs
         public static readonly DependencyProperty ControllerProperty =
         public static readonly DependencyProperty ControllerProperty =
             DependencyProperty.Register(nameof(Controller), typeof(CommandController), typeof(ShortcutPopup));
             DependencyProperty.Register(nameof(Controller), typeof(CommandController), typeof(ShortcutPopup));
 
 
+        Command settingsCommand;
+        
         public CommandController Controller
         public CommandController Controller
         {
         {
             get => (CommandController)GetValue(ControllerProperty);
             get => (CommandController)GetValue(ControllerProperty);
@@ -30,6 +32,7 @@ namespace PixiEditor.Views.Dialogs
             DataContext = this;
             DataContext = this;
             InitializeComponent();
             InitializeComponent();
             Controller = controller;
             Controller = controller;
+            settingsCommand = Controller.Commands["PixiEditor.Window.OpenSettingsWindow"];
         }
         }
 
 
         protected override void OnClosing(CancelEventArgs e)
         protected override void OnClosing(CancelEventArgs e)
@@ -39,6 +42,16 @@ namespace PixiEditor.Views.Dialogs
             Hide();
             Hide();
         }
         }
 
 
+        private void ShortcutPopup_OnKeyDown(object sender, KeyEventArgs e)
+        {
+            if (settingsCommand.Shortcut != new KeyCombination(e.Key, e.KeyboardDevice.Modifiers))
+            {
+                return;
+            }
+            
+            settingsCommand.Methods.Execute("Keybinds");
+        }
+
         private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
         private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
         {
         {
             e.CanExecute = true;
             e.CanExecute = true;