private void NewTextRuleBtn_Click(object sender, EventArgs e) { TextRuleEditForm form = new TextRuleEditForm(true); if (form.ShowDialog() == DialogResult.OK) { string dt = DateTime.Now.ToString() + "." + DateTime.Now.Millisecond.ToString(); ExtractRule textRule = new ExtractRule(dt, form.StartLabel, form.EndLabel, ""); textRule.ExtractRuleState = WebRuleState.New; textRule.IsStateChange = true; activeRule.ExtractRuleCollection.Add(textRule); this.TextRuleNameComboBox.Items.Add(dt); this.TextRuleNameComboBox.Text = dt; } }
private void DelTextRuleBtn_Click(object sender, EventArgs e) { //得到当前操作的ExtractRule对象 string name = this.TextRuleNameComboBox.Text; ExtractRule delRule = activeRule.ExtractRuleCollection[name]; if (MessageBox.Show("确定要删除", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { if (delRule.ExtractRuleState == WebRuleState.New) { activeRule.ExtractRuleCollection.Remove(delRule); } else { delRule.ExtractRuleState = WebRuleState.Delete; delRule.IsStateChange = true; } this.TextRuleNameComboBox.Items.Remove(name); } }
private void ModifyTextRuleBtn_Click(object sender, EventArgs e) { //得到当前操作的ExtractRule对象 string name = this.TextRuleNameComboBox.Text; ExtractRule modRule = activeRule.ExtractRuleCollection[name]; if (modRule.ExtractRuleState != WebRuleState.New) { modRule.ExtractRuleState = WebRuleState.Modify; modRule.IsStateChange = true; } TextRuleEditForm form = new TextRuleEditForm(false); form.StartLabel = modRule.Start; form.EndLabel = modRule.End; if (form.ShowDialog() == DialogResult.OK) { modRule.Start = form.StartLabel; modRule.End = form.EndLabel; } }