mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-03 13:40:34 +12:00
Added mock data support to image history form
This commit is contained in:
parent
20578d7ec1
commit
bbb051b6d3
|
@ -39,7 +39,6 @@ public partial class HistoryForm : Form
|
||||||
public string HistoryPath { get; private set; }
|
public string HistoryPath { get; private set; }
|
||||||
public HistorySettings Settings { get; private set; }
|
public HistorySettings Settings { get; private set; }
|
||||||
|
|
||||||
private HistoryManager history;
|
|
||||||
private HistoryItemManager him;
|
private HistoryItemManager him;
|
||||||
private HistoryItem[] allHistoryItems;
|
private HistoryItem[] allHistoryItems;
|
||||||
private string defaultTitle;
|
private string defaultTitle;
|
||||||
|
@ -120,6 +119,8 @@ private HistoryItem[] him_GetHistoryItems()
|
||||||
|
|
||||||
private HistoryItem[] GetHistoryItems(bool mockData = false)
|
private HistoryItem[] GetHistoryItems(bool mockData = false)
|
||||||
{
|
{
|
||||||
|
HistoryManager history;
|
||||||
|
|
||||||
if (mockData)
|
if (mockData)
|
||||||
{
|
{
|
||||||
history = new HistoryManagerMock(HistoryPath);
|
history = new HistoryManagerMock(HistoryPath);
|
||||||
|
|
|
@ -43,7 +43,6 @@ public partial class ImageHistoryForm : Form
|
||||||
public string SearchText { get; set; }
|
public string SearchText { get; set; }
|
||||||
public bool SearchInTags { get; set; } = true;
|
public bool SearchInTags { get; set; } = true;
|
||||||
|
|
||||||
private HistoryManager history;
|
|
||||||
private HistoryItemManager him;
|
private HistoryItemManager him;
|
||||||
private string defaultTitle;
|
private string defaultTitle;
|
||||||
|
|
||||||
|
@ -94,11 +93,12 @@ private void UpdateTitle(int total, int filtered)
|
||||||
Text = $"{defaultTitle} (Total: {total:N0} - Filtered: {filtered:N0})";
|
Text = $"{defaultTitle} (Total: {total:N0} - Filtered: {filtered:N0})";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshHistoryItems()
|
private void RefreshHistoryItems(bool mockData = false)
|
||||||
{
|
{
|
||||||
UpdateSearchText();
|
UpdateSearchText();
|
||||||
ilvImages.Items.Clear();
|
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);
|
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);
|
history = new HistoryManagerJSON(HistoryPath);
|
||||||
}
|
}
|
||||||
|
@ -181,10 +187,18 @@ private void ImageHistoryForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
|
||||||
private void ImageHistoryForm_KeyDown(object sender, KeyEventArgs e)
|
private void ImageHistoryForm_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyCode == Keys.F5)
|
switch (e.KeyData)
|
||||||
{
|
{
|
||||||
|
case Keys.F5:
|
||||||
RefreshHistoryItems();
|
RefreshHistoryItems();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
#if DEBUG
|
||||||
|
case Keys.Control | Keys.F5:
|
||||||
|
RefreshHistoryItems(true);
|
||||||
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue