mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 22:21:23 +12:00
Show screen record encoding progress in tray icon
This commit is contained in:
parent
e9e2385aaa
commit
08a59c29be
|
@ -52,6 +52,7 @@ public partial class ScreenRecordForm : Form
|
|||
private Rectangle borderRectangle0Based;
|
||||
private bool activateWindow;
|
||||
private float duration;
|
||||
private static int lastIconStatus = -1;
|
||||
|
||||
public ScreenRecordForm(Rectangle regionRectangle, TaskSettings taskSettings, bool activateWindow = true, float duration = 0)
|
||||
{
|
||||
|
@ -306,6 +307,38 @@ public void ChangeState(ScreenRecordState state)
|
|||
public void ChangeStateProgress(int progress)
|
||||
{
|
||||
niTray.Text = $"ShareX - {Resources.ScreenRecordForm_StartRecording_Encoding___} {progress}%";
|
||||
|
||||
if (niTray.Visible && lastIconStatus != progress)
|
||||
{
|
||||
Icon icon;
|
||||
|
||||
if (progress >= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
icon = TaskHelpers.GetProgressIcon(progress);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
progress = -1;
|
||||
if (lastIconStatus == progress) return;
|
||||
icon = Resources.camcorder_pencil.ToIcon();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = Resources.camcorder_pencil.ToIcon();
|
||||
}
|
||||
|
||||
using (Icon oldIcon = niTray.Icon)
|
||||
{
|
||||
niTray.Icon = icon;
|
||||
oldIcon.DisposeHandle();
|
||||
}
|
||||
|
||||
lastIconStatus = progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue