private IEnumerable <HistoryItem> GetHistoryItems(bool mockData = false) { HistoryManager history; if (mockData) { history = new HistoryManagerMock(HistoryPath); } else { history = new HistoryManagerJSON(HistoryPath); } List <HistoryItem> historyItems = history.GetHistoryItems(); List <HistoryItem> filteredHistoryItems = new List <HistoryItem>(); Regex regex = null; if (!string.IsNullOrEmpty(SearchText)) { string pattern = Regex.Escape(SearchText).Replace("\\?", ".").Replace("\\*", ".*"); regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); } for (int i = historyItems.Count - 1; i >= 0; i--) { HistoryItem hi = historyItems[i]; if (!string.IsNullOrEmpty(hi.FilePath) && Helpers.IsImageFile(hi.FilePath) && (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); if (Settings.MaxItemCount > 0 && filteredHistoryItems.Count >= Settings.MaxItemCount) { break; } } } UpdateTitle(historyItems.Count, filteredHistoryItems.Count); return(filteredHistoryItems); }
private HistoryItem[] GetHistoryItems(bool mockData = false) { HistoryManager history; if (mockData) { history = new HistoryManagerMock(HistoryPath); } else { history = new HistoryManagerJSON(HistoryPath); } List <HistoryItem> historyItems = history.GetHistoryItems(); historyItems.Reverse(); return(historyItems.ToArray()); }