public void AddResource(DesignerItem designerItem) { switch (designerItem.Tag.ToString()) { case "Information": var informationWindow = new InformationWindow(new InformationResource()); informationWindow.ShowDialog(); if (informationWindow.DialogResult.HasValue && informationWindow.DialogResult.Value) { Resources.Add(informationWindow.InformationResource); designerItem.BoundLogicItem = informationWindow.InformationResource; //designerItem.dispName = informationWindow.InformationResource.Title; } break; //resource = new InformationResource(Guid.NewGuid(), this.id, "Operation" + num); break; case "Finance": var financeWindow = new FinanceWindow(new FinancialResource()); financeWindow.ShowDialog(); if (financeWindow.DialogResult.HasValue && financeWindow.DialogResult.Value) { Resources.Add(financeWindow.FinancialResource); designerItem.BoundLogicItem = financeWindow.FinancialResource; //designerItem.dispName = financeWindow.FinancialResource.Title; } break; case "Labour": var labourWindow = new LabourWindow(new LabourForce()); labourWindow.ShowDialog(); if (labourWindow.DialogResult.HasValue && labourWindow.DialogResult.Value) { Resources.Add(labourWindow.LabourForce); designerItem.BoundLogicItem = labourWindow.LabourForce; //designerItem.dispName = financeWindow.FinancialResource.Title; } break; case "Equipment": var equipmentWindow = new EquipmentWindow(new Equipment()); equipmentWindow.ShowDialog(); if (equipmentWindow.DialogResult.HasValue && equipmentWindow.DialogResult.Value) { Resources.Add(equipmentWindow.Equipment); designerItem.BoundLogicItem = equipmentWindow.Equipment; //designerItem.dispName = financeWindow.FinancialResource.Title; } break; case "Product": var productWindow = new ProductWindow(new Product()); productWindow.ShowDialog(); if (productWindow.DialogResult.HasValue && productWindow.DialogResult.Value) { Resources.Add(productWindow.Product); designerItem.BoundLogicItem = productWindow.Product; //designerItem.dispName = financeWindow.FinancialResource.Title; } break; case "Service": var serviceWindow = new ServiceWindow(new Service()); serviceWindow.ShowDialog(); if (serviceWindow.DialogResult.HasValue && serviceWindow.DialogResult.Value) { Resources.Add(serviceWindow.Service); designerItem.BoundLogicItem = serviceWindow.Service; //designerItem.dispName = financeWindow.FinancialResource.Title; } break; default: return; } }
public void UpdateResource(DesignerItem designerItem) { if (designerItem.BoundLogicItem is InformationResource) { //MessageBox.Show("UpdateResource1 : " + designerItem.BoundLogicItem.ID.ToString()); var item = designerItem.BoundLogicItem as InformationResource; var resourceWindow = new InformationWindow(item); resourceWindow.ShowDialog(); if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value) { if (Resources.Contains(item)) { Resources.Remove(item); } Resources.Add(resourceWindow.InformationResource); designerItem.BoundLogicItem = resourceWindow.InformationResource; } else { ResourceDesigner.RemoveChild(designerItem); //Toolbox. } return; } if (designerItem.BoundLogicItem is FinancialResource) { var item = designerItem.BoundLogicItem as FinancialResource; var resourceWindow = new FinanceWindow(item); resourceWindow.ShowDialog(); if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value) { if (Resources.Contains(item)) { Resources.Remove(item); } Resources.Add(resourceWindow.FinancialResource); designerItem.BoundLogicItem = resourceWindow.FinancialResource; } return; } if (designerItem.BoundLogicItem is LabourForce) { var item = designerItem.BoundLogicItem as LabourForce; var resourceWindow = new LabourWindow(item); resourceWindow.ShowDialog(); if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value) { if (Resources.Contains(item)) { Resources.Remove(item); } Resources.Add(resourceWindow.LabourForce); designerItem.BoundLogicItem = resourceWindow.LabourForce; } return; } if (designerItem.BoundLogicItem is Equipment) { var item = designerItem.BoundLogicItem as Equipment; var resourceWindow = new EquipmentWindow(item); resourceWindow.ShowDialog(); if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value) { if (Resources.Contains(item)) { Resources.Remove(item); } Resources.Add(resourceWindow.Equipment); designerItem.BoundLogicItem = resourceWindow.Equipment; } return; } if (designerItem.BoundLogicItem is Product) { var item = designerItem.BoundLogicItem as Product; var resourceWindow = new ProductWindow(item); resourceWindow.ShowDialog(); if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value) { if (Resources.Contains(item)) { Resources.Remove(item); } Resources.Add(resourceWindow.Product); designerItem.BoundLogicItem = resourceWindow.Product; } return; } if (designerItem.BoundLogicItem is Service) { var item = designerItem.BoundLogicItem as Service; var resourceWindow = new ServiceWindow(item); resourceWindow.ShowDialog(); if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value) { if (Resources.Contains(item)) { Resources.Remove(item); } Resources.Add(resourceWindow.Service); designerItem.BoundLogicItem = resourceWindow.Service; } return; } }