Пример #1
0
        private void insertExternalNeighborLinks(IContainerNode parentContainerNode, GoLayoutForceDirectedNetwork net)
        {
            foreach (var childContainerNode in parentContainerNode.GetDirectChildren <IContainerNode>())
            {
                foreach (var neighborhoodNode in childContainerNode.GetLinkedNodes <INeighborhoodNode>())
                {
                    if (!parentContainerNode.ContainsChildNode(neighborhoodNode, true))
                    {
                        var  otherContainerNode = neighborhoodNode.GetOtherContainerNode(childContainerNode);
                        var  nodeOnBoundary     = new GoLayoutForceDirectedNode();
                        var  pos         = neighborhoodNode.Location;
                        bool pointExists = GoObject.GetNearestIntersectionPoint(parentContainerNode.Bounds, otherContainerNode.Center, childContainerNode.Center, out pos);

                        if (!pointExists)
                        {
                            continue;
                        }

                        //to be not deleted due to invisible node, seems to set also the position
                        nodeOnBoundary.GoObject  = neighborhoodNode as GoObject;
                        nodeOnBoundary.IsFixed   = true;
                        nodeOnBoundary.UserFlags = NodeLayoutType.REMOTE_CONTAINER_BOUNDARY_NODE;

                        //set Position after setting GoObject, because setting GoObject seems to set position
                        nodeOnBoundary.Position = pos;
                        net.AddNode(nodeOnBoundary);
                        net.LinkNodes(net.FindNode(childContainerNode as GoObject), nodeOnBoundary, neighborhoodNode as GoObject);
                    }
                }
            }
        }
Пример #2
0
        private void copyContainerRecursive(IContainerBase sourceTopContainer, IContainerBase targetTopContainer,
                                            IContainerNode targetContainerNode, int topLevelsToSkip)
        {
            bool   expanded = targetContainerNode.IsExpanded;
            PointF location = targetContainerNode.Location;

            targetContainerNode.IsExpanded = true;

            foreach (var targetNode in targetContainerNode.GetDirectChildren <IContainerNode>())
            {
                copyContainerRecursive(sourceTopContainer, targetTopContainer, targetNode, topLevelsToSkip);

                var sourceNode = getNodeByPath(sourceTopContainer, targetTopContainer, targetNode, topLevelsToSkip);

                if (sourceNode == null)
                {
                    targetNode.Collapse(0);
                    continue;
                }

                targetNode.CopyLayoutInfoFrom(sourceNode, location);
            }

            foreach (var targetNode in targetContainerNode.GetDirectChildren <IElementBaseNode>())
            {
                var sourceNode = getNodeByPath(sourceTopContainer, targetTopContainer, targetNode, topLevelsToSkip);
                if (sourceNode == null)
                {
                    continue;
                }
                targetNode.CopyLayoutInfoFrom(sourceNode, location);
            }

            // reset Expansion state and Location of container itself
            targetContainerNode.IsExpanded = expanded;
            targetContainerNode.Location   = location;
        }