Ejemplo n.º 1
0
        private void UpdateUI()
        {
            using (new FormDrawLocker(this))
            {
                // Determine current directory.
                this.UpdateCurrentDirectory();

                if (_currentDirectory == null)
                {
                    DirectoryNotFoundLabel.Visible = true;
                    FileListView.Visible           = false;
                    return;
                }

                DirectoryNotFoundLabel.Visible = false;
                FileListView.Visible           = true;

                FileListView.Items.Clear();
                foreach (var item in _currentDirectory.Children)
                {
                    var newItem = new ListViewItem();
                    newItem.Text     = item.Name;
                    newItem.Tag      = item;
                    newItem.ImageKey = (item is Directory) ? @"Directory_Closed" : @"File";
                    if (item is File)
                    {
                        var itemFile = (File)item;
                        newItem.SubItems.Add(itemFile.EntryLengthBytes.ToString());
                        newItem.SubItems.Add(itemFile.Id.ToString());
                        newItem.SubItems.Add(itemFile.Extension.ToString());
                    }
                    else if (item is Directory)
                    {
                        var itemDir = (Directory)item;
                        newItem.SubItems.Add("");
                        newItem.SubItems.Add(itemDir.Id.Value.ToString());
                        newItem.SubItems.Add(itemDir.Extension.ToString());
                    }

                    FileListView.Items.Add(newItem);
                }

                if (FileListView.Items.Count > 0)
                {
                    FileListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                }
                else
                {
                    FileListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                }

                FileListView.ListViewItemSorter = new ListViewSorter();
            }
        }
Ejemplo n.º 2
0
        private void RefreshFileList()
        {
            ListViewItem ptrListItem;

            FileListView.Items.Clear();
            if (SelectedFolder == null)
            {
                return;
            }

            FileExplorerItemInfo[] folders = ExplorerHandler.GetDirectories(SelectedFolder);
            foreach (FileExplorerItemInfo ptrItem in folders)
            {
                if (ptrItem.Attributes.HasFlag(FileAttributes.System) && HideSystemFolder)
                {
                    continue;
                }
                ptrListItem            = FileListView.Items.Add(ptrItem.Name);
                ptrListItem.Text       = ptrItem.Name;
                ptrListItem.ImageIndex = (int)ImageIndexName.Folder;
            }

            FileExplorerItemInfo[] files = ExplorerHandler.GetFiles(SelectedFolder);
            foreach (FileExplorerItemInfo ptrFile in files)
            {
                if (ptrFile.Attributes.HasFlag(FileAttributes.System) && HideSystemFolder)
                {
                    continue;
                }
                ptrListItem      = FileListView.Items.Add(ptrFile.Name);
                ptrListItem.Text = ptrFile.Name;
                ptrListItem.SubItems.Add(ptrFile.LastWriteTime.ToString());
                ptrListItem.SubItems.Add((ptrFile.Length / 1024).ToString() + " KB");
                ptrListItem.ImageIndex = (int)ImageIndexName.File;
            }

            FileListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }