From 633d4e040bea40a9a3e54107a5584bfb41174513 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 12 Oct 2015 17:12:20 -0700 Subject: [PATCH] Add export option for (filtered?) results. It might be wise to just ball up all the results (as decrypted) to speed up form loading (by just having to read one file instead of >1000 at a time). Maybe just scoop up all the files into the database and filter dupes, but no way to remove stuff.... --- SAV/SAV_Database.Designer.cs | 22 ++++++++++++++++------ SAV/SAV_Database.cs | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/SAV/SAV_Database.Designer.cs b/SAV/SAV_Database.Designer.cs index 17cfe6054..03c477afd 100644 --- a/SAV/SAV_Database.Designer.cs +++ b/SAV/SAV_Database.Designer.cs @@ -141,6 +141,7 @@ private void InitializeComponent() this.L_Generation = new System.Windows.Forms.Label(); this.CB_Generation = new System.Windows.Forms.ComboBox(); this.L_Viewed = new System.Windows.Forms.Label(); + this.Menu_Export = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.bpkx30)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bpkx29)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bpkx28)).BeginInit(); @@ -915,7 +916,8 @@ private void InitializeComponent() // this.Menu_Tools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.Menu_OpenDB, - this.Menu_Report}); + this.Menu_Report, + this.Menu_Export}); this.Menu_Tools.Name = "Menu_Tools"; this.Menu_Tools.Size = new System.Drawing.Size(48, 20); this.Menu_Tools.Text = "Tools"; @@ -923,14 +925,14 @@ private void InitializeComponent() // Menu_OpenDB // this.Menu_OpenDB.Name = "Menu_OpenDB"; - this.Menu_OpenDB.Size = new System.Drawing.Size(176, 22); - this.Menu_OpenDB.Text = "Open Box Database"; + this.Menu_OpenDB.Size = new System.Drawing.Size(197, 22); + this.Menu_OpenDB.Text = "Open Database Folder"; this.Menu_OpenDB.Click += new System.EventHandler(this.openDB); // // Menu_Report // this.Menu_Report.Name = "Menu_Report"; - this.Menu_Report.Size = new System.Drawing.Size(176, 22); + this.Menu_Report.Size = new System.Drawing.Size(197, 22); this.Menu_Report.Text = "Create Data Report"; this.Menu_Report.Click += new System.EventHandler(this.generateDBReport); // @@ -1506,13 +1508,21 @@ private void InitializeComponent() // // L_Viewed // + this.L_Viewed.AutoSize = true; this.L_Viewed.Location = new System.Drawing.Point(9, 381); this.L_Viewed.Name = "L_Viewed"; - this.L_Viewed.Size = new System.Drawing.Size(535, 13); + this.L_Viewed.Size = new System.Drawing.Size(85, 13); this.L_Viewed.TabIndex = 117; this.L_Viewed.Text = "Last Viewed: {0}"; this.L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // + // Menu_Export + // + this.Menu_Export.Name = "Menu_Export"; + this.Menu_Export.Size = new System.Drawing.Size(197, 22); + this.Menu_Export.Text = "Export Results to Folder"; + this.Menu_Export.Click += new System.EventHandler(this.Menu_Export_Click); + // // SAV_Database // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1557,7 +1567,6 @@ private void InitializeComponent() this.Controls.Add(this.CB_Species); this.Controls.Add(this.P_Results); this.Controls.Add(this.menuStrip1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MaximumSize = new System.Drawing.Size(800, 435); @@ -1755,6 +1764,7 @@ private void InitializeComponent() private System.Windows.Forms.Label L_Generation; private System.Windows.Forms.ComboBox CB_Generation; private System.Windows.Forms.Label L_Viewed; + private System.Windows.Forms.ToolStripMenuItem Menu_Export; } } \ No newline at end of file diff --git a/SAV/SAV_Database.cs b/SAV/SAV_Database.cs index fe5b8978f..475277d63 100644 --- a/SAV/SAV_Database.cs +++ b/SAV/SAV_Database.cs @@ -297,6 +297,26 @@ private void openDB(object sender, EventArgs e) if (Directory.Exists(DatabasePath)) Process.Start("explorer.exe", @DatabasePath); } + private void Menu_Export_Click(object sender, EventArgs e) + { + if (Results == null || Results.Count == 0) + { Util.Alert("No results to export."); return; } + + if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Export to a folder?")) + return; + + FolderBrowserDialog fbd = new FolderBrowserDialog(); + if (DialogResult.OK != fbd.ShowDialog()) + return; + + string path = fbd.SelectedPath; + if (!Directory.Exists(path)) // just in case... + Directory.CreateDirectory(path); + + foreach (PK6 pk6 in Results) + File.WriteAllBytes(Path.Combine(path, Util.CleanFileName(pk6.FileName)), + pk6.Data.Take(0xE8).ToArray()); + } // View Updates private void B_Search_Click(object sender, EventArgs e)