private void InitializeUI() { imageList = new ImageList(); this.ImageList = imageList; this.StateImageList = imageList; BeginUpdate(); try { root = new PathNode("", "My Computer"); foreach (DriveInfo di in DriveInfo.GetDrives()) { if (!di.IsReady) continue; string name = di.Name; if (!string.IsNullOrEmpty(di.VolumeLabel)) name += string.Format("({0})", di.VolumeLabel); Icon icon = Shell.SmallIconFromPath(di.Name); imageList.Images.Add(di.Name, icon); PathNode n = new PathNode(di.Name, name); root.children[di.Name.ToUpper()] = n; n.ImageKey = di.Name; root.Nodes.Add(n); } Nodes.Add(root); root.Expand(); } finally { EndUpdate(); } }
public void ExpandDirectories() { if (expanded || string.IsNullOrEmpty(path)) return; expanded = true; Nodes.Clear(); FileSystemTree fst = this.TreeView as FileSystemTree; foreach (string subdir in Directory.EnumerateDirectories(path)) { string name = Path.GetFileName(subdir); PathNode child = new PathNode(subdir, name); children[name.ToUpper()] = child; child.SelectedImageKey = child.ImageKey = fst.GetImageKey(subdir); Nodes.Add(child); } }