Fix history selection issue

This commit is contained in:
Jaex 2019-10-26 19:36:24 +03:00
parent 82ad2deb94
commit f576029f70
3 changed files with 28 additions and 28 deletions

View file

@ -312,14 +312,17 @@ private void UpdateTitle(HistoryItem[] historyItems = null)
private void UpdateControls()
{
if (him.RefreshInfo())
{
UpdatePictureBox();
}
else
HistoryItem previousHistoryItem = him.HistoryItem;
HistoryItem historyItem = him.UpdateSelectedHistoryItem();
if (historyItem == null)
{
pbThumbnail.Reset();
}
else if (historyItem != previousHistoryItem)
{
UpdatePictureBox();
}
}
private void UpdatePictureBox()

View file

@ -175,7 +175,7 @@ private void ImageHistoryForm_KeyDown(object sender, KeyEventArgs e)
private void ilvImages_SelectionChanged(object sender, EventArgs e)
{
him.RefreshInfo();
him.UpdateSelectedHistoryItem();
}
private void ilvImages_ItemDoubleClick(object sender, ItemClickEventArgs e)

View file

@ -59,34 +59,31 @@ public HistoryItemManager(Action<string> uploadFile, Action<string> editImage)
InitializeComponent();
}
public bool RefreshInfo()
public HistoryItem UpdateSelectedHistoryItem()
{
HistoryItem tempHistoryItem = GetSelectedHistoryItem();
HistoryItem = GetSelectedHistoryItem();
if (tempHistoryItem != null)
if (HistoryItem != null)
{
if (HistoryItem != tempHistoryItem)
{
HistoryItem = tempHistoryItem;
IsURLExist = !string.IsNullOrEmpty(HistoryItem.URL);
IsShortenedURLExist = !string.IsNullOrEmpty(HistoryItem.ShortenedURL);
IsThumbnailURLExist = !string.IsNullOrEmpty(HistoryItem.ThumbnailURL);
IsDeletionURLExist = !string.IsNullOrEmpty(HistoryItem.DeletionURL);
IsImageURL = IsURLExist && Helpers.IsImageFile(HistoryItem.URL);
IsTextURL = IsURLExist && Helpers.IsTextFile(HistoryItem.URL);
IsFilePathValid = !string.IsNullOrEmpty(HistoryItem.FilePath) && Path.HasExtension(HistoryItem.FilePath);
IsFileExist = IsFilePathValid && File.Exists(HistoryItem.FilePath);
IsImageFile = IsFileExist && Helpers.IsImageFile(HistoryItem.FilePath);
IsTextFile = IsFileExist && Helpers.IsTextFile(HistoryItem.FilePath);
IsURLExist = !string.IsNullOrEmpty(HistoryItem.URL);
IsShortenedURLExist = !string.IsNullOrEmpty(HistoryItem.ShortenedURL);
IsThumbnailURLExist = !string.IsNullOrEmpty(HistoryItem.ThumbnailURL);
IsDeletionURLExist = !string.IsNullOrEmpty(HistoryItem.DeletionURL);
IsImageURL = IsURLExist && Helpers.IsImageFile(HistoryItem.URL);
IsTextURL = IsURLExist && Helpers.IsTextFile(HistoryItem.URL);
IsFilePathValid = !string.IsNullOrEmpty(HistoryItem.FilePath) && Path.HasExtension(HistoryItem.FilePath);
IsFileExist = IsFilePathValid && File.Exists(HistoryItem.FilePath);
IsImageFile = IsFileExist && Helpers.IsImageFile(HistoryItem.FilePath);
IsTextFile = IsFileExist && Helpers.IsTextFile(HistoryItem.FilePath);
UpdateButtons();
return true;
}
UpdateButtons();
}
else
{
cmsHistory.Enabled = false;
}
cmsHistory.Enabled = false;
return false;
return HistoryItem;
}
private HistoryItem GetSelectedHistoryItem()