日期:2014-05-17 浏览次数:21016 次
private void AllNode(TreeNode Node)
{
for (int i = 0; i < Node.Nodes.Count; i++)
{
AllNode(Node.Nodes[i]);
}
if (Node.Name != "treZero")
{
strJosn =strJosn+ "\"" + Node.Text + "\":\"" + Node.Tag + "\"," ;
}
}
public class SerializeNode
{
public string Name{get;set;}
List<SerializeNode> Nodes{get;}
}
public class Tree
{
/// <summary>
/// 树的深度
/// </summary>
public int Depth { get; set; }
/// <summary>
/// 根结点
/// </summary>
public TreeNode Root { get; set; }
public void AddNode(int parentId, TreeNode insert)
{
var parent = FindNode(Root, parentId);
if (parent == null) return;
insert.Level = parent.Level + 1;//深度加1
//在叶子结点下插入
if (parent.Children == null)
{
parent.Children = new List<T