Пример #1
0
        private void DoReload()
        {
            _reloadPending = false;

            if (Directory == null)
            {
                return;
            }

            _listView.BeginUpdate();

            _updating++;

            string[] selectedFiles = SelectedFiles;

            _listView.Items.Clear();

            if (IODirectory.Exists(Directory))
            {
                foreach (string path in IODirectory.GetFiles(Directory))
                {
                    if (new FileInfo(path).Attributes.IsHidden())
                    {
                        continue;
                    }
                    if (FileBrowserManager == null || !FileBrowserManager.Matches(path))
                    {
                        continue;
                    }

                    var item = new ListViewItem(Path.GetFileNameWithoutExtension(path));
                    item.ImageIndex = _imageList.AddShellIcon(path, ShellIconType.UseFileAttributes);
                    item.Tag        = path;

                    var values = FileBrowserManager.GetValues(path);

                    for (int i = 0; i < values.Length; i++)
                    {
                        item.SubItems.Add(values[i]);
                    }

                    _listView.Items.Add(item);
                }
            }

            foreach (string selectedFile in selectedFiles)
            {
                var item = _listView.Items.Cast <ListViewItem>().SingleOrDefault(p => (string)p.Tag == selectedFile);
                if (item != null)
                {
                    item.Selected = true;
                }
            }

            _updating--;

            _listView.EndUpdate();

            OnSelectedFilesChanged(EventArgs.Empty);
        }
Пример #2
0
        private TreeNode BuildNode(string path)
        {
            var node = new TreeNode(Path.GetFileName(path));

            node.ImageIndex = node.SelectedImageIndex = _imageList.AddShellIcon(path, 0);
            node.Tag        = path;

            ReloadNodes(node.Nodes, path);

            return(node);
        }