private void Button_Click(object sender, RoutedEventArgs e) { ResultWindow window = new ResultWindow(); bool ready = true; for (int i = 0; i < expertList.Count(); i++) { try { Expert expert = expertList[i]; expert.CalculateResult(); expertList[i] = expert; } catch (Exception ex) { ready = false; MessageBox.Show(ex.Message); } } if (ready) { window.AddAlternatives(listOfChoiceNames); window.AddExperts(expertList); window.Show(); return; } window.Clear(); }
private void CriteriasDeleteButton_Click(object sender, RoutedEventArgs e) { if (criteriasListBox.SelectedIndex != -1) { listOfCriteriasNames.RemoveAt(criteriasListBox.SelectedIndex); model.DeleteCriteria(criteriasListBox.SelectedIndex); if (expertList.Count() != 0) { for (int i = 0; i < expertList.Count(); i++) { Expert expert = expertList[i]; expert.DeleteCriteria(criteriasListBox.SelectedIndex); expertList[i] = expert; } } //alternativeCriteriasComboBox.ItemsSource = listOfCriteriasNames.Select((s) => s = $"K{count++} - {s}").ToList(); criteriasСomboBox2.SelectedIndex = 0; criteriasListBox.ItemsSource = null; criteriasListBox.ItemsSource = listOfCriteriasNames; } else { MessageBox.Show("Спочатку виберіть критерій!"); } }
private void AlternativesRateListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (AlternativeComboBox1.SelectedIndex != -1 && AlternativeComboBox2.SelectedIndex != -1) { if (AlternativeComboBox1.SelectedIndex != AlternativeComboBox2.SelectedIndex) { Expert exp = expertList[expertChooseListBox.SelectedIndex]; exp[alternativeCriteriasComboBox.SelectedIndex, AlternativeComboBox1.SelectedIndex, AlternativeComboBox2.SelectedIndex] = alternativesRateListBox.SelectedIndex; expertList[expertChooseListBox.SelectedIndex] = exp; ChangeAlternatives(); } } }
private void CriteriasRateListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (criteriasСomboBox1.SelectedIndex != -1 && criteriasСomboBox2.SelectedIndex != -1) { if (criteriasСomboBox1.SelectedIndex != criteriasСomboBox2.SelectedIndex) { Expert exp = expertList[expertChooseListBox.SelectedIndex]; exp[criteriasСomboBox1.SelectedIndex, criteriasСomboBox2.SelectedIndex] = criteriasRateListBox.SelectedIndex; expertList[expertChooseListBox.SelectedIndex] = exp; ChangeCriterias(); } } }
public Expert(Expert expert, string newName = "") { if (newName != "") { this.name = newName; } else { this.name = expert.name; } this.ratedCriterias = expert.ratedCriterias; this.criterias = expert.criterias; this.ratedAlternatives = new List <double[][]>(); this.alternatives = expert.alternatives; for (int i = 0; i < expert.ratedAlternatives.Count; i++) { ratedAlternatives.Add(expert.ratedAlternatives[i]); } this.model = null; }
private void CriteriasAddButton_Click(object sender, RoutedEventArgs e) { if (criterias < 20) { if (criteriasEnterTextBox.Text != "") { if (!listOfCriteriasNames.Contains(criteriasEnterTextBox.Text)) { listOfCriteriasNames.Add(criteriasEnterTextBox.Text); criterias++; criteriasListBox.ItemsSource = null; criteriasListBox.ItemsSource = listOfCriteriasNames; model.AddCriteria(); if (expertList.Count() != 0) { for (int i = 0; i < expertList.Count(); i++) { Expert expert = expertList[i]; expert.AddCriteria(); expertList[i] = expert; } } criteriasEnterTextBox.Text = ""; } else { MessageBox.Show("В моделі вже є критерій з таким ім'ям!"); } } else { MessageBox.Show("Порожні критерії заборонені!"); } } else { MessageBox.Show("Більше 20 критеріїв не підтримуються!"); } }