From 91d7f78b301cd19e62b5802b4b28ff63ef5b95e8 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sat, 1 Jan 2022 02:48:41 +0300 Subject: [PATCH] Automatically apply filter when value changed --- .../Forms/HistoryForm.Designer.cs | 21 +- ShareX.HistoryLib/Forms/HistoryForm.cs | 26 +- ShareX.HistoryLib/Forms/HistoryForm.resx | 653 ++++++------------ 3 files changed, 233 insertions(+), 467 deletions(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs index 2f5b5d328..0511e4129 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs @@ -33,7 +33,6 @@ private void InitializeComponent() this.tscHistory = new System.Windows.Forms.ToolStripContainer(); this.gbAdvancedSearch = new System.Windows.Forms.GroupBox(); this.btnAdvancedSearchReset = new System.Windows.Forms.Button(); - this.btnAdvancedSearch = new System.Windows.Forms.Button(); this.lblURLFilter = new System.Windows.Forms.Label(); this.txtURLFilter = new System.Windows.Forms.TextBox(); this.lblFilenameFilter = new System.Windows.Forms.Label(); @@ -99,7 +98,6 @@ private void InitializeComponent() // gbAdvancedSearch // this.gbAdvancedSearch.Controls.Add(this.btnAdvancedSearchReset); - this.gbAdvancedSearch.Controls.Add(this.btnAdvancedSearch); this.gbAdvancedSearch.Controls.Add(this.lblURLFilter); this.gbAdvancedSearch.Controls.Add(this.txtURLFilter); this.gbAdvancedSearch.Controls.Add(this.lblFilenameFilter); @@ -124,13 +122,6 @@ private void InitializeComponent() this.btnAdvancedSearchReset.UseVisualStyleBackColor = true; this.btnAdvancedSearchReset.Click += new System.EventHandler(this.btnAdvancedSearchReset_Click); // - // btnAdvancedSearch - // - resources.ApplyResources(this.btnAdvancedSearch, "btnAdvancedSearch"); - this.btnAdvancedSearch.Name = "btnAdvancedSearch"; - this.btnAdvancedSearch.UseVisualStyleBackColor = true; - this.btnAdvancedSearch.Click += new System.EventHandler(this.btnAdvancedSearch_Click); - // // lblURLFilter // resources.ApplyResources(this.lblURLFilter, "lblURLFilter"); @@ -140,7 +131,7 @@ private void InitializeComponent() // resources.ApplyResources(this.txtURLFilter, "txtURLFilter"); this.txtURLFilter.Name = "txtURLFilter"; - this.txtURLFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtURLFilter_KeyDown); + this.txtURLFilter.TextChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // lblFilenameFilter // @@ -152,6 +143,7 @@ private void InitializeComponent() this.cbHostFilterSelection.FormattingEnabled = true; resources.ApplyResources(this.cbHostFilterSelection, "cbHostFilterSelection"); this.cbHostFilterSelection.Name = "cbHostFilterSelection"; + this.cbHostFilterSelection.SelectedIndexChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // cbTypeFilterSelection // @@ -159,23 +151,27 @@ private void InitializeComponent() this.cbTypeFilterSelection.FormattingEnabled = true; resources.ApplyResources(this.cbTypeFilterSelection, "cbTypeFilterSelection"); this.cbTypeFilterSelection.Name = "cbTypeFilterSelection"; + this.cbTypeFilterSelection.SelectedIndexChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // cbHostFilter // resources.ApplyResources(this.cbHostFilter, "cbHostFilter"); this.cbHostFilter.Name = "cbHostFilter"; this.cbHostFilter.UseVisualStyleBackColor = true; + this.cbHostFilter.CheckedChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // cbTypeFilter // resources.ApplyResources(this.cbTypeFilter, "cbTypeFilter"); this.cbTypeFilter.Name = "cbTypeFilter"; this.cbTypeFilter.UseVisualStyleBackColor = true; + this.cbTypeFilter.CheckedChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // dtpFilterFrom // resources.ApplyResources(this.dtpFilterFrom, "dtpFilterFrom"); this.dtpFilterFrom.Name = "dtpFilterFrom"; + this.dtpFilterFrom.ValueChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // lblFilterFrom // @@ -192,17 +188,19 @@ private void InitializeComponent() resources.ApplyResources(this.cbDateFilter, "cbDateFilter"); this.cbDateFilter.Name = "cbDateFilter"; this.cbDateFilter.UseVisualStyleBackColor = true; + this.cbDateFilter.CheckedChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // dtpFilterTo // resources.ApplyResources(this.dtpFilterTo, "dtpFilterTo"); this.dtpFilterTo.Name = "dtpFilterTo"; + this.dtpFilterTo.ValueChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // txtFilenameFilter // resources.ApplyResources(this.txtFilenameFilter, "txtFilenameFilter"); this.txtFilenameFilter.Name = "txtFilenameFilter"; - this.txtFilenameFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtFilenameFilter_KeyDown); + this.txtFilenameFilter.TextChanged += new System.EventHandler(this.AdvancedFilter_ValueChanged); // // lvHistory // @@ -435,7 +433,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator tss1; private System.Windows.Forms.ToolStripButton tsbSettings; private System.Windows.Forms.ToolStripButton tsbAdvancedSearch; - private System.Windows.Forms.Button btnAdvancedSearch; private System.Windows.Forms.Button btnAdvancedSearchReset; private System.Windows.Forms.ToolStripSeparator tss2; private System.Windows.Forms.PropertyGrid pgHistoryItemInfo; diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index cb230b64d..f032d70a2 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -453,32 +453,8 @@ private void tsbSettings_Click(object sender, EventArgs e) } } - private void txtFilenameFilter_KeyDown(object sender, KeyEventArgs e) + private void AdvancedFilter_ValueChanged(object sender, EventArgs e) { - if (e.KeyCode == Keys.Enter) - { - e.Handled = true; - e.SuppressKeyPress = true; - ApplyFilterAdvanced(); - txtFilenameFilter.Focus(); - } - } - - private void txtURLFilter_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - e.Handled = true; - e.SuppressKeyPress = true; - ApplyFilterAdvanced(); - txtURLFilter.Focus(); - } - } - - private void btnAdvancedSearch_Click(object sender, EventArgs e) - { - gbAdvancedSearch.Visible = false; - tsbAdvancedSearch.Checked = false; ApplyFilterAdvanced(); } diff --git a/ShareX.HistoryLib/Forms/HistoryForm.resx b/ShareX.HistoryLib/Forms/HistoryForm.resx index 06aa0e5e5..f4e0c7ebc 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.resx +++ b/ShareX.HistoryLib/Forms/HistoryForm.resx @@ -129,6 +129,20 @@ 4 + + + 272, 176 + + + 120, 24 + + + + 22 + + + Reset + btnAdvancedSearchReset @@ -141,17 +155,24 @@ 0 - - btnAdvancedSearch + + True - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + NoControl - - gbAdvancedSearch + + 13, 48 - - 1 + + 32, 13 + + + 20 + + + URL: lblURLFilter @@ -163,7 +184,16 @@ gbAdvancedSearch - 2 + 1 + + + 96, 44 + + + 296, 20 + + + 19 txtURLFilter @@ -175,7 +205,25 @@ gbAdvancedSearch - 3 + 2 + + + True + + + NoControl + + + 13, 24 + + + 52, 13 + + + 17 + + + Filename: lblFilenameFilter @@ -187,7 +235,16 @@ gbAdvancedSearch - 4 + 3 + + + 168, 142 + + + 224, 21 + + + 16 cbHostFilterSelection @@ -199,7 +256,16 @@ gbAdvancedSearch - 5 + 4 + + + 168, 118 + + + 224, 21 + + + 11 cbTypeFilterSelection @@ -211,7 +277,25 @@ gbAdvancedSearch - 6 + 5 + + + True + + + NoControl + + + 16, 144 + + + 51, 17 + + + 12 + + + Host: cbHostFilter @@ -223,7 +307,25 @@ gbAdvancedSearch - 7 + 6 + + + True + + + NoControl + + + 16, 120 + + + 53, 17 + + + 10 + + + Type: cbTypeFilter @@ -235,7 +337,16 @@ gbAdvancedSearch - 8 + 7 + + + 168, 70 + + + 224, 20 + + + 2 dtpFilterFrom @@ -247,7 +358,25 @@ gbAdvancedSearch - 9 + 8 + + + True + + + NoControl + + + 93, 74 + + + 33, 13 + + + 1 + + + From: lblFilterFrom @@ -259,7 +388,25 @@ gbAdvancedSearch - 10 + 9 + + + True + + + NoControl + + + 93, 98 + + + 23, 13 + + + 3 + + + To: lblFilterTo @@ -271,7 +418,25 @@ gbAdvancedSearch - 11 + 10 + + + True + + + NoControl + + + 16, 72 + + + 52, 17 + + + 0 + + + Date: cbDateFilter @@ -283,7 +448,16 @@ gbAdvancedSearch - 12 + 11 + + + 168, 94 + + + 224, 20 + + + 4 dtpFilterTo @@ -295,7 +469,16 @@ gbAdvancedSearch - 13 + 12 + + + 96, 20 + + + 296, 20 + + + 6 txtFilenameFilter @@ -307,16 +490,14 @@ gbAdvancedSearch - 14 + 13 - 71, 3 409, 213 - 4 @@ -338,31 +519,6 @@ 0 - - - - - 24 - - - Date - - - 115 - - - Filename - - - 170 - - - URL - - - 230 - - Fill @@ -489,392 +645,29 @@ 0 - - 272, 176 + + - - 120, 24 + + 24 - - 22 + + Date - - Reset + + 115 - - btnAdvancedSearchReset + + Filename - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 170 - - gbAdvancedSearch + + URL - - 0 - - - NoControl - - - 144, 176 - - - 120, 24 - - - 21 - - - Search - - - btnAdvancedSearch - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 1 - - - True - - - NoControl - - - 13, 48 - - - 32, 13 - - - 20 - - - URL: - - - lblURLFilter - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 2 - - - 96, 44 - - - 296, 20 - - - 19 - - - txtURLFilter - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 3 - - - True - - - NoControl - - - 13, 24 - - - 52, 13 - - - 17 - - - Filename: - - - lblFilenameFilter - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 4 - - - 168, 142 - - - 224, 21 - - - 16 - - - cbHostFilterSelection - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 5 - - - 168, 118 - - - 224, 21 - - - 11 - - - cbTypeFilterSelection - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 6 - - - True - - - NoControl - - - 16, 144 - - - 51, 17 - - - 12 - - - Host: - - - cbHostFilter - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 7 - - - True - - - NoControl - - - 16, 120 - - - 53, 17 - - - 10 - - - Type: - - - cbTypeFilter - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 8 - - - 168, 70 - - - 224, 20 - - - 2 - - - dtpFilterFrom - - - System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 9 - - - True - - - NoControl - - - 93, 74 - - - 33, 13 - - - 1 - - - From: - - - lblFilterFrom - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 10 - - - True - - - NoControl - - - 93, 98 - - - 23, 13 - - - 3 - - - To: - - - lblFilterTo - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 11 - - - True - - - NoControl - - - 16, 72 - - - 52, 17 - - - 0 - - - Date: - - - cbDateFilter - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 12 - - - 168, 94 - - - 224, 20 - - - 4 - - - dtpFilterTo - - - System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 13 - - - 96, 20 - - - 296, 20 - - - 6 - - - txtFilenameFilter - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbAdvancedSearch - - - 14 + + 230 45, 22 @@ -979,7 +772,7 @@ 0, 0 - 627, 439 + 627, 436 3 @@ -1018,7 +811,7 @@ 0, 0 - 627, 215 + 627, 218 0 @@ -1051,7 +844,7 @@ 627, 661 - 439 + 436 7