From 75be21bac248654e8e7adda617b5e56886a9537c Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 13 Nov 2015 18:31:01 -0800 Subject: [PATCH] Improved search filters Automatically ignore bad sanity/species Allow user to select Box&/Database as their search source. --- SAV/SAV_Database.Designer.cs | 46 +++++++++++++++++++++++++++++++----- SAV/SAV_Database.cs | 16 ++++++++++--- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/SAV/SAV_Database.Designer.cs b/SAV/SAV_Database.Designer.cs index 03c477afd..12c745552 100644 --- a/SAV/SAV_Database.Designer.cs +++ b/SAV/SAV_Database.Designer.cs @@ -96,6 +96,7 @@ private void InitializeComponent() this.Menu_Tools = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_OpenDB = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_Report = new System.Windows.Forms.ToolStripMenuItem(); + this.Menu_Export = new System.Windows.Forms.ToolStripMenuItem(); this.P_Results = new System.Windows.Forms.Panel(); this.PAN_Box = new System.Windows.Forms.Panel(); this.bpkx66 = new System.Windows.Forms.PictureBox(); @@ -141,7 +142,9 @@ 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(); + this.searchSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.Menu_SearchBoxes = new System.Windows.Forms.ToolStripMenuItem(); + this.Menu_SearchDatabase = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.bpkx30)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bpkx29)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bpkx28)).BeginInit(); @@ -915,6 +918,7 @@ private void InitializeComponent() // Menu_Tools // this.Menu_Tools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.searchSettingsToolStripMenuItem, this.Menu_OpenDB, this.Menu_Report, this.Menu_Export}); @@ -936,6 +940,13 @@ private void InitializeComponent() this.Menu_Report.Text = "Create Data Report"; this.Menu_Report.Click += new System.EventHandler(this.generateDBReport); // + // 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); + // // P_Results // this.P_Results.BackColor = System.Drawing.SystemColors.ButtonHighlight; @@ -1516,12 +1527,32 @@ private void InitializeComponent() this.L_Viewed.Text = "Last Viewed: {0}"; this.L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // Menu_Export + // searchSettingsToolStripMenuItem // - 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); + this.searchSettingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.Menu_SearchBoxes, + this.Menu_SearchDatabase}); + this.searchSettingsToolStripMenuItem.Name = "searchSettingsToolStripMenuItem"; + this.searchSettingsToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.searchSettingsToolStripMenuItem.Text = "Search Settings"; + // + // Menu_SearchBoxes + // + this.Menu_SearchBoxes.Checked = true; + this.Menu_SearchBoxes.CheckOnClick = true; + this.Menu_SearchBoxes.CheckState = System.Windows.Forms.CheckState.Checked; + this.Menu_SearchBoxes.Name = "Menu_SearchBoxes"; + this.Menu_SearchBoxes.Size = new System.Drawing.Size(198, 22); + this.Menu_SearchBoxes.Text = "Search Within Boxes"; + // + // Menu_SearchDatabase + // + this.Menu_SearchDatabase.Checked = true; + this.Menu_SearchDatabase.CheckOnClick = true; + this.Menu_SearchDatabase.CheckState = System.Windows.Forms.CheckState.Checked; + this.Menu_SearchDatabase.Name = "Menu_SearchDatabase"; + this.Menu_SearchDatabase.Size = new System.Drawing.Size(198, 22); + this.Menu_SearchDatabase.Text = "Search Within Database"; // // SAV_Database // @@ -1765,6 +1796,9 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox CB_Generation; private System.Windows.Forms.Label L_Viewed; private System.Windows.Forms.ToolStripMenuItem Menu_Export; + private System.Windows.Forms.ToolStripMenuItem searchSettingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem Menu_SearchBoxes; + private System.Windows.Forms.ToolStripMenuItem Menu_SearchDatabase; } } \ No newline at end of file diff --git a/SAV/SAV_Database.cs b/SAV/SAV_Database.cs index c3d2b15ae..898281654 100644 --- a/SAV/SAV_Database.cs +++ b/SAV/SAV_Database.cs @@ -288,7 +288,7 @@ private void prepareDBForSearch() foreach (var db in Database) RawDB.AddRange(db.Slot); - RawDB = new List(RawDB.Where(pk => pk.Checksum == pk.CalculateChecksum())); + RawDB = new List(RawDB.Where(pk => pk.Checksum == pk.CalculateChecksum() && pk.Species != 0 && pk.Sanity == 0)); RawDB = new List(RawDB.Distinct()); setResults(RawDB); } @@ -428,11 +428,21 @@ private void B_Search_Click(object sender, EventArgs e) break; } + // Filter for Selected Source + if (!Menu_SearchBoxes.Checked) + res = res.Where(pk => pk.Identifier.Contains("db\\")); + if (!Menu_SearchDatabase.Checked) + res = res.Where(pk => !pk.Identifier.Contains("db\\")); + slotSelected = -1; // reset the slot last viewed var results = res.ToArray(); if (results.Length == 0) - Util.Alert("No results found!"); - + { + if (!Menu_SearchBoxes.Checked && !Menu_SearchDatabase.Checked) + Util.Alert("No data source to search!", "No results found!"); + else + Util.Alert("No results found!"); + } setResults(new List(results)); // updates Count Label as well. System.Media.SystemSounds.Asterisk.Play(); }