private void CreateWood_Button_Click(object sender, RoutedEventArgs e) { Wood newWood = new Wood(); woodWPF woodModal = new woodWPF(newWood); if (woodModal.ShowDialog() == true) { Woods_ComboBox.Items.Add(newWood.ToString()); woods.Add(newWood); Wood.WriteWoodsToFile("Woods", woods); } else { MessageBox.Show("Изменения не сохранены"); } }
private void EditWood_Button_Click(object sender, RoutedEventArgs e) { int selectedIndex = Woods_ComboBox.SelectedIndex; if (selectedIndex < 0 || selectedIndex >= woods.Count) { MessageBox.Show("Необходимо выбрать древесину!"); return; } woodWPF woodModal = new woodWPF(woods[selectedIndex]); if (woodModal.ShowDialog() == true) { Woods_ComboBox.Items[selectedIndex] = woods[selectedIndex].ToString(); Wood.WriteWoodsToFile("Woods", woods); } else { MessageBox.Show("Изменения не сохранены"); } }