예제 #1
0
 private void addNewRuleOperation()
 {
     var form = new RuleForm("Rule #" + (ruleTreeView.Nodes[0].Nodes.Count + 1));
     if (form.ShowDialog() == DialogResult.OK)
     {
         ICategory category = form.GetCategory();
         IAction action = form.GetAction();
         var newRule = new Rule(category, form.GetRuleName());
         newRule.Action = action;
         newRule.Condition = new AndCondition();
         TreeNode ruleSetNode = ruleTreeView.Nodes[0];
         var ruleSet = ruleSetNode.Tag as RuleSet;
         ruleSet.AddRule(newRule);
         // Add tree node.
         TreeNode ruleNode = RuleSet2TreeNodeProcessor.GetRuleTreeNode(newRule);
         ruleNode.ExpandAll();
         ruleSetNode.Nodes.Add(ruleNode);
         SetModified(true);
     }
 }
예제 #2
0
 private void addNewRuleFromHereOperation(IMatchTarget matchTarget)
 {
     if (!HasRuleSet())
     {
         MessageBox.Show(Resource.FormatString("Wrn_NoRuleFileToAddRuleTo"));
         return;
     }
     ICategory fixedCategory = matchTarget.GetCategory();
     var form = new RuleForm(fixedCategory,
         "Rule #" + (ruleTreeView.Nodes[0].Nodes.Count + 1));
     if (form.ShowDialog() == DialogResult.OK)
     {
         IAction action = form.GetAction();
         AndCondition andCondition = ExtractDefaultConditions(matchTarget);
         var newRule = new Rule(fixedCategory, action, andCondition, form.GetRuleName());
         var ruleSet = ruleTreeView.Nodes[0].Tag as RuleSet;
         ruleSet.AddRule(newRule);
         // Add tree node.
         TreeNode ruleNode = RuleSet2TreeNodeProcessor.GetRuleTreeNode(newRule);
         ruleNode.ExpandAll();
         ruleTreeView.Nodes[0].Nodes.Add(ruleNode);
         // set modified
         SetModified(true);
     }
 }