Beispiel #1
0
    public void init(MultTreeNode pNode = null)
    {
        if (childList == null)
        {
            childList = new List <MultTreeNode>();
        }
        parentId = 0;
        selfId   = 0;
        nodeName = "";
        obj      = null;

        if (pNode != null)
        {
            nodeName = pNode.getNodeName();
            if (pNode.getObj() != null)
            {
                obj = new Hashtable((Hashtable)pNode.getObj());
            }
            parentNode = pNode.getParentNode();
            if (pNode.getChildList() != null)
            {
                childList = new List <MultTreeNode>(pNode.getChildList());
            }
        }
    }
Beispiel #2
0
 /// <summary>
 /// TreeNode构造函数
 /// </summary>
 /// <param name="node"></param>
 public MultTreeNodeData(MultTreeNode node)
 {
     //this.Text = node.getNodeName();
     //this.Name = node.getSelfId();
     this.Text = node.NodeName;
     this.Name = node.SelfId;
     //  this.ImageIndex = node.ImageIndex;
     //  this.SelectedImageIndex = node.SelectedImageIndex;
     // this.Checked = node.Checked;
     // this.Expanded = node.IsExpanded;
     this.Nodes = new MultTreeNodeData[node.getChildList().Count];
     if ((!(node.Obj == null)) && node.Obj.GetType().IsSerializable)
     {
         this.Tag = node.Obj;
     }
     else
     {
         this.Tag = null;
     }
     if (node.getChildList().Count == 0)
     {
         return;
     }
     for (int i = 0; i <= node.getChildList().Count - 1; i++)
     {
         Nodes[i] = new MultTreeNodeData(node.getChildList()[i]);
     }
 }
Beispiel #3
0
            /// <summary>
            /// TreeNodeData返回TreeNode
            /// </summary>
            /// <returns></returns>
            public MultTreeNode ToTreeNode()
            {
                MultTreeNode ToTreeNode = new MultTreeNode();

                //    ToTreeNode.Checked = this.Checked;
                //  ToTreeNode.setObj(this.Tag);
                ToTreeNode.Obj      = this.Tag;
                ToTreeNode.NodeName = this.Text;
                ToTreeNode.SelfId   = this.Name;
                // ToTreeNode.setNodeName(this.Name);
                //if (this.Expanded)
                //{
                //    ToTreeNode.Expand();
                //}
                if (this.Nodes == null && this.Nodes.Length == 0)
                {
                    return(null);
                }
                if (ToTreeNode != null && this.Nodes.Length == 0)
                {
                    return(ToTreeNode);
                }
                for (int i = 0; i <= this.Nodes.Length - 1; i++)
                {
                    ToTreeNode.getChildList().Add(this.Nodes[i].ToTreeNode());
                }
                return(ToTreeNode);
            }
Beispiel #4
0
            /// <summary>
            /// TreeNode构造函数
            /// </summary>
            /// <param name="node"></param>
            public TreeNodeData(MultTreeNode node)
            {
                //this.Text = node.getNodeName();
                //this.Name = node.getSelfId();
                this.Text = node.NodeName;
                this.Name = node.SelfId;
                #region 无用代码
                // this.Parent = node.getParentId();
                //  this.ImageIndex = node.ImageIndex;
                //this.SelectedImageIndex = node.SelectedImageIndex;
                //  this.Checked = node.Checked;
                // this.Expanded = node.IsExpanded;
                #endregion

                this.Nodes = new TreeNodeData[node.getChildNodeCount()];
                if ((!(node.Obj == null)) && node.Obj.GetType().IsSerializable)
                {
                    this.Tag = node.Obj;
                }
                else
                {
                    this.Tag = null;
                }

                #region  无用代码
                //if (node.getParentNode() != null)
                //{
                //    this.parentNodes = node.getParentNode();
                //}
                //else
                //{
                //    this.parentNodes = null;
                //}
                #endregion

                if (node.getChildNodeCount() == 0)
                {
                    return;
                }
                for (int i = 0; i <= node.getChildNodeCount() - 1; i++)
                {
                    Nodes[i] = new TreeNodeData(node.getChildList()[i]);
                }
            }
Beispiel #5
0
    /// <summary>
    /// find one note in tree.
    /// 2016-03-04 16:21:34
    /// modify when empty path .return this instead of null.
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    public MultTreeNode findNodeByPath(string path)
    {
        if (string.IsNullOrEmpty(path))
        {
            return(this);
        }
        //path = StrUtils.FormatPath(path);
        //path = StrUtils.GetSDirString(path);
        string[] pathArr = path.Split(new char[] { '\\' }); //StrUtils.Split(path, "\\"); //path.Split('\\');
        if (pathArr[0] == null)
        {
            pathArr[0] = path;
        }

        // make sure this is root path.
        if (nodeName != pathArr[0])
        {
            return(null);
        }

        MultTreeNode node = this;

        for (int i = 0; i < pathArr.Count(); i++)
        {
            // 说明:注释。不知道为什么要加这句 可能会影响代码生成。需要注意
            // 修改为 break; => continue; \ 查找具有 相同节点名称的 子节点 逻辑
            // 短暂测试是正常的。
            // 修改日期:2014-8-5 14:20:28
            if (string.IsNullOrEmpty(pathArr[i]))
            {
                List <MultTreeNode> list = node.getChildList();
                if (i < pathArr.Count() - 1)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (list[j].getNodeName() == pathArr[i + 1])
                        {
                            node = list[j];
                        }
                    }
                }
                continue;
            }
            // use path to avoid error like 0\0\0
            // 2016-07-11 21:34:54
            string nodePath = node.getPath();
            string testPath = StrUtils.FromArr(ArrayUtils.SplitArray <string>(pathArr, 0, i - 1), "\\");

            if (node.getNodeName() == pathArr[i] && nodePath == testPath)
            {
                List <MultTreeNode> list = node.getChildList();
                for (int j = 0; j < list.Count; j++)
                {
                    if (i + 1 < pathArr.Length && list[j].getNodeName() == pathArr[i + 1])
                    {
                        node = list[j];
                    }
                }
            }
            else
            {
                node = null;
                break;
            }
        }
        return(node);
    }