]> granicus.if.org Git - handbrake/commitdiff
WinGui: Add support for keyboard shortcuts. These are slightly different to the old...
authorsr55 <sr55.hb@outlook.com>
Sun, 8 Jul 2012 11:25:45 +0000 (11:25 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 8 Jul 2012 11:25:45 +0000 (11:25 +0000)
// Start Encode (Ctrl+S)
// Stop Encode (Ctrl+K)
// Open Log Window (Ctrl+L)
// Open Queue Window (Ctrl+Q)
// Add to Queue (Ctrl+A)
// Scan a File (Ctrl+F)
// Scan a Folder (Ctrl+R)

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4820 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs
win/CS/HandBrakeWPF/Views/MainView.xaml.cs
win/CS/HandBrakeWPF/Views/ShellView.xaml.cs

diff --git a/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs b/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs
new file mode 100644 (file)
index 0000000..cc5b546
--- /dev/null
@@ -0,0 +1,111 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="ProcessShortcutCommand.cs" company="HandBrake Project (http://handbrake.fr)">\r
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+//   Keyboard Shortcut Processor\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Commands\r
+{\r
+    using System;\r
+    using System.Windows.Input;\r
+\r
+    using Caliburn.Micro;\r
+\r
+    using HandBrakeWPF.ViewModels.Interfaces;\r
+\r
+    /// <summary>\r
+    /// Keyboard Shortcut Processor\r
+    /// </summary>\r
+    public class ProcessShortcutCommand : ICommand\r
+    {\r
+        /// <summary>\r
+        /// The Gesture\r
+        /// </summary>\r
+        private readonly KeyGesture gesture;\r
+\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="ProcessShortcutCommand"/> class.\r
+        /// </summary>\r
+        /// <param name="gesture">\r
+        /// The gesture.\r
+        /// </param>\r
+        public ProcessShortcutCommand(KeyGesture gesture)\r
+        {\r
+            this.gesture = gesture;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Defines the method to be called when the command is invoked.\r
+        /// </summary>\r
+        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>\r
+        public void Execute(object parameter)\r
+        {\r
+            if (gesture != null)\r
+            {\r
+                IMainViewModel mainViewModel = IoC.Get<IMainViewModel>();\r
+                \r
+                // Start Encode (Ctrl+S)\r
+                if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.S)\r
+                {\r
+                    mainViewModel.StartEncode();\r
+                }\r
+\r
+                // Stop Encode (Ctrl+K)\r
+                if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.K)\r
+                {\r
+                    mainViewModel.StopEncode();\r
+                }\r
+\r
+                // Open Log Window (Ctrl+L)\r
+                if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.L)\r
+                {\r
+                    mainViewModel.OpenLogWindow();\r
+                }\r
+\r
+                // Open Queue Window (Ctrl+Q)\r
+                if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.Q)\r
+                {\r
+                    mainViewModel.OpenQueueWindow();\r
+                }\r
+\r
+                // Add to Queue (Ctrl+A)\r
+                if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.A)\r
+                {\r
+                    mainViewModel.AddToQueue();\r
+                }\r
+\r
+                // Scan a File (Ctrl+F)\r
+                if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.F)\r
+                {\r
+                    mainViewModel.FileScan();\r
+                }\r
+\r
+                // Scan a Folder (Ctrl+R)\r
+                if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.R)\r
+                {\r
+                    mainViewModel.FolderScan();\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Defines the method that determines whether the command can execute in its current state.\r
+        /// </summary>\r
+        /// <returns>\r
+        /// true if this command can be executed; otherwise, false.\r
+        /// </returns>\r
+        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>\r
+        public bool CanExecute(object parameter)\r
+        {\r
+            return true;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Can Execute Changed\r
+        /// </summary>\r
+        public event EventHandler CanExecuteChanged;\r
+    }\r
+}\r
index e8e57eb2320d54a68cd91c003f8c457158220c03..7ef57cd7478cfae281a0351a775659fd75895b62 100644 (file)
       <SubType>Designer</SubType>\r
     </ApplicationDefinition>\r
     <Compile Include="AttachedProperties\MenuItemExtensions.cs" />\r
+    <Compile Include="Commands\ProcessShortcutCommand.cs" />\r
     <Compile Include="Controls\Loading.xaml.cs">\r
       <DependentUpon>Loading.xaml</DependentUpon>\r
     </Compile>\r
index e9e2c4901ac0726d8e920ec57cd7bdcf45889031..8f1f6e5a622f71df64b596bf72d560777bd93a0b 100644 (file)
@@ -25,5 +25,40 @@ namespace HandBrakeWPF.ViewModels.Interfaces
         /// Shutdown the Application\r
         /// </summary>\r
         void ExitApplication();\r
+\r
+        /// <summary>\r
+        /// Open the Log Window\r
+        /// </summary>\r
+        void OpenLogWindow();\r
+\r
+        /// <summary>\r
+        /// Open the Queue Window.\r
+        /// </summary>\r
+        void OpenQueueWindow();\r
+\r
+        /// <summary>\r
+        /// Add the current task to the queue.\r
+        /// </summary>\r
+        void AddToQueue();\r
+\r
+        /// <summary>\r
+        /// File Scan\r
+        /// </summary>\r
+        void FileScan();\r
+\r
+        /// <summary>\r
+        /// Folder Scan\r
+        /// </summary>\r
+        void FolderScan();\r
+\r
+        /// <summary>\r
+        /// Stop an Encode.\r
+        /// </summary>\r
+        void StopEncode();\r
+\r
+        /// <summary>\r
+        /// Start an Encode\r
+        /// </summary>\r
+        void StartEncode();\r
     }\r
 }
\ No newline at end of file
index 8b21e2d40fb559728dcc5378dd0339168d01bdb5..c6bb6356842e6521e8f2fb1d714ca7cbeddaa9e6 100644 (file)
@@ -9,8 +9,10 @@
 \r
 namespace HandBrakeWPF.Views\r
 {\r
+    using System;\r
     using System.Windows;\r
     using System.Windows.Controls;\r
+    using System.Windows.Input;\r
 \r
     /// <summary>\r
     /// Interaction logic for MainView.xaml\r
index 6b291702db64d2026d19ef4be02ba2a035a16b68..9a24120e159e531ee032330aa11509eb31a61fbe 100644 (file)
@@ -4,13 +4,15 @@
 // </copyright>\r
 // <summary>\r
 //   Interaction logic for ShellView.xaml\r
-// </summary>\r
+// </summary> \r
 // --------------------------------------------------------------------------------------------------------------------\r
 \r
 namespace HandBrakeWPF.Views\r
 {\r
     using System.Windows;\r
+    using System.Windows.Input;\r
 \r
+    using HandBrakeWPF.Commands;\r
     using HandBrakeWPF.ViewModels.Interfaces;\r
 \r
     /// <summary>\r
@@ -24,6 +26,22 @@ namespace HandBrakeWPF.Views
         public ShellView()\r
         {\r
             this.InitializeComponent();\r
+\r
+            // Start Encode (Ctrl+S)\r
+            // Stop Encode (Ctrl+K)\r
+            // Open Log Window (Ctrl+L)\r
+            // Open Queue Window (Ctrl+Q)\r
+            // Add to Queue (Ctrl+A)\r
+            // Scan a File (Ctrl+F)\r
+            // Scan a Folder (Ctrl+R)\r
+\r
+            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.S, ModifierKeys.Control)), new KeyGesture(Key.S, ModifierKeys.Control)));\r
+            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.K, ModifierKeys.Control)), new KeyGesture(Key.K, ModifierKeys.Control)));\r
+            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.L, ModifierKeys.Control)), new KeyGesture(Key.L, ModifierKeys.Control)));\r
+            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.Q, ModifierKeys.Control)), new KeyGesture(Key.Q, ModifierKeys.Control)));\r
+            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control)), new KeyGesture(Key.A, ModifierKeys.Control)));\r
+            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.F, ModifierKeys.Control)), new KeyGesture(Key.F, ModifierKeys.Control)));\r
+            this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.R, ModifierKeys.Control)), new KeyGesture(Key.R, ModifierKeys.Control)));\r
         }\r
 \r
         /// <summary>\r