Esempio n. 1
0
        private void tvDir_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Directory dir = (e.Node.Tag as Directory);

            _selectedDir = dir;
            PopulateListView();
        }
Esempio n. 2
0
        private void CreateDirectoryNode(TreeNode node, Directory dir)
        {
            node.Tag = dir;

            foreach (var item in dir)
            {
                if (item.IsDirectory)
                {
                    Directory subdir  = item as Directory;
                    TreeNode  subnode = node.Nodes.Add(subdir.Name);
                    CreateDirectoryNode(subnode, subdir);
                }
            }
        }
Esempio n. 3
0
 private void ExtractToPath(Directory dir, string path)
 {
     foreach (var item in dir)
     {
         if (item.IsDirectory)
         {
             try
             {
                 IODirectory.CreateDirectory(path + item.Name);
                 ExtractToPath(item as Directory, path + item.Name + "\\");
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             File   file = item as File;
             byte[] data = file.GetData();
             IOFile.WriteAllBytes(Path.Combine(path, file.Name), data);
         }
     }
 }
Esempio n. 4
0
        private void PopulateListView()
        {
            // Redisable some buttons (will be autoenabled based on selection)
            tsbPreview.Enabled = false;
            tsbEdit.Enabled    = false;

            Directory dir = _selectedDir;

            string filterString = tstFilterBox.Text;

            List <string> selectedFileNames = new List <string>();

            foreach (var o in lvFiles.SelectedItems)
            {
                selectedFileNames.Add((o as ListViewItem).Text);
            }

            var comparer = lvFiles.ListViewItemSorter;

            lvFiles.ListViewItemSorter = null;

            lvFiles.BeginUpdate();

            lvFiles.Items.Clear();

            using (new WaitCursor(this))
            {
                foreach (var item in dir)
                {
                    if (!item.IsDirectory)
                    {
                        File file = item as File;

                        if (filterString == "" || file.Name.IndexOf(filterString) > -1)
                        {
                            ListViewItem lvi = lvFiles.Items.Add(file.Name);
                            lvi.Tag = file;

                            lvi.SubItems.Add(FriendlySize(file.Size));

                            /*
                             * string compressed = file.IsCompressed ? "Yes (" + FriendlySize(file.CompressedSize) + ")" : "No";
                             * lvi.SubItems.Add(compressed);
                             */

                            string resources = file.IsResource ? "Yes" : "No";
                            if (file.IsResource)
                            {
                                string rscType = Enum.IsDefined(file.ResourceType.GetType(), file.ResourceType)
                                                     ?
                                                 file.ResourceType.ToString()
                                                     : string.Format("Unknown 0x{0:x}", (int)file.ResourceType);
                                resources += " (" + rscType + ")";
                            }
                            lvi.SubItems.Add(resources);

                            if (file.IsCustomData)
                            {
                                lvi.ForeColor = CustomDataForeColor;
                            }

                            if (selectedFileNames.Contains(file.Name))
                            {
                                lvi.Selected = true;
                            }
                        }
                    }
                }
            }

            lvFiles.EndUpdate();

            lvFiles.ListViewItemSorter = comparer;
            lvFiles.Sort();
        }
Esempio n. 5
0
 private void tvDir_AfterSelect(object sender, TreeViewEventArgs e)
 {
     Directory dir = (e.Node.Tag as Directory);
     _selectedDir = dir;
     PopulateListView();
 }
Esempio n. 6
0
 private void ExtractToPath(Directory dir, string path)
 {
     foreach (var item in dir)
     {
         if (item.IsDirectory)
         {
             try
             {
                 IODirectory.CreateDirectory(path + item.Name);
                 ExtractToPath(item as Directory, path + item.Name + "\\");
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             File file = item as File;
             byte[] data = file.GetData();
             IOFile.WriteAllBytes(Path.Combine(path, file.Name), data);
         }
     }
 }
Esempio n. 7
0
        private void CreateDirectoryNode(TreeNode node, Directory dir)
        {
            node.Tag = dir;

            foreach (var item in dir)
            {
                if (item.IsDirectory)
                {
                    Directory subdir = item as Directory;
                    TreeNode subnode = node.Nodes.Add(subdir.Name);
                    CreateDirectoryNode(subnode, subdir);
                }
            }
        }