private static void LoadItems(IVirtualFolder folder, ConfigNode parentnode) { var loaded = new Dictionary <string, ConfigFileNode>(); List <ConfigNode> result = new List <ConfigNode>(); var files = folder.LoadFiles(); files.Sort((a, b) => a.Name.Length - b.Name.Length); foreach (IVirtualFile file in files) { if (PrefixTest(loaded, file)) { continue; } var childnode = ConfigNodeHandlerAddonType.Instance.LoadFile(parentnode, file); if (childnode == null) { continue; } parentnode.Children.Add(childnode); loaded[file.Name] = childnode; } foreach (IVirtualFolder cf in folder.LoadFolders()) { var master = PrefixTest(loaded, cf); if (master != null) { var childnode = ConfigNodeHandlerAddonType.Instance.LoadSubFolder(master, cf); if (childnode == null) { childnode = new ConfigFolderNode(master, cf) { _Title = cf.Name.Substring(master.Name.Length), _Image = CoreIcons.img_folder, } } ; childnode._AutoSelect = false; LoadItems(cf, childnode); master.Children.Add(childnode); } else { var childnode = ConfigNodeHandlerAddonType.Instance.LoadFolder(parentnode, cf); if (childnode == null) { continue; } LoadItems(cf, childnode); parentnode.Children.Add(childnode); } } }
public static void CopyFolderContent(this IVirtualFolder folder, IVirtualFolder dstfolder, CopyFileMode mode) { foreach (var file in folder.LoadFiles()) { file.CopyFileTo(dstfolder.GetFile(file.Name), mode); } foreach (var fld in folder.LoadFolders()) { fld.CopyResursiveFolderTo(dstfolder.GetFolder(fld.Name), mode); } }
//public override void DragDrop(ITreeNode draggingNode) //{ // if (draggingNode is FileTreeNodeBase || draggingNode is VirtualFileTreeNodeBase) // { // ContextMenuStripEx menu = new ContextMenuStripEx(); // var copy = menu.Items.Add(Texts.Get("s_copy_here")); // copy.Click += (sender, ev) => DragDropFile(draggingNode, CopyFileMode.Copy); // var move = menu.Items.Add(Texts.Get("s_move_here")); // move.Click += (sender, ev) => DragDropFile(draggingNode, CopyFileMode.Move); // menu.ShowOnCursor(); // } //} private void DoGetChildren() { var loaded = new Dictionary <string, ITreeNode>(); List <ITreeNode> result = new List <ITreeNode>(); var files = m_folder.LoadFiles(); HTree.CallFilterFolderFiles(files); files.Sort((a, b) => a.FullPath.Length - b.FullPath.Length); foreach (IVirtualFile file in files) { if (PrefixTest(loaded, file)) { continue; } ITreeNode node = null; if (file.DiskPath != null) { if (DeletedFileRegistrer.DeletedInvisible.Contains(file.DiskPath.ToLower())) { continue; } if (DeletedFileRegistrer.DeletedVisible.Contains(file.DiskPath.ToLower())) { node = new DeletedPathNode(this, file.DiskPath); } } try { if (node == null) { node = NodeFactory.FromFile(this, file); } } catch { node = new UnknownVirtualFileNode(this, new UnknownFileHandler { FileObject = file }); } //if (node == null) node = new UnknownVirtualFileNode(this, file); if (node != null) { result.Add(node); } if (node is VirtualFileTreeNodeBase) { loaded[file.Name] = (VirtualFileTreeNodeBase)node; } } var dirs = m_folder.LoadFolders(); dirs.Sort((a, b) => a.FullPath.Length - b.FullPath.Length); foreach (var dir in dirs) { //if (System.IO.Path.GetFileName(dir).ToLower().StartsWith(".private")) continue; if (dir.DiskPath != null && IOTool.IsVersioningDirectory(dir.DiskPath)) { continue; } if (PrefixTest(loaded, dir)) { continue; } ITreeNode node = null; if (dir.DiskPath != null) { if (DeletedFileRegistrer.DeletedInvisible.Contains(dir.DiskPath.ToLower())) { continue; } if (DeletedFileRegistrer.DeletedVisible.Contains(dir.DiskPath.ToLower())) { node = new DeletedPathNode(this, dir.DiskPath); } } if (node == null) { var newnode = new VirtualFolderTreeNode(this, dir, dir.Name); loaded[dir.Name] = newnode; node = newnode; } result.Add(node); } result.Sort(CompareNodes); PostprocessChildren(result); m_children = result.ToArray(); }