Пример #1
0
        public void Remove(FormulaBuilderDTO formulaDTO)
        {
            var formula = getFormulaForDTO(formulaDTO);

            if (formula == null)
            {
                return;
            }
            if (_formulaUsageChecker.FormulaUsedIn(_buildingBlock, formula))
            {
                _dialogCreator.MessageBoxInfo(AppConstants.Exceptions.FormulaInUse(formula));
                return;
            }

            var result = _dialogCreator.MessageBoxYesNo(AppConstants.Captions.ReallyDeleteFormula(formula.Name));

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

            AddCommand(new RemoveFormulaFromFormulaCacheCommand(_buildingBlock, formula).Run(_context));
            //Ensure that if an invalid formula is removed, the invalid message is removed as well
            _context.PublishEvent(new FormulaValidEvent(formula, _buildingBlock));
            Edit(_buildingBlock);
        }
        private static SuperToolTip addFormulaToolTip(FormulaBuilderDTO formula, SuperToolTip toolTip, string title)
        {
            if (formula == null || formula.FormulaType != ObjectTypes.ExplicitFormula)
            {
                return(toolTip);
            }

            toolTip.Items.AddSeparator();
            toolTip.WithTitle(title);
            toolTip.WithText(formula.FormulaString);

            toolTip.Items.AddSeparator();
            toolTip.WithTitle(AppConstants.Captions.References);

            var sb = new StringBuilder();

            foreach (var objectPath in formula.ObjectPaths)
            {
                sb.AppendLine($"<I>{objectPath.Alias}</I> is defined as: {objectPath.Path}");
            }

            toolTip.WithText(sb.ToString());

            return(toolTip);
        }
Пример #3
0
 public void Select(FormulaBuilderDTO formulaDTO)
 {
     if (formulaDTO == null)
     {
         return;
     }
     Select(getFormulaForDTO(formulaDTO));
 }
        public void SetFormula(ObserverBuilderDTO dtoObserverBuilder, FormulaBuilderDTO newValue, FormulaBuilderDTO oldValue)
        {
            var newFormula      = _buildingBlock.FormulaCache[newValue.Id];
            var oldFormula      = _buildingBlock.FormulaCache[oldValue.Id];
            var observerBuilder = _context.Get <IObserverBuilder>(dtoObserverBuilder.Id);

            AddCommand(new EditObjectBasePropertyInBuildingBlockCommand("Formula", newFormula, oldFormula, observerBuilder, BuildingBlock).Run(_context)); //<IFormula>
        }
 protected override void Context()
 {
     base.Context();
     _commandCollector = A.Fake <ICommandCollector>();
     sut.InitializeWith(_commandCollector);
     _assingmentDTO = new EventAssignmentBuilderDTO().WithId("AA");
     _formulaDTO    = new FormulaBuilderDTO().WithId("B");
     A.CallTo(() => _context.Get <ExplicitFormula>(A <string> ._)).Returns(A.Fake <ExplicitFormula>());
     A.CallTo(() => _context.Get <IEventAssignmentBuilder>(A <string> ._)).Returns(A.Fake <IEventAssignmentBuilder>());
 }
 protected override void Context()
 {
     base.Context();
     _buildingBlock = new MoBiSpatialStructure();
     _formula       = new ExplicitFormula().WithName("Formula").WithId("F1");
     _buildingBlock.AddFormula(_formula);
     _commandCollector = A.Fake <ICommandCollector>();
     sut.InitializeWith(_commandCollector);
     sut.Edit(_buildingBlock);
     _dtoFormula    = new FormulaBuilderDTO();
     _dtoFormula.Id = _formula.Id;
     A.CallTo(() => _formulaChecker.FormulaUsedIn(_buildingBlock, _formula)).Returns(false);
     A.CallTo(() => _messagePresenter.MessageBoxYesNo(AppConstants.Captions.ReallyDeleteFormula(_formula.Name), ViewResult.Yes))
     .Returns(ViewResult.Yes);
 }
Пример #7
0
        public void Rename(FormulaBuilderDTO formulaDTO)
        {
            var formula = getFormulaForDTO(formulaDTO);

            if (formula == null)
            {
                return;
            }

            var newName = _dialogCreator.AskForInput(AppConstants.Captions.NewName, AppConstants.Captions.EnterNewFormulaName, formula.Name, _buildingBlock.FormulaCache.Select(x => x.Name));

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

            AddCommand(new RenameObjectBaseCommand(formula, newName, _buildingBlock).Run(_context));
            Edit(_buildingBlock);
        }
Пример #8
0
        public void Clone(FormulaBuilderDTO formulaDTO)
        {
            var formula = getFormulaForDTO(formulaDTO);

            if (formula == null)
            {
                return;
            }

            var newName = _dialogCreator.AskForInput(AppConstants.Captions.NewName, AppConstants.Captions.CloneFormulaTitle, formula.Name, _buildingBlock.FormulaCache.Select(x => x.Name));

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

            var cloneFormula = _cloneManager.Clone(formula, new FormulaCache());

            cloneFormula.Name = newName;
            addToParent(cloneFormula);
        }
 public ContextMenuForFormula(FormulaBuilderDTO formulaDTO, IFormulaCachePresenter presenter)
 {
     _formulaDTO = formulaDTO;
     _presenter  = presenter;
 }
Пример #10
0
        public void SetFormulaFor(EventAssignmentBuilderDTO eventAssignmentBuilderDTO, FormulaBuilderDTO formulaBuilderDTO)
        {
            var newFormula             = _context.Get <ExplicitFormula>(formulaBuilderDTO.Id);
            var eventAssignmentBuilder = _context.Get <IEventAssignmentBuilder>(eventAssignmentBuilderDTO.Id);

            AddCommand(
                new EditObjectBasePropertyInBuildingBlockCommand(eventAssignmentBuilder.PropertyName(b => b.Formula), newFormula, eventAssignmentBuilder.Formula, eventAssignmentBuilder, BuildingBlock).Run(_context));
        }
        public void Select(FormulaBuilderDTO dtoFormulaBuilder)
        {
            var rowHandle = _gridBinder.RowHandleFor(dtoFormulaBuilder);

            grdFormulaList.FocusedRowHandle = rowHandle;
        }
Пример #12
0
 private IFormula getFormulaForDTO(FormulaBuilderDTO dtoFormulaBuilder)
 {
     return(_cache.FindById(dtoFormulaBuilder.Id));
 }
        public void UpdateFormula(ApplicationMoleculeBuilderDTO applicationMoleculeBuilderDTO, FormulaBuilderDTO newFormulaDTO)
        {
            var applicationMoleculeBuilder = _context.Get <IApplicationMoleculeBuilder>(applicationMoleculeBuilderDTO.Id);
            var newFormula = FormulaCache.FindById(newFormulaDTO.Id);

            AddCommand(new EditObjectBasePropertyInBuildingBlockCommand(_formulaPropertyName, newFormula, applicationMoleculeBuilder.Formula, applicationMoleculeBuilder, BuildingBlock).Run(_context));
        }