protected string BuildRelFilePath(FileTreeNode aNode, string BaseDir) { string EndDir = aNode.Text; string StartDir = BuildDirPath((FileTreeNode)aNode.Parent).Substring(BaseDir.Length); return(StartDir + "\\" + EndDir); }
private void tvTree_AfterSelect(object sender, TreeViewEventArgs e) { FileTreeNode node = (FileTreeNode)tvTree.SelectedNode; if (node != null) { var info = node.NodeFileInfo; tbSelectedFile.Text = info.Name; } }
public void CopyToTreeControl(TreeView tv, bool fullTree) { FileTreeNode aNode = new FileTreeNode(false, RootDirectoryPath, 0, 1); tv.Nodes.Add(aNode); PopulateFiles(aNode, RootSlynchyDirectory, fullTree); PopulateSubDirs(aNode, RootSlynchyDirectory, fullTree); tv.Nodes[0].ExpandAll(); }
private void butDeleteSelectedFile_Click(object sender, EventArgs e) { FileTreeNode node = (FileTreeNode)tvTree.SelectedNode; if (node != null) { var info = node.NodeFileInfo; File.Delete(info.FullName); LoadTree(); } }
protected string BuildDirPath(FileTreeNode aNode) { FileTreeNode theNode = aNode; string Dir = ""; while (theNode != null) { Dir = theNode.Text + Dir; theNode = (FileTreeNode)theNode.Parent; } return(Dir); }
private static void CloneChildFileNodes(FileTreeNode ParentSourceNode, FileTreeNode ParentDestNode) { FileTreeNode aNode = null; for (int i = 0; i < ParentSourceNode.Nodes.Count; i++) { aNode = (FileTreeNode)ParentSourceNode.Nodes[i]; FileTreeNode aClone = aNode.FTClone(); ParentDestNode.Nodes.Add(aClone); if (aNode.Nodes.Count > 0) { CloneChildFileNodes(aNode, aClone); } } }
public void CopyToTreeControl(TreeView tv, Label treeName, Label dirCount, Label fileCount, bool fullTree) { treeName.Text = Name; int CountDir = 1; int CountFiles = 0; FileTreeNode aNode = new FileTreeNode(false, RootDirectoryPath, 0, 1); tv.Nodes.Add(aNode); PopulateFiles(aNode, RootSlynchyDirectory, fileCount, ref CountFiles, fullTree); PopulateSubDirs(aNode, RootSlynchyDirectory, dirCount, ref CountDir, fileCount, ref CountFiles, fullTree); tv.Nodes[0].ExpandAll(); }
private void PopulateSubDirs(FileTreeNode aNode, SlynchyDirectory sDir, bool fullTree) { foreach (var subDir in sDir.SubDirectoryInfoList) { if (!subDir.Exclude) { var SubDirName = "\\" + subDir.LastDirectoryPart(subDir.Info.Name); FileTreeNode ChildNode = new FileTreeNode(false, SubDirName, 0, 1); aNode.Nodes.Add(ChildNode); PopulateFiles(ChildNode, subDir, fullTree); Application.DoEvents(); PopulateSubDirs(ChildNode, subDir, fullTree); } } Application.DoEvents(); }
private void PopulateFiles(FileTreeNode aNode, SlynchyDirectory sDir, bool fullTree) { foreach (var fileInfo in sDir.DirectoryFileInfoList) { var FileName = fileInfo.Info.Name; if (fullTree) { aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2)); } else { if (!fileInfo.Exclude) { aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2)); } } } Application.DoEvents(); }
public static void CloneFileTreeView(System.Windows.Forms.TreeView tvSource, System.Windows.Forms.TreeView tvDest) { FileTreeNode RootNodeSource = (FileTreeNode)tvSource.Nodes[0]; tvDest.Nodes.Add(RootNodeSource.FTClone()); FileTreeNode RootNodeDest = (FileTreeNode)tvDest.Nodes[0]; FileTreeNode aNode = null; for (int i = 0; i < RootNodeSource.Nodes.Count; i++) { aNode = (FileTreeNode)RootNodeSource.Nodes[i]; FileTreeNode aClone = aNode.FTClone(); RootNodeDest.Nodes.Add(aClone); if (aNode.Nodes.Count > 0) { CloneChildFileNodes(aNode, aClone); } } }
private void PopulateFiles(FileTreeNode aNode, SlynchyDirectory sDir, Label countDisplay, ref int count, bool fullTree) { count += sDir.DirectoryFileInfoList.Count; countDisplay.Text = count.ToString() + " Files"; foreach (var fileInfo in sDir.DirectoryFileInfoList) { if (fullTree) { var FileName = fileInfo.Info.Name; aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2)); } else { if (!fileInfo.Exclude) { var FileName = fileInfo.Info.Name; aNode.Nodes.Add(new FileTreeNode(true, FileName, fileInfo.Info, 2)); } } } Application.DoEvents(); }
private void PopulateSubDirs(FileTreeNode aNode, SlynchyDirectory sDir, Label dirCountDisplay, ref int dirCount, Label fileCountDisplay, ref int fileCount, bool fullTree) { foreach (var subDir in sDir.SubDirectoryInfoList) { if (!subDir.Exclude) { var SubDirName = "\\" + subDir.LastDirectoryPart(subDir.Info.Name); FileTreeNode ChildNode = new FileTreeNode(false, SubDirName, 0, 1); aNode.Nodes.Add(ChildNode); dirCount++; dirCountDisplay.Text = dirCount.ToString() + " Directories"; PopulateFiles(ChildNode, subDir, fileCountDisplay, ref fileCount, fullTree); Application.DoEvents(); PopulateSubDirs(ChildNode, subDir, dirCountDisplay, ref dirCount, fileCountDisplay, ref fileCount, fullTree); } } Application.DoEvents(); }
protected string BuildRelDirPath(FileTreeNode aNode, string BaseDir) { return(BuildDirPath(aNode).Substring(BaseDir.Length)); }
public FileTreeNode FTClone() { FileTreeNode aNode = (FileTreeNode)base.Clone(); aNode.IsFile = this.IsFile; return aNode; }