Fix countdown

This commit is contained in:
Jaex 2022-09-03 18:23:44 +03:00
parent 12c49166c3
commit 0b2a4a7411
2 changed files with 6 additions and 4 deletions

View file

@ -344,6 +344,6 @@ public enum ScreenRecordState
public enum ScreenRecordingStatus public enum ScreenRecordingStatus
{ {
Waiting, Countdown, Working, Recording, Paused, Stopped, Aborted Waiting, Working, Recording, Paused, Stopped, Aborted
} }
} }

View file

@ -52,6 +52,7 @@ private set
} }
public TimeSpan Countdown { get; set; } public TimeSpan Countdown { get; set; }
public bool IsCountdown { get; private set; }
public Stopwatch Timer { get; private set; } public Stopwatch Timer { get; private set; }
public ManualResetEvent RecordResetEvent { get; set; } public ManualResetEvent RecordResetEvent { get; set; }
@ -158,7 +159,7 @@ protected void OnStopRequested()
public void StartCountdown(int milliseconds) public void StartCountdown(int milliseconds)
{ {
Status = ScreenRecordingStatus.Countdown; IsCountdown = true;
Countdown = TimeSpan.FromMilliseconds(milliseconds); Countdown = TimeSpan.FromMilliseconds(milliseconds);
Timer.Start(); Timer.Start();
@ -170,8 +171,9 @@ public void StartRecordingTimer()
{ {
if (Duration > 0) if (Duration > 0)
{ {
Status = ScreenRecordingStatus.Countdown; IsCountdown = true;
} }
Countdown = TimeSpan.FromSeconds(Duration); Countdown = TimeSpan.FromSeconds(Duration);
borderColor = Color.FromArgb(0, 255, 0); borderColor = Color.FromArgb(0, 255, 0);
@ -196,7 +198,7 @@ private void UpdateTimer()
{ {
TimeSpan timer; TimeSpan timer;
if (Status == ScreenRecordingStatus.Countdown) if (IsCountdown)
{ {
timer = Countdown - Timer.Elapsed; timer = Countdown - Timer.Elapsed;
if (timer.Ticks < 0) timer = TimeSpan.Zero; if (timer.Ticks < 0) timer = TimeSpan.Zero;