private void cbxMajors_SelectionChanged(object sender, SelectionChangedEventArgs e) { ClearClicked(); var selectedMajor = MajorHandler.GetMajorFromName(cbxMajors.SelectedItem.ToString()); if (selectedMajor == null) { return; } for (var i = 0; i < maoa.Count; i++) { var year = maoa[i]; for (var j = 0; j < year.Count; j++) { foreach (var course in selectedMajor.Courses[i]) { if (year[j].Id == course) { year[j].CourseClick(sender, null); } } } } }
/// <summary> /// Deleted the major /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnDeleteMajor_Click(object sender, RoutedEventArgs e) { var dialogResult = MessageBox.Show("Do you wish to delete", "Delete?", MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { var selectedMajor = MajorHandler.GetMajorFromName(((ListBox)sender).SelectedItems[0].ToString()); MajorList.Remove(selectedMajor); LbxMajors.Items.Remove(selectedMajor.Name); } }
/// <summary> /// Changes the list of the courses, this is needed to change the requirements for major /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LbxMajors_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedMajor = MajorHandler.GetMajorFromName(((ListBox)sender).SelectedItems[0].ToString()); LbxInMajor.Items.Clear(); LbxNotMajor.Items.Clear(); foreach (var course in CourseList) { if (selectedMajor != null) { if (selectedMajor.Courses[course.Year - 1].Contains(course.Id)) { LbxInMajor.Items.Add(course.Id); } else { LbxNotMajor.Items.Add(course.Id); } } } }
/// <summary> /// Moves course needed in the major into the one that isnt /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnMoveDown_Click(object sender, RoutedEventArgs e) { var selectedItem = CourseHandler.GetCourseFromId(((ListBox)sender).SelectedItems[0].ToString()); LbxNotMajor.Items.Add(selectedItem); var major = MajorHandler.GetMajorFromName(((ListBox)sender).SelectedItems[0].ToString()); var i = major.Courses[selectedItem.Year - 1].ToList(); i.Remove(selectedItem.Id); major.Courses[selectedItem.Year - 1] = i.ToArray(); for (var j = 0; j < MajorList.Count; j++) { if (major.Name == MajorList[j].Name) { MajorList[j] = major; } } LbxInMajor.Items.Remove(selectedItem.Id); }