protected override void Context() { base.Context(); _convertedObject = A.Fake <IObjectBase>().WithName("BB"); A.CallTo(() => _workspace.AddCommand(A <OSPSuiteInfoCommand> ._)) .Invokes(x => _command = x.GetArgument <OSPSuiteInfoCommand>(0)); A.CallTo(() => _executionContext.TypeFor(_convertedObject)).Returns("TYPE"); }
public void Handle(SimulationRunFinishedEvent eventToHandle) { var command = new OSPSuiteInfoCommand { Description = PKSimConstants.Command.RunSimulationDescription(eventToHandle.Simulation.Name, eventToHandle.ExecutionTime.ToDisplay()), BuildingBlockName = eventToHandle.Simulation.Name, BuildingBlockType = PKSimConstants.ObjectTypes.Simulation, ObjectType = PKSimConstants.ObjectTypes.Simulation }; executeCommandAndAddToWorkspace(command); }
private IInfoCommand getSimulationResultLabel(SimulationRunResults results) { var command = new OSPSuiteInfoCommand { Description = simulationLabelDescription(results) }; if (results.Warnings.Any()) { command.Comment = AppConstants.Commands.SimulationLabelComment(results.Warnings.Count()); } return(command); }
public void Handle(ObjectConvertedEvent eventToHandle) { var objectName = _displayNameProvider.DisplayNameFor(eventToHandle.ConvertedObject); var objectType = _context.TypeFor(eventToHandle.ConvertedObject); var fromVersion = eventToHandle.FromVersion; var command = new OSPSuiteInfoCommand { ObjectType = _context.TypeFor(eventToHandle.ConvertedObject), Description = AppConstants.Commands.ObjectConvertedCommand(objectName, objectType, fromVersion.VersionDisplay, _applicationConfiguration.Version), }; command.Run(_context); _context.AddToHistory(command); }
public void Handle(ObjectBaseConvertedEvent eventToHandle) { var buildingBlock = eventToHandle.ConvertedObject; var buildingBlockType = _executionContext.TypeFor(buildingBlock); var fromVersion = eventToHandle.FromVersion; var command = new OSPSuiteInfoCommand { Description = PKSimConstants.Command.ObjectConvertedDescription(buildingBlock.Name, buildingBlockType, fromVersion.VersionDisplay, _applicationConfiguration.Version), BuildingBlockName = buildingBlock.Name, BuildingBlockType = buildingBlockType, ObjectType = buildingBlockType }; executeCommandAndAddToWorkspace(command); }
private bool saveCurrentProjectAs(string defaultName) { var defaultNameIsUndefined = string.Equals(CoreConstants.PROJECT_UNDEFINED, defaultName); var defaultFileName = defaultNameIsUndefined ? string.Empty : defaultName; var fileName = _dialogCreator.AskForFileToSave(PKSimConstants.UI.SaveProjectTitle, CoreConstants.Filter.SAVE_PROJECT_FILTER, Constants.DirectoryKey.PROJECT, defaultFileName); if (string.IsNullOrEmpty(fileName)) { return(false); } var previousName = _workspace.Project.Name; var previousPath = _workspace.Project.FilePath; if (!saveProjectToFile(fileName)) { return(false); } if (shouldShowWarningForSharedJournal(previousPath)) { var journalName = FileHelper.FileNameFromFileFullPath(_journalRetriever.JournalFullPath); _dialogCreator.MessageBoxInfo(Captions.Journal.JournalWillBeSharedBetweenProjectInfo(journalName)); } if (string.Equals(previousName, _workspace.Project.Name)) { return(true); } //Project was renamed var command = new OSPSuiteInfoCommand { Description = PKSimConstants.Command.ProjectRenamedDescription(previousName, _workspace.Project.Name), ObjectType = PKSimConstants.ObjectTypes.Project }; _workspace.AddCommand(command); return(true); }
private void executeCommandAndAddToWorkspace(OSPSuiteInfoCommand command) { command.Run(_executionContext); _workspace.AddCommand(command); }