private void btAddShortcut_Click(object sender, EventArgs e) { var sc = new ShortcutItemConfiguration(); if (sc.ShowDialog(this) == DialogResult.OK) { var s = sc.GetShortcut(); lvShortcuts.Items.Add(new ListViewItem(new string[] { s.KeyCombo.ToString(), string.Join(", ", s.ActionChain.ActionItems.Select(ai => ai.ActionType.DisplayText())) }) { Checked = s.Enabled, Tag = s, Group = s.RequirePreviewOpen ? lvShortcuts.Groups["lvgPreview"] : lvShortcuts.Groups["lvgGlobal"] }); Configuration.Shortcuts.Add(s); Configuration.Write(); } }
private void btEditShortcut_Click(object sender, EventArgs e) { if (lvShortcuts.SelectedIndices.Count > 0) { var shortcut = Configuration.Shortcuts[lvShortcuts.SelectedIndices[0]]; var sc = new ShortcutItemConfiguration(shortcut); if (sc.ShowDialog(this) == DialogResult.OK) { var s = sc.GetShortcut(); Configuration.Shortcuts[lvShortcuts.SelectedIndices[0]] = s; lvShortcuts.SelectedItems[0].Group = s.RequirePreviewOpen ? lvShortcuts.Groups["lvgPreview"] : lvShortcuts.Groups["lvgGlobal"]; lvShortcuts.SelectedItems[0].Tag = s; lvShortcuts.SelectedItems[0].SubItems[0].Text = s.KeyCombo.ToString(); lvShortcuts.SelectedItems[0].SubItems[1].Text = string.Join(", ", s.ActionChain.ActionItems.Select(ai => ai.ActionType.DisplayText())); Configuration.Write(); } } }