Clicking on thumbnail will open fullscreen preview

This commit is contained in:
Jaex 2019-05-12 23:55:30 +03:00
parent 0546e1b80d
commit 0d6ffbce79
2 changed files with 26 additions and 6 deletions

View file

@ -90,6 +90,7 @@ private void InitializeComponent()
this.pbThumbnail.Size = new System.Drawing.Size(246, 246);
this.pbThumbnail.TabIndex = 2;
this.pbThumbnail.TabStop = false;
this.pbThumbnail.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PbThumbnail_MouseDown);
//
// TaskPanel
//

View file

@ -169,16 +169,23 @@ public void UpdateThumbnail()
{
string filePath = Task.Info.FilePath;
using (Image img = ImageHelpers.LoadImage(filePath))
try
{
if (img != null)
using (Image img = ImageHelpers.LoadImage(filePath))
{
ThumbnailSourceFilePath = filePath;
ThumbnailImage = ImageHelpers.CreateThumbnail(img, ThumbnailSize.Width, ThumbnailSize.Height);
pbThumbnail.Image = ThumbnailImage;
if (img != null)
{
ThumbnailImage = ImageHelpers.CreateThumbnail(img, ThumbnailSize.Width, ThumbnailSize.Height);
pbThumbnail.Image = ThumbnailImage;
ThumbnailSourceFilePath = filePath;
pbThumbnail.Cursor = Cursors.Hand;
}
}
}
catch (Exception e)
{
DebugHelper.WriteException(e);
}
}
}
@ -191,11 +198,23 @@ public void ClearThumbnail()
ThumbnailImage.Dispose();
ThumbnailImage = null;
}
ThumbnailSourceFilePath = null;
}
public void UpdateProgress()
{
Progress = (int)Task.Info.Progress.Percentage;
}
private void PbThumbnail_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && !string.IsNullOrEmpty(ThumbnailSourceFilePath))
{
pbThumbnail.Enabled = false;
ImageViewer.ShowImage(ThumbnailSourceFilePath);
pbThumbnail.Enabled = true;
}
}
}
}