示例#1
0
        /// <summary>Handles a shortcut item's delete button being pressed.</summary>
        private void DeleteKeybind(ShortcutItem sender, Keybind keybindTarget)
        {
            keybinds.Remove(keybindTarget);              // delete keybind
            keyList.Children.Remove(sender);             // delete UI representing keybind

            TriggerKeybindChange(sender, keybindTarget); // Trigger a change event
        }
示例#2
0
        /// <summary>Creates a new keybind/shortcut list item and assigns the relevant listeners.</summary>
        /// <param name="k">Keybind that the shortcut item will represent.</param>
        private ShortcutItem CreateShortcutItem(Keybind k)
        {
            ShortcutItem s = new ShortcutItem(k);

            keyList.Children.Add(s);
            s.KeybindChange   += TriggerKeybindChange;
            s.DeleteTriggered += DeleteKeybind;
            return(s);
        }
示例#3
0
        /// <summary>Triggered when the add new button is pressed.</summary>
        private void addNew_Click(object sender, RoutedEventArgs e)
        {
            // Create a keybind object and a shortcut item to represent it
            Keybind k = new Keybind();

            keybinds.Add(k);
            ShortcutItem s = CreateShortcutItem(k);

            TriggerKeybindChange(s, k); // Trigger a change event (since there is a new item)
        }
示例#4
0
 /// <summary>Handler for keybind's change event and can be called manually to fire a change event.</summary>
 private void TriggerKeybindChange(ShortcutItem item, Keybind @new)
 {
     KeybindsChanged?.Invoke(this);
 }