Clicking on task panel title will open URL or file path

This commit is contained in:
Jaex 2019-07-24 14:47:13 +03:00
parent 092b93efc8
commit 86e20a74e4
3 changed files with 38 additions and 6 deletions

View file

@ -94,6 +94,7 @@ private void InitializeComponent()
this.lblTitle.TabIndex = 1;
this.lblTitle.Text = "Test.png";
this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblTitle.MouseClick += new System.Windows.Forms.MouseEventHandler(this.LblTitle_MouseClick);
//
// TaskThumbnailPanel
//

View file

@ -303,6 +303,20 @@ public void UpdateStatus()
{
pThumbnail.UpdateStatusColor(Task.Status);
}
UpdateTitleCursor();
}
private void UpdateTitleCursor()
{
if (Task.Info != null && !string.IsNullOrEmpty(Task.Info.ToString()))
{
lblTitle.Cursor = Cursors.Hand;
}
else
{
lblTitle.Cursor = Cursors.Default;
}
}
public void ClearThumbnail()
@ -321,6 +335,28 @@ public void ClearThumbnail()
ThumbnailExists = false;
}
private void LblTitle_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && Task.Info != null)
{
if (Task.Info.Result != null)
{
string url = Task.Info.Result.ToString();
if (!string.IsNullOrEmpty(url))
{
URLHelpers.OpenURL(url);
return;
}
}
if (!string.IsNullOrEmpty(Task.Info.FilePath))
{
Helpers.OpenFile(Task.Info.FilePath);
}
}
}
private void PbThumbnail_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)

View file

@ -333,12 +333,7 @@ private static void Task_TaskCompleted(WorkerTask task)
{
DebugHelper.WriteLine($"Task completed. Filename: {info.FileName}, Duration: {(long)info.TaskDuration.TotalMilliseconds} ms");
string result = info.Result.ToString();
if (string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(info.FilePath))
{
result = info.FilePath;
}
string result = info.ToString();
if (lvi != null)
{