mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 09:17:36 +13:00
Added mock data support to image history form
This commit is contained in:
parent
20578d7ec1
commit
bbb051b6d3
2 changed files with 24 additions and 9 deletions
|
@ -39,7 +39,6 @@ public partial class HistoryForm : Form
|
|||
public string HistoryPath { get; private set; }
|
||||
public HistorySettings Settings { get; private set; }
|
||||
|
||||
private HistoryManager history;
|
||||
private HistoryItemManager him;
|
||||
private HistoryItem[] allHistoryItems;
|
||||
private string defaultTitle;
|
||||
|
@ -120,6 +119,8 @@ private HistoryItem[] him_GetHistoryItems()
|
|||
|
||||
private HistoryItem[] GetHistoryItems(bool mockData = false)
|
||||
{
|
||||
HistoryManager history;
|
||||
|
||||
if (mockData)
|
||||
{
|
||||
history = new HistoryManagerMock(HistoryPath);
|
||||
|
|
|
@ -43,7 +43,6 @@ public partial class ImageHistoryForm : Form
|
|||
public string SearchText { get; set; }
|
||||
public bool SearchInTags { get; set; } = true;
|
||||
|
||||
private HistoryManager history;
|
||||
private HistoryItemManager him;
|
||||
private string defaultTitle;
|
||||
|
||||
|
@ -94,11 +93,12 @@ private void UpdateTitle(int total, int filtered)
|
|||
Text = $"{defaultTitle} (Total: {total:N0} - Filtered: {filtered:N0})";
|
||||
}
|
||||
|
||||
private void RefreshHistoryItems()
|
||||
private void RefreshHistoryItems(bool mockData = false)
|
||||
{
|
||||
UpdateSearchText();
|
||||
ilvImages.Items.Clear();
|
||||
ImageListViewItem[] ilvItems = GetHistoryItems().Select(hi => new ImageListViewItem(hi.FilePath) { Tag = hi }).ToArray();
|
||||
IEnumerable<HistoryItem> historyItems = GetHistoryItems(mockData);
|
||||
ImageListViewItem[] ilvItems = historyItems.Select(hi => new ImageListViewItem(hi.FilePath) { Tag = hi }).ToArray();
|
||||
ilvImages.Items.AddRange(ilvItems);
|
||||
}
|
||||
|
||||
|
@ -116,9 +116,15 @@ private void UpdateSearchText()
|
|||
}
|
||||
}
|
||||
|
||||
private IEnumerable<HistoryItem> GetHistoryItems()
|
||||
private IEnumerable<HistoryItem> GetHistoryItems(bool mockData = false)
|
||||
{
|
||||
if (history == null)
|
||||
HistoryManager history;
|
||||
|
||||
if (mockData)
|
||||
{
|
||||
history = new HistoryManagerMock(HistoryPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
history = new HistoryManagerJSON(HistoryPath);
|
||||
}
|
||||
|
@ -181,10 +187,18 @@ private void ImageHistoryForm_FormClosing(object sender, FormClosingEventArgs e)
|
|||
|
||||
private void ImageHistoryForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.F5)
|
||||
switch (e.KeyData)
|
||||
{
|
||||
case Keys.F5:
|
||||
RefreshHistoryItems();
|
||||
e.Handled = true;
|
||||
break;
|
||||
#if DEBUG
|
||||
case Keys.Control | Keys.F5:
|
||||
RefreshHistoryItems(true);
|
||||
e.Handled = true;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue