public override void RequestRootNode() { // do not call base class here // base.RequestRootNode(); AttachSystemImageList(Helper); // setup up root node collection switch (RootFolder) { case Raccoom.Win32.ShellAPI.CSIDL.DESKTOP: // create root node <Desktop> TreeNodePath desktopNode = CreateTreeNode(Helper.TreeView.Nodes, null, _shell.DesktopItem); _rootCollection = desktopNode.Nodes; // enable shell objects always to fill desktop level bool settingBackup = _showAllShellObjects; _showAllShellObjects = true; // set setting back to original value _showAllShellObjects = settingBackup; break; case Raccoom.Win32.ShellAPI.CSIDL.DRIVES: this.FillMyComputer(_shell.MyComputerItem, Helper.TreeView.Nodes, Helper); break; default: // TreeNodePath rootNode = CreateTreeNode(Helper.TreeView.Nodes, null, _shell.GetSpecialFolderShellItem(RootFolder)); if (!rootNode.HasDummyNode) { rootNode.AddDummyNode(); } _rootCollection = rootNode.Nodes; break; } }
public override void RequestChildNodes(TreeNodePath parent, System.Windows.Forms.TreeViewCancelEventArgs e) { if (parent.Path == null) { return; } // System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(parent.Path); // check persmission new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, directory.FullName).Demand(); // foreach (System.IO.DirectoryInfo dir in directory.GetDirectories()) { if ((dir.Attributes & System.IO.FileAttributes.System) == System.IO.FileAttributes.System) { continue; } if ((dir.Attributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden) { continue; } TreeNodePath newNode = this.CreateTreeNode(parent, dir.Name, dir.FullName, false, false, false); // try { if (dir.GetDirectories().GetLength(0) > 0) { newNode.AddDummyNode(); } } catch (System.UnauthorizedAccessException) { // eat the exception } catch (System.Exception ex) { throw ex; } } if (ShowFiles) { foreach (System.IO.FileInfo file in directory.GetFiles()) { this.CreateTreeNode(parent.Nodes, parent, file.Name, file.FullName, true, false, false); } } }
private TreeNodePath CreateTreeNode(string text, string path, bool addDummyNode, bool isSpecialFolder) { // if (text == "Pictures" || text == "Videos") { } TreeNodePath newNode = new TreeNodePath(text, isSpecialFolder); newNode.Path = path; // if (addDummyNode) { // add dummy node, otherwise there is no + sign newNode.AddDummyNode(); } // return(newNode); }
public virtual void RequestSubDirs(TreeViewFolderBrowserHelper helper, TreeNodePath parent, TreeViewCancelEventArgs e) { if (parent.Path == null) { return; } // DirectoryInfo directory = new DirectoryInfo(parent.Path); // check persmission new FileIOPermission(FileIOPermissionAccess.PathDiscovery, directory.FullName).Demand(); // // Sort the Directories, as Samba might return unsorted DirectoryInfo[] dirInfo = directory.GetDirectories(); Array.Sort(dirInfo, new Comparison <DirectoryInfo>( delegate(DirectoryInfo d1, DirectoryInfo d2) { return(string.Compare(d1.Name, d2.Name)); })); foreach (DirectoryInfo dir in dirInfo) { if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } TreeNodePath newNode = CreateTreeNode(helper, dir.Name, dir.FullName, false, ((helper.TreeView.CheckboxBehaviorMode != CheckboxBehaviorMode.None) && (parent.Checked)), false); parent.Nodes.Add(newNode); // try { if (dir.GetDirectories().GetLength(0) > 0) { newNode.AddDummyNode(); } } catch {} } }
/// <summary> /// Creates a tree node and add it to the <c>TreeNodeCollection</c>. /// </summary> /// <param name="text">The text displayed in the label of the tree node.</param> /// <param name="path">The path the node represents.</param> /// <param name="addDummyNode">True to add + sign, otherwise no + sign appears.</param> /// <param name="forceChecked">True to check node in each case, otherwise false to allow normal check against selected paths.</param> /// <param name="isSpecialFolder">Specifies if this node is a special folder. Special folders do not request data from the attached data provider.</param> /// <returns></returns> private TreeNodePath CreateTreeNode(string text, string path, bool addDummyNode, bool forceChecked, bool isSpecialFolder) { // TreeNodePath newNode = new TreeNodePath(text, isSpecialFolder); // path newNode.Path = path; // try { _treeView.SuppressCheckEvent(true); // if (forceChecked) { newNode.Checked = true; } else { newNode.Checked = _treeView.SelectedDirectories.Contains(path); } _treeView.MarkNode(newNode); } catch (System.ApplicationException e) { System.Diagnostics.Debug.WriteLine(e.Message, _treeView.Name); } finally { _treeView.SuppressCheckEvent(false); } // if (addDummyNode) { // add dummy node, otherwise there is no + sign newNode.AddDummyNode(); } // return(newNode); }
/// <summary> /// Used for drives like floppy, cd - rom ect. where it can be that no valid medium is inserted. /// in this case the click on the + will remove the +, after double click there's a new + to give the user /// the chance to browse this device after inserting a valid medium. /// </summary> protected override void OnDoubleClick(System.EventArgs e) { if (this.SelectedNode == null) { return; } // TreeNodePath node = this.SelectedNode as TreeNodePath; if (node == null || node.Path == null) { return; } // if ((node.Nodes.Count > 0) || (node.Path.Length > 3)) { return; } // node.AddDummyNode(); // base.OnDoubleClick(e); }
/// <summary> /// Creates a tree node and add it to the <c>TreeNodeCollection</c>. /// </summary> /// <param name = "text">The text displayed in the label of the tree node.</param> /// <param name = "path">The path the node represents.</param> /// <param name = "addDummyNode">True to add + sign, otherwise no + sign appears.</param> /// <param name = "forceChecked">True to check node in each case, otherwise false to allow normal check against selected paths.</param> /// <param name = "isSpecialFolder">Specifies if this node is a special folder. Special folders do not request data from the attached data provider.</param> /// <returns></returns> public virtual TreeNodePath CreateTreeNode(string text, string path, bool addDummyNode, bool forceChecked, bool isSpecialFolder) { TreeNodePath newNode = new TreeNodePath(text, isSpecialFolder); // path newNode.Path = path; // try { _treeView.SupressCheckEvent(true); // if (forceChecked) { newNode.Checked = true; } else { newNode.Checked = _treeView.SelectedDirectories.Contains(path); } _treeView.MarkNode(newNode); } catch (Exception e) { Debug.WriteLine(e.Message, _treeView.Name); } finally { _treeView.SupressCheckEvent(false); } // if (addDummyNode) { // add dummy node, otherwise there is no + sign newNode.AddDummyNode(); } // return newNode; }