public void New() { _currentConfigFilepath = ""; TimetableData ttData = new TimetableData(); BlockContext = new BlockController(); RoomContext = new RoomController(); LecturerContext = new LecturerController(); GroupContext = new GroupController(); CourseContext = new CourseController(BlockContext, RoomContext, GroupContext, LecturerContext); }
public void Load() { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "xml-Files (*.xml)|*.xml"; fileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); fileDialog.ShowDialog(); TimetableData t = new TimetableData(); TimetableData ttData = TimetableConfigIO.ImportTimetableConfig(fileDialog.FileName); if (ttData == null) { MessageBox.Show("Data could not be loaded.", "Loading error", MessageBoxButton.OK, MessageBoxImage.Error); return; } BlockContext = new BlockController(); foreach (var block in ttData.Blocks) { BlockContext.BlockList.Add(block); } if (ttData.Blocks.Length > 0) BlockContext.SelectedIndex = 0; RoomContext = new RoomController(); foreach (var room in ttData.Rooms) { RoomContext.RoomList.Add(room); } if (ttData.Rooms.Length > 0) RoomContext.SelectedIndex = 0; GroupContext = new GroupController(); foreach (var group in ttData.Groups) { GroupContext.GroupList.Add(group); } if (ttData.Groups.Length > 0) GroupContext.SelectedIndex = 0; LecturerContext = new LecturerController(); foreach (var lecturer in ttData.Lecturers) { LecturerContext.LecturersList.Add(lecturer); } if (ttData.Lecturers.Length > 0) LecturerContext.SelectedIndex = 0; CourseContext = new CourseController(BlockContext, RoomContext, GroupContext, LecturerContext); AddCourses(CourseContext, ttData.Courses); if (ttData.Courses.Length > 0) CourseContext.SelectedIndex = 0; }
private void AddCourses(CourseController CourseContext, Course[] courses) { foreach (Course course in courses) { bool isListed = false; foreach (Course storedCourse in CourseContext.Repetitions.Keys) { if (storedCourse.Id.Equals(course.Id)) { isListed = true; CourseContext.Repetitions[storedCourse]++; break; } } if (!isListed) { CourseContext.CourseList.Add(course); CourseContext.Repetitions.Add(course, 1); } } }
internal void LoadCourseData() { CourseContext = new CourseController(BlockContext, RoomContext, GroupContext, LecturerContext); }