private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e) { TreeNodeFolder tnf = e.Node as TreeNodeFolder; if (tnf != null && !tnf.NextLevelLoaded) { tnf.NextLevelLoaded = true; List <TreeNodeLoader> l = new List <TreeNodeLoader>(); for (int i = 0; i < e.Node.Nodes.Count; i++) { TreeNodeLoader tnl = e.Node.Nodes[i] as TreeNodeLoader; if (tnl != null) { l.Add(tnl); } } if (l.Count > 0) { for (int i = 0; i < l.Count; i++) { e.Node.Nodes.Remove(l[i]); } for (int i = 0; i < l.Count; i++) { l[i].LoadNextLevel(tnf); } } } }
void filesTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { DirectoryInfo currentDirInfo = (DirectoryInfo)e.Node.Tag; FillFileListView(currentDirInfo); try { TreeNodeLoader.GetCurrentDirectories(currentDirInfo.GetDirectories(), e.Node); } catch (UnauthorizedAccessException) { MessageBox.Show("You don't have permission to access this folder"); } searchBar.Text = currentDirInfo.FullName; }
/// <summary> /// This method Updates the list of Nodes in the TreeView part of the window. /// </summary> /// <param name="pathToGo">A string which shows the path of the node.</param> private void FillNodes(string pathToGo) { filesTreeView.Nodes.Clear(); filesTreeView.Nodes.Add(TreeNodeLoader.PopulateTreeView(pathToGo)); }
private void MainWindow_Load(object sender, EventArgs e) { searchBar.Text = defaultHomeFolder; filesTreeView.Nodes.Add(TreeNodeLoader.PopulateTreeView(defaultHomeFolder)); }