Beispiel #1
0
        public IMoBiCommand Rename(IObjectBase objectBase, IEnumerable <string> allreadyNames, IBuildingBlock buildingBlock)
        {
            var unallowedNames = new List <string>(allreadyNames);

            unallowedNames.AddRange(AppConstants.UnallowedNames);
            var    objectName = _objectTypeResolver.TypeFor(objectBase);
            string newName    = _dialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(objectBase.Name), AppConstants.Captions.NewName, objectBase.Name, unallowedNames);

            if (string.IsNullOrEmpty(newName))
            {
                return(new MoBiEmptyCommand());
            }


            var commandCollector = new MoBiMacroCommand
            {
                CommandType = AppConstants.Commands.RenameCommand,
                ObjectType  = objectName,
                Description = AppConstants.Commands.RenameDescription(objectBase, newName)
            };

            if (CheckUsagesFor(newName, objectBase.Name, objectBase, commandCollector))
            {
                commandCollector.AddCommand(new RenameObjectBaseCommand(objectBase, newName, buildingBlock)
                {
                    ObjectType = objectName
                });
            }

            commandCollector.Run(_context);
            return(commandCollector);
        }
        public void ChangeTranportName(TransporterMoleculeContainer transporterMoleculeContainer, IBuildingBlock buildingBlock)
        {
            var unallowedNames = new List <string>(AppConstants.UnallowedNames);

            unallowedNames.AddRange(GetForbiddenNamesWithoutSelf(transporterMoleculeContainer, transporterMoleculeContainer.ParentContainer));
            var oldTransportName = transporterMoleculeContainer.TransportName;
            var newName          = _dialogCreator.AskForInput(AppConstants.Dialog.AskForNewName(oldTransportName), AppConstants.Captions.NewName, oldTransportName, unallowedNames);

            if (string.IsNullOrEmpty(newName))
            {
                return;
            }

            var commandCollector = new MoBiMacroCommand
            {
                CommandType = AppConstants.Commands.RenameCommand,
                ObjectType  = ObjectName,
                Description = AppConstants.Commands.RenameDescription(transporterMoleculeContainer, newName)
            };

            if (_objectBaseTask.CheckUsagesFor(newName, transporterMoleculeContainer.TransportName, transporterMoleculeContainer, commandCollector))
            {
                commandCollector.AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(transporterMoleculeContainer.PropertyName(x => x.TransportName), newName, oldTransportName, transporterMoleculeContainer, buildingBlock)
                {
                    ObjectType = ObjectName
                });
            }
            commandCollector.Run(_context);
            _context.AddToHistory(commandCollector);
        }
        public void AddMoleculeNode()
        {
            using (var presenter = _applicationController.Start <IMultipleStringSelectionPresenter>())
            {
                var moleculeNames = presenter.Show(AppConstants.Captions.AddReactionMolecule,
                                                   AppConstants.Dialog.GetReactionMoleculeName, getMoleculeNames(), ToolTips.AddMoleculeNameToList, canAdd: true);

                var command = new MoBiMacroCommand
                {
                    ObjectType  = ObjectTypes.Molecule,
                    CommandType = AppConstants.Commands.AddCommand,
                    Description = AppConstants.Commands.AddManyMoleculesDescription
                };
                moleculeNames.Each(nodeName => addMoleculeNode(nodeName, command));
                AddCommand(command.Run(_context));
            }
        }
        public void RemoveResultsFromSimulations(IReadOnlyList <DataRepository> resultsToRemove)
        {
            if (_dialogCreator.MessageBoxYesNo(AppConstants.Dialog.RemoveSelectedResultsFromSimulations) != ViewResult.Yes)
            {
                return;
            }

            var macroCommand = new MoBiMacroCommand
            {
                Description = AppConstants.Commands.RemoveMultipleResultsFromSimulations,
                ObjectType  = AppConstants.MoBiObjectTypes.Data,
                CommandType = AppConstants.Commands.DeleteCommand
            };

            resultsToRemove.Each(result => { macroCommand.Add(removeResultFromSimulationCommand(result)); });

            _context.AddToHistory(macroCommand.Run(_context));
        }
Beispiel #5
0
        public void DeleteAllResultsFromAllSimulation()
        {
            var viewResult = _dialogCreator.MessageBoxYesNo(AppConstants.Dialog.RemoveAllResultsFromProject());

            if (viewResult == ViewResult.No)
            {
                return;
            }

            var simulations = _context.CurrentProject.Simulations;
            var macoCommand = new MoBiMacroCommand
            {
                CommandType = Command.CommandTypeDelete,
                ObjectType  = ObjectTypes.ObservedData,
                Description = AppConstants.Commands.DeleteAllResultsFromAllSimulations,
            };

            simulations.Each(s => macoCommand.AddCommand(deleteAllResultsFromSimulationCommand(s)));
            _context.AddToHistory(macoCommand.Run(_context));
        }
        public IMoBiCommand Rename(IObjectBase objectBase, IEnumerable <string> alreadyUsedNames, IBuildingBlock buildingBlock)
        {
            var unallowedNames = new List <string>(alreadyUsedNames);

            unallowedNames.AddRange(AppConstants.UnallowedNames);
            var objectName = _objectTypeResolver.TypeFor(objectBase);

            string newName;

            using (var renameObjectPresenter = _applicationController.Start <IRenameObjectPresenter>())
            {
                newName = renameObjectPresenter.NewNameFrom(objectBase, unallowedNames);
            }


            if (string.IsNullOrEmpty(newName))
            {
                return(new MoBiEmptyCommand());
            }


            var commandCollector = new MoBiMacroCommand
            {
                CommandType = AppConstants.Commands.RenameCommand,
                ObjectType  = objectName,
                Description = AppConstants.Commands.RenameDescription(objectBase, newName)
            };

            if (CheckUsagesFor(newName, objectBase.Name, objectBase, commandCollector))
            {
                commandCollector.AddCommand(new RenameObjectBaseCommand(objectBase, newName, buildingBlock)
                {
                    ObjectType = objectName
                });
            }

            commandCollector.Run(_context);
            return(commandCollector);
        }