summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Commands
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-07-08 11:25:45 +0000
committersr55 <[email protected]>2012-07-08 11:25:45 +0000
commitda44aa82136fb9423f041b200b3e40632b8287e7 (patch)
tree3488aa667e0bcb0b8a54eec8c11fd8f98e3c2c41 /win/CS/HandBrakeWPF/Commands
parent7746907bf0ae4ef3f02aaa28a34a493dade912a2 (diff)
WinGui: Add support for keyboard shortcuts. These are slightly different to the old UI. See Below.
// 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
Diffstat (limited to 'win/CS/HandBrakeWPF/Commands')
-rw-r--r--win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs111
1 files changed, 111 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs b/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs
new file mode 100644
index 000000000..cc5b546a2
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs
@@ -0,0 +1,111 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ProcessShortcutCommand.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Keyboard Shortcut Processor
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Commands
+{
+ using System;
+ using System.Windows.Input;
+
+ using Caliburn.Micro;
+
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// Keyboard Shortcut Processor
+ /// </summary>
+ public class ProcessShortcutCommand : ICommand
+ {
+ /// <summary>
+ /// The Gesture
+ /// </summary>
+ private readonly KeyGesture gesture;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ProcessShortcutCommand"/> class.
+ /// </summary>
+ /// <param name="gesture">
+ /// The gesture.
+ /// </param>
+ public ProcessShortcutCommand(KeyGesture gesture)
+ {
+ this.gesture = gesture;
+ }
+
+ /// <summary>
+ /// Defines the method to be called when the command is invoked.
+ /// </summary>
+ /// <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>
+ public void Execute(object parameter)
+ {
+ if (gesture != null)
+ {
+ IMainViewModel mainViewModel = IoC.Get<IMainViewModel>();
+
+ // Start Encode (Ctrl+S)
+ if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.S)
+ {
+ mainViewModel.StartEncode();
+ }
+
+ // Stop Encode (Ctrl+K)
+ if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.K)
+ {
+ mainViewModel.StopEncode();
+ }
+
+ // Open Log Window (Ctrl+L)
+ if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.L)
+ {
+ mainViewModel.OpenLogWindow();
+ }
+
+ // Open Queue Window (Ctrl+Q)
+ if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.Q)
+ {
+ mainViewModel.OpenQueueWindow();
+ }
+
+ // Add to Queue (Ctrl+A)
+ if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.A)
+ {
+ mainViewModel.AddToQueue();
+ }
+
+ // Scan a File (Ctrl+F)
+ if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.F)
+ {
+ mainViewModel.FileScan();
+ }
+
+ // Scan a Folder (Ctrl+R)
+ if (gesture.Modifiers == ModifierKeys.Control && gesture.Key == Key.R)
+ {
+ mainViewModel.FolderScan();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Defines the method that determines whether the command can execute in its current state.
+ /// </summary>
+ /// <returns>
+ /// true if this command can be executed; otherwise, false.
+ /// </returns>
+ /// <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>
+ public bool CanExecute(object parameter)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// Can Execute Changed
+ /// </summary>
+ public event EventHandler CanExecuteChanged;
+ }
+}