private void AddMaterial(Object parameter) { try { var materialToAdd = materialsFactory.NewMaterial(ChosenMaterial); CurrentJewelryMaterials.Add(materialToAdd); addMaterialsView.AlterMaterial(ref materialToAdd, () => MaterialAlteredCallback()); CurrentAppScreen = (int)ApplicationScreen.CreateMaterial; } catch (Exception ex) { MessageBox.Show($"Could not add material. Reason: {ex.Message}"); } }
private void AddJewelry(Object parameter) { try { CurrentJewelryMaterials.RemoveAll(x => !IsMaterialAlterred(x)); if (CurrentJewelryMaterials.Count == 0) { MessageBox.Show("No materials were choosen for this jewelry. Please add some."); return; } if (string.IsNullOrEmpty(JewelryName)) { MessageBox.Show("Please choose some name for your jewelry."); return; } var jewelry = jewelryFactory.NewJewelry(SelectedJewelryType); var visitor = new JewelryVisitor(this); jewelry.Accept(visitor); MessageBox.Show($"Successfully added {jewelry.Name}."); JewelryList.Add(jewelry); JewelryListUI.Add(jewelry); ClearFields(); CurrentJewelryMaterials = null; CurrentJewelryMaterials = new List <Material>(); } catch (Exception ex) { MessageBox.Show($"Can't add jewelry. Reason: {ex.Message}."); } }