Пример #1
0
        public IDiagramModel CreateCopy(string containerId = null)
        {
            IContainerBase source = null;

            if (String.IsNullOrEmpty(containerId))
            {
                source = this;
            }
            else if (_nodes.Contains(containerId))
            {
                source = GetNode <IContainerNode>(containerId);
            }

            // cannot create copy for other
            if (source == null)
            {
                return(null);
            }


            var diagramModel = new DiagramModel {
                DiagramOptions = DiagramOptions
            };
            var goCollection = new GoCollection {
                source as GoNode
            };

            var copy = diagramModel.CopyFromCollection(goCollection);

            // _nodes is empty - overridden Add method seems not to be used in CopyFromCollection
            foreach (var node in diagramModel.GetAllChildren <IBaseNode>())
            {
                diagramModel.AddNodeId(node);
            }

            return(diagramModel);
        }