Example #1
0
        /// <summary>
        /// добавление правила
        /// </summary>
        private void RAdd_Click(object sender, RoutedEventArgs e)
        {
            if (RIf.Text.Length > 0 && RThen.SelectedItem != null)
            {
                List <Fact> fl = new List <Fact>();
                string      s  = RIf.Text;
                string[]    t  = s.Split('&');
                foreach (string k in t)
                {
                    fl.Add(knowlegeBase.Facts.Find(x => x.Title == k));
                }
                Conclusion c = new Conclusion();
                c.Title = RThen.SelectedItem.ToString();

                ////////формирование строки
                string rule = string.Empty;
                rule += "IF (";
                foreach (var fact in fl)
                {
                    rule += fact + "&";
                }
                rule  = rule.Substring(0, rule.Length - 1);
                rule += ") THEN " + c;
                ////////
                knowlegeBase.RulesViews.Add(rule);
                XMLDataLoader.Serialize(knowlegeBase);
                Load_CB();
                FQ.Clear();
            }
        }
Example #2
0
 /// <summary>
 /// добавление факта
 /// </summary>
 private void FAdd_Click(object sender, RoutedEventArgs e)
 {
     if (FTitle.Text.Length > 0 && FQ.Text.Length > 0)
     {
         Fact f = new Fact();
         f.ConditionTitle = FCTitle.Text;
         f.Title          = FTitle.Text;
         f.Question       = FQ.Text;
         knowlegeBase.Facts.Add(f);
         XMLDataLoader.Serialize(knowlegeBase);
         Load_CB();
         FQ.Clear();
     }
 }