private void FileToDatas(string filename) { for (int dayHour = 0; dayHour < 24; dayHour++) { string monday = null; string tuesday = null; string wednesday = null; string thursday = null; string friday = null; string saturday = null; string sunday = null; Week week = new Week((dayHour + " - " + (dayHour + 1)), monday, tuesday, wednesday, thursday, friday, saturday, sunday); this.WeekGrid.RemoveAt(dayHour); this.WeekGrid.Insert(dayHour, week); } StudentList.Clear(); GroupStudentList.Clear(); GroupList.Clear(); using (var readFromFile = new StreamReader(filename)) { var deserializer = new XmlSerializer(typeof(ObservableCollection <Student>)); ObservableCollection <Student> tmpStudentList = (ObservableCollection <Student>)deserializer.Deserialize(readFromFile); foreach (var item in tmpStudentList) { StudentList.Add(item); } deserializer = new XmlSerializer(typeof(ObservableCollection <Student>)); foreach (var item in tmpStudentList) { GroupStudentList.Add(item); } deserializer = new XmlSerializer(typeof(ObservableCollection <Group>)); ObservableCollection <Group> tmpGroupList = (ObservableCollection <Group>)deserializer.Deserialize(readFromFile); foreach (var item in tmpGroupList) { GroupList.Add(item); } deserializer = new XmlSerializer(typeof(ObservableCollection <Week>)); ObservableCollection <Week> tmpWeekGrid = (ObservableCollection <Week>)deserializer.Deserialize(readFromFile); foreach (var item in tmpWeekGrid) { WeekGrid.Add(item); } } }
private void NewButtonClick(object sender, RoutedEventArgs e) { for (int dayHour = 0; dayHour < 24; dayHour++) { string monday = null; string tuesday = null; string wednesday = null; string thursday = null; string friday = null; string saturday = null; string sunday = null; Week week = new Week((dayHour + " - " + (dayHour + 1)), monday, tuesday, wednesday, thursday, friday, saturday, sunday); this.WeekGrid.RemoveAt(dayHour); this.WeekGrid.Insert(dayHour, week); } StudentList.Clear(); GroupStudentList.Clear(); GroupList.Clear(); }