In image history window support searching tags

This commit is contained in:
Jaex 2021-05-26 02:04:00 +03:00
parent e1ee32f7cd
commit 8874c18fe7

View file

@ -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<HistoryItem> 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<HistoryItem> 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);