Esempio n. 1
0
        private void listView1_DragDrop_1(object sender, DragEventArgs e)
        {
            lockedItemSelect = true;
            string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (selectedPck != null && paths != null && paths.Length >= 0)
            {
                string packFullPath = selectedPck.Title;
                if (openedPckFies != null)
                {
                    Dictionary <string, PckEntry> path_datafile = new Dictionary <string, PckEntry>();

                    for (int i = 0; i < paths.Length; i++)
                    {
                        string FilePath = paths[i];
                        progress_bar("Adding files...", i, paths.Length);
                        Application.DoEvents();
                        if (Path.GetExtension(FilePath) == ".pck" || Path.GetExtension(FilePath) == ".rar" || Path.GetExtension(FilePath) == ".zip")
                        {
                        }
                        else
                        {
                            string DirectoryPath = textBox1.Text + FilePath.Replace(Path.GetDirectoryName(FilePath), "").Replace("/", "\\");
                            if (Path.HasExtension(FilePath))
                            {
                                openedPckFies.addFilesToTable(DirectoryPath, FilePath);
                            }
                            else
                            {
                                string[] files = Directory.GetFiles(FilePath, "*", SearchOption.AllDirectories);
                                for (int x = 0; x < files.Length; x++)
                                {
                                    string sFilePath = files[x];
                                    progress_bar("Adding sub-files...", x, files.Length);
                                    Application.DoEvents();
                                    DirectoryPath = textBox1.Text + Path.DirectorySeparatorChar + sFilePath.Replace(Path.GetDirectoryName(FilePath), "").Replace("/", "\\").Remove(0, 1);
                                    if (Path.HasExtension(sFilePath))
                                    {
                                        openedPckFies.addFilesToTable(DirectoryPath, sFilePath);
                                    }
                                }
                            }
                        }
                    }



                    progress_bar("Drawing grid", 0, 0);
                    this.FileList.SuspendLayout();
                    this.FileList.BeginUpdate();
                    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);

                    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);
                    }
                    // folderDeep++;
                }
                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);
            }
            else
            {
                JMessageBox.Show(this, "Please enter pck directory.");
            }
            lockedItemSelect = false;
            progress_bar("Ready", 0, 0);
        }