private void UpdateControls() { QuickColorizer colorizer = GetSelectedQuickColorizer(); buttonRemoveQuickColorizer.Enabled = colorizer != null; buttonModifyQuickColorizer.Enabled = colorizer != null; }
private void buttonModifyQuickColorizer_Click(object sender, EventArgs e) { QuickColorizer colorizer = GetSelectedQuickColorizer(); if (colorizer == null) { return; } QuickColorizerEdit edit = new QuickColorizerEdit(colorizer); DialogResult dr = edit.ShowDialog(this); listViewQuickColorizers.Focus(); if (dr != DialogResult.OK) { return; } QuickColorizer existing = GetExistingQuickColorizer(edit.QuickColorizer); if ((existing != null) && (existing != edit.QuickColorizer)) { Remove(edit.QuickColorizer); return; } ListViewItem item = listViewQuickColorizers.SelectedItems[0]; item.Text = edit.QuickColorizer.Active.ToString(); item.SubItems[1].Text = edit.QuickColorizer.IgnoreCase.ToString(); item.SubItems[2].Text = edit.QuickColorizer.WholeText.ToString(); item.SubItems[3].Text = edit.QuickColorizer.ColorSet != null?edit.QuickColorizer.ColorSet.ToString() : string.Empty; item.SubItems[4].Text = edit.QuickColorizer.Text; }
private static ListViewItem GetQuickColorizerItem(QuickColorizer colorizer) { var item = new ListViewItem(colorizer.Active.ToString()); item.SubItems.Add(colorizer.IgnoreCase.ToString()); item.SubItems.Add(colorizer.WholeText.ToString()); item.SubItems.Add(colorizer.ColorSet != null ? colorizer.ColorSet.ToString() : string.Empty); item.SubItems.Add(colorizer.Text); item.Tag = colorizer; return(item); }
private void buttonRemoveQuickColorizer_Click(object sender, EventArgs e) { QuickColorizer colorizer = GetSelectedQuickColorizer(); if (colorizer == null) { return; } listViewQuickColorizers.SelectedItems[0].Remove(); }
public QuickColorizerEdit(QuickColorizer colorizer) { if (colorizer == null) { colorizer = new QuickColorizer(); } QuickColorizer = colorizer; InitializeComponent(); textBoxDefinition.Text = colorizer.Text; textBoxColor.Text = colorizer.ColorSet != null?colorizer.ColorSet.ToString() : string.Empty; textBoxColor.Tag = colorizer.ColorSet; checkBoxIgnoreCase.Checked = colorizer.IgnoreCase; checkBoxWholeText.Checked = colorizer.WholeText; checkBoxActive.Checked = colorizer.Active; UpdateControls(); }
private void buttonAddQuickColorizer_Click(object sender, EventArgs e) { QuickColorizerEdit edit = new QuickColorizerEdit(null); DialogResult dr = edit.ShowDialog(this); listViewQuickColorizers.Focus(); if (dr != DialogResult.OK) { return; } QuickColorizer existing = GetExistingQuickColorizer(edit.QuickColorizer); if (existing != null) { GetQuickColorizerItem(existing).Selected = true; return; } listViewQuickColorizers.Items.Add(GetQuickColorizerItem(edit.QuickColorizer)).Selected = true; }
private QuickColorizer GetExistingQuickColorizer(QuickColorizer colorizer) { return(AllQuickColorizers.FirstOrDefault(c => c.Equals(colorizer))); }