private void GetTreeNode(ref WinUglifier.TreeView.TreeNode root, string[] items) { foreach (string item in items) { if (Directory.Exists(item)) // is directory ? { WinUglifier.TreeView.TreeNode node = new WinUglifier.TreeView.TreeNode(null, Path.GetFileName(item)); SetNodeImage(item, ref node); string[] files = Directory.GetFiles(item); if (files.Length > 0) // has files? { GetTreeNode(ref node, files); } foreach (string dir in Directory.GetDirectories(item)) { GetTreeNode(ref node, new string[] { dir }); } if (node.Value != null || (node.Value == null && node.Nodes.Count > 0)) { root.Nodes.Add(node); } } else { string name = Path.GetFileName(item); if (IsAddableType(name)) { WinUglifier.TreeView.TreeNode node = new WinUglifier.TreeView.TreeNode(item, name); SetNodeImage(item, ref node); root.Nodes.Add(node); } } } }
private void SetNodeImage(string item, ref WinUglifier.TreeView.TreeNode node) { treeItems.ImageList.Images.Add(ShellIcon.GetSmallIcon(item).ToBitmap(), Color.Empty); node.ImageIndex = treeItems.ImageList.Images.Count - 1; node.SelectedImageIndex = treeItems.ImageList.Images.Count - 1; }