--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\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
// </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
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