Exemplo n.º 1
0
        private void ListFiles(IVirtualFolder nodeFolderInfo)
        {
            ListViewItem.ListViewSubItem[] subItems;
            ListViewItem item         = null;
            bool         isSmallImage = true;

            foreach (var file in nodeFolderInfo.Files)
            {
                isSmallImage = true;
                item         = new ListViewItem(file.Name, (int)file.FileData.Type);
                item.Tag     = file;

                if (file.FileData is VirtualFileDataInArchive)
                {
                    var archiveIndex    = file.FileData as VirtualFileDataInArchive;
                    var fileSizeInBytes = archiveIndex.End - archiveIndex.Start;
                    subItems = new ListViewItem.ListViewSubItem[]
                    {
                        new ListViewItem.ListViewSubItem(item, FormatUtils.GetBytesReadable(fileSizeInBytes)),
                        new ListViewItem.ListViewSubItem(item, "(" + archiveIndex.Start + ", " + archiveIndex.End + ")")
                    };

                    // using a size cutoff for now, not reliable, but useful
                    // anything below 20KB is filtered out
                    // (I've never seen a cube face size fall below 30KB+)
                    isSmallImage = fileSizeInBytes < 20000;
                }
                else if (file.FileData is VirtualFileTiledImage)
                {
                    isSmallImage    = false;
                    item.ImageIndex = 9;
                    var tiledImage = file.FileData as VirtualFileTiledImage;
                    subItems = new ListViewItem.ListViewSubItem[]
                    {
                        new ListViewItem.ListViewSubItem(item, ""),
                        new ListViewItem.ListViewSubItem(item, tiledImage.Tiles.Count().ToString() + " images")
                    };
                }
                else
                {
                    subItems = new ListViewItem.ListViewSubItem[0];
                }

                if (filterSmallImages)
                {
                    if (isSmallImage)
                    {
                        continue;
                    }
                }

                item.SubItems.AddRange(subItems);
                fileExplorer.Items.Add(item);
            }
        }