/// <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(); } }
/// <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(); }
/// <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(); }
/// <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(); } }
/// <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(); } }
/// <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(); } }
/// <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(); } }
/// <summary> /// конструктор окна редактирования /// </summary> public EditDB() { InitializeComponent(); knowlegeBase = XMLDataLoader.Deserialize(); Load_CB(); }