private void AddHotkeyCommandExecute([NotNull] object obj) { Assert.ArgumentNotNull(obj, "obj"); var oldHotkey = new Hotkey(); oldHotkey.Actions.Add(new SendTextAction()); var hotKeyToAdd = new GlobalHotkeyViewModel(oldHotkey, _actionDescriptions); var hotKeyEditDialog = new GlobalHotkeyEditDialog { DataContext = hotKeyToAdd, Owner = (Window)obj }; var dialogResult = hotKeyEditDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { var hotkeyViewModel = Hotkeys.FirstOrDefault(hotk => hotk.Key == hotKeyToAdd.Key && hotk.ModifierKeys == hotKeyToAdd.ModifierKeys); if (hotkeyViewModel != null) { Hotkeys.Remove(hotkeyViewModel); } var hotkey = _hotkeys.FirstOrDefault(hotk => hotk.Key == hotKeyToAdd.Key && hotk.ModifierKeys == hotKeyToAdd.ModifierKeys); if (hotkey != null) { _hotkeys.Remove(hotkey); } Hotkeys.Add(hotKeyToAdd); _hotkeys.Add(hotKeyToAdd.Hotkey); } }
/// <summary> /// duplicated from GitExtensionsForm /// </summary> /// <param name="commandCode"></param> /// <returns></returns> private HotkeyCommand GetHotkeyCommand(int commandCode) { if (Hotkeys == null) { return(null); } return(Hotkeys.FirstOrDefault(h => h.CommandCode == commandCode)); }
public void TriggerHotkey(int key, int modifier, int id) { Hotkey triggeredHotkey = Hotkeys.FirstOrDefault(m => m.Key == key && m.Modifier == modifier && m.ID == id); if (triggeredHotkey == null) { throw new Exception("The triggered hotkey was null! Is there a loose hotkey still registered?"); } triggeredHotkey.HotkeyTriggered(); }
private void DeleteHotkeyCommandExecute([CanBeNull] object obj) { if (SelectedHotkey == null) { return; } var hotkey = _hotkeys.FirstOrDefault(hotk => hotk.Key == SelectedHotkey.Key && hotk.ModifierKeys == SelectedHotkey.ModifierKeys); if (hotkey != null) { _hotkeys.Remove(hotkey); } var hotkeyViewModel = Hotkeys.FirstOrDefault(hotk => hotk.Key == SelectedHotkey.Key && hotk.ModifierKeys == SelectedHotkey.ModifierKeys); if (hotkeyViewModel != null) { Hotkeys.Remove(hotkeyViewModel); } }
protected override bool ExecuteCommand(int cmd) { if (fnbImage.Focused || fnbVideo.Focused) { return(false); } if (capturedFilesView.Editing) { return(false); } if (!presenter.Synched) { return(ExecuteScreenCommand(cmd)); } // If we are in dual capture mode, check if the command is handled by the common controls. HotkeyCommand command = Hotkeys.FirstOrDefault(h => h != null && h.CommandCode == cmd); if (command == null) { return(false); } bool dualCaptureHandled = HotkeySettingsManager.IsHandler("DualCapture", command.KeyData); if (dualCaptureHandled && DualCommandReceived != null) { DualCommandReceived(this, new EventArgs <HotkeyCommand>(command)); return(true); } else { return(ExecuteScreenCommand(cmd)); } }
private void EditHotkeyCommandExecute([NotNull] object obj) { Assert.ArgumentNotNull(obj, "obj"); if (SelectedHotkey == null) { return; } var hotkeyViewModel = SelectedHotkey.Clone(); var hotKeyEditDialog = new GlobalHotkeyEditDialog { DataContext = hotkeyViewModel, Owner = (Window)obj }; var dialogResult = hotKeyEditDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { var hotkeyViewModelToRemove = Hotkeys.FirstOrDefault(hotk => hotk.Key == hotkeyViewModel.Key && hotk.ModifierKeys == hotkeyViewModel.ModifierKeys); if (hotkeyViewModelToRemove != null) { Hotkeys.Remove(hotkeyViewModelToRemove); } var hotkey = _hotkeys.FirstOrDefault(hotk => hotk.Key == hotkeyViewModel.Key && hotk.ModifierKeys == hotkeyViewModel.ModifierKeys); if (hotkey != null) { _hotkeys.Remove(hotkey); } Hotkeys.Add(hotkeyViewModel); _hotkeys.Add(hotkeyViewModel.Hotkey); SelectedHotkey = hotkeyViewModel; } }