diff --git a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs
index 53491b830..9c51742c8 100644
--- a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs
+++ b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs
@@ -159,6 +159,8 @@
//
// tstbSearch
//
+ this.tstbSearch.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
+ this.tstbSearch.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
this.tstbSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
resources.ApplyResources(this.tstbSearch, "tstbSearch");
this.tstbSearch.Name = "tstbSearch";
diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs
index bef009d75..bde0215c3 100644
--- a/ShareX.HistoryLib/Forms/HistoryForm.cs
+++ b/ShareX.HistoryLib/Forms/HistoryForm.cs
@@ -122,18 +122,20 @@ namespace ShareX.HistoryLib
{
allHistoryItems = await GetHistoryItems(mockData);
- ApplyFilterSimple();
-
cbTypeFilterSelection.Items.Clear();
cbHostFilterSelection.Items.Clear();
+ tstbSearch.AutoCompleteCustomSource.Clear();
if (allHistoryItems.Length > 0)
{
- allTypeNames = allHistoryItems.Select(x => x.Type).Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray();
+ allTypeNames = allHistoryItems.Select(x => x.Type).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToArray();
cbTypeFilterSelection.Items.AddRange(allTypeNames.Select(x => typeNamesLocaleLookup.TryGetValue(x, out string value) ? value : x).ToArray());
- cbHostFilterSelection.Items.AddRange(allHistoryItems.Select(x => x.Host).Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray());
+ cbHostFilterSelection.Items.AddRange(allHistoryItems.Select(x => x.Host).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToArray());
+ tstbSearch.AutoCompleteCustomSource.AddRange(allHistoryItems.Select(x => x.TagsProcessName).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToArray());
}
+ ApplyFilterSimple();
+
ResetFilters();
}
diff --git a/ShareX.HistoryLib/Forms/HistoryForm.resx b/ShareX.HistoryLib/Forms/HistoryForm.resx
index 6d5fcc292..29d51ff35 100644
--- a/ShareX.HistoryLib/Forms/HistoryForm.resx
+++ b/ShareX.HistoryLib/Forms/HistoryForm.resx
@@ -129,31 +129,6 @@
4
-
-
-
-
-
- 24
-
-
- Date
-
-
- 115
-
-
- Filename
-
-
- 170
-
-
- URL
-
-
- 230
-
Fill
@@ -165,6 +140,7 @@
550, 636
+
0
@@ -172,7 +148,7 @@
lvHistory
- ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=15.0.2.0, Culture=neutral, PublicKeyToken=null
tscHistory.ContentPanel
@@ -345,6 +321,237 @@
0
+
+
+
+
+ 24
+
+
+ Date
+
+
+ 115
+
+
+ Filename
+
+
+ 170
+
+
+ URL
+
+
+ 230
+
+
+ btnAdvancedSearchClose
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 0
+
+
+ btnAdvancedSearchReset
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 1
+
+
+ lblURLFilter
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 2
+
+
+ txtURLFilter
+
+
+ System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 3
+
+
+ lblFilenameFilter
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 4
+
+
+ cbHostFilterSelection
+
+
+ System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 5
+
+
+ cbTypeFilterSelection
+
+
+ System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 6
+
+
+ cbHostFilter
+
+
+ System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 7
+
+
+ cbTypeFilter
+
+
+ System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 8
+
+
+ dtpFilterFrom
+
+
+ System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 9
+
+
+ lblFilterFrom
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 10
+
+
+ lblFilterTo
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 11
+
+
+ cbDateFilter
+
+
+ System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 12
+
+
+ dtpFilterTo
+
+
+ System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 13
+
+
+ txtFilenameFilter
+
+
+ System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ gbAdvancedSearch
+
+
+ 14
+
+
+ 0, 0
+
+
+ 409, 213
+
+
+ 4
+
+
+ Advanced search
+
+
+ False
+
+
+ gbAdvancedSearch
+
+
+ System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ scHistoryItemInfo.Panel1
+
+
+ 0
+
272, 176
@@ -729,33 +936,6 @@
14
-
- 0, 0
-
-
- 409, 213
-
-
- 4
-
-
- Advanced search
-
-
- False
-
-
- gbAdvancedSearch
-
-
- System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- scHistoryItemInfo.Panel1
-
-
- 0
-
Fill
@@ -796,7 +976,7 @@
0, 0
- 627, 421
+ 627, 415
3
@@ -805,7 +985,7 @@
pbThumbnail
- ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=15.0.2.0, Culture=neutral, PublicKeyToken=null
scHistoryItemInfo.Panel1
@@ -835,7 +1015,7 @@
0, 0
- 627, 233
+ 627, 239
0
@@ -868,7 +1048,7 @@
627, 661
- 421
+ 415
7
@@ -880,7 +1060,7 @@
scHistoryItemInfo
- ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=15.0.2.0, Culture=neutral, PublicKeyToken=null
scMain.Panel2
@@ -919,7 +1099,7 @@
scMain
- ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=15.0.2.0, Culture=neutral, PublicKeyToken=null
$this
diff --git a/ShareX.HistoryLib/Forms/ImageHistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/ImageHistoryForm.Designer.cs
index cf89763b5..d6d4cd854 100644
--- a/ShareX.HistoryLib/Forms/ImageHistoryForm.Designer.cs
+++ b/ShareX.HistoryLib/Forms/ImageHistoryForm.Designer.cs
@@ -122,6 +122,8 @@
//
// tstbSearch
//
+ this.tstbSearch.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
+ this.tstbSearch.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
this.tstbSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
resources.ApplyResources(this.tstbSearch, "tstbSearch");
this.tstbSearch.Name = "tstbSearch";
diff --git a/ShareX.HistoryLib/Forms/ImageHistoryForm.cs b/ShareX.HistoryLib/Forms/ImageHistoryForm.cs
index e93f7aea0..9fa4dd4a5 100644
--- a/ShareX.HistoryLib/Forms/ImageHistoryForm.cs
+++ b/ShareX.HistoryLib/Forms/ImageHistoryForm.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShareX.HistoryLib
@@ -44,6 +45,7 @@ namespace ShareX.HistoryLib
private HistoryItemManager him;
private string defaultTitle;
+ private List allHistoryItems;
public ImageHistoryForm(string historyPath, ImageHistorySettings settings, Action uploadFile = null, Action editImage = null, Action pinToScreen = null)
{
@@ -87,13 +89,18 @@ namespace ShareX.HistoryLib
Text = $"{defaultTitle} ({Resources.Total}: {total:N0} - {Resources.Filtered}: {filtered:N0})";
}
- private void RefreshHistoryItems(bool mockData = false)
+ private async Task RefreshHistoryItems(bool mockData = false)
{
- UpdateSearchText();
- ilvImages.Items.Clear();
- IEnumerable historyItems = GetHistoryItems(mockData);
- ImageListViewItem[] ilvItems = historyItems.Select(hi => new ImageListViewItem(hi.FilePath) { Tag = hi }).ToArray();
- ilvImages.Items.AddRange(ilvItems);
+ allHistoryItems = await GetHistoryItems(mockData);
+
+ tstbSearch.AutoCompleteCustomSource.Clear();
+
+ if (allHistoryItems.Count > 0)
+ {
+ tstbSearch.AutoCompleteCustomSource.AddRange(allHistoryItems.Select(x => x.TagsProcessName).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToArray());
+ }
+
+ ApplyFilter();
}
private void UpdateSearchText()
@@ -110,7 +117,7 @@ namespace ShareX.HistoryLib
}
}
- private IEnumerable GetHistoryItems(bool mockData = false)
+ private async Task> GetHistoryItems(bool mockData = false)
{
HistoryManager history;
@@ -123,7 +130,17 @@ namespace ShareX.HistoryLib
history = new HistoryManagerJSON(HistoryPath);
}
- List historyItems = history.GetHistoryItems();
+ List historyItems = await history.GetHistoryItemsAsync();
+ historyItems.Reverse();
+ return historyItems;
+ }
+
+ private void ApplyFilter()
+ {
+ UpdateSearchText();
+
+ ilvImages.Items.Clear();
+
List filteredHistoryItems = new List();
Regex regex = null;
@@ -134,9 +151,9 @@ namespace ShareX.HistoryLib
regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
}
- for (int i = historyItems.Count - 1; i >= 0; i--)
+ for (int i = 0; i < allHistoryItems.Count; i++)
{
- HistoryItem hi = historyItems[i];
+ HistoryItem hi = allHistoryItems[i];
if (!string.IsNullOrEmpty(hi.FilePath) && FileHelpers.IsImageFile(hi.FilePath) &&
(regex == null || regex.IsMatch(hi.FileName) || (SearchInTags && hi.Tags != null && hi.Tags.Any(tag => regex.IsMatch(tag.Value)))) &&
@@ -151,9 +168,10 @@ namespace ShareX.HistoryLib
}
}
- UpdateTitle(historyItems.Count, filteredHistoryItems.Count);
+ UpdateTitle(allHistoryItems.Count, filteredHistoryItems.Count);
- return filteredHistoryItems;
+ ImageListViewItem[] ilvItems = filteredHistoryItems.Select(hi => new ImageListViewItem(hi.FilePath) { Tag = hi }).ToArray();
+ ilvImages.Items.AddRange(ilvItems);
}
private HistoryItem[] him_GetHistoryItems()
@@ -163,12 +181,12 @@ namespace ShareX.HistoryLib
#region Form events
- private void ImageHistoryForm_Shown(object sender, EventArgs e)
+ private async void ImageHistoryForm_Shown(object sender, EventArgs e)
{
tstbSearch.Focus();
- Application.DoEvents();
this.ForceActivate();
- RefreshHistoryItems();
+
+ await RefreshHistoryItems();
}
private void ImageHistoryForm_FormClosing(object sender, FormClosingEventArgs e)
@@ -179,16 +197,16 @@ namespace ShareX.HistoryLib
}
}
- private void ImageHistoryForm_KeyDown(object sender, KeyEventArgs e)
+ private async void ImageHistoryForm_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.F5:
- RefreshHistoryItems();
+ await RefreshHistoryItems();
e.SuppressKeyPress = true;
break;
case Keys.Control | Keys.F5 when HelpersOptions.DevMode:
- RefreshHistoryItems(true);
+ await RefreshHistoryItems(true);
e.SuppressKeyPress = true;
break;
}
@@ -228,14 +246,15 @@ namespace ShareX.HistoryLib
{
if (e.KeyCode == Keys.Enter)
{
- RefreshHistoryItems();
+ ApplyFilter();
+
e.SuppressKeyPress = true;
}
}
private void tsbSearch_Click(object sender, EventArgs e)
{
- RefreshHistoryItems();
+ ApplyFilter();
}
private void tsbSettings_Click(object sender, EventArgs e)
@@ -246,7 +265,8 @@ namespace ShareX.HistoryLib
}
ilvImages.ThumbnailSize = Settings.ThumbnailSize;
- RefreshHistoryItems();
+
+ ApplyFilter();
}
private void ilvImages_KeyDown(object sender, KeyEventArgs e)