private void exportAllToolStripMenuItem_Click(object sender, EventArgs e) { FolderSelectDialog fsd = new FolderSelectDialog(); fsd.Title = "Export all files"; if (fsd.ShowDialog()) { ProgressDialog progress = new ProgressDialog(); progress.title.Text = "Exporting all files"; progress.action.Text = String.Empty; BackgroundWorker bw = new BackgroundWorker(); bw.WorkerReportsProgress = true; bw.DoWork += delegate(object sender2, DoWorkEventArgs e2) { gameISO.ExportDirectory(gameISO.FileSystem.Root, fsd.FileName, sender2 as BackgroundWorker); }; bw.RunWorkerCompleted += delegate(object sender2, RunWorkerCompletedEventArgs e2) { progress.Close(); this.Enabled = true; this.Focus(); }; bw.ProgressChanged += delegate(object sender2, ProgressChangedEventArgs e2) { progress.action.Text = (string)e2.UserState; progress.progressBar.Value = e2.ProgressPercentage; }; this.Enabled = false; progress.Show(); bw.RunWorkerAsync(); } }
private void rebuildDATABINQuickToolStripMenuItem_Click(object sender, EventArgs e) { FolderSelectDialog fsd = new FolderSelectDialog(); fsd.Title = "Rebuild ISO (Quick)"; if (fsd.ShowDialog()) { ProgressDialog progress = new ProgressDialog(); progress.title.Text = "Rebuilding ISO"; progress.action.Text = String.Empty; BackgroundWorker bw = new BackgroundWorker(); bw.WorkerReportsProgress = true; bw.DoWork += delegate(object sender2, DoWorkEventArgs e2) { gameISO.Rebuild(fsd.FileName, true, sender2 as BackgroundWorker); }; bw.RunWorkerCompleted += delegate(object sender2, RunWorkerCompletedEventArgs e2) { progress.Close(); this.Enabled = true; this.Focus(); }; bw.ProgressChanged += delegate(object sender2, ProgressChangedEventArgs e2) { progress.action.Text = (string)e2.UserState; progress.progressBar.Value = e2.ProgressPercentage; }; this.Enabled = false; progress.Show(); bw.RunWorkerAsync(); } }
private void filesystem_MouseUp(object sender, MouseEventArgs e) { ContextMenuStrip cm = new ContextMenuStrip(); if (e.Button == MouseButtons.Right) { // Select the clicked node filesystem.SelectedNode = filesystem.GetNodeAt(e.X, e.Y); if (filesystem.SelectedNode != null) { // Is a directory if (filesystem.SelectedNode.Nodes.Count != 0) { FileSystem.DirectoryEntry entry = (FileSystem.DirectoryEntry)filesystem.SelectedNode.Tag; ToolStripItem extract = new ToolStripMenuItem(); extract.Text = "Export directory"; extract.Click += delegate(object sender2, EventArgs e2) { FolderSelectDialog fsd = new FolderSelectDialog(); fsd.Title = "Export a directory"; if (fsd.ShowDialog()) { ProgressDialog progress = new ProgressDialog(); progress.title.Text = "Exporting directory"; progress.action.Text = String.Empty; BackgroundWorker bw = new BackgroundWorker(); bw.WorkerReportsProgress = true; bw.DoWork += delegate(object sender3, DoWorkEventArgs e3) { gameISO.ExportDirectory(entry, fsd.FileName, sender3 as BackgroundWorker); }; bw.RunWorkerCompleted += delegate(object sender3, RunWorkerCompletedEventArgs e3) { progress.Close(); this.Enabled = true; this.Focus(); }; bw.ProgressChanged += delegate(object sender3, ProgressChangedEventArgs e3) { progress.action.Text = (string)e3.UserState; progress.progressBar.Value = e3.ProgressPercentage; }; this.Enabled = false; progress.Show(); bw.RunWorkerAsync(); } }; cm.Items.Add(extract); } else // Is a file { FileSystem.FileEntry entry = (FileSystem.FileEntry)filesystem.SelectedNode.Tag; bool isArchive = entry.Name.ToLower().EndsWith(".mrg") || entry.Name.ToLower().EndsWith(".mrz") || entry.Name.ToLower().EndsWith(".tex") || entry.Name.ToLower().EndsWith(".tez") || entry.Name.ToLower().EndsWith(".spk"); ToolStripItem extract = new ToolStripMenuItem(); extract.Text = "Export"; extract.Click += delegate(object sender2, EventArgs e2) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Export file"; sfd.FileName = entry.Name; sfd.Filter = "All files (*.*)|*.*"; sfd.OverwritePrompt = true; if (sfd.ShowDialog() == DialogResult.OK) gameISO.ExportFile(entry, Path.GetDirectoryName(sfd.FileName)); }; cm.Items.Add(extract); if (isArchive) { ToolStripItem exportAndExtract = new ToolStripMenuItem(); exportAndExtract.Text = "Export and extract archive"; exportAndExtract.Click += delegate(object sender2, EventArgs e2) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Export and extract archive"; sfd.FileName = entry.Name; sfd.Filter = "All files (*.*)|*.*"; sfd.OverwritePrompt = true; if (sfd.ShowDialog() == DialogResult.OK) gameISO.ExportAndExtractFile(entry, Path.GetDirectoryName(sfd.FileName)); }; cm.Items.Add(exportAndExtract); cm.Items.Add(new ToolStripSeparator()); } ToolStripItem import = new ToolStripMenuItem(); import.Text = "Import"; import.Click += delegate(object sender2, EventArgs e2) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Import file"; ofd.Filter = "All files (*.*)|*.*"; ofd.CheckFileExists = true; if (ofd.ShowDialog() == DialogResult.OK) gameISO.ImportFile(entry, ofd.FileName); }; cm.Items.Add(import); if (isArchive) { ToolStripItem importFromDirectory = new ToolStripMenuItem(); importFromDirectory.Text = "Import from loose files"; importFromDirectory.Click += delegate(object sender2, EventArgs e2) { FolderSelectDialog fsd = new FolderSelectDialog(); fsd.Title = "Select the directory containing the files for the archive."; if (fsd.ShowDialog()) gameISO.ImportFileFromDirectory(entry, fsd.FileName); }; cm.Items.Add(importFromDirectory); } } cm.Show(filesystem, e.Location); } } }