private void RefreshButton() { RegularExpressionItem item = GetSelectedItem(); this.buttonModifyItem.Enabled = item != null && _isEdit; this.buttonDeleteItem.Enabled = item != null; this.buttonAddItem.Enabled = _isEdit; }
private void Add() { RegularExpressionItem item = new RegularExpressionItem(); item.Description = this.textBoxDescription.Text; item.Expression = this.textBoxRegExpression.Text; item.Replacement = this.textBoxReplacement.Text; Program.ConfigMgt.Config.RegularExpressions.Add(item); _isEdit = false; RefreshList(); SelectItem(item); }
private void SelectItem(RegularExpressionItem item) { if (item == null) { return; } foreach (ListViewItem i in this.listViewList.Items) { if (item == i.Tag as RegularExpressionItem) { i.Selected = true; break; } } }
private void Delete() { RegularExpressionItem item = GetSelectedItem(); if (item == null) { return; } Program.ConfigMgt.Config.RegularExpressions.Remove(item); RefreshList(); RefreshText(); RefreshButton(); }
private void Edit() { RegularExpressionItem item = GetSelectedItem(); if (item == null) { return; } item.Description = this.textBoxDescription.Text; item.Expression = this.textBoxRegExpression.Text; item.Replacement = this.textBoxReplacement.Text; RefreshList(); RefreshText(); RefreshButton(); }
private void Import() { FormRegExpression frm = new FormRegExpression(); if (frm.ShowDialog(this) != DialogResult.OK) { return; } RegularExpressionItem item = frm.RegExpression; if (item == null) { return; } this.textBoxDescription.Text = item.Description; this.textBoxReplacement.Text = item.Replacement; this.textBoxRegExpression.Text = item.Expression; }
private void RefreshText() { _isEdit = false; _isLock = true; RegularExpressionItem item = GetSelectedItem(); if (item == null) { this.textBoxDescription.Text = ""; this.textBoxRegExpression.Text = ""; this.textBoxReplacement.Text = ""; } else { this.textBoxReplacement.Text = item.Replacement; this.textBoxRegExpression.Text = item.Expression; this.textBoxDescription.Text = item.Description; } _isLock = false; }