Ejemplo n.º 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;
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="index"></param>
 /// <param name="hotkeyToAdd"></param>
 public void InsertHotkey(int index, [NotNull] HotkeyViewModel hotkeyToAdd)
 {
     Assert.ArgumentNotNull(hotkeyToAdd, "hotkeyToAdd");
     Group.Hotkeys.Insert(index, hotkeyToAdd.Hotkey);
     _hotkeys.Insert(index, hotkeyToAdd);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Removes the hot key.
 /// </summary>
 /// <param name="hotkeyToRemove">The hot key to remove.</param>
 public void RemoveHotkey([NotNull] HotkeyViewModel hotkeyToRemove)
 {
     Assert.ArgumentNotNull(hotkeyToRemove, "hotkeyToRemove");
     Group.Hotkeys.Remove(hotkeyToRemove.Hotkey);
     _hotkeys.Remove(hotkeyToRemove);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the hot key.
 /// </summary>
 /// <param name="hotkeyToAdd">The hot key to add.</param>
 public void AddHotkey([NotNull] HotkeyViewModel hotkeyToAdd)
 {
     Assert.ArgumentNotNull(hotkeyToAdd, "hotkeyToAdd");
     Group.Hotkeys.Add(hotkeyToAdd.Hotkey);
     _hotkeys.Add(hotkeyToAdd);
 }