示例#1
0
 private void InitializeNodes(DependencyViewerNode.NodeInputSide treeSide)
 {
     TreeLayout.ForeachNode_PostOrderTraversal(_refTargetNode, treeSide, (data) =>
     {
         int direction             = (treeSide == DependencyViewerNode.NodeInputSide.Right ? 1 : -1);
         data.currentNode.Position = new Vector2(data.depth * (data.currentNode.GetWidth() + DependencyViewerGraphDrawer.DistanceBetweenNodes.x) * direction, -1);
         data.currentNode.Mod      = 0;
     });
 }
示例#2
0
    private void CalculateInitialY(DependencyViewerNode.NodeInputSide treeSide)
    {
        TreeLayout.ForeachNode_PostOrderTraversal(_refTargetNode, treeSide, (data) =>
        {
            var node = data.currentNode;

            if (node.IsLeaf(data.TreeSide))
            {
                if (node.IsFirstSibling(data.TreeSide))
                {
                    node.SetPositionY(0);
                }
                else
                {
                    var previousSibling = node.GetPreviousSibling(data.TreeSide);
                    node.SetPositionY(previousSibling.Position.y + previousSibling.GetHeight() + DependencyViewerGraphDrawer.DistanceBetweenNodes.y);
                }
            }
            else if (node.GetNumChildren(data.TreeSide) == 1)
            {
                if (node.IsFirstSibling(data.TreeSide))
                {
                    node.SetPositionY(node.GetChildren(data.TreeSide)[0].Position.y);
                }
                else
                {
                    var previousSibling = node.GetPreviousSibling(data.TreeSide);
                    node.SetPositionY(previousSibling.Position.y + previousSibling.GetHeight() + DependencyViewerGraphDrawer.DistanceBetweenNodes.y);
                    node.Mod = node.Position.y - node.GetChildren(data.TreeSide)[0].Position.y;
                }
            }
            else
            {
                var prevChild = node.GetFirstChild(data.TreeSide);
                var nextChild = node.GetLastChild(data.TreeSide);
                float mid     = (nextChild.Position.y - prevChild.Position.y) / 2;

                if (node.IsFirstSibling(data.TreeSide))
                {
                    node.SetPositionY(mid);
                }
                else
                {
                    node.SetPositionY(node.GetPreviousSibling(data.TreeSide).Position.y + node.GetHeight() + DependencyViewerGraphDrawer.DistanceBetweenNodes.y);
                    node.Mod = node.Position.y - mid;
                }
            }

            if (node.GetNumChildren(data.TreeSide) > 0 && !node.IsFirstSibling(data.TreeSide))
            {
                CheckForConflicts(node, data.depth, data.TreeSide);
            }
        });
    }