Пример #1
0
    /// <summary>
    /// 添加节点。
    /// </summary>
    /// <param name="obj">Object.</param>
    private void ContextNodeAddCallback(object obj)
    {
        ITreeNode param = (ITreeNode)Activator.CreateInstance((Type)obj);

        TreeNode node = data.AddNode(param);

        node.rect = new Rect(mMousePosition.x, mMousePosition.y, TreeNode.WIDTH, TreeNode.HEIGHT);
    }
Пример #2
0
 protected static void AddChildNode(ref TreeNodeGraph graph, ref TreeNode parent, ITreeNode param)
 {
     if (parent != null)
     {
         for (int i = 0; i < param.children.Count; ++i)
         {
             TreeNode node = graph.AddNode(param.children[i]);
             node.parent = parent;
             AddChildNode(ref graph, ref node, param.children[i]);
         }
     }
 }
Пример #3
0
    public static TreeNodeGraph CreateGraph(ITreeNode root)
    {
        if (root == null)
        {
            return(null);
        }
        TreeNodeGraph graph = new TreeNodeGraph();

        var node = graph.AddNode(root);

        AddChildNode(ref graph, ref node, root);
        return(graph);
    }