private void Btn_New_Click(object sender, RoutedEventArgs e) { ValueDialogBox vdb = new ValueDialogBox("New Material Name"); vdb.ShowDialog(); if (vdb.isAccepted == true) { CarboMaterial newMaterial = new CarboMaterial(); newMaterial.Name = vdb.Value; returnedDatabase.AddMaterial(newMaterial); RefreshMaterialList(); selectMaterial(vdb.Value); } }
private void btn_SyncFrom_Click(object sender, RoutedEventArgs e) { if (liv_TemplateMaterials.SelectedItems.Count > 0) { try { MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to update the project materials with the selected materials from the template?" + Environment.NewLine + "Materials with excact same name will be overwritten, others will be added to the project", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { CarboDatabase buffer = new CarboDatabase(); foreach (object item in liv_TemplateMaterials.SelectedItems) { CarboMaterial cm = item as CarboMaterial; if (cm != null) { buffer.AddMaterial(cm); } } projectDatabase.SyncMaterials(buffer); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } } else { MessageBoxResult result = System.Windows.MessageBox.Show("Please select a material to syncronise", "Computer says no", MessageBoxButton.YesNo); } refreshTemplateMaterials(); refreshProjectMaterials(); }