From 8874c18fe7f3b8f092819785e850e6321b298468 Mon Sep 17 00:00:00 2001 From: Jaex Date: Wed, 26 May 2021 02:04:00 +0300 Subject: [PATCH] In image history window support searching tags --- ShareX.HistoryLib/Forms/ImageHistoryForm.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ShareX.HistoryLib/Forms/ImageHistoryForm.cs b/ShareX.HistoryLib/Forms/ImageHistoryForm.cs index 7a73be586..72144bb83 100644 --- a/ShareX.HistoryLib/Forms/ImageHistoryForm.cs +++ b/ShareX.HistoryLib/Forms/ImageHistoryForm.cs @@ -40,6 +40,7 @@ public partial class ImageHistoryForm : Form public string HistoryPath { get; private set; } public ImageHistorySettings Settings { get; private set; } public string SearchText { get; set; } + public bool SearchInTags { get; set; } = true; private HistoryManager history; private HistoryItemManager him; @@ -124,7 +125,7 @@ private IEnumerable GetHistoryItems() if (!string.IsNullOrEmpty(SearchText)) { string pattern = Regex.Escape(SearchText).Replace("\\?", ".").Replace("\\*", ".*"); - regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); } for (int i = historyItems.Count - 1; i >= 0; i--) @@ -132,7 +133,7 @@ private IEnumerable GetHistoryItems() HistoryItem hi = historyItems[i]; if (!string.IsNullOrEmpty(hi.FilePath) && Helpers.IsImageFile(hi.FilePath) && - (regex == null || regex.IsMatch(hi.FileName)) && + (regex == null || regex.IsMatch(hi.FileName) || (SearchInTags && hi.Tags != null && hi.Tags.Any(tag => regex.IsMatch(tag.Value)))) && (!Settings.FilterMissingFiles || File.Exists(hi.FilePath))) { filteredHistoryItems.Add(hi);