예제 #1
0
        public IPKSimBuildingBlock CreateCloneFor(IPKSimBuildingBlock buildingBlockToClone)
        {
            //This should never fail
            var expressionProfile = buildingBlockToClone.DowncastTo <ExpressionProfile>();

            var(molecule, _) = expressionProfile;
            _dto             = _expressionProfileDTOMapper.MapFrom(expressionProfile);
            _view.Caption    = Captions.CloneObjectBase(PKSimConstants.ObjectTypes.ExpressionProfile, buildingBlockToClone.Name);

            _view.BindTo(_dto);
            _view.Display();

            if (_view.Canceled)
            {
                return(null);
            }

            //create a new expression profile using the same molecule name as the original so that we can update the values. Then we rename
            var newExpressionProfile = _expressionProfileFactory.Create(molecule.MoleculeType, _dto.Species.Name, molecule.Name);

            newExpressionProfile.Category = _dto.Category;

            //synchronize values
            _expressionProfileUpdater.SynchronizeExpressionProfileWithExpressionProfile(expressionProfile, newExpressionProfile);

            //rename using the new name
            _expressionProfileUpdater.UpdateMoleculeName(newExpressionProfile, _dto.MoleculeName);

            return(newExpressionProfile);
        }
 protected override ITreeNode AddBuildingBlockToTree(IPKSimBuildingBlock buildingBlock)
 {
     if (buildingBlock.BuildingBlockType != PKSimBuildingBlockType.Simulation)
     {
         return(null);
     }
     return(addSimulationToTree(buildingBlock.DowncastTo <Simulation>()));
 }
예제 #3
0
        protected override ITreeNode AddBuildingBlockToTree(IPKSimBuildingBlock buildingBlock)
        {
            switch (buildingBlock.BuildingBlockType)
            {
            case PKSimBuildingBlockType.Compound:
                return(addCompoundToTree(buildingBlock.DowncastTo <Compound>()));

            case PKSimBuildingBlockType.Formulation:
                return(addFormulationToTree(buildingBlock.DowncastTo <Formulation>()));

            case PKSimBuildingBlockType.Protocol:
                return(addProtocolToTree(buildingBlock.DowncastTo <Protocol>()));

            case PKSimBuildingBlockType.Individual:
                return(addIndividualToTree(buildingBlock.DowncastTo <Individual>()));

            case PKSimBuildingBlockType.Population:
                return(addPopulationToTree(buildingBlock.DowncastTo <Population>()));

            case PKSimBuildingBlockType.Event:
                return(addEventToTree(buildingBlock.DowncastTo <PKSimEvent>()));

            case PKSimBuildingBlockType.ObserverSet:
                return(addObserversToTree(buildingBlock.DowncastTo <ObserverSet>()));

            case PKSimBuildingBlockType.Simulation:
                return(null);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public IPKSimCommand ConfigureSimulationWithBuildingBlock(Simulation simulation, IPKSimBuildingBlock templateBuildingBlock)
        {
            Action            updateAction   = () => { };
            ISubPresenterItem itemToActivate = SimulationItems.Model;

            switch (templateBuildingBlock.BuildingBlockType)
            {
            case PKSimBuildingBlockType.Individual:
            case PKSimBuildingBlockType.Population:
                itemToActivate = SimulationItems.Model;
                updateAction   = () => PresenterAt(SimulationItems.Model).UpdateSelectedSubject(templateBuildingBlock.DowncastTo <ISimulationSubject>());
                break;

            case PKSimBuildingBlockType.Compound:
                itemToActivate = SimulationItems.Model;
                updateAction   = () => PresenterAt(SimulationItems.Model).UpdateSelectedCompound(templateBuildingBlock.DowncastTo <Compound>());
                break;

            case PKSimBuildingBlockType.Formulation:
                itemToActivate = SimulationItems.CompoundProtocols;
                updateAction   = () => PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedFormulation(templateBuildingBlock.DowncastTo <Formulation>());
                break;

            case PKSimBuildingBlockType.Protocol:
                itemToActivate = SimulationItems.CompoundProtocols;
                updateAction   = () => PresenterAt(SimulationItems.CompoundProtocols).UpdateSelectedProtocol(templateBuildingBlock.DowncastTo <Protocol>());
                break;

            case PKSimBuildingBlockType.Event:
                break;

            case PKSimBuildingBlockType.ObserverSet:
                itemToActivate = SimulationItems.Observers;
                break;

            default:
                throw new ArgumentOutOfRangeException(templateBuildingBlock.BuildingBlockType.ToString());
            }
            return(configureSimulation(simulation, itemToActivate, updateAction));
        }