// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Keyboard Shortcut Processor // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Commands { using System; using System.Windows.Input; using Caliburn.Micro; using HandBrakeWPF.ViewModels.Interfaces; /// /// Keyboard Shortcut Processor /// public class ProcessShortcutCommand : ICommand { /// /// The Gesture /// private readonly KeyGesture gesture; /// /// Initializes a new instance of the class. /// /// /// The gesture. /// public ProcessShortcutCommand(KeyGesture gesture) { this.gesture = gesture; } /// /// Defines the method to be called when the command is invoked. /// /// Data used by the command. If the command does not require data to be passed, this object can be set to null. public void Execute(object parameter) { if (gesture != null) { IMainViewModel mainViewModel = IoC.Get(); // 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(); } if (gesture.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift) && gesture.Key == Key.D) { mainViewModel.ShowCliQuery(); } } } /// /// Defines the method that determines whether the command can execute in its current state. /// /// /// true if this command can be executed; otherwise, false. /// /// Data used by the command. If the command does not require data to be passed, this object can be set to null. public bool CanExecute(object parameter) { return true; } /// /// Can Execute Changed /// public event EventHandler CanExecuteChanged; } }