private void SaveAndExit(object sender, MouseButtonEventArgs e) { ControllerSettings.SaveModel(this.modelGroupItem, this, this.viewGroupItem); ControllerGroupItem.ChangeGroupItem(this.modelGroupItem); this.Close(MessageBoxResult.Yes); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (result == MessageBoxResult.No) { result = System.Windows.MessageBox.Show("Сохранить изменения?", "Yes/No", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { ControllerSettings.SaveModel(this.modelGroupItem, this, this.viewGroupItem); ControllerGroupItem.ChangeGroupItem(this.modelGroupItem); } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (FileStream Stream = new FileStream("userdata/Serialization.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(ListGroupItems)); ListGroupItems SaveList = (ListGroupItems)xmlSerializer.Deserialize(Stream); foreach (ModelGroupItem modelGroupItem in SaveList.listGroupItem) { modelGroupItem.listbox = listBox; modelGroupItem.listGroupItem = listGroupItem; ViewGroupItem viewGroupItem = new ViewGroupItem(modelGroupItem, viewSettings); modelGroupItem.viewGroupItem = viewGroupItem; modelGroupItem.SetStatus(); // Проверяем заполненные поля и выставляем стату готовности к отправке ControllerGroupItem.ChangeGroupItem(modelGroupItem); // Добавляем модель в список моделей и вид в lisBox listGroupItem.Add(modelGroupItem); listBox.Items.Insert(listBox.Items.Count - 1, viewGroupItem); } } }