From c13c0afec7c61fb8d723d284b4877a9373044bdc Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 25 Jul 2021 05:00:36 +0300 Subject: [PATCH 01/10] Added simple search bar, refactor history filtering --- .../Forms/HistoryForm.Designer.cs | 107 +++++-- ShareX.HistoryLib/Forms/HistoryForm.cs | 121 ++++---- ShareX.HistoryLib/Forms/HistoryForm.resx | 272 ++++++++++++------ ShareX.HistoryLib/HistoryFilter.cs | 106 +++++++ ShareX.HistoryLib/ShareX.HistoryLib.csproj | 1 + 5 files changed, 416 insertions(+), 191 deletions(-) create mode 100644 ShareX.HistoryLib/HistoryFilter.cs diff --git a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs index 692f7ef6f..f117d9869 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs @@ -31,8 +31,6 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistoryForm)); this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter(); - this.pStats = new System.Windows.Forms.Panel(); - this.rtbStats = new System.Windows.Forms.RichTextBox(); this.lvHistory = new ShareX.HelpersLib.MyListView(); this.chIcon = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -40,7 +38,6 @@ private void InitializeComponent() this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.nudMaxItemCount = new System.Windows.Forms.NumericUpDown(); this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox(); - this.btnShowStats = new System.Windows.Forms.Button(); this.lblMaxItemCount = new System.Windows.Forms.Label(); this.gbFilters = new System.Windows.Forms.GroupBox(); this.lblURLFilter = new System.Windows.Forms.Label(); @@ -58,13 +55,22 @@ private void InitializeComponent() this.cbDateFilter = new System.Windows.Forms.CheckBox(); this.dtpFilterTo = new System.Windows.Forms.DateTimePicker(); this.txtFilenameFilter = new System.Windows.Forms.TextBox(); + this.tscHistory = new System.Windows.Forms.ToolStripContainer(); + this.tssHistory = new System.Windows.Forms.ToolStrip(); + this.tslSearch = new System.Windows.Forms.ToolStripLabel(); + this.tstbSearch = new System.Windows.Forms.ToolStripTextBox(); + this.tsbSearch = new System.Windows.Forms.ToolStripButton(); + this.btnCopyStats = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); this.scMain.Panel1.SuspendLayout(); this.scMain.Panel2.SuspendLayout(); this.scMain.SuspendLayout(); - this.pStats.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudMaxItemCount)).BeginInit(); this.gbFilters.SuspendLayout(); + this.tscHistory.ContentPanel.SuspendLayout(); + this.tscHistory.TopToolStripPanel.SuspendLayout(); + this.tscHistory.SuspendLayout(); + this.tssHistory.SuspendLayout(); this.SuspendLayout(); // // scMain @@ -75,32 +81,19 @@ private void InitializeComponent() // // scMain.Panel1 // - this.scMain.Panel1.Controls.Add(this.pStats); - this.scMain.Panel1.Controls.Add(this.lvHistory); + this.scMain.Panel1.Controls.Add(this.tscHistory); // // scMain.Panel2 // + this.scMain.Panel2.Controls.Add(this.btnCopyStats); this.scMain.Panel2.Controls.Add(this.nudMaxItemCount); this.scMain.Panel2.Controls.Add(this.pbThumbnail); - this.scMain.Panel2.Controls.Add(this.btnShowStats); this.scMain.Panel2.Controls.Add(this.lblMaxItemCount); this.scMain.Panel2.Controls.Add(this.gbFilters); this.scMain.SplitterColor = System.Drawing.Color.White; this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189))))); this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved); // - // pStats - // - this.pStats.Controls.Add(this.rtbStats); - resources.ApplyResources(this.pStats, "pStats"); - this.pStats.Name = "pStats"; - // - // rtbStats - // - this.rtbStats.BorderStyle = System.Windows.Forms.BorderStyle.None; - resources.ApplyResources(this.rtbStats, "rtbStats"); - this.rtbStats.Name = "rtbStats"; - // // lvHistory // this.lvHistory.AllowColumnSort = true; @@ -160,13 +153,6 @@ private void InitializeComponent() this.pbThumbnail.PictureBoxBackColor = System.Drawing.SystemColors.Control; this.pbThumbnail.ShowImageSizeLabel = true; // - // btnShowStats - // - resources.ApplyResources(this.btnShowStats, "btnShowStats"); - this.btnShowStats.Name = "btnShowStats"; - this.btnShowStats.UseVisualStyleBackColor = true; - this.btnShowStats.Click += new System.EventHandler(this.BtnShowStats_Click); - // // lblMaxItemCount // resources.ApplyResources(this.lblMaxItemCount, "lblMaxItemCount"); @@ -280,6 +266,58 @@ private void InitializeComponent() this.txtFilenameFilter.Name = "txtFilenameFilter"; this.txtFilenameFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtFilenameFilter_KeyDown); // + // tscHistory + // + // + // tscHistory.ContentPanel + // + this.tscHistory.ContentPanel.Controls.Add(this.lvHistory); + resources.ApplyResources(this.tscHistory.ContentPanel, "tscHistory.ContentPanel"); + resources.ApplyResources(this.tscHistory, "tscHistory"); + this.tscHistory.Name = "tscHistory"; + // + // tscHistory.TopToolStripPanel + // + this.tscHistory.TopToolStripPanel.Controls.Add(this.tssHistory); + // + // tssHistory + // + resources.ApplyResources(this.tssHistory, "tssHistory"); + this.tssHistory.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.tssHistory.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tslSearch, + this.tstbSearch, + this.tsbSearch}); + this.tssHistory.Name = "tssHistory"; + this.tssHistory.ShowItemToolTips = false; + // + // tslSearch + // + this.tslSearch.Name = "tslSearch"; + resources.ApplyResources(this.tslSearch, "tslSearch"); + // + // tstbSearch + // + this.tstbSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + resources.ApplyResources(this.tstbSearch, "tstbSearch"); + this.tstbSearch.Name = "tstbSearch"; + this.tstbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tstbSearch_KeyDown); + // + // tsbSearch + // + this.tsbSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbSearch.Image = global::ShareX.HistoryLib.Properties.Resources.magnifier; + resources.ApplyResources(this.tsbSearch, "tsbSearch"); + this.tsbSearch.Name = "tsbSearch"; + this.tsbSearch.Click += new System.EventHandler(this.tsbSearch_Click); + // + // btnCopyStats + // + resources.ApplyResources(this.btnCopyStats, "btnCopyStats"); + this.btnCopyStats.Name = "btnCopyStats"; + this.btnCopyStats.UseVisualStyleBackColor = true; + this.btnCopyStats.Click += new System.EventHandler(this.btnCopyStats_Click); + // // HistoryForm // resources.ApplyResources(this, "$this"); @@ -296,10 +334,16 @@ private void InitializeComponent() this.scMain.Panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit(); this.scMain.ResumeLayout(false); - this.pStats.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.nudMaxItemCount)).EndInit(); this.gbFilters.ResumeLayout(false); this.gbFilters.PerformLayout(); + this.tscHistory.ContentPanel.ResumeLayout(false); + this.tscHistory.TopToolStripPanel.ResumeLayout(false); + this.tscHistory.TopToolStripPanel.PerformLayout(); + this.tscHistory.ResumeLayout(false); + this.tscHistory.PerformLayout(); + this.tssHistory.ResumeLayout(false); + this.tssHistory.PerformLayout(); this.ResumeLayout(false); } @@ -329,10 +373,13 @@ private void InitializeComponent() private System.Windows.Forms.Label lblFilenameFilter; private System.Windows.Forms.Label lblURLFilter; private System.Windows.Forms.TextBox txtURLFilter; - private System.Windows.Forms.Button btnShowStats; - private System.Windows.Forms.RichTextBox rtbStats; - private System.Windows.Forms.Panel pStats; private System.Windows.Forms.Label lblMaxItemCount; private System.Windows.Forms.NumericUpDown nudMaxItemCount; + private System.Windows.Forms.ToolStripContainer tscHistory; + private System.Windows.Forms.ToolStrip tssHistory; + private System.Windows.Forms.ToolStripLabel tslSearch; + private System.Windows.Forms.ToolStripTextBox tstbSearch; + private System.Windows.Forms.ToolStripButton tsbSearch; + private System.Windows.Forms.Button btnCopyStats; } } \ No newline at end of file diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 6025d2541..55b6f6316 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -30,7 +30,6 @@ You should have received a copy of the GNU General Public License using System.IO; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using System.Windows.Forms; namespace ShareX.HistoryLib @@ -39,7 +38,6 @@ public partial class HistoryForm : Form { public string HistoryPath { get; private set; } public HistorySettings Settings { get; private set; } - public bool SearchInTags { get; set; } = true; private HistoryManager history; private HistoryItemManager him; @@ -90,12 +88,12 @@ public HistoryForm(string historyPath, HistorySettings settings, Action private void RefreshHistoryItems() { allHistoryItems = GetHistoryItems(); - ApplyFiltersAndAdd(); + ApplyFilter(); } private void OutputStats(HistoryItem[] historyItems) { - rtbStats.ResetText(); + /*rtbStats.ResetText(); rtbStats.SetFontBold(); rtbStats.AppendLine(Resources.HistoryItemCounts); @@ -145,7 +143,7 @@ private void OutputStats(HistoryItem[] historyItems) OrderByDescending(x => x.Count()). Select(x => string.Format("{0} ({1})", x.Key, x.Count())); - rtbStats.AppendLine(string.Join(Environment.NewLine, hosts)); + rtbStats.AppendLine(string.Join(Environment.NewLine, hosts));*/ } private HistoryItem[] him_GetHistoryItems() @@ -165,11 +163,36 @@ private HistoryItem[] GetHistoryItems() return historyItems.ToArray(); } - private void ApplyFiltersAndAdd() + private void ApplyFilter() + { + HistoryFilter filter = new HistoryFilter() + { + FileName = txtFilenameFilter.Text, + URL = txtURLFilter.Text, + FilterDate = cbDateFilter.Checked, + FromDate = dtpFilterFrom.Value.Date, + ToDate = dtpFilterTo.Value.Date, + FilterType = cbTypeFilter.Checked, + Type = cbTypeFilterSelection.Text, + FilterHost = cbHostFilter.Checked, + Host = cbHostFilterSelection.Text + }; + + ApplyFilter(filter); + } + + private void ApplyFilterSimple() + { + HistoryFilter filter = new HistoryFilter(tstbSearch.Text); + + ApplyFilter(filter); + } + + private void ApplyFilter(HistoryFilter filter) { if (allHistoryItems != null && allHistoryItems.Length > 0) { - HistoryItem[] historyItems = ApplyFilters(allHistoryItems); + HistoryItem[] historyItems = filter.ApplyFilter(allHistoryItems); if (Settings.MaxItemCount > 0 && historyItems.Length > Settings.MaxItemCount) { @@ -180,63 +203,6 @@ private void ApplyFiltersAndAdd() } } - private HistoryItem[] ApplyFilters(HistoryItem[] historyItems) - { - if (!cbTypeFilter.Checked && !cbHostFilter.Checked && string.IsNullOrEmpty(txtFilenameFilter.Text) && string.IsNullOrEmpty(txtURLFilter.Text) && !cbDateFilter.Checked) - { - return historyItems; - } - - IEnumerable result = historyItems.AsEnumerable(); - - if (cbTypeFilter.Checked) - { - string type = cbTypeFilterSelection.Text; - - if (!string.IsNullOrEmpty(type)) - { - result = result.Where(x => !string.IsNullOrEmpty(x.Type) && x.Type.Equals(type, StringComparison.InvariantCultureIgnoreCase)); - } - } - - if (cbHostFilter.Checked) - { - string host = cbHostFilterSelection.Text; - - if (!string.IsNullOrEmpty(host)) - { - result = result.Where(x => !string.IsNullOrEmpty(x.Host) && x.Host.Contains(host, StringComparison.InvariantCultureIgnoreCase)); - } - } - - string filenameFilter = txtFilenameFilter.Text; - - if (!string.IsNullOrEmpty(filenameFilter)) - { - string pattern = Regex.Escape(filenameFilter).Replace("\\?", ".").Replace("\\*", ".*"); - Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); - result = result.Where(x => (x.FileName != null && regex.IsMatch(x.FileName)) || - (SearchInTags && x.Tags != null && x.Tags.Any(tag => regex.IsMatch(tag.Value)))); - } - - string urlFilter = txtURLFilter.Text; - - if (!string.IsNullOrEmpty(urlFilter)) - { - result = result.Where(x => x.URL != null && x.URL.Contains(urlFilter, StringComparison.InvariantCultureIgnoreCase)); - } - - if (cbDateFilter.Checked) - { - DateTime fromDate = dtpFilterFrom.Value.Date; - DateTime toDate = dtpFilterTo.Value.Date; - - result = result.Where(x => x.DateTime.Date >= fromDate && x.DateTime.Date <= toDate); - } - - return result.ToArray(); - } - private void AddHistoryItems(HistoryItem[] historyItems) { Cursor = Cursors.WaitCursor; @@ -395,13 +361,28 @@ private void scMain_SplitterMoved(object sender, SplitterEventArgs e) Settings.SplitterDistance = scMain.SplitterDistance; } + private void tstbSearch_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.Handled = true; + e.SuppressKeyPress = true; + ApplyFilterSimple(); + } + } + + private void tsbSearch_Click(object sender, EventArgs e) + { + ApplyFilterSimple(); + } + private void txtFilenameFilter_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { e.Handled = true; e.SuppressKeyPress = true; - ApplyFiltersAndAdd(); + ApplyFilter(); txtFilenameFilter.Focus(); } } @@ -412,14 +393,14 @@ private void txtURLFilter_KeyDown(object sender, KeyEventArgs e) { e.Handled = true; e.SuppressKeyPress = true; - ApplyFiltersAndAdd(); + ApplyFilter(); txtURLFilter.Focus(); } } private void btnApplyFilters_Click(object sender, EventArgs e) { - ApplyFiltersAndAdd(); + ApplyFilter(); } private void btnRemoveFilters_Click(object sender, EventArgs e) @@ -427,9 +408,9 @@ private void btnRemoveFilters_Click(object sender, EventArgs e) AddHistoryItems(allHistoryItems); } - private void BtnShowStats_Click(object sender, EventArgs e) + private void btnCopyStats_Click(object sender, EventArgs e) { - if (showingStats) + /*if (showingStats) { lvHistory.Visible = true; pStats.Visible = false; @@ -445,7 +426,7 @@ private void BtnShowStats_Click(object sender, EventArgs e) OutputStats(allHistoryItems); Cursor = Cursors.Default; showingStats = true; - } + }*/ } private void nudMaxItemCount_ValueChanged(object sender, EventArgs e) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.resx b/ShareX.HistoryLib/Forms/HistoryForm.resx index 2f2852f9b..734937152 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.resx +++ b/ShareX.HistoryLib/Forms/HistoryForm.resx @@ -125,70 +125,22 @@ 0, 0 - - Fill + + tscHistory.BottomToolStripPanel - - Arial, 9.75pt + + System.Windows.Forms.ToolStripPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 3, 3 + + tscHistory - - 544, 635 - - - - 1 - - - - - - rtbStats - - - System.Windows.Forms.RichTextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - pStats - - - 0 - - - Fill - - - 0, 0 - - - 3, 3, 3, 3 - - - 550, 641 - - - 2 - - - False - - - pStats - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - scMain.Panel1 - - - 0 + + 4 + 24 @@ -217,7 +169,7 @@ 0, 0 - 550, 641 + 550, 616 0 @@ -229,11 +181,134 @@ ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=13.5.1.0, Culture=neutral, PublicKeyToken=null - scMain.Panel1 + tscHistory.ContentPanel + 0 + + + 550, 616 + + + tscHistory.ContentPanel + + + System.Windows.Forms.ToolStripContentPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tscHistory + + + 0 + + + Fill + + + tscHistory.LeftToolStripPanel + + + System.Windows.Forms.ToolStripPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tscHistory + + 1 + + 0, 0 + + + tscHistory.RightToolStripPanel + + + System.Windows.Forms.ToolStripPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tscHistory + + + 2 + + + 550, 641 + + + 2 + + + toolStripContainer1 + + + 17, 17 + + + None + + + 45, 22 + + + Search: + + + Segoe UI, 9pt + + + 300, 25 + + + Magenta + + + 23, 22 + + + 3, 0 + + + 373, 25 + + + 0 + + + tssHistory + + + System.Windows.Forms.ToolStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tscHistory.TopToolStripPanel + + + 0 + + + tscHistory.TopToolStripPanel + + + System.Windows.Forms.ToolStripPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tscHistory + + + 3 + + + tscHistory + + + System.Windows.Forms.ToolStripContainer, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + scMain.Panel1 + + + 0 + scMain.Panel1 @@ -249,6 +324,33 @@ 100 + + Bottom, Left + + + 8, 608 + + + 144, 23 + + + 8 + + + Copy stats + + + btnCopyStats + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + scMain.Panel2 + + + 0 + Bottom, Left @@ -274,7 +376,7 @@ scMain.Panel2 - 0 + 1 Top, Bottom, Left, Right @@ -283,7 +385,7 @@ 8, 8 - 402, 352 + 400, 352 3 @@ -298,36 +400,6 @@ scMain.Panel2 - 1 - - - Bottom, Left - - - NoControl - - - 8, 604 - - - 144, 24 - - - 5 - - - Show stats - - - btnShowStats - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - scMain.Panel2 - - 2 @@ -858,6 +930,24 @@ System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tslSearch + + + System.Windows.Forms.ToolStripLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tstbSearch + + + System.Windows.Forms.ToolStripTextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tsbSearch + + + System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + HistoryForm diff --git a/ShareX.HistoryLib/HistoryFilter.cs b/ShareX.HistoryLib/HistoryFilter.cs new file mode 100644 index 000000000..5939624d9 --- /dev/null +++ b/ShareX.HistoryLib/HistoryFilter.cs @@ -0,0 +1,106 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2020 ShareX Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using ShareX.HelpersLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; + +namespace ShareX.HistoryLib +{ + public class HistoryFilter + { + public string FileName { get; set; } + public string URL { get; set; } + public bool FilterDate { get; set; } + public DateTime FromDate { get; set; } + public DateTime ToDate { get; set; } + public bool FilterType { get; set; } + public string Type { get; set; } + public bool FilterHost { get; set; } + public string Host { get; set; } + + public bool SearchInTags { get; set; } = true; + + public bool IsFiltered + { + get + { + return !string.IsNullOrEmpty(FileName) || !string.IsNullOrEmpty(URL) || FilterDate || + (FilterType && !string.IsNullOrEmpty(Type)) || (FilterHost && !string.IsNullOrEmpty(Host)); + } + } + + public HistoryFilter() + { + } + + public HistoryFilter(string filename) + { + FileName = filename; + } + + public HistoryItem[] ApplyFilter(HistoryItem[] historyItems) + { + if (!IsFiltered) + { + return historyItems; + } + + IEnumerable result = historyItems.AsEnumerable(); + + if (FilterType && !string.IsNullOrEmpty(Type)) + { + result = result.Where(x => !string.IsNullOrEmpty(x.Type) && x.Type.Equals(Type, StringComparison.InvariantCultureIgnoreCase)); + } + + if (FilterHost && !string.IsNullOrEmpty(Host)) + { + result = result.Where(x => !string.IsNullOrEmpty(x.Host) && x.Host.Contains(Host, StringComparison.InvariantCultureIgnoreCase)); + } + + if (!string.IsNullOrEmpty(FileName)) + { + string pattern = Regex.Escape(FileName).Replace("\\?", ".").Replace("\\*", ".*"); + Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + result = result.Where(x => (x.FileName != null && regex.IsMatch(x.FileName)) || + (SearchInTags && x.Tags != null && x.Tags.Any(tag => regex.IsMatch(tag.Value)))); + } + + if (!string.IsNullOrEmpty(URL)) + { + result = result.Where(x => x.URL != null && x.URL.Contains(URL, StringComparison.InvariantCultureIgnoreCase)); + } + + if (FilterDate) + { + result = result.Where(x => x.DateTime.Date >= FromDate && x.DateTime.Date <= ToDate); + } + + return result.ToArray(); + } + } +} \ No newline at end of file diff --git a/ShareX.HistoryLib/ShareX.HistoryLib.csproj b/ShareX.HistoryLib/ShareX.HistoryLib.csproj index c76e3a8fc..068c1c6b1 100644 --- a/ShareX.HistoryLib/ShareX.HistoryLib.csproj +++ b/ShareX.HistoryLib/ShareX.HistoryLib.csproj @@ -86,6 +86,7 @@ Properties\SharedAssemblyInfo.cs + Form From 27e1bf9514913e2dbde321b5e6621454681f0322 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 25 Jul 2021 05:55:01 +0300 Subject: [PATCH 02/10] MaxItemCount moved to HistoryFilter --- ShareX.HistoryLib/Forms/HistoryForm.cs | 56 +++++++++++++------------- ShareX.HistoryLib/HistoryFilter.cs | 41 ++++++------------- 2 files changed, 41 insertions(+), 56 deletions(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 55b6f6316..07fdad728 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -88,7 +88,7 @@ public HistoryForm(string historyPath, HistorySettings settings, Action private void RefreshHistoryItems() { allHistoryItems = GetHistoryItems(); - ApplyFilter(); + ApplyFilterAdvanced(); } private void OutputStats(HistoryItem[] historyItems) @@ -163,7 +163,28 @@ private HistoryItem[] GetHistoryItems() return historyItems.ToArray(); } - private void ApplyFilter() + private void ApplyFilter(HistoryFilter filter) + { + if (allHistoryItems != null && allHistoryItems.Length > 0) + { + IEnumerable historyItems = filter.ApplyFilter(allHistoryItems); + + AddHistoryItems(historyItems.ToArray()); + } + } + + private void ApplyFilterSimple() + { + HistoryFilter filter = new HistoryFilter() + { + FileName = tstbSearch.Text, + MaxItemCount = Settings.MaxItemCount + }; + + ApplyFilter(filter); + } + + private void ApplyFilterAdvanced() { HistoryFilter filter = new HistoryFilter() { @@ -175,34 +196,13 @@ private void ApplyFilter() FilterType = cbTypeFilter.Checked, Type = cbTypeFilterSelection.Text, FilterHost = cbHostFilter.Checked, - Host = cbHostFilterSelection.Text + Host = cbHostFilterSelection.Text, + MaxItemCount = Settings.MaxItemCount }; ApplyFilter(filter); } - private void ApplyFilterSimple() - { - HistoryFilter filter = new HistoryFilter(tstbSearch.Text); - - ApplyFilter(filter); - } - - private void ApplyFilter(HistoryFilter filter) - { - if (allHistoryItems != null && allHistoryItems.Length > 0) - { - HistoryItem[] historyItems = filter.ApplyFilter(allHistoryItems); - - if (Settings.MaxItemCount > 0 && historyItems.Length > Settings.MaxItemCount) - { - historyItems = historyItems.Take(Settings.MaxItemCount).ToArray(); - } - - AddHistoryItems(historyItems); - } - } - private void AddHistoryItems(HistoryItem[] historyItems) { Cursor = Cursors.WaitCursor; @@ -382,7 +382,7 @@ private void txtFilenameFilter_KeyDown(object sender, KeyEventArgs e) { e.Handled = true; e.SuppressKeyPress = true; - ApplyFilter(); + ApplyFilterAdvanced(); txtFilenameFilter.Focus(); } } @@ -393,14 +393,14 @@ private void txtURLFilter_KeyDown(object sender, KeyEventArgs e) { e.Handled = true; e.SuppressKeyPress = true; - ApplyFilter(); + ApplyFilterAdvanced(); txtURLFilter.Focus(); } } private void btnApplyFilters_Click(object sender, EventArgs e) { - ApplyFilter(); + ApplyFilterAdvanced(); } private void btnRemoveFilters_Click(object sender, EventArgs e) diff --git a/ShareX.HistoryLib/HistoryFilter.cs b/ShareX.HistoryLib/HistoryFilter.cs index 5939624d9..74b0a41a8 100644 --- a/ShareX.HistoryLib/HistoryFilter.cs +++ b/ShareX.HistoryLib/HistoryFilter.cs @@ -43,64 +43,49 @@ public class HistoryFilter public bool FilterHost { get; set; } public string Host { get; set; } + public int MaxItemCount { get; set; } public bool SearchInTags { get; set; } = true; - public bool IsFiltered - { - get - { - return !string.IsNullOrEmpty(FileName) || !string.IsNullOrEmpty(URL) || FilterDate || - (FilterType && !string.IsNullOrEmpty(Type)) || (FilterHost && !string.IsNullOrEmpty(Host)); - } - } - public HistoryFilter() { } - public HistoryFilter(string filename) + public IEnumerable ApplyFilter(IEnumerable historyItems) { - FileName = filename; - } - - public HistoryItem[] ApplyFilter(HistoryItem[] historyItems) - { - if (!IsFiltered) - { - return historyItems; - } - - IEnumerable result = historyItems.AsEnumerable(); - if (FilterType && !string.IsNullOrEmpty(Type)) { - result = result.Where(x => !string.IsNullOrEmpty(x.Type) && x.Type.Equals(Type, StringComparison.InvariantCultureIgnoreCase)); + historyItems = historyItems.Where(x => !string.IsNullOrEmpty(x.Type) && x.Type.Equals(Type, StringComparison.InvariantCultureIgnoreCase)); } if (FilterHost && !string.IsNullOrEmpty(Host)) { - result = result.Where(x => !string.IsNullOrEmpty(x.Host) && x.Host.Contains(Host, StringComparison.InvariantCultureIgnoreCase)); + historyItems = historyItems.Where(x => !string.IsNullOrEmpty(x.Host) && x.Host.Contains(Host, StringComparison.InvariantCultureIgnoreCase)); } if (!string.IsNullOrEmpty(FileName)) { string pattern = Regex.Escape(FileName).Replace("\\?", ".").Replace("\\*", ".*"); Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); - result = result.Where(x => (x.FileName != null && regex.IsMatch(x.FileName)) || + historyItems = historyItems.Where(x => (x.FileName != null && regex.IsMatch(x.FileName)) || (SearchInTags && x.Tags != null && x.Tags.Any(tag => regex.IsMatch(tag.Value)))); } if (!string.IsNullOrEmpty(URL)) { - result = result.Where(x => x.URL != null && x.URL.Contains(URL, StringComparison.InvariantCultureIgnoreCase)); + historyItems = historyItems.Where(x => x.URL != null && x.URL.Contains(URL, StringComparison.InvariantCultureIgnoreCase)); } if (FilterDate) { - result = result.Where(x => x.DateTime.Date >= FromDate && x.DateTime.Date <= ToDate); + historyItems = historyItems.Where(x => x.DateTime.Date >= FromDate && x.DateTime.Date <= ToDate); } - return result.ToArray(); + if (MaxItemCount > 0) + { + historyItems = historyItems.Take(MaxItemCount); + } + + return historyItems; } } } \ No newline at end of file From f4188f2c7518b28c9bf2b0473ceb89313b59aeb0 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 25 Jul 2021 06:07:12 +0300 Subject: [PATCH 03/10] Automatically select first item after filtering --- ShareX.HistoryLib/Forms/HistoryForm.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 07fdad728..d4d5874a6 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -245,6 +245,11 @@ private void AddHistoryItems(HistoryItem[] historyItems) lvHistory.FillLastColumn(); lvHistory.Focus(); + if (lvHistory.Items.Count > 0) + { + lvHistory.Items[0].Selected = true; + } + Cursor = Cursors.Default; } @@ -323,8 +328,6 @@ private void HistoryForm_Shown(object sender, EventArgs e) if (lvHistory.Items.Count > 0) { - lvHistory.Items[0].Selected = true; - cbTypeFilterSelection.Items.Clear(); cbTypeFilterSelection.Items.AddRange(allHistoryItems.Select(x => x.Type).Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray()); From 5927686e2492ae9ba9b57e5bea276173dca5d57a Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 25 Jul 2021 06:22:06 +0300 Subject: [PATCH 04/10] Added copy stats --- ShareX.HistoryLib/Forms/HistoryForm.cs | 132 ++++++++---------- .../Properties/Resources.Designer.cs | 18 --- ShareX.HistoryLib/Properties/Resources.resx | 6 - 3 files changed, 55 insertions(+), 101 deletions(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index d4d5874a6..c678e8dae 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -43,7 +43,6 @@ public partial class HistoryForm : Form private HistoryItemManager him; private HistoryItem[] allHistoryItems; private string defaultTitle; - private bool showingStats; public HistoryForm(string historyPath, HistorySettings settings, Action uploadFile = null, Action editImage = null) { @@ -91,61 +90,6 @@ private void RefreshHistoryItems() ApplyFilterAdvanced(); } - private void OutputStats(HistoryItem[] historyItems) - { - /*rtbStats.ResetText(); - - rtbStats.SetFontBold(); - rtbStats.AppendLine(Resources.HistoryItemCounts); - rtbStats.SetFontRegular(); - rtbStats.AppendLine(Resources.HistoryStats_Total + " " + historyItems.Length); - - IEnumerable types = historyItems. - GroupBy(x => x.Type). - OrderByDescending(x => x.Count()). - Select(x => string.Format("{0}: {1} ({2:N0}%)", x.Key, x.Count(), x.Count() / (float)historyItems.Length * 100)); - - rtbStats.AppendLine(string.Join(Environment.NewLine, types)); - - rtbStats.AppendLine(); - rtbStats.SetFontBold(); - rtbStats.AppendLine(Resources.HistoryStats_YearlyUsages); - rtbStats.SetFontRegular(); - - IEnumerable yearlyUsages = historyItems. - GroupBy(x => x.DateTime.Year). - OrderByDescending(x => x.Key). - Select(x => string.Format("{0}: {1} ({2:N0}%)", x.Key, x.Count(), x.Count() / (float)historyItems.Length * 100)); - - rtbStats.AppendLine(string.Join(Environment.NewLine, yearlyUsages)); - - rtbStats.AppendLine(); - rtbStats.SetFontBold(); - rtbStats.AppendLine(Resources.HistoryStats_FileExtensions); - rtbStats.SetFontRegular(); - - IEnumerable fileExtensions = historyItems. - Where(x => !string.IsNullOrEmpty(x.FileName) && !x.FileName.EndsWith(")")). - Select(x => Helpers.GetFilenameExtension(x.FileName)). - GroupBy(x => x). - OrderByDescending(x => x.Count()). - Select(x => string.Format("{0} ({1})", x.Key, x.Count())); - - rtbStats.AppendLine(string.Join(Environment.NewLine, fileExtensions)); - - rtbStats.AppendLine(); - rtbStats.SetFontBold(); - rtbStats.AppendLine(Resources.HistoryStats_Hosts); - rtbStats.SetFontRegular(); - - IEnumerable hosts = historyItems. - GroupBy(x => x.Host). - OrderByDescending(x => x.Count()). - Select(x => string.Format("{0} ({1})", x.Key, x.Count())); - - rtbStats.AppendLine(string.Join(Environment.NewLine, hosts));*/ - } - private HistoryItem[] him_GetHistoryItems() { return lvHistory.SelectedItems.Cast().Select(x => x.Tag as HistoryItem).ToArray(); @@ -318,6 +262,55 @@ private void UpdatePictureBox() } } + private string OutputStats(HistoryItem[] historyItems) + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine(Resources.HistoryItemCounts); + sb.AppendLine(Resources.HistoryStats_Total + " " + historyItems.Length); + + IEnumerable types = historyItems. + GroupBy(x => x.Type). + OrderByDescending(x => x.Count()). + Select(x => string.Format("{0}: {1} ({2:N0}%)", x.Key, x.Count(), x.Count() / (float)historyItems.Length * 100)); + + sb.AppendLine(string.Join(Environment.NewLine, types)); + + sb.AppendLine(); + sb.AppendLine(Resources.HistoryStats_YearlyUsages); + + IEnumerable yearlyUsages = historyItems. + GroupBy(x => x.DateTime.Year). + OrderByDescending(x => x.Key). + Select(x => string.Format("{0}: {1} ({2:N0}%)", x.Key, x.Count(), x.Count() / (float)historyItems.Length * 100)); + + sb.AppendLine(string.Join(Environment.NewLine, yearlyUsages)); + + sb.AppendLine(); + sb.AppendLine(Resources.HistoryStats_FileExtensions); + + IEnumerable fileExtensions = historyItems. + Where(x => !string.IsNullOrEmpty(x.FileName) && !x.FileName.EndsWith(")")). + Select(x => Helpers.GetFilenameExtension(x.FileName)). + GroupBy(x => x). + OrderByDescending(x => x.Count()). + Select(x => string.Format("{0} ({1})", x.Key, x.Count())); + + sb.AppendLine(string.Join(Environment.NewLine, fileExtensions)); + + sb.AppendLine(); + sb.AppendLine(Resources.HistoryStats_Hosts); + + IEnumerable hosts = historyItems. + GroupBy(x => x.Host). + OrderByDescending(x => x.Count()). + Select(x => string.Format("{0} ({1})", x.Key, x.Count())); + + sb.Append(string.Join(Environment.NewLine, hosts)); + + return sb.ToString(); + } + #region Form events private void HistoryForm_Shown(object sender, EventArgs e) @@ -411,32 +404,17 @@ private void btnRemoveFilters_Click(object sender, EventArgs e) AddHistoryItems(allHistoryItems); } - private void btnCopyStats_Click(object sender, EventArgs e) - { - /*if (showingStats) - { - lvHistory.Visible = true; - pStats.Visible = false; - btnShowStats.Text = Resources.BtnShowStats_ShowStats; - showingStats = false; - } - else - { - pStats.Visible = true; - lvHistory.Visible = false; - btnShowStats.Text = Resources.BtnShowStats_HideStats; - Cursor = Cursors.WaitCursor; - OutputStats(allHistoryItems); - Cursor = Cursors.Default; - showingStats = true; - }*/ - } - private void nudMaxItemCount_ValueChanged(object sender, EventArgs e) { Settings.MaxItemCount = (int)nudMaxItemCount.Value; } + private void btnCopyStats_Click(object sender, EventArgs e) + { + string stats = OutputStats(allHistoryItems); + ClipboardHelpers.CopyText(stats); + } + private void lvHistory_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { UpdateControls(); diff --git a/ShareX.HistoryLib/Properties/Resources.Designer.cs b/ShareX.HistoryLib/Properties/Resources.Designer.cs index 38d630d26..f5ea478be 100644 --- a/ShareX.HistoryLib/Properties/Resources.Designer.cs +++ b/ShareX.HistoryLib/Properties/Resources.Designer.cs @@ -70,24 +70,6 @@ internal static System.Drawing.Bitmap application_block { } } - /// - /// Looks up a localized string similar to Hide stats. - /// - internal static string BtnShowStats_HideStats { - get { - return ResourceManager.GetString("BtnShowStats_HideStats", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Show stats. - /// - internal static string BtnShowStats_ShowStats { - get { - return ResourceManager.GetString("BtnShowStats_ShowStats", resourceCulture); - } - } - /// /// Looks up a localized string similar to Error occured while reading history file:. /// diff --git a/ShareX.HistoryLib/Properties/Resources.resx b/ShareX.HistoryLib/Properties/Resources.resx index 2ae66cc58..0443a934c 100644 --- a/ShareX.HistoryLib/Properties/Resources.resx +++ b/ShareX.HistoryLib/Properties/Resources.resx @@ -220,12 +220,6 @@ Edit image... - - Show stats - - - Hide stats - History item counts: From 6b5a055084d2373c8611799aa424a66acc6fdf6f Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 25 Jul 2021 07:17:10 +0300 Subject: [PATCH 05/10] Added history settings form --- .../Forms/HistoryForm.Designer.cs | 205 +++++++++--------- ShareX.HistoryLib/Forms/HistoryForm.cs | 21 +- ShareX.HistoryLib/Forms/HistoryForm.resx | 107 ++++----- .../Forms/HistorySettingsForm.Designer.cs | 74 +++++++ .../Forms/HistorySettingsForm.cs | 50 +++++ .../Forms/HistorySettingsForm.resx | 195 +++++++++++++++++ .../ImageHistorySettingsForm.Designer.cs | 1 - .../Forms/ImageHistorySettingsForm.resx | 22 +- ShareX.HistoryLib/HistoryFilter.cs | 6 +- ShareX.HistoryLib/ShareX.HistoryLib.csproj | 9 + 10 files changed, 490 insertions(+), 200 deletions(-) create mode 100644 ShareX.HistoryLib/Forms/HistorySettingsForm.Designer.cs create mode 100644 ShareX.HistoryLib/Forms/HistorySettingsForm.cs create mode 100644 ShareX.HistoryLib/Forms/HistorySettingsForm.resx diff --git a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs index f117d9869..b7ebc462f 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs @@ -30,15 +30,21 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistoryForm)); - this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter(); + this.tscHistory = new System.Windows.Forms.ToolStripContainer(); this.lvHistory = new ShareX.HelpersLib.MyListView(); this.chIcon = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.nudMaxItemCount = new System.Windows.Forms.NumericUpDown(); + this.tssHistory = new System.Windows.Forms.ToolStrip(); + this.tslSearch = new System.Windows.Forms.ToolStripLabel(); + this.tstbSearch = new System.Windows.Forms.ToolStripTextBox(); + this.tsbSearch = new System.Windows.Forms.ToolStripButton(); + this.tss1 = new System.Windows.Forms.ToolStripSeparator(); + this.tsbSettings = new System.Windows.Forms.ToolStripButton(); + this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter(); + this.btnCopyStats = new System.Windows.Forms.Button(); this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox(); - this.lblMaxItemCount = new System.Windows.Forms.Label(); this.gbFilters = new System.Windows.Forms.GroupBox(); this.lblURLFilter = new System.Windows.Forms.Label(); this.txtURLFilter = new System.Windows.Forms.TextBox(); @@ -55,44 +61,30 @@ private void InitializeComponent() this.cbDateFilter = new System.Windows.Forms.CheckBox(); this.dtpFilterTo = new System.Windows.Forms.DateTimePicker(); this.txtFilenameFilter = new System.Windows.Forms.TextBox(); - this.tscHistory = new System.Windows.Forms.ToolStripContainer(); - this.tssHistory = new System.Windows.Forms.ToolStrip(); - this.tslSearch = new System.Windows.Forms.ToolStripLabel(); - this.tstbSearch = new System.Windows.Forms.ToolStripTextBox(); - this.tsbSearch = new System.Windows.Forms.ToolStripButton(); - this.btnCopyStats = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); - this.scMain.Panel1.SuspendLayout(); - this.scMain.Panel2.SuspendLayout(); - this.scMain.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudMaxItemCount)).BeginInit(); - this.gbFilters.SuspendLayout(); this.tscHistory.ContentPanel.SuspendLayout(); this.tscHistory.TopToolStripPanel.SuspendLayout(); this.tscHistory.SuspendLayout(); this.tssHistory.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); + this.scMain.Panel1.SuspendLayout(); + this.scMain.Panel2.SuspendLayout(); + this.scMain.SuspendLayout(); + this.gbFilters.SuspendLayout(); this.SuspendLayout(); // - // scMain + // tscHistory // - resources.ApplyResources(this.scMain, "scMain"); - this.scMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; - this.scMain.Name = "scMain"; // - // scMain.Panel1 + // tscHistory.ContentPanel // - this.scMain.Panel1.Controls.Add(this.tscHistory); + this.tscHistory.ContentPanel.Controls.Add(this.lvHistory); + resources.ApplyResources(this.tscHistory.ContentPanel, "tscHistory.ContentPanel"); + resources.ApplyResources(this.tscHistory, "tscHistory"); + this.tscHistory.Name = "tscHistory"; // - // scMain.Panel2 + // tscHistory.TopToolStripPanel // - this.scMain.Panel2.Controls.Add(this.btnCopyStats); - this.scMain.Panel2.Controls.Add(this.nudMaxItemCount); - this.scMain.Panel2.Controls.Add(this.pbThumbnail); - this.scMain.Panel2.Controls.Add(this.lblMaxItemCount); - this.scMain.Panel2.Controls.Add(this.gbFilters); - this.scMain.SplitterColor = System.Drawing.Color.White; - this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189))))); - this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved); + this.tscHistory.TopToolStripPanel.Controls.Add(this.tssHistory); // // lvHistory // @@ -131,16 +123,76 @@ private void InitializeComponent() // resources.ApplyResources(this.chURL, "chURL"); // - // nudMaxItemCount + // tssHistory // - resources.ApplyResources(this.nudMaxItemCount, "nudMaxItemCount"); - this.nudMaxItemCount.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.nudMaxItemCount.Name = "nudMaxItemCount"; - this.nudMaxItemCount.ValueChanged += new System.EventHandler(this.nudMaxItemCount_ValueChanged); + resources.ApplyResources(this.tssHistory, "tssHistory"); + this.tssHistory.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.tssHistory.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tslSearch, + this.tstbSearch, + this.tsbSearch, + this.tss1, + this.tsbSettings}); + this.tssHistory.Name = "tssHistory"; + this.tssHistory.ShowItemToolTips = false; + // + // tslSearch + // + this.tslSearch.Name = "tslSearch"; + resources.ApplyResources(this.tslSearch, "tslSearch"); + // + // tstbSearch + // + this.tstbSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + resources.ApplyResources(this.tstbSearch, "tstbSearch"); + this.tstbSearch.Name = "tstbSearch"; + this.tstbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tstbSearch_KeyDown); + // + // tsbSearch + // + this.tsbSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbSearch.Image = global::ShareX.HistoryLib.Properties.Resources.magnifier; + resources.ApplyResources(this.tsbSearch, "tsbSearch"); + this.tsbSearch.Name = "tsbSearch"; + this.tsbSearch.Click += new System.EventHandler(this.tsbSearch_Click); + // + // tss1 + // + this.tss1.Name = "tss1"; + resources.ApplyResources(this.tss1, "tss1"); + // + // tsbSettings + // + this.tsbSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + resources.ApplyResources(this.tsbSettings, "tsbSettings"); + this.tsbSettings.Name = "tsbSettings"; + this.tsbSettings.Click += new System.EventHandler(this.tsbSettings_Click); + // + // scMain + // + resources.ApplyResources(this.scMain, "scMain"); + this.scMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.scMain.Name = "scMain"; + // + // scMain.Panel1 + // + this.scMain.Panel1.Controls.Add(this.tscHistory); + // + // scMain.Panel2 + // + this.scMain.Panel2.Controls.Add(this.btnCopyStats); + this.scMain.Panel2.Controls.Add(this.pbThumbnail); + this.scMain.Panel2.Controls.Add(this.gbFilters); + this.scMain.SplitterColor = System.Drawing.Color.White; + this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189))))); + this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved); + // + // btnCopyStats + // + resources.ApplyResources(this.btnCopyStats, "btnCopyStats"); + this.btnCopyStats.Name = "btnCopyStats"; + this.btnCopyStats.UseVisualStyleBackColor = true; + this.btnCopyStats.Click += new System.EventHandler(this.btnCopyStats_Click); // // pbThumbnail // @@ -153,11 +205,6 @@ private void InitializeComponent() this.pbThumbnail.PictureBoxBackColor = System.Drawing.SystemColors.Control; this.pbThumbnail.ShowImageSizeLabel = true; // - // lblMaxItemCount - // - resources.ApplyResources(this.lblMaxItemCount, "lblMaxItemCount"); - this.lblMaxItemCount.Name = "lblMaxItemCount"; - // // gbFilters // resources.ApplyResources(this.gbFilters, "gbFilters"); @@ -266,58 +313,6 @@ private void InitializeComponent() this.txtFilenameFilter.Name = "txtFilenameFilter"; this.txtFilenameFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtFilenameFilter_KeyDown); // - // tscHistory - // - // - // tscHistory.ContentPanel - // - this.tscHistory.ContentPanel.Controls.Add(this.lvHistory); - resources.ApplyResources(this.tscHistory.ContentPanel, "tscHistory.ContentPanel"); - resources.ApplyResources(this.tscHistory, "tscHistory"); - this.tscHistory.Name = "tscHistory"; - // - // tscHistory.TopToolStripPanel - // - this.tscHistory.TopToolStripPanel.Controls.Add(this.tssHistory); - // - // tssHistory - // - resources.ApplyResources(this.tssHistory, "tssHistory"); - this.tssHistory.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; - this.tssHistory.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tslSearch, - this.tstbSearch, - this.tsbSearch}); - this.tssHistory.Name = "tssHistory"; - this.tssHistory.ShowItemToolTips = false; - // - // tslSearch - // - this.tslSearch.Name = "tslSearch"; - resources.ApplyResources(this.tslSearch, "tslSearch"); - // - // tstbSearch - // - this.tstbSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - resources.ApplyResources(this.tstbSearch, "tstbSearch"); - this.tstbSearch.Name = "tstbSearch"; - this.tstbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tstbSearch_KeyDown); - // - // tsbSearch - // - this.tsbSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.tsbSearch.Image = global::ShareX.HistoryLib.Properties.Resources.magnifier; - resources.ApplyResources(this.tsbSearch, "tsbSearch"); - this.tsbSearch.Name = "tsbSearch"; - this.tsbSearch.Click += new System.EventHandler(this.tsbSearch_Click); - // - // btnCopyStats - // - resources.ApplyResources(this.btnCopyStats, "btnCopyStats"); - this.btnCopyStats.Name = "btnCopyStats"; - this.btnCopyStats.UseVisualStyleBackColor = true; - this.btnCopyStats.Click += new System.EventHandler(this.btnCopyStats_Click); - // // HistoryForm // resources.ApplyResources(this, "$this"); @@ -329,14 +324,6 @@ private void InitializeComponent() this.Shown += new System.EventHandler(this.HistoryForm_Shown); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.HistoryForm_KeyDown); this.Resize += new System.EventHandler(this.HistoryForm_Resize); - this.scMain.Panel1.ResumeLayout(false); - this.scMain.Panel2.ResumeLayout(false); - this.scMain.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit(); - this.scMain.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.nudMaxItemCount)).EndInit(); - this.gbFilters.ResumeLayout(false); - this.gbFilters.PerformLayout(); this.tscHistory.ContentPanel.ResumeLayout(false); this.tscHistory.TopToolStripPanel.ResumeLayout(false); this.tscHistory.TopToolStripPanel.PerformLayout(); @@ -344,6 +331,12 @@ private void InitializeComponent() this.tscHistory.PerformLayout(); this.tssHistory.ResumeLayout(false); this.tssHistory.PerformLayout(); + this.scMain.Panel1.ResumeLayout(false); + this.scMain.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit(); + this.scMain.ResumeLayout(false); + this.gbFilters.ResumeLayout(false); + this.gbFilters.PerformLayout(); this.ResumeLayout(false); } @@ -373,13 +366,13 @@ private void InitializeComponent() private System.Windows.Forms.Label lblFilenameFilter; private System.Windows.Forms.Label lblURLFilter; private System.Windows.Forms.TextBox txtURLFilter; - private System.Windows.Forms.Label lblMaxItemCount; - private System.Windows.Forms.NumericUpDown nudMaxItemCount; private System.Windows.Forms.ToolStripContainer tscHistory; private System.Windows.Forms.ToolStrip tssHistory; private System.Windows.Forms.ToolStripLabel tslSearch; private System.Windows.Forms.ToolStripTextBox tstbSearch; private System.Windows.Forms.ToolStripButton tsbSearch; private System.Windows.Forms.Button btnCopyStats; + private System.Windows.Forms.ToolStripSeparator tss1; + private System.Windows.Forms.ToolStripButton tsbSettings; } } \ No newline at end of file diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index c678e8dae..ce549992b 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -77,8 +77,6 @@ public HistoryForm(string historyPath, HistorySettings settings, Action scMain.SplitterDistance = Settings.SplitterDistance; } - nudMaxItemCount.SetValue(Settings.MaxItemCount); - ShareXResources.ApplyTheme(this); Settings.WindowState.AutoHandleFormState(this); @@ -121,7 +119,7 @@ private void ApplyFilterSimple() { HistoryFilter filter = new HistoryFilter() { - FileName = tstbSearch.Text, + Filename = tstbSearch.Text, MaxItemCount = Settings.MaxItemCount }; @@ -132,7 +130,7 @@ private void ApplyFilterAdvanced() { HistoryFilter filter = new HistoryFilter() { - FileName = txtFilenameFilter.Text, + Filename = txtFilenameFilter.Text, URL = txtURLFilter.Text, FilterDate = cbDateFilter.Checked, FromDate = dtpFilterFrom.Value.Date, @@ -372,6 +370,16 @@ private void tsbSearch_Click(object sender, EventArgs e) ApplyFilterSimple(); } + private void tsbSettings_Click(object sender, EventArgs e) + { + using (HistorySettingsForm form = new HistorySettingsForm(Settings)) + { + form.ShowDialog(); + } + + RefreshHistoryItems(); + } + private void txtFilenameFilter_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) @@ -404,11 +412,6 @@ private void btnRemoveFilters_Click(object sender, EventArgs e) AddHistoryItems(allHistoryItems); } - private void nudMaxItemCount_ValueChanged(object sender, EventArgs e) - { - Settings.MaxItemCount = (int)nudMaxItemCount.Value; - } - private void btnCopyStats_Click(object sender, EventArgs e) { string stats = OutputStats(allHistoryItems); diff --git a/ShareX.HistoryLib/Forms/HistoryForm.resx b/ShareX.HistoryLib/Forms/HistoryForm.resx index 734937152..70ec165d5 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.resx +++ b/ShareX.HistoryLib/Forms/HistoryForm.resx @@ -117,14 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Fill - - - - 0, 0 - tscHistory.BottomToolStripPanel @@ -162,9 +154,11 @@ 230 + Fill + 0, 0 @@ -264,11 +258,23 @@ 23, 22 + + 6, 25 + + + Magenta + + + 62, 22 + + + Settings... + 3, 0 - 373, 25 + 441, 25 0 @@ -309,6 +315,12 @@ 0 + + Fill + + + 0, 0 + scMain.Panel1 @@ -351,33 +363,6 @@ 0 - - Bottom, Left - - - 224, 576 - - - 80, 20 - - - 7 - - - Center - - - nudMaxItemCount - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - scMain.Panel2 - - - 1 - Top, Bottom, Left, Right @@ -385,7 +370,7 @@ 8, 8 - 400, 352 + 406, 352 3 @@ -400,37 +385,7 @@ scMain.Panel2 - 2 - - - Bottom, Left - - - True - - - 5, 580 - - - 96, 13 - - - 6 - - - Maximum item limit: - - - lblMaxItemCount - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - scMain.Panel2 - - - 3 + 1 Bottom, Left @@ -829,7 +784,7 @@ 8, 368 - 404, 200 + 408, 200 4 @@ -847,7 +802,7 @@ scMain.Panel2 - 4 + 2 scMain.Panel2 @@ -948,6 +903,18 @@ System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tss1 + + + System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tsbSettings + + + System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + HistoryForm diff --git a/ShareX.HistoryLib/Forms/HistorySettingsForm.Designer.cs b/ShareX.HistoryLib/Forms/HistorySettingsForm.Designer.cs new file mode 100644 index 000000000..655b4f12e --- /dev/null +++ b/ShareX.HistoryLib/Forms/HistorySettingsForm.Designer.cs @@ -0,0 +1,74 @@ + +namespace ShareX.HistoryLib +{ + partial class HistorySettingsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistorySettingsForm)); + this.lblMaximumItemLimit = new System.Windows.Forms.Label(); + this.nudMaximumItemLimit = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.nudMaximumItemLimit)).BeginInit(); + this.SuspendLayout(); + // + // lblMaximumItemLimit + // + resources.ApplyResources(this.lblMaximumItemLimit, "lblMaximumItemLimit"); + this.lblMaximumItemLimit.Name = "lblMaximumItemLimit"; + // + // nudMaximumItemLimit + // + resources.ApplyResources(this.nudMaximumItemLimit, "nudMaximumItemLimit"); + this.nudMaximumItemLimit.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.nudMaximumItemLimit.Name = "nudMaximumItemLimit"; + this.nudMaximumItemLimit.ValueChanged += new System.EventHandler(this.nudMaximumItemLimit_ValueChanged); + // + // HistorySettingsForm + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.Controls.Add(this.nudMaximumItemLimit); + this.Controls.Add(this.lblMaximumItemLimit); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "HistorySettingsForm"; + ((System.ComponentModel.ISupportInitialize)(this.nudMaximumItemLimit)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblMaximumItemLimit; + private System.Windows.Forms.NumericUpDown nudMaximumItemLimit; + } +} \ No newline at end of file diff --git a/ShareX.HistoryLib/Forms/HistorySettingsForm.cs b/ShareX.HistoryLib/Forms/HistorySettingsForm.cs new file mode 100644 index 000000000..518d1ee19 --- /dev/null +++ b/ShareX.HistoryLib/Forms/HistorySettingsForm.cs @@ -0,0 +1,50 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2020 ShareX Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using ShareX.HelpersLib; +using System; +using System.Windows.Forms; + +namespace ShareX.HistoryLib +{ + public partial class HistorySettingsForm : Form + { + public HistorySettings Settings { get; private set; } + + public HistorySettingsForm(HistorySettings settings) + { + InitializeComponent(); + ShareXResources.ApplyTheme(this); + + Settings = settings; + nudMaximumItemLimit.SetValue(Settings.MaxItemCount); + } + + private void nudMaximumItemLimit_ValueChanged(object sender, EventArgs e) + { + Settings.MaxItemCount = (int)nudMaximumItemLimit.Value; + } + } +} \ No newline at end of file diff --git a/ShareX.HistoryLib/Forms/HistorySettingsForm.resx b/ShareX.HistoryLib/Forms/HistorySettingsForm.resx new file mode 100644 index 000000000..45b4734a7 --- /dev/null +++ b/ShareX.HistoryLib/Forms/HistorySettingsForm.resx @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + 13, 16 + + + 96, 13 + + + 0 + + + Maximum item limit: + + + lblMaximumItemLimit + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + 16, 32 + + + 64, 20 + + + 1 + + + + Center + + + nudMaximumItemLimit + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 96, 96 + + + 305, 191 + + + CenterScreen + + + ShareX - History settings + + + HistorySettingsForm + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.Designer.cs b/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.Designer.cs index fd07dd618..936dfec07 100644 --- a/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.Designer.cs @@ -119,7 +119,6 @@ private void InitializeComponent() // ImageHistorySettingsForm // resources.ApplyResources(this, "$this"); - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.SystemColors.Window; this.Controls.Add(this.cbFilterMissingFiles); diff --git a/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.resx b/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.resx index d4a5b7da7..fd9d424c3 100644 --- a/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.resx +++ b/ShareX.HistoryLib/Forms/ImageHistorySettingsForm.resx @@ -123,7 +123,7 @@ - 5, 8 + 13, 16 62, 13 @@ -150,7 +150,7 @@ True - 5, 56 + 13, 64 80, 13 @@ -177,7 +177,7 @@ True - 5, 104 + 13, 112 105, 13 @@ -201,7 +201,7 @@ 6 - 8, 24 + 16, 32 120, 21 @@ -222,7 +222,7 @@ 5 - 8, 72 + 16, 80 64, 20 @@ -247,7 +247,7 @@ 4 - 8, 120 + 16, 128 64, 20 @@ -274,7 +274,7 @@ True - 77, 76 + 85, 84 18, 13 @@ -304,7 +304,7 @@ NoControl - 8, 176 + 16, 184 138, 17 @@ -331,7 +331,7 @@ True - 8, 152 + 16, 160 106, 17 @@ -358,10 +358,10 @@ True - 6, 13 + 96, 96 - 344, 226 + 344, 218 CenterScreen diff --git a/ShareX.HistoryLib/HistoryFilter.cs b/ShareX.HistoryLib/HistoryFilter.cs index 74b0a41a8..68c5a5c07 100644 --- a/ShareX.HistoryLib/HistoryFilter.cs +++ b/ShareX.HistoryLib/HistoryFilter.cs @@ -33,7 +33,7 @@ namespace ShareX.HistoryLib { public class HistoryFilter { - public string FileName { get; set; } + public string Filename { get; set; } public string URL { get; set; } public bool FilterDate { get; set; } public DateTime FromDate { get; set; } @@ -62,9 +62,9 @@ public IEnumerable ApplyFilter(IEnumerable historyItem historyItems = historyItems.Where(x => !string.IsNullOrEmpty(x.Host) && x.Host.Contains(Host, StringComparison.InvariantCultureIgnoreCase)); } - if (!string.IsNullOrEmpty(FileName)) + if (!string.IsNullOrEmpty(Filename)) { - string pattern = Regex.Escape(FileName).Replace("\\?", ".").Replace("\\*", ".*"); + string pattern = Regex.Escape(Filename).Replace("\\?", ".").Replace("\\*", ".*"); Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); historyItems = historyItems.Where(x => (x.FileName != null && regex.IsMatch(x.FileName)) || (SearchInTags && x.Tags != null && x.Tags.Any(tag => regex.IsMatch(tag.Value)))); diff --git a/ShareX.HistoryLib/ShareX.HistoryLib.csproj b/ShareX.HistoryLib/ShareX.HistoryLib.csproj index 068c1c6b1..6aa574387 100644 --- a/ShareX.HistoryLib/ShareX.HistoryLib.csproj +++ b/ShareX.HistoryLib/ShareX.HistoryLib.csproj @@ -86,6 +86,12 @@ Properties\SharedAssemblyInfo.cs + + Form + + + HistorySettingsForm.cs + @@ -247,6 +253,9 @@ HistoryItemInfoForm.cs + + HistorySettingsForm.cs + ImageHistoryForm.cs From c2a6fe6dc9b6549448408a7e3701c232f98a2c09 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 25 Jul 2021 07:34:02 +0300 Subject: [PATCH 06/10] Focus back to textbox after press enter --- ShareX.HistoryLib/Forms/HistoryForm.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index ce549992b..15d316d57 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -85,7 +85,7 @@ public HistoryForm(string historyPath, HistorySettings settings, Action private void RefreshHistoryItems() { allHistoryItems = GetHistoryItems(); - ApplyFilterAdvanced(); + ApplyFilterSimple(); } private HistoryItem[] him_GetHistoryItems() @@ -362,6 +362,7 @@ private void tstbSearch_KeyDown(object sender, KeyEventArgs e) e.Handled = true; e.SuppressKeyPress = true; ApplyFilterSimple(); + tstbSearch.Focus(); } } From 2eccedb2eb9f5046ebf3d9abcb58888db7a3f02a Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 25 Jul 2021 08:46:33 +0300 Subject: [PATCH 07/10] Added advanced search button --- .../Forms/HistoryForm.Designer.cs | 353 +++---- ShareX.HistoryLib/Forms/HistoryForm.cs | 10 +- ShareX.HistoryLib/Forms/HistoryForm.resx | 861 +++++++++--------- .../Properties/Resources.Designer.cs | 10 + ShareX.HistoryLib/Properties/Resources.resx | 91 +- .../Resources/magnifier--plus.png | Bin 0 -> 803 bytes ShareX.HistoryLib/ShareX.HistoryLib.csproj | 3 + 7 files changed, 688 insertions(+), 640 deletions(-) create mode 100644 ShareX.HistoryLib/Resources/magnifier--plus.png diff --git a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs index b7ebc462f..72becfc9f 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs @@ -31,27 +31,13 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HistoryForm)); this.tscHistory = new System.Windows.Forms.ToolStripContainer(); - this.lvHistory = new ShareX.HelpersLib.MyListView(); - this.chIcon = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.tssHistory = new System.Windows.Forms.ToolStrip(); - this.tslSearch = new System.Windows.Forms.ToolStripLabel(); - this.tstbSearch = new System.Windows.Forms.ToolStripTextBox(); - this.tsbSearch = new System.Windows.Forms.ToolStripButton(); - this.tss1 = new System.Windows.Forms.ToolStripSeparator(); - this.tsbSettings = new System.Windows.Forms.ToolStripButton(); - this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter(); - this.btnCopyStats = new System.Windows.Forms.Button(); - this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox(); - this.gbFilters = new System.Windows.Forms.GroupBox(); + 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(); this.cbHostFilterSelection = new System.Windows.Forms.ComboBox(); - this.btnRemoveFilters = new System.Windows.Forms.Button(); - this.btnApplyFilters = new System.Windows.Forms.Button(); this.cbTypeFilterSelection = new System.Windows.Forms.ComboBox(); this.cbHostFilter = new System.Windows.Forms.CheckBox(); this.cbTypeFilter = new System.Windows.Forms.CheckBox(); @@ -61,15 +47,30 @@ private void InitializeComponent() this.cbDateFilter = new System.Windows.Forms.CheckBox(); this.dtpFilterTo = new System.Windows.Forms.DateTimePicker(); this.txtFilenameFilter = new System.Windows.Forms.TextBox(); + this.lvHistory = new ShareX.HelpersLib.MyListView(); + this.chIcon = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tssHistory = new System.Windows.Forms.ToolStrip(); + this.tslSearch = new System.Windows.Forms.ToolStripLabel(); + this.tstbSearch = new System.Windows.Forms.ToolStripTextBox(); + this.tsbSearch = new System.Windows.Forms.ToolStripButton(); + this.tsbAdvancedSearch = new System.Windows.Forms.ToolStripButton(); + this.tss1 = new System.Windows.Forms.ToolStripSeparator(); + this.tsbSettings = new System.Windows.Forms.ToolStripButton(); + this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter(); + this.btnCopyStats = new System.Windows.Forms.Button(); + this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox(); this.tscHistory.ContentPanel.SuspendLayout(); this.tscHistory.TopToolStripPanel.SuspendLayout(); this.tscHistory.SuspendLayout(); + this.gbAdvancedSearch.SuspendLayout(); this.tssHistory.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); this.scMain.Panel1.SuspendLayout(); this.scMain.Panel2.SuspendLayout(); this.scMain.SuspendLayout(); - this.gbFilters.SuspendLayout(); this.SuspendLayout(); // // tscHistory @@ -77,6 +78,7 @@ private void InitializeComponent() // // tscHistory.ContentPanel // + this.tscHistory.ContentPanel.Controls.Add(this.gbAdvancedSearch); this.tscHistory.ContentPanel.Controls.Add(this.lvHistory); resources.ApplyResources(this.tscHistory.ContentPanel, "tscHistory.ContentPanel"); resources.ApplyResources(this.tscHistory, "tscHistory"); @@ -86,145 +88,40 @@ private void InitializeComponent() // this.tscHistory.TopToolStripPanel.Controls.Add(this.tssHistory); // - // lvHistory + // gbAdvancedSearch // - this.lvHistory.AllowColumnSort = true; - this.lvHistory.AutoFillColumn = true; - this.lvHistory.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.lvHistory.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chIcon, - this.chDateTime, - this.chFilename, - this.chURL}); - resources.ApplyResources(this.lvHistory, "lvHistory"); - this.lvHistory.FullRowSelect = true; - this.lvHistory.HideSelection = false; - this.lvHistory.Name = "lvHistory"; - this.lvHistory.UseCompatibleStateImageBehavior = false; - this.lvHistory.View = System.Windows.Forms.View.Details; - this.lvHistory.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvHistory_ItemDrag); - this.lvHistory.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvHistory_ItemSelectionChanged); - this.lvHistory.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvHistory_KeyDown); - this.lvHistory.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvHistory_MouseDoubleClick); + 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); + this.gbAdvancedSearch.Controls.Add(this.cbHostFilterSelection); + this.gbAdvancedSearch.Controls.Add(this.cbTypeFilterSelection); + this.gbAdvancedSearch.Controls.Add(this.cbHostFilter); + this.gbAdvancedSearch.Controls.Add(this.cbTypeFilter); + this.gbAdvancedSearch.Controls.Add(this.dtpFilterFrom); + this.gbAdvancedSearch.Controls.Add(this.lblFilterFrom); + this.gbAdvancedSearch.Controls.Add(this.lblFilterTo); + this.gbAdvancedSearch.Controls.Add(this.cbDateFilter); + this.gbAdvancedSearch.Controls.Add(this.dtpFilterTo); + this.gbAdvancedSearch.Controls.Add(this.txtFilenameFilter); + resources.ApplyResources(this.gbAdvancedSearch, "gbAdvancedSearch"); + this.gbAdvancedSearch.Name = "gbAdvancedSearch"; + this.gbAdvancedSearch.TabStop = false; // - // chIcon + // btnAdvancedSearchReset // - resources.ApplyResources(this.chIcon, "chIcon"); + resources.ApplyResources(this.btnAdvancedSearchReset, "btnAdvancedSearchReset"); + this.btnAdvancedSearchReset.Name = "btnAdvancedSearchReset"; + this.btnAdvancedSearchReset.UseVisualStyleBackColor = true; + this.btnAdvancedSearchReset.Click += new System.EventHandler(this.btnAdvancedSearchReset_Click); // - // chDateTime + // btnAdvancedSearch // - resources.ApplyResources(this.chDateTime, "chDateTime"); - // - // chFilename - // - resources.ApplyResources(this.chFilename, "chFilename"); - // - // chURL - // - resources.ApplyResources(this.chURL, "chURL"); - // - // tssHistory - // - resources.ApplyResources(this.tssHistory, "tssHistory"); - this.tssHistory.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; - this.tssHistory.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tslSearch, - this.tstbSearch, - this.tsbSearch, - this.tss1, - this.tsbSettings}); - this.tssHistory.Name = "tssHistory"; - this.tssHistory.ShowItemToolTips = false; - // - // tslSearch - // - this.tslSearch.Name = "tslSearch"; - resources.ApplyResources(this.tslSearch, "tslSearch"); - // - // tstbSearch - // - this.tstbSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - resources.ApplyResources(this.tstbSearch, "tstbSearch"); - this.tstbSearch.Name = "tstbSearch"; - this.tstbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tstbSearch_KeyDown); - // - // tsbSearch - // - this.tsbSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.tsbSearch.Image = global::ShareX.HistoryLib.Properties.Resources.magnifier; - resources.ApplyResources(this.tsbSearch, "tsbSearch"); - this.tsbSearch.Name = "tsbSearch"; - this.tsbSearch.Click += new System.EventHandler(this.tsbSearch_Click); - // - // tss1 - // - this.tss1.Name = "tss1"; - resources.ApplyResources(this.tss1, "tss1"); - // - // tsbSettings - // - this.tsbSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - resources.ApplyResources(this.tsbSettings, "tsbSettings"); - this.tsbSettings.Name = "tsbSettings"; - this.tsbSettings.Click += new System.EventHandler(this.tsbSettings_Click); - // - // scMain - // - resources.ApplyResources(this.scMain, "scMain"); - this.scMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; - this.scMain.Name = "scMain"; - // - // scMain.Panel1 - // - this.scMain.Panel1.Controls.Add(this.tscHistory); - // - // scMain.Panel2 - // - this.scMain.Panel2.Controls.Add(this.btnCopyStats); - this.scMain.Panel2.Controls.Add(this.pbThumbnail); - this.scMain.Panel2.Controls.Add(this.gbFilters); - this.scMain.SplitterColor = System.Drawing.Color.White; - this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189))))); - this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved); - // - // btnCopyStats - // - resources.ApplyResources(this.btnCopyStats, "btnCopyStats"); - this.btnCopyStats.Name = "btnCopyStats"; - this.btnCopyStats.UseVisualStyleBackColor = true; - this.btnCopyStats.Click += new System.EventHandler(this.btnCopyStats_Click); - // - // pbThumbnail - // - resources.ApplyResources(this.pbThumbnail, "pbThumbnail"); - this.pbThumbnail.BackColor = System.Drawing.SystemColors.Window; - this.pbThumbnail.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pbThumbnail.DrawCheckeredBackground = true; - this.pbThumbnail.FullscreenOnClick = true; - this.pbThumbnail.Name = "pbThumbnail"; - this.pbThumbnail.PictureBoxBackColor = System.Drawing.SystemColors.Control; - this.pbThumbnail.ShowImageSizeLabel = true; - // - // gbFilters - // - resources.ApplyResources(this.gbFilters, "gbFilters"); - this.gbFilters.Controls.Add(this.lblURLFilter); - this.gbFilters.Controls.Add(this.txtURLFilter); - this.gbFilters.Controls.Add(this.lblFilenameFilter); - this.gbFilters.Controls.Add(this.cbHostFilterSelection); - this.gbFilters.Controls.Add(this.btnRemoveFilters); - this.gbFilters.Controls.Add(this.btnApplyFilters); - this.gbFilters.Controls.Add(this.cbTypeFilterSelection); - this.gbFilters.Controls.Add(this.cbHostFilter); - this.gbFilters.Controls.Add(this.cbTypeFilter); - this.gbFilters.Controls.Add(this.dtpFilterFrom); - this.gbFilters.Controls.Add(this.lblFilterFrom); - this.gbFilters.Controls.Add(this.lblFilterTo); - this.gbFilters.Controls.Add(this.cbDateFilter); - this.gbFilters.Controls.Add(this.dtpFilterTo); - this.gbFilters.Controls.Add(this.txtFilenameFilter); - this.gbFilters.Name = "gbFilters"; - this.gbFilters.TabStop = false; + resources.ApplyResources(this.btnAdvancedSearch, "btnAdvancedSearch"); + this.btnAdvancedSearch.Name = "btnAdvancedSearch"; + this.btnAdvancedSearch.UseVisualStyleBackColor = true; + this.btnAdvancedSearch.Click += new System.EventHandler(this.btnAdvancedSearch_Click); // // lblURLFilter // @@ -248,20 +145,6 @@ private void InitializeComponent() resources.ApplyResources(this.cbHostFilterSelection, "cbHostFilterSelection"); this.cbHostFilterSelection.Name = "cbHostFilterSelection"; // - // btnRemoveFilters - // - resources.ApplyResources(this.btnRemoveFilters, "btnRemoveFilters"); - this.btnRemoveFilters.Name = "btnRemoveFilters"; - this.btnRemoveFilters.UseVisualStyleBackColor = true; - this.btnRemoveFilters.Click += new System.EventHandler(this.btnRemoveFilters_Click); - // - // btnApplyFilters - // - resources.ApplyResources(this.btnApplyFilters, "btnApplyFilters"); - this.btnApplyFilters.Name = "btnApplyFilters"; - this.btnApplyFilters.UseVisualStyleBackColor = true; - this.btnApplyFilters.Click += new System.EventHandler(this.btnApplyFilters_Click); - // // cbTypeFilterSelection // this.cbTypeFilterSelection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -313,6 +196,133 @@ private void InitializeComponent() this.txtFilenameFilter.Name = "txtFilenameFilter"; this.txtFilenameFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtFilenameFilter_KeyDown); // + // lvHistory + // + this.lvHistory.AllowColumnSort = true; + this.lvHistory.AutoFillColumn = true; + this.lvHistory.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.lvHistory.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chIcon, + this.chDateTime, + this.chFilename, + this.chURL}); + resources.ApplyResources(this.lvHistory, "lvHistory"); + this.lvHistory.FullRowSelect = true; + this.lvHistory.HideSelection = false; + this.lvHistory.Name = "lvHistory"; + this.lvHistory.UseCompatibleStateImageBehavior = false; + this.lvHistory.View = System.Windows.Forms.View.Details; + this.lvHistory.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvHistory_ItemDrag); + this.lvHistory.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvHistory_ItemSelectionChanged); + this.lvHistory.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvHistory_KeyDown); + this.lvHistory.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvHistory_MouseDoubleClick); + // + // chIcon + // + resources.ApplyResources(this.chIcon, "chIcon"); + // + // chDateTime + // + resources.ApplyResources(this.chDateTime, "chDateTime"); + // + // chFilename + // + resources.ApplyResources(this.chFilename, "chFilename"); + // + // chURL + // + resources.ApplyResources(this.chURL, "chURL"); + // + // tssHistory + // + resources.ApplyResources(this.tssHistory, "tssHistory"); + this.tssHistory.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.tssHistory.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tslSearch, + this.tstbSearch, + this.tsbSearch, + this.tsbAdvancedSearch, + this.tss1, + this.tsbSettings}); + this.tssHistory.Name = "tssHistory"; + this.tssHistory.ShowItemToolTips = false; + // + // tslSearch + // + this.tslSearch.Name = "tslSearch"; + resources.ApplyResources(this.tslSearch, "tslSearch"); + // + // tstbSearch + // + this.tstbSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + resources.ApplyResources(this.tstbSearch, "tstbSearch"); + this.tstbSearch.Name = "tstbSearch"; + this.tstbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tstbSearch_KeyDown); + // + // tsbSearch + // + this.tsbSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbSearch.Image = global::ShareX.HistoryLib.Properties.Resources.magnifier; + resources.ApplyResources(this.tsbSearch, "tsbSearch"); + this.tsbSearch.Name = "tsbSearch"; + this.tsbSearch.Click += new System.EventHandler(this.tsbSearch_Click); + // + // tsbAdvancedSearch + // + this.tsbAdvancedSearch.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbAdvancedSearch.Image = global::ShareX.HistoryLib.Properties.Resources.magnifier__plus; + resources.ApplyResources(this.tsbAdvancedSearch, "tsbAdvancedSearch"); + this.tsbAdvancedSearch.Name = "tsbAdvancedSearch"; + this.tsbAdvancedSearch.Click += new System.EventHandler(this.tsbAdvancedSearch_Click); + // + // tss1 + // + this.tss1.Name = "tss1"; + resources.ApplyResources(this.tss1, "tss1"); + // + // tsbSettings + // + this.tsbSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + resources.ApplyResources(this.tsbSettings, "tsbSettings"); + this.tsbSettings.Name = "tsbSettings"; + this.tsbSettings.Click += new System.EventHandler(this.tsbSettings_Click); + // + // scMain + // + resources.ApplyResources(this.scMain, "scMain"); + this.scMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.scMain.Name = "scMain"; + // + // scMain.Panel1 + // + this.scMain.Panel1.Controls.Add(this.tscHistory); + // + // scMain.Panel2 + // + this.scMain.Panel2.Controls.Add(this.btnCopyStats); + this.scMain.Panel2.Controls.Add(this.pbThumbnail); + this.scMain.SplitterColor = System.Drawing.Color.White; + this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189))))); + this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved); + // + // btnCopyStats + // + resources.ApplyResources(this.btnCopyStats, "btnCopyStats"); + this.btnCopyStats.Name = "btnCopyStats"; + this.btnCopyStats.UseVisualStyleBackColor = true; + this.btnCopyStats.Click += new System.EventHandler(this.btnCopyStats_Click); + // + // pbThumbnail + // + resources.ApplyResources(this.pbThumbnail, "pbThumbnail"); + this.pbThumbnail.BackColor = System.Drawing.SystemColors.Window; + this.pbThumbnail.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pbThumbnail.DrawCheckeredBackground = true; + this.pbThumbnail.FullscreenOnClick = true; + this.pbThumbnail.Name = "pbThumbnail"; + this.pbThumbnail.PictureBoxBackColor = System.Drawing.SystemColors.Control; + this.pbThumbnail.ShowImageSizeLabel = true; + // // HistoryForm // resources.ApplyResources(this, "$this"); @@ -329,14 +339,14 @@ private void InitializeComponent() this.tscHistory.TopToolStripPanel.PerformLayout(); this.tscHistory.ResumeLayout(false); this.tscHistory.PerformLayout(); + this.gbAdvancedSearch.ResumeLayout(false); + this.gbAdvancedSearch.PerformLayout(); this.tssHistory.ResumeLayout(false); this.tssHistory.PerformLayout(); this.scMain.Panel1.ResumeLayout(false); this.scMain.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit(); this.scMain.ResumeLayout(false); - this.gbFilters.ResumeLayout(false); - this.gbFilters.PerformLayout(); this.ResumeLayout(false); } @@ -350,10 +360,8 @@ private void InitializeComponent() private System.Windows.Forms.ColumnHeader chIcon; private ShareX.HelpersLib.SplitContainerCustomSplitter scMain; private HelpersLib.MyPictureBox pbThumbnail; - private System.Windows.Forms.GroupBox gbFilters; + private System.Windows.Forms.GroupBox gbAdvancedSearch; private System.Windows.Forms.ComboBox cbHostFilterSelection; - private System.Windows.Forms.Button btnRemoveFilters; - private System.Windows.Forms.Button btnApplyFilters; private System.Windows.Forms.ComboBox cbTypeFilterSelection; private System.Windows.Forms.CheckBox cbHostFilter; private System.Windows.Forms.CheckBox cbTypeFilter; @@ -374,5 +382,8 @@ private void InitializeComponent() private System.Windows.Forms.Button btnCopyStats; 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; } } \ No newline at end of file diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 15d316d57..ff5d28160 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -381,6 +381,11 @@ private void tsbSettings_Click(object sender, EventArgs e) RefreshHistoryItems(); } + private void tsbAdvancedSearch_Click(object sender, EventArgs e) + { + gbAdvancedSearch.Visible = !gbAdvancedSearch.Visible; + } + private void txtFilenameFilter_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) @@ -403,12 +408,13 @@ private void txtURLFilter_KeyDown(object sender, KeyEventArgs e) } } - private void btnApplyFilters_Click(object sender, EventArgs e) + private void btnAdvancedSearch_Click(object sender, EventArgs e) { + gbAdvancedSearch.Visible = false; ApplyFilterAdvanced(); } - private void btnRemoveFilters_Click(object sender, EventArgs e) + private void btnAdvancedSearchReset_Click(object sender, EventArgs e) { AddHistoryItems(allHistoryItems); } diff --git a/ShareX.HistoryLib/Forms/HistoryForm.resx b/ShareX.HistoryLib/Forms/HistoryForm.resx index 70ec165d5..d40966283 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.resx +++ b/ShareX.HistoryLib/Forms/HistoryForm.resx @@ -129,10 +129,426 @@ 4 + + + 272, 176 + + + 120, 24 + + + + 22 + + + Reset + + + btnAdvancedSearchReset + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gbAdvancedSearch + + + 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 + + + 71, 3 + + + 409, 213 + + + 4 + + + Advanced search + + + False + + + gbAdvancedSearch + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tscHistory.ContentPanel + + + 0 + - 24 @@ -154,11 +570,9 @@ 230 - Fill - 0, 0 @@ -178,7 +592,7 @@ tscHistory.ContentPanel - 0 + 1 550, 616 @@ -258,6 +672,18 @@ 23, 22 + + Search + + + Magenta + + + 23, 22 + + + Advanced search... + 6, 25 @@ -274,7 +700,7 @@ 3, 0 - 441, 25 + 464, 25 0 @@ -370,7 +796,7 @@ 8, 8 - 406, 352 + 402, 352 3 @@ -387,423 +813,6 @@ 1 - - Bottom, Left - - - 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 - - - gbFilters - - - 0 - - - 96, 44 - - - 296, 20 - - - 19 - - - txtURLFilter - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 1 - - - 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 - - - gbFilters - - - 2 - - - 168, 142 - - - 224, 21 - - - 16 - - - cbHostFilterSelection - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 3 - - - NoControl - - - 168, 168 - - - 144, 24 - - - 15 - - - Remove filters - - - btnRemoveFilters - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 4 - - - NoControl - - - 16, 168 - - - 144, 24 - - - 14 - - - Apply filters - - - btnApplyFilters - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 5 - - - 168, 118 - - - 224, 21 - - - 11 - - - cbTypeFilterSelection - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 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 - - - gbFilters - - - 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 - - - gbFilters - - - 8 - - - 168, 70 - - - 224, 20 - - - 2 - - - dtpFilterFrom - - - System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 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 - - - gbFilters - - - 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 - - - gbFilters - - - 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 - - - gbFilters - - - 12 - - - 168, 94 - - - 224, 20 - - - 4 - - - dtpFilterTo - - - System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 13 - - - 96, 20 - - - 296, 20 - - - 6 - - - txtFilenameFilter - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbFilters - - - 14 - - - 8, 368 - - - 408, 200 - - - 4 - - - Filters - - - gbFilters - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - scMain.Panel2 - - - 2 - scMain.Panel2 @@ -903,6 +912,12 @@ System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tsbAdvancedSearch + + + System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + tss1 diff --git a/ShareX.HistoryLib/Properties/Resources.Designer.cs b/ShareX.HistoryLib/Properties/Resources.Designer.cs index f5ea478be..fce03f666 100644 --- a/ShareX.HistoryLib/Properties/Resources.Designer.cs +++ b/ShareX.HistoryLib/Properties/Resources.Designer.cs @@ -415,6 +415,16 @@ internal static System.Drawing.Bitmap magnifier { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap magnifier__plus { + get { + object obj = ResourceManager.GetObject("magnifier--plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShareX.HistoryLib/Properties/Resources.resx b/ShareX.HistoryLib/Properties/Resources.resx index 0443a934c..1388ed667 100644 --- a/ShareX.HistoryLib/Properties/Resources.resx +++ b/ShareX.HistoryLib/Properties/Resources.resx @@ -117,33 +117,45 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Error + + + ..\Resources\magnifier.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Thumbnail URL + + File path + + + Hosts: + + + History item counts: + Image preview... File - - Image + + File extensions: + + + Filtered: {0} Markdown link + + Yearly usages: + Folder - - URL - - - - ..\Resources\globe.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + File name File name with extension @@ -160,8 +172,8 @@ Total: {0} - - Filtered: {0} + + ..\Resources\globe.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Open @@ -181,6 +193,15 @@ HTML linked image + + Edit image... + + + Error + + + Total: + Forum (BBCode) linked image @@ -190,52 +211,34 @@ Forum (BBCode) image + + Error occured while reading history file: + Text + + Image + ..\Resources\image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\application-block.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Shortened URL - - File name - - - File path - - - Forum (BBCode) link - - - ..\Resources\magnifier.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Upload file - - Edit image... + + ..\Resources\application-block.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - History item counts: + + URL - - Total: + + Forum (BBCode) link - - Yearly usages: - - - File extensions: - - - Hosts: - - - Error occured while reading history file: + + ..\Resources\magnifier--plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/ShareX.HistoryLib/Resources/magnifier--plus.png b/ShareX.HistoryLib/Resources/magnifier--plus.png new file mode 100644 index 0000000000000000000000000000000000000000..7343b14027a77318dbc1836968bb2b97373eeef6 GIT binary patch literal 803 zcmV+;1Kj+HP)U4h1gpI|>nTZrSB`P8l1L=bWkz)N4C;d?RmlOn15EVf(Dk72;q>vyR3;GYny#pZRRI;uam!iu8xwJfJ^xs zJkQteZ)tPrjRoaKhNdxjQylNhN{g!x9B$u(^W+M$*{rgB>u#sJ3~!?GR2oB>;BeJd zzVP3%$^sn6Deu{Qjb^7HN^)Q?F&LBy%dwOic2!!;7(~ z{}Z*qy967VbK=I!4JK1zTYvw+fY;l36UdL@cuA^Jg$1AX0XV@8@wbGKupnOKfINdF z6qGAyYHB)GRaJASuWz8&>pgit91aaba!@=50^=CXCEpFv^r^em}RU1>V4-Q`I z?e0G9k3{CjFj?-l2d*>FM0jcH>7-0@cDmf5k-1>b^C%~fN~IW3T`K002ovPDHLkV1k@aZ@vHk literal 0 HcmV?d00001 diff --git a/ShareX.HistoryLib/ShareX.HistoryLib.csproj b/ShareX.HistoryLib/ShareX.HistoryLib.csproj index 6aa574387..c9d55a93c 100644 --- a/ShareX.HistoryLib/ShareX.HistoryLib.csproj +++ b/ShareX.HistoryLib/ShareX.HistoryLib.csproj @@ -389,6 +389,9 @@ + + + From 3e60f24919cbed623613b9ceba32b7251d59d367 Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 26 Jul 2021 02:39:35 +0300 Subject: [PATCH 08/10] Added mock history data when ctrl + f5 pressed while in debug mode --- ShareX.HistoryLib/Forms/HistoryForm.cs | 18 +++-- ShareX.HistoryLib/HistoryManagerMock.cs | 79 ++++++++++++++++++++++ ShareX.HistoryLib/ShareX.HistoryLib.csproj | 1 + 3 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 ShareX.HistoryLib/HistoryManagerMock.cs diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index ff5d28160..7240a4e3a 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -82,9 +82,9 @@ public HistoryForm(string historyPath, HistorySettings settings, Action Settings.WindowState.AutoHandleFormState(this); } - private void RefreshHistoryItems() + private void RefreshHistoryItems(bool mockData = false) { - allHistoryItems = GetHistoryItems(); + allHistoryItems = GetHistoryItems(mockData); ApplyFilterSimple(); } @@ -93,9 +93,13 @@ private HistoryItem[] him_GetHistoryItems() return lvHistory.SelectedItems.Cast().Select(x => x.Tag as HistoryItem).ToArray(); } - private HistoryItem[] GetHistoryItems() + private HistoryItem[] GetHistoryItems(bool mockData = false) { - if (history == null) + if (mockData) + { + history = new HistoryManagerMock(HistoryPath); + } + else { history = new HistoryManagerJSON(HistoryPath); } @@ -347,6 +351,12 @@ private void HistoryForm_KeyDown(object sender, KeyEventArgs e) RefreshHistoryItems(); e.Handled = true; break; +#if DEBUG + case Keys.Control | Keys.F5: + RefreshHistoryItems(true); + e.Handled = true; + break; +#endif } } diff --git a/ShareX.HistoryLib/HistoryManagerMock.cs b/ShareX.HistoryLib/HistoryManagerMock.cs new file mode 100644 index 000000000..1fbf5d255 --- /dev/null +++ b/ShareX.HistoryLib/HistoryManagerMock.cs @@ -0,0 +1,79 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2020 ShareX Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using ShareX.HelpersLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ShareX.HistoryLib +{ + public class HistoryManagerMock : HistoryManager + { + private int itemCount = 10000; + + public HistoryManagerMock(string filePath) : base(filePath) + { + } + + protected override List Load(string filePath) + { + List items = new List(); + + for (int i = 0; i < itemCount; i++) + { + items.Add(CreateMockHistoryItem()); + } + + return items.OrderBy(x => x.DateTime).ToList(); + } + + private HistoryItem CreateMockHistoryItem() + { + string fileName = $"ShareX_{Helpers.GetRandomAlphanumeric(10)}.png"; + + HistoryItem historyItem = new HistoryItem() + { + FileName = fileName, + FilePath = @"..\..\..\ShareX.HelpersLib\Resources\ShareX_Logo.png", + DateTime = DateTime.Now.AddSeconds(-RandomFast.Next(0, 1000000)), + Type = "Image", + Host = "Amazon S3", + URL = "https://i.example.com/" + fileName, + ThumbnailURL = "https://t.example.com/" + fileName, + DeletionURL = "https://d.example.com/" + fileName, + ShortenedURL = "https://s.example.com/" + fileName + }; + + return historyItem; + } + + protected override bool Append(string filePath, IEnumerable historyItems) + { + return true; + } + } +} \ No newline at end of file diff --git a/ShareX.HistoryLib/ShareX.HistoryLib.csproj b/ShareX.HistoryLib/ShareX.HistoryLib.csproj index c9d55a93c..0cd88388e 100644 --- a/ShareX.HistoryLib/ShareX.HistoryLib.csproj +++ b/ShareX.HistoryLib/ShareX.HistoryLib.csproj @@ -107,6 +107,7 @@ ImageHistorySettingsForm.cs + From bc108cdf9bead65f49865a7e34a3f6c69c1d6a70 Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 26 Jul 2021 03:00:12 +0300 Subject: [PATCH 09/10] Moved copy stats button to toolstrip --- .../Forms/HistoryForm.Designer.cs | 33 ++++++---- ShareX.HistoryLib/Forms/HistoryForm.cs | 22 +++---- ShareX.HistoryLib/Forms/HistoryForm.resx | 59 +++++++++--------- .../Properties/Resources.Designer.cs | 20 ++++++ ShareX.HistoryLib/Properties/Resources.resx | 42 +++++++------ .../Resources/clipboard-list.png | Bin 0 -> 600 bytes ShareX.HistoryLib/Resources/gear.png | Bin 0 -> 721 bytes ShareX.HistoryLib/ShareX.HistoryLib.csproj | 6 ++ 8 files changed, 110 insertions(+), 72 deletions(-) create mode 100644 ShareX.HistoryLib/Resources/clipboard-list.png create mode 100644 ShareX.HistoryLib/Resources/gear.png diff --git a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs index 72becfc9f..d02966c83 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs @@ -58,9 +58,10 @@ private void InitializeComponent() this.tsbSearch = new System.Windows.Forms.ToolStripButton(); this.tsbAdvancedSearch = new System.Windows.Forms.ToolStripButton(); this.tss1 = new System.Windows.Forms.ToolStripSeparator(); + this.tsbCopyStats = new System.Windows.Forms.ToolStripButton(); + this.tss2 = new System.Windows.Forms.ToolStripSeparator(); this.tsbSettings = new System.Windows.Forms.ToolStripButton(); this.scMain = new ShareX.HelpersLib.SplitContainerCustomSplitter(); - this.btnCopyStats = new System.Windows.Forms.Button(); this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox(); this.tscHistory.ContentPanel.SuspendLayout(); this.tscHistory.TopToolStripPanel.SuspendLayout(); @@ -243,9 +244,10 @@ private void InitializeComponent() this.tsbSearch, this.tsbAdvancedSearch, this.tss1, + this.tsbCopyStats, + this.tss2, this.tsbSettings}); this.tssHistory.Name = "tssHistory"; - this.tssHistory.ShowItemToolTips = false; // // tslSearch // @@ -280,9 +282,23 @@ private void InitializeComponent() this.tss1.Name = "tss1"; resources.ApplyResources(this.tss1, "tss1"); // + // tsbCopyStats + // + this.tsbCopyStats.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbCopyStats.Image = global::ShareX.HistoryLib.Properties.Resources.clipboard_list; + resources.ApplyResources(this.tsbCopyStats, "tsbCopyStats"); + this.tsbCopyStats.Name = "tsbCopyStats"; + this.tsbCopyStats.Click += new System.EventHandler(this.tsbCopyStats_Click); + // + // tss2 + // + this.tss2.Name = "tss2"; + resources.ApplyResources(this.tss2, "tss2"); + // // tsbSettings // - this.tsbSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.tsbSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsbSettings.Image = global::ShareX.HistoryLib.Properties.Resources.gear; resources.ApplyResources(this.tsbSettings, "tsbSettings"); this.tsbSettings.Name = "tsbSettings"; this.tsbSettings.Click += new System.EventHandler(this.tsbSettings_Click); @@ -299,19 +315,11 @@ private void InitializeComponent() // // scMain.Panel2 // - this.scMain.Panel2.Controls.Add(this.btnCopyStats); this.scMain.Panel2.Controls.Add(this.pbThumbnail); this.scMain.SplitterColor = System.Drawing.Color.White; this.scMain.SplitterLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(189)))), ((int)(((byte)(189)))), ((int)(((byte)(189))))); this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved); // - // btnCopyStats - // - resources.ApplyResources(this.btnCopyStats, "btnCopyStats"); - this.btnCopyStats.Name = "btnCopyStats"; - this.btnCopyStats.UseVisualStyleBackColor = true; - this.btnCopyStats.Click += new System.EventHandler(this.btnCopyStats_Click); - // // pbThumbnail // resources.ApplyResources(this.pbThumbnail, "pbThumbnail"); @@ -379,11 +387,12 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripLabel tslSearch; private System.Windows.Forms.ToolStripTextBox tstbSearch; private System.Windows.Forms.ToolStripButton tsbSearch; - private System.Windows.Forms.Button btnCopyStats; 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.ToolStripButton tsbCopyStats; + private System.Windows.Forms.ToolStripSeparator tss2; } } \ No newline at end of file diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 7240a4e3a..166e3c353 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -381,6 +381,17 @@ private void tsbSearch_Click(object sender, EventArgs e) ApplyFilterSimple(); } + private void tsbAdvancedSearch_Click(object sender, EventArgs e) + { + gbAdvancedSearch.Visible = !gbAdvancedSearch.Visible; + } + + private void tsbCopyStats_Click(object sender, EventArgs e) + { + string stats = OutputStats(allHistoryItems); + ClipboardHelpers.CopyText(stats); + } + private void tsbSettings_Click(object sender, EventArgs e) { using (HistorySettingsForm form = new HistorySettingsForm(Settings)) @@ -391,11 +402,6 @@ private void tsbSettings_Click(object sender, EventArgs e) RefreshHistoryItems(); } - private void tsbAdvancedSearch_Click(object sender, EventArgs e) - { - gbAdvancedSearch.Visible = !gbAdvancedSearch.Visible; - } - private void txtFilenameFilter_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) @@ -429,12 +435,6 @@ private void btnAdvancedSearchReset_Click(object sender, EventArgs e) AddHistoryItems(allHistoryItems); } - private void btnCopyStats_Click(object sender, EventArgs e) - { - string stats = OutputStats(allHistoryItems); - ClipboardHelpers.CopyText(stats); - } - private void lvHistory_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { UpdateControls(); diff --git a/ShareX.HistoryLib/Forms/HistoryForm.resx b/ShareX.HistoryLib/Forms/HistoryForm.resx index d40966283..e4e5614aa 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.resx +++ b/ShareX.HistoryLib/Forms/HistoryForm.resx @@ -687,11 +687,23 @@ 6, 25 + + Magenta + + + 23, 22 + + + Copy stats + + + 6, 25 + Magenta - 62, 22 + 23, 22 Settings... @@ -700,7 +712,7 @@ 3, 0 - 464, 25 + 454, 25 0 @@ -762,33 +774,6 @@ 100 - - Bottom, Left - - - 8, 608 - - - 144, 23 - - - 8 - - - Copy stats - - - btnCopyStats - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - scMain.Panel2 - - - 0 - Top, Bottom, Left, Right @@ -796,7 +781,7 @@ 8, 8 - 402, 352 + 406, 352 3 @@ -811,7 +796,7 @@ scMain.Panel2 - 1 + 0 scMain.Panel2 @@ -924,6 +909,18 @@ System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tsbCopyStats + + + System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tss2 + + + System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + tsbSettings diff --git a/ShareX.HistoryLib/Properties/Resources.Designer.cs b/ShareX.HistoryLib/Properties/Resources.Designer.cs index fce03f666..1c13d29c3 100644 --- a/ShareX.HistoryLib/Properties/Resources.Designer.cs +++ b/ShareX.HistoryLib/Properties/Resources.Designer.cs @@ -70,6 +70,16 @@ internal static System.Drawing.Bitmap application_block { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap clipboard_list { + get { + object obj = ResourceManager.GetObject("clipboard-list", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized string similar to Error occured while reading history file:. /// @@ -79,6 +89,16 @@ internal static string ErrorOccuredWhileReadingHistoryFile { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap gear { + get { + object obj = ResourceManager.GetObject("gear", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShareX.HistoryLib/Properties/Resources.resx b/ShareX.HistoryLib/Properties/Resources.resx index 1388ed667..bbd196a62 100644 --- a/ShareX.HistoryLib/Properties/Resources.resx +++ b/ShareX.HistoryLib/Properties/Resources.resx @@ -139,17 +139,17 @@ File - - File extensions: - Filtered: {0} + + Shortened URL + Markdown link - - Yearly usages: + + File extensions: Folder @@ -163,6 +163,9 @@ Copy + + Forum (BBCode) image + HTML image @@ -175,12 +178,18 @@ ..\Resources\globe.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\clipboard-list.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Open More info... + + ..\Resources\magnifier--plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + HTML link @@ -208,11 +217,8 @@ Deletion URL - - Forum (BBCode) image - - - Error occured while reading history file: + + Upload file Text @@ -223,22 +229,22 @@ ..\Resources\image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Shortened URL - - - Upload file - ..\Resources\application-block.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Error occured while reading history file: + + + Yearly usages: + URL Forum (BBCode) link - - ..\Resources\magnifier--plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\gear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/ShareX.HistoryLib/Resources/clipboard-list.png b/ShareX.HistoryLib/Resources/clipboard-list.png new file mode 100644 index 0000000000000000000000000000000000000000..fa14de3fda5cf4bab5d08e9daede2a2bdebc677a GIT binary patch literal 600 zcmV-e0;m0nP)bcnQOyLpvGx`S}@md3hOFSy>sreErJs>ElNR zF}orLwa5sD?JKYu@RxxB zpxl2ZCa_u(m(j02Lm(aDn0S!-ovFU%q6x|NJ>v41_^yu)5&SKZp(c ze6KS60je<5)<&`Y4^$T;BO_QXrU8E;Ubt9Q&Y<1g#&GG*9bimwF#P!O15ASeCnqO^ zvZN$fEv5l~AO@&4wlMq#x7BCDz_%SF9 zfMOsFQiIh6zoA~J3VsV#ps%HcH4H#%e*eYg0-)sd?rv~spSgIE;qIeH3|DU61k)f4 z5(j$$n+tyaf<$9dVIkO=x@fTgO9vn|KYw8{;N52+2bgR*xw#qe0gxJyS_}ied}lZt m$IH$@3}9je=SDC92rvL^X9ena&iX_E0000=5v{uK>{LTtc;2fYLYMFOH$2zc-kdQh)MOCU&ZUUE?oLIMHnPf221XpEN< zTdZjb;?}LHRr1r_b-pCKc<+O^GtBpW^WM(95p-Rr!z?R4p-_lKQ6!tqMuH#^l3Fa5 zGYpOOcx6>p3kKG1w@K49N~hD^1jb_UESr;TU$a0;rBVry!{P8Pj#U}E#P$>0yrB{Q z6QA>VJXey*WWwQaTw|fQvm;Zz{tG9Hhyeo!Ttg?|O2J?d{v9SfmE|Aga=B=AwX`lt zk{dv&R9g4>eD2*{g$4$WQzR0(%i(9)Y_@xYy}dnZG#am>(P*r%ua9I|rje0hx2CCt z4S#?CHvt0&TxiT+;9Fd1wOUtewb~y(ZNqA{Qn6TEo1P9Ou;C*H3>@jx&-5~gg0RsnIXrS$Mq1kL&8jU6$9H^wK8n@EQLTekX z!h(+&FmS+y#w;RNc8cvO1ZHOL-I$mN3~g@-{QG=&IP>ba2(^JwL34dR@;s<_Lr~zfm@ovT$n|4 zI-TZ_7}LqK5Mpz_m;XJtGu + + + + + + From 17c95282e506c740bb5ac430d87c8021af5fd035 Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 26 Jul 2021 03:18:50 +0300 Subject: [PATCH 10/10] Improve reset filters logic --- ShareX.HistoryLib/Forms/HistoryForm.cs | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 166e3c353..fdce2954d 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -82,6 +82,23 @@ public HistoryForm(string historyPath, HistorySettings settings, Action Settings.WindowState.AutoHandleFormState(this); } + private void ResetFilters() + { + tstbSearch.Text = ""; + txtFilenameFilter.ResetText(); + txtURLFilter.ResetText(); + cbDateFilter.Checked = false; + dtpFilterFrom.ResetText(); + dtpFilterTo.ResetText(); + cbTypeFilter.Checked = false; + if (cbTypeFilterSelection.Items.Count > 0) + { + cbTypeFilterSelection.SelectedIndex = 0; + } + cbHostFilter.Checked = false; + cbHostFilterSelection.ResetText(); + } + private void RefreshHistoryItems(bool mockData = false) { allHistoryItems = GetHistoryItems(mockData); @@ -325,14 +342,9 @@ private void HistoryForm_Shown(object sender, EventArgs e) { cbTypeFilterSelection.Items.Clear(); cbTypeFilterSelection.Items.AddRange(allHistoryItems.Select(x => x.Type).Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray()); - - if (cbTypeFilterSelection.Items.Count > 0) - { - cbTypeFilterSelection.SelectedIndex = 0; - } - cbHostFilterSelection.Items.Clear(); cbHostFilterSelection.Items.AddRange(allHistoryItems.Select(x => x.Host).Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray()); + ResetFilters(); } this.ForceActivate(); @@ -432,7 +444,8 @@ private void btnAdvancedSearch_Click(object sender, EventArgs e) private void btnAdvancedSearchReset_Click(object sender, EventArgs e) { - AddHistoryItems(allHistoryItems); + ResetFilters(); + ApplyFilterAdvanced(); } private void lvHistory_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)