示例#1
0
        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);
            }
        }
示例#2
0
        /// <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));
        }
示例#3
0
        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();
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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));
            }
        }
示例#6
0
        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;
            }
        }