Beispiel #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lockedItemDrop || selectedPck == null || selectedtree == null)
            {
                return;
            }
            string pckName = selectedPck.fiullFilePath;

            if (openedPckFies != null)
            {
                this.FileList.SuspendLayout();
                this.FileList.BeginUpdate();
                // this.Cursor = Cursors.WaitCursor;
                List <int> ids = new List <int>();
                foreach (ListViewItem item in FileList.SelectedItems)
                {
                    int index = item.Index;
                    if (FileList.Items[index].Tag is PckEntry)
                    {
                        PckEntry file = (PckEntry)FileList.Items[index].Tag;
                        ids.Add(file.id);
                        foreach (FolderTreeModel row in selectedtree.Rows)
                        {
                            if (row.Title == Path.GetFileName(file.filePath))
                            {
                                selectedtree.Rows.Remove(row);
                                break;
                            }
                        }
                        FileList.Items.RemoveAt(index);
                    }
                    else if (FileList.Items[index].Tag is FolderTreeModel)
                    {
                        FolderTreeModel file  = (FolderTreeModel)FileList.Items[index].Tag;
                        List <PckEntry> files = openedPckFies.directoryStructure.getAllFIles(file);
                        foreach (PckEntry row in files)
                        {
                            ids.Add(row.id);
                        }
                        FileList.Items.RemoveAt(index);
                        selectedtree.Rows.Remove(file);
                    }
                }
                openedPckFies.deleteFile(ids.ToArray());
                if (selectedtree.Rows == null || selectedtree.Rows != null && selectedtree.Rows.Count == 0)
                {
                    selectedtree = selectedPck.root;
                }


                FileList.Items.Clear();
                ListViewItem lvi = new ListViewItem();
                lvi.Text       = "..";
                lvi.ImageIndex = _iconListManager.AddFileId("d", "d", true);
                FileList.Items.Add(lvi);
                //folderDeeplist[folderDeep - 1] = selectedtree;
                foreach (FolderTreeModel row in selectedtree.Rows.OrderBy(o => o.File != null).ToList())
                {
                    lvi      = new ListViewItem();
                    lvi.Text = row.Title;
                    if (row.File != null)
                    {
                        lvi.ImageIndex = _iconListManager.AddFileId(Path.GetExtension(row.Title), row.Title, false);
                        double compresRatio = ConvertSize(row.File.decompressedSize, "MB") - ConvertSize(row.File.compressedSize, "MB") / ConvertSize(row.File.decompressedSize, "MB");
                        lvi.SubItems.Add(SizeSuffix(row.File.compressedSize));
                        lvi.SubItems.Add(SizeSuffix(row.File.decompressedSize));
                        lvi.SubItems.Add((compresRatio * 100).ToString("F").Substring(1) + " %");
                        lvi.Tag = row.File;
                    }
                    else
                    {
                        lvi.ImageIndex = _iconListManager.AddFileId(row.Title, row.Title, true);
                        lvi.SubItems.Add("-");
                        lvi.SubItems.Add("-");
                        lvi.SubItems.Add("-");
                        lvi.Tag = row;
                    }

                    FileList.Items.Add(lvi);
                }
                this.FileList.ResumeLayout();
                this.FileList.EndUpdate();
                textBox1.Text = "";
                foreach (FolderTreeModel list in folderDeeplist.Values)
                {
                    textBox1.AppendText(list.Title + Path.DirectorySeparatorChar);
                }
                string ddd = textBox1.Text;
                textBox1.Text = ddd.TrimEnd(Path.DirectorySeparatorChar);
            }
        }