示例#1
0
        public void AddNodes(TreeNode thisNode, String path, Int32 getLevels)
        {
            String[] dirNames;
            labelStatus.Text = "Adding folder " + thisNode.Text;
            dirNames         = myPhone.GetDirectories(path);
            if (thisNode.TreeView != null)
            {
                thisNode.TreeView.BeginUpdate();
            }

            if (dirNames.Length > 0)
            {
                if (getLevels != 0)
                {
                    for (int i = 0; i < dirNames.Length; i++)
                    {
                        TreeNode childNode = new TreeNode(dirNames[i]);
                        childNode.ImageKey = "Folder";
                        childNode.Name     = path + "/" + dirNames[i];
                        ItemProperty thisItem = ipItems.FindItem(childNode.Name);
                        if (thisItem != null)
                        {
                            childNode.ImageKey = thisItem.ImageKey;
                            childNode.Tag      = thisItem.Tag;
                        }
                        else
                        {
                            childNode.ImageKey = "Other";
                            childNode.Tag      = "Unknown";
                        }
                        AddNodes(childNode, path + "/" + dirNames[i], (getLevels - 1));
                        thisNode.Nodes.Add(childNode);
                        thisNode.Tag = "loaded";
                        Application.DoEvents();
                    }
                }
                else
                {
                    TreeNode childNode = new TreeNode(".");
                    childNode.Name = path + "/.";
                    thisNode.Nodes.Add(childNode);
                    if (thisNode.ImageKey == "Folder")
                    {
                        thisNode.ImageKey = "Folder-Files";
                    }
                    thisNode.Tag = "notloaded";
                    Application.DoEvents();
                }
            }
            if (thisNode.TreeView != null)
            {
                thisNode.TreeView.EndUpdate();
            }
        }