public void ScaleIndividual(Individual individualToScale) { _buildingBlockTask.Load(individualToScale); using (var presenter = _applicationController.Start <IScaleIndividualPresenter>()) { var scaleCommand = presenter.ScaleIndividual(individualToScale); //User cancel action. return if (scaleCommand.IsEmpty()) { return; } var scaledIndividual = presenter.Individual; var overallCommand = new PKSimMacroCommand { CommandType = PKSimConstants.Command.CommandTypeScale, ObjectType = PKSimConstants.ObjectTypes.Individual, Description = PKSimConstants.Command.ScaleIndividualDescription(individualToScale.Name, scaledIndividual.Name), BuildingBlockName = scaledIndividual.Name, BuildingBlockType = PKSimConstants.ObjectTypes.Individual }; //indvidual was not scaled but cloned. Create a new individual var addToProjectCommand = new AddBuildingBlockToProjectCommand(scaledIndividual, _executionContext).Run(_executionContext); overallCommand.Add(addToProjectCommand); //these needs to be done afterwards in order to be able to undo the scaling action var macroCommand = scaleCommand as IPKSimMacroCommand; if (macroCommand != null) { macroCommand.All().Each(overallCommand.Add); } overallCommand.ReplaceNameTemplateWithName(scaledIndividual.Name); overallCommand.ReplaceTypeTemplateWithType(PKSimConstants.ObjectTypes.Individual); _buildingBlockTask.AddCommandToHistory(overallCommand); } }
public void ScaleIndividual(Individual individualToScale) { _buildingBlockTask.Load(individualToScale); using (var presenter = _applicationController.Start <IScaleIndividualPresenter>()) { var scaleCommand = presenter.ScaleIndividual(individualToScale); //User cancel action. return if (scaleCommand.IsEmpty()) { return; } var scaledIndividual = presenter.Individual; var overallCommand = new PKSimMacroCommand { CommandType = PKSimConstants.Command.CommandTypeScale, ObjectType = PKSimConstants.ObjectTypes.Individual, Description = PKSimConstants.Command.ScaleIndividualDescription(individualToScale.Name, scaledIndividual.Name), BuildingBlockName = scaledIndividual.Name, BuildingBlockType = PKSimConstants.ObjectTypes.Individual }; //Do not add to history as the add action should be part of the overall command var addToProjectCommand = _buildingBlockTask.AddToProject(scaledIndividual, addToHistory: false); overallCommand.Add(addToProjectCommand); //these needs to be done afterwards in order to be able to undo the scaling action var macroCommand = scaleCommand as IPKSimMacroCommand; macroCommand?.All().Each(overallCommand.Add); overallCommand.ReplaceNameTemplateWithName(scaledIndividual.Name); overallCommand.ReplaceTypeTemplateWithType(PKSimConstants.ObjectTypes.Individual); _buildingBlockTask.AddCommandToHistory(overallCommand); } }