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.Size = new System.Drawing.Size(246, 246);
this.pbThumbnail.TabIndex = 2; this.pbThumbnail.TabIndex = 2;
this.pbThumbnail.TabStop = false; this.pbThumbnail.TabStop = false;
this.pbThumbnail.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PbThumbnail_MouseDown);
// //
// TaskPanel // TaskPanel
// //

View file

@ -169,17 +169,24 @@ public void UpdateThumbnail()
{ {
string filePath = Task.Info.FilePath; string filePath = Task.Info.FilePath;
try
{
using (Image img = ImageHelpers.LoadImage(filePath)) using (Image img = ImageHelpers.LoadImage(filePath))
{ {
if (img != null) if (img != null)
{ {
ThumbnailSourceFilePath = filePath;
ThumbnailImage = ImageHelpers.CreateThumbnail(img, ThumbnailSize.Width, ThumbnailSize.Height); ThumbnailImage = ImageHelpers.CreateThumbnail(img, ThumbnailSize.Width, ThumbnailSize.Height);
pbThumbnail.Image = ThumbnailImage; pbThumbnail.Image = ThumbnailImage;
ThumbnailSourceFilePath = filePath;
pbThumbnail.Cursor = Cursors.Hand;
} }
} }
} }
catch (Exception e)
{
DebugHelper.WriteException(e);
}
}
} }
public void ClearThumbnail() public void ClearThumbnail()
@ -191,11 +198,23 @@ public void ClearThumbnail()
ThumbnailImage.Dispose(); ThumbnailImage.Dispose();
ThumbnailImage = null; ThumbnailImage = null;
} }
ThumbnailSourceFilePath = null;
} }
public void UpdateProgress() public void UpdateProgress()
{ {
Progress = (int)Task.Info.Progress.Percentage; 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;
}
}
} }
} }