Beispiel #1
0
        private void SetChildNodes(TreeNode node)
        {
            string path = string.Concat(node.FullPath, "\\");
              DirectoryInfo dir = new DirectoryInfo(path);
              if (dir.Exists) {
            try {
              var dirNodes = dir.GetDirectories()
            .Select(subDir => {
              TreeNode childNode = new OogTreeNode(true);
              childNode.Text = subDir.Name;
              childNode.ImageIndex = imageIndexDic[string.Empty];
              childNode.SelectedImageIndex = imageIndexDic[string.Empty];
              return childNode;
            });

              var extNodes = dir.GetFiles()
            .Select(file => new { File = file, Ext = Path.GetExtension(file.Name).ToLower() })
            .Where(fileExt => !string.IsNullOrEmpty(fileExt.Ext))
            .Where(fileExt => extractorFactories.ContainsKey(fileExt.Ext))
            .Select(fileExt => {
              TreeNode childNode = new OogTreeNode(false);
              childNode.Text = fileExt.File.Name;
              childNode.ImageIndex = imageIndexDic[fileExt.Ext];
              childNode.SelectedImageIndex = imageIndexDic[fileExt.Ext];
              return childNode;
            });

              node.Nodes.AddRange(Enumerable.Concat(dirNodes, extNodes).ToArray());
            }
            catch { }
              }
              node.Tag = setObj;
        }
Beispiel #2
0
        public void RefreshTree()
        {
            InitializeImageIndex();
              this.Nodes.Clear();
              Array.ForEach(Environment.GetLogicalDrives(), delegate(string drive) {
            if (Directory.Exists(drive)) {
              TreeNode node = new OogTreeNode();
              node.Text = drive.TrimEnd('\\');
              node.ImageIndex = 0;
              this.Nodes.Add(node);

              FindChildNode(node);
            }
              });

              if (this.Nodes.Count > 0) {
            this.SelectedNode = this.Nodes[0];
              }
        }