/// <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); }
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]); } } }
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); }