public void ApplyLayoutTemplate(IContainerBase containerBase, string diagramTemplateXmlFilePath, bool recursive)
        {
            if (string.IsNullOrEmpty(diagramTemplateXmlFilePath))
            {
                diagramTemplateXmlFilePath = _dialogCreator.AskForFileToOpen(AppConstants.Captions.OpenLayoutFromFile, AppConstants.Filter.MOBI_DIAGRAM_TEMPLATE_FILTER, AppConstants.DirectoryKey.LAYOUT);
            }

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

            try
            {
                _view.BeginUpdate();
                _diagramTask.ApplyLayoutTemplate(containerBase, diagramTemplateXmlFilePath, DiagramModel, DiagramManager.RefreshFromDiagramOptions, recursive);
                foreach (var container in containerBase.GetAllChildren <IContainerNode>())
                {
                    container.IsExpanded = container.IsExpandedByDefault; // set Default Expansion in the container, because subnodes may be collapsed during Layout application, e.g. in application of container layout to diagram
                }
            }
            finally
            {
                _view.EndUpdate();
            }
        }
        public void LayoutReactionDiagram(IContainerBase containerBase)
        {
            var diagramModel = containerBase as IDiagramModel;

            foreach (var reactionNode in containerBase.GetAllChildren <ReactionNode>())
            {
                reactionNode.DisplayEductsRight = false;
            }

            _layerLayouter.PerformLayout(containerBase, null);

            if (diagramModel != null)
            {
                diagramModel.IsLayouted = true;
            }
        }
Beispiel #3
0
        public void ApplyLayoutTemplate(IContainerBase containerBase, string diagramTemplateXmlFilePath, IDiagramModel model, Action refreshFromDiagramOptions, bool recursive)
        {
            if (string.IsNullOrEmpty(diagramTemplateXmlFilePath))
            {
                throw new MoBiException(AppConstants.Exceptions.MissingName);
            }
            var diagramTemplateModel = LoadDiagramTemplate(diagramTemplateXmlFilePath);

            if (diagramTemplateModel == null)
            {
                throw new MoBiException(AppConstants.Exceptions.DeserializationFailed);
            }

            try
            {
                model.BeginUpdate();

                var copier = new LayoutCopyService();
                if (recursive)
                {
                    copier.CopyRecursive(diagramTemplateModel, containerBase);
                }
                else
                {
                    copier.Copy(diagramTemplateModel, containerBase);
                }

                foreach (var neighborhoodNode in containerBase.GetAllChildren <INeighborhoodNode>())
                {
                    neighborhoodNode.AdjustPosition();
                }

                refreshFromDiagramOptions();
                model.IsLayouted = true;
            }
            finally { model.EndUpdate(); }
        }