private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            AIRule rule = new AIRule();
            rule.ID = "Rule_" + mRUles.Rules.Count;

            CommandManager.Execute(new AddRule(mRUles, rule));
        }
Пример #2
0
 public AddRule(AIRulesList list, AIRule rule)
 {
     mList = list;
     mRule = rule;
     mRule.Action = new AIAction();
     mRule.Action.ID = "-1";
     mRule.Priority = new Script();
     mRule.Priority.Code = "";
     mRule.Condition = new Script();
     mRule.Condition.Code = "";
     mRule.Target = new ActionTarget();
     mRule.Target.Selector = new TargetSelector();
     mRule.Target.Selector.ID = "-1";
 }
Пример #3
0
        XElement SaveRule(AIRule rule)
        {
            XElement e = new XElement("AIRule");

            e.SetAttributeValue("ID", rule.ID);
            e.SetAttributeValue("ActionID", rule.Action.ID);
            e.SetAttributeValue("Condition", rule.Condition.Code);
            e.SetAttributeValue("Priority", rule.Priority.Code);
            e.SetAttributeValue("Target", rule.Target.Selector.ID);
            e.Add(SaveAction(rule.Action));
            e.Add(SaveTargetSelector(rule.Target.Selector));

            return(e);
        }
Пример #4
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     AIRule rule = new AIRule();
     repeat:
     foreach (AIRule i in mRules.Rules)
         if (i.ID == IDgenerator.ToString())
         {
             IDgenerator++;
             goto repeat;
         }
     rule.ID = IDgenerator.ToString();
     Commands.AddRule command = new Commands.AddRule(mRules, rule);
     mCommandManager.Execute(command);
     list.SelectedIndex = mRules.Rules.IndexOf(rule);
 }
Пример #5
0
 public AIRule LoadRule(XElement element)
 {
     AIRule rule = new AIRule();
     rule.Action = new AIAction();
     rule.Priority = new Script();
     rule.Condition = new Script();
     rule.Target = new ActionTarget();
     rule.Target.Selector = new TargetSelector();
     rule.ID = element.Attribute("ID").Value;
     rule.Action.ID = element.Attribute("ActionID").Value;
     rule.Condition.Code = element.Attribute("Condition").Value;
     rule.Priority.Code = element.Attribute("Priority").Value;
     rule.Target.Selector.ID = element.Attribute("Target").Value;
     return rule;
 }
Пример #6
0
        public AIRule LoadRule(XElement element)
        {
            AIRule rule = new AIRule();

            rule.Action          = new AIAction();
            rule.Priority        = new Script();
            rule.Condition       = new Script();
            rule.Target          = new ActionTarget();
            rule.Target.Selector = new TargetSelector();
            rule.ID                 = element.Attribute("ID").Value;
            rule.Action.ID          = element.Attribute("ActionID").Value;
            rule.Condition.Code     = element.Attribute("Condition").Value;
            rule.Priority.Code      = element.Attribute("Priority").Value;
            rule.Target.Selector.ID = element.Attribute("Target").Value;
            return(rule);
        }
Пример #7
0
        public AIRulesList LoadFromFile(String fileName)
        {
            AIRulesList mRules = new AIRulesList();
            //читаем данные из файла
            XDocument doc = XDocument.Load(fileName);

            foreach (XElement e in doc.Root.Elements())
            {
                AIRule         rule       = LoadRule(e);
                AIAction       ruleAction = LoadAction(e);
                TargetSelector ruleTarget = LoadTarget(e);
                mRules.Rules.Add(rule);
                mRules.Actions.Add(ruleAction);
                mRules.TargetSelectors.Add(ruleTarget);
            }
            return(mRules);
        }
Пример #8
0
        private void btnDel_Click(object sender, RoutedEventArgs e)
        {
            int current = list.SelectedIndex;
            if (current != -1)
            {
                AIRule rule = new AIRule();
                foreach (AIRule r in mRules.Rules)
                {
                    if (r.ID == text.Text)
                        rule = r;
                }
                Commands.DelRule command = new Commands.DelRule(mRules, rule);
                mCommandManager.Execute(command);
                if (current != list.Items.Count)
                    list.SelectedIndex = current;
                else
                    list.SelectedIndex = current - 1;

            }
            else
                MessageBox.Show("Выберите элемент");
        }
Пример #9
0
 private void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (list.SelectedIndex != -1)
     {
         AIRule rule = new AIRule();
         rule = mRules.Rules.ElementAt(list.SelectedIndex);
         text.Text = rule.ID;
         comboBox1.SelectedIndex = int.Parse(rule.Action.ID);
         text3.Text = rule.Priority.Code;
         text2.Text = rule.Condition.Code;
         comboBox2.SelectedIndex = int.Parse(rule.Target.Selector.ID);
     }
     else
     {
         text.Text = "";
         comboBox1.SelectedIndex = -1;
         text3.Text = "";
         text2.Text = "";
         comboBox2.SelectedIndex = -1;
     }
 }
Пример #10
0
 public SetAction(AIRule rule, String ActionID)
 {
     mRule = rule;
     newActionID = ActionID;
     oldActionID = rule.Action.ID;
 }
Пример #11
0
 public DelRule(AIRulesList list, AIRule rule)
 {
     mList = list;
     mRule = rule;
 }
Пример #12
0
 public SetCondition(AIRule rule, String condition)
 {
     mRule = rule;
     oldCondition = rule.Condition.Code;
     newCondition = condition;
 }
Пример #13
0
        XElement SaveRule(AIRule rule)
        {
            XElement e = new XElement("AIRule");
            e.SetAttributeValue("ID", rule.ID);
            e.SetAttributeValue("ActionID", rule.Action.ID);
            e.SetAttributeValue("Condition", rule.Condition.Code);
            e.SetAttributeValue("Priority", rule.Priority.Code);
            e.SetAttributeValue("Target", rule.Target.Selector.ID);
            e.Add(SaveAction(rule.Action));
            e.Add(SaveTargetSelector(rule.Target.Selector));

            return e;
        }
Пример #14
0
 public SetTargetSelector(AIRule rule, String TargetID)
 {
     mRule = rule;
     newTargetID = TargetID;
     oldTargetID = rule.Target.Selector.ID;
 }
Пример #15
0
 public SetPriority(AIRule rule, String priority)
 {
     mRule = rule;
     oldPriority = rule.Priority.Code;
     newPriority = priority;
 }
Пример #16
0
 public SetID(AIRule rule, String id)
 {
     mRule = rule;
     oldID = rule.ID;
     newID = id;
 }