/// <summary> /// Create a virtual node of directories only based on its fullpath /// </summary> /// <param name="tree"></param> /// <param name="parent"></param> /// <param name="controller"></param> /// <param name="delimiter"></param> /// <param name="fullPath"></param> /// <param name="verifyFilename"></param> /// <param name="VirtualImageIndex"></param> /// <param name="NonVirtualImageIndex"></param> /// <param name="VirtualFileImageIndex"></param> /// <param name="NonVirtualFileImageIndex"></param> /// <returns></returns> private TreeNode CreateTreeNodeFullPath(TreeView tree, TreeNode parent, string workspaceDirectory, string delimiter, string fullPath, string verifyFilename, DirectorySetInfo fileInfo, int VirtualImageIndex, int NonVirtualImageIndex, int VirtualFileImageIndex, int NonVirtualFileImageIndex, bool directoriesOnly) { TreeNodeCollection topNodes = null; // Get our collections to search if (parent != null) { topNodes = parent.Nodes; } else { topNodes = tree.Nodes; } // Split the full path by the delimiter passed in string[] lastNodeParts = fullPath.Split(delimiter.ToCharArray()); // find the first name TreeNode alreadyExistNode = null; if (parent != null && string.Compare(parent.Text, lastNodeParts[0], true) == 0) { alreadyExistNode = parent; } else { alreadyExistNode = FindTreeNode(topNodes, lastNodeParts[0]); } // if exist find then next from the children of the first if (alreadyExistNode != null) { // Is this a file or directory if (fileInfo.Type == DirectorySetInfo.TYPE.Folder || fileInfo.Type == DirectorySetInfo.TYPE.FolderName) { // Must be a directory if (!DosUtils.PathIsDriveRooted(verifyFilename) || Directory.Exists(verifyFilename)) { alreadyExistNode.ImageIndex = NonVirtualImageIndex; alreadyExistNode.SelectedImageIndex = NonVirtualImageIndex; alreadyExistNode.ForeColor = SystemColors.ControlText; } else { alreadyExistNode.ImageIndex = VirtualImageIndex; alreadyExistNode.SelectedImageIndex = VirtualImageIndex; alreadyExistNode.ForeColor = SystemColors.GrayText; } } else { // Must be a file if (!DosUtils.PathIsDriveRooted(verifyFilename) || File.Exists(verifyFilename)) { alreadyExistNode.ImageIndex = NonVirtualFileImageIndex; alreadyExistNode.SelectedImageIndex = NonVirtualFileImageIndex; alreadyExistNode.ForeColor = SystemColors.ControlText; } else { alreadyExistNode.ImageIndex = VirtualFileImageIndex; alreadyExistNode.SelectedImageIndex = VirtualFileImageIndex; alreadyExistNode.ForeColor = SystemColors.GrayText; } } string LastNodePath = ""; // Update our path to be less than what it was for (int i = 1; i < lastNodeParts.Length; i++) { if (LastNodePath.Length == 0) { LastNodePath = lastNodeParts[i]; } else { LastNodePath = LastNodePath + "\\" + lastNodeParts[i]; } } if (LastNodePath.Length > 0) { // recurse into this function for the next node parent = CreateTreeNodeFullPath(tree, alreadyExistNode, workspaceDirectory, delimiter, LastNodePath, verifyFilename, fileInfo, VirtualImageIndex, NonVirtualImageIndex, VirtualFileImageIndex, NonVirtualFileImageIndex, directoriesOnly); } } // if not, create it and all its children right here else { foreach (string nodeLeafName in lastNodeParts) { if (nodeLeafName.Length > 0) { // If we are a file and this is a directoriesOnly create, skip if (fileInfo.Type == DirectorySetInfo.TYPE.File && directoriesOnly) { break; } // Create a node TreeNode newChild = new TreeNode(nodeLeafName); guiAssetTreeTag info = new guiAssetTreeTag(verifyFilename, newChild, workspaceDirectory, true); // Is this a file or directory if (fileInfo.Type == DirectorySetInfo.TYPE.Folder || fileInfo.Type == DirectorySetInfo.TYPE.FolderName) { // Set our type info.TagType = guiAssetTreeTag.TREE_FOCUS.FOLDER; // Must be a directory if (!DosUtils.PathIsDriveRooted(verifyFilename) || Directory.Exists(verifyFilename)) { newChild.ImageIndex = NonVirtualImageIndex; newChild.SelectedImageIndex = NonVirtualImageIndex; newChild.ForeColor = SystemColors.ControlText; } else { newChild.ImageIndex = VirtualImageIndex; newChild.SelectedImageIndex = VirtualImageIndex; newChild.ForeColor = SystemColors.GrayText; } } else { // Set our type info.TagType = guiAssetTreeTag.TREE_FOCUS.FILE; // Must be a file if (!DosUtils.PathIsDriveRooted(verifyFilename) || File.Exists(verifyFilename)) { newChild.ImageIndex = NonVirtualFileImageIndex; newChild.SelectedImageIndex = NonVirtualFileImageIndex; newChild.ForeColor = SystemColors.ControlText; } else { newChild.ImageIndex = VirtualFileImageIndex; newChild.SelectedImageIndex = VirtualFileImageIndex; newChild.ForeColor = SystemColors.GrayText; } } if (parent != null) { parent.Nodes.Add(newChild); parent = newChild; } else { int index = tree.Nodes.Add(newChild); parent = tree.Nodes[index]; } newChild.Tag = info; } } // If we are a file and this is a directoriesOnly create, skip if (fileInfo.Type == DirectorySetInfo.TYPE.File && directoriesOnly) { return(null); } return(parent); } return(null); }