private void _addRuleButton_Click(object sender, EventArgs e) { var newRule = new MatchRule(); using (var regexForm = new RegexRuleForm(newRule)) { if (regexForm.ShowDialog(this) == DialogResult.OK) { _rulesListView.Items.Add(new RegexRuleListItem(newRule)); UpdateEnabledState(); } } }
private void _editRuleButton_Click(object sender, EventArgs e) { if (_rulesListView.SelectedItems.Count > 0) { var regexItem = _rulesListView.SelectedItems[0] as RegexRuleListItem; if (regexItem == null) { return; } var rule = regexItem.GetRule(); using (var regexForm = new RegexRuleForm(rule)) { if (regexForm.ShowDialog(this) == DialogResult.OK) { regexItem.SetRule(rule); } } } }