public Shortcut(Shortcut stc) { Text = stc.Text; ObjectName = stc.Text; Method = stc.Method; Key = stc.Key; Alt = stc.Alt; Ctrl = stc.Ctrl; Shift = stc.Shift; IsMenu = stc.IsMenu; }
public void Add(string text, string obj, string method, Keys key = Keys.None, bool alt = false, bool ctrl = false, bool shift = false, bool ismenu = false) { if (this.ContainsKey(key, alt, ctrl, shift)) throw new ArgumentException("已添加了具有相同键的项。"); Shortcut stc = new Shortcut(text, obj, method, key, alt, ctrl, shift, ismenu); if (this.ContainsText(text)) this[text] = stc; else items.Add(stc); }
public void Add(Shortcut item) { if (this.ContainsKey(item.Key, item.Alt, item.Ctrl, item.Shift)) throw new ArgumentException("已添加了具有相同键的项。"); if (this.ContainsText(item.Text)) this[item.Text] = item; else items.Add(item); }
private void listViewKeys_SelectedIndexChanged(object sender, EventArgs e) { if (listViewKeys.SelectedItems.Count == 0) return; currShortcut = new Shortcut(shortcuts[listViewKeys.SelectedItems[0].Text]); textBoxKeys.Text = ShortcutKey2String(currShortcut.Key, currShortcut.Alt, currShortcut.Ctrl, currShortcut.Shift); }