예제 #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();
            }
        }
예제 #2
0
 /// <summary>
 /// запуск программы заного
 /// </summary>
 public void Again()
 {
     knowlegeBase = XMLDataLoader.Deserialize();
     knowlegeBase.LoadRules();
     workMemory     = new WorkMemory(knowlegeBase.Facts);
     confirmedFacts = new List <Fact>();
     title          = string.Empty;
     ybtn.IsEnabled = true;
     nbtn.IsEnabled = true;
     ExplW.Clear();
     Run();
 }
예제 #3
0
 /// <summary>
 /// конструктор окна
 /// </summary>
 public MainWindow()
 {
     InitializeComponent();
     knowlegeBase = XMLDataLoader.Deserialize();
     knowlegeBase.LoadRules();
     workMemory     = new WorkMemory(knowlegeBase.Facts);
     confirmedFacts = new List <Fact>();
     facts          = new List <string>();
     ExplW          = new ExplanationWindow();
     title          = string.Empty;
     Run();
 }
예제 #4
0
 /// <summary>
 /// добавление вывода
 /// </summary>
 private void CAdd_Click(object sender, RoutedEventArgs e)
 {
     if (CT.Text.Length > 0)
     {
         Conclusion c = new Conclusion();
         c.Title = CT.Text;
         knowlegeBase.Conclusions.Add(c);
         XMLDataLoader.Serialize(knowlegeBase);
         Load_CB();
         CT.Clear();
     }
 }
예제 #5
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();
     }
 }
예제 #6
0
 /// <summary>
 /// удаление вывода
 /// </summary>
 private void CD_Click(object sender, RoutedEventArgs e)
 {
     if (CCb.SelectedItem != null)
     {
         for (int i = 0; i < knowlegeBase.Conclusions.Count; i++)
         {
             if (knowlegeBase.Conclusions[i].Title == CCb.SelectedItem.ToString())
             {
                 knowlegeBase.Conclusions.Remove(knowlegeBase.Conclusions[i]);
             }
         }
         XMLDataLoader.Serialize(knowlegeBase);
         Load_CB();
     }
 }
예제 #7
0
 /// <summary>
 /// удаление правила
 /// </summary>
 private void RD_Click(object sender, RoutedEventArgs e)
 {
     if (RCb.SelectedItem != null)
     {
         for (int i = 0; i < knowlegeBase.RulesViews.Count; i++)
         {
             if (knowlegeBase.RulesViews[i] == RCb.SelectedItem.ToString())
             {
                 knowlegeBase.RulesViews.Remove(knowlegeBase.RulesViews[i]);
             }
         }
         XMLDataLoader.Serialize(knowlegeBase);
         Load_CB();
     }
 }
예제 #8
0
 /// <summary>
 /// конструктор окна редактирования
 /// </summary>
 public EditDB()
 {
     InitializeComponent();
     knowlegeBase = XMLDataLoader.Deserialize();
     Load_CB();
 }