private void btnEdit_Click(object sender, EventArgs e) { if (lvRules.SelectedItems.Count > 0) { int index = (int)lvRules.SelectedItems[0].Tag; if (index < lvRules.Items.Count) { RuleForm form = new RuleForm(); HttpRule rule = httpRules[index]; form.Init(rule); if (form.ShowDialog() == DialogResult.OK) { UpdateListView(httpRules); } } } }
private void btnAdd_Click(object sender, EventArgs e) { RuleForm form = new RuleForm(); HttpRule rule = new HttpRule() { Name = "Новое правило", Active = true, RequestResponse = RequestResponce.Request, Action = HttpAction.FindReplace, UrlSearchPattern = "Шаблон Url", SearchPattern = "Шаблон поиска", ReplaceStr = "строка для замены" }; form.Init(rule); if (form.ShowDialog() == DialogResult.OK) { httpRules.Add(rule); UpdateListView(httpRules); } }