예제 #1
0
        private void EditHotkeyCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            if (SelectedHotkey == null)
            {
                return;
            }

            var originalHotKey   = SelectedHotkey;
            var hotKeyEditDialog = new HotkeyEditDialog {
                DataContext = originalHotKey.Clone(), Owner = (Window)obj
            };
            var dialogResult = hotKeyEditDialog.ShowDialog();

            if (!dialogResult.HasValue || !dialogResult.Value)
            {
                return;
            }

            var changedHotKey = (HotkeyViewModel)hotKeyEditDialog.DataContext;

            if (originalHotKey.HotkeyGroup == changedHotKey.HotkeyGroup)
            {
                var originalIndex = originalHotKey.HotkeyGroup.Hotkeys.IndexOf(originalHotKey);
                originalHotKey.HotkeyGroup.InsertHotkey(originalIndex, (HotkeyViewModel)hotKeyEditDialog.DataContext);
            }
            else
            {
                changedHotKey.HotkeyGroup.AddHotkey(changedHotKey);
            }

            originalHotKey.HotkeyGroup.RemoveHotkey(originalHotKey);
            SelectedHotkey = (HotkeyViewModel)hotKeyEditDialog.DataContext;
        }
예제 #2
0
        private void AddHotkeyCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            var hotkey = new Hotkey();

            hotkey.Actions.Add(new SendTextAction());
            var hotKeyToAdd      = new HotkeyViewModel(Groups, Groups.First(g => g.IsBuildIn), hotkey, _actionDescriptions);
            var hotKeyEditDialog = new HotkeyEditDialog {
                DataContext = hotKeyToAdd, Owner = (Window)obj
            };
            var dialogResult = hotKeyEditDialog.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value)
            {
                hotKeyToAdd.HotkeyGroup.AddHotkey(hotKeyToAdd);
            }
        }