Allow stop/kill before recording start

This commit is contained in:
Jaex 2015-09-15 10:00:38 +03:00
parent c34a5b5619
commit 5e00cff459
5 changed files with 10 additions and 7 deletions

View file

@ -35,7 +35,7 @@ public abstract class ExternalCLIManager : IDisposable
public event DataReceivedEventHandler OutputDataReceived;
public event DataReceivedEventHandler ErrorDataReceived;
private Process process;
protected Process process;
public virtual int Open(string path, string args = null)
{

View file

@ -180,9 +180,9 @@ public DirectShowDevices GetDirectShowDevices()
public override void Close()
{
if (closeTryCount >= 3)
if (closeTryCount >= 2)
{
base.Close();
process.Kill();
}
else
{

View file

@ -241,6 +241,6 @@ public enum ImagePreviewVisibility
public enum ScreenRecordState
{
Waiting, BeforeStart, AfterStart, AfterStop
Waiting, BeforeStart, AfterStart, AfterRecordingStart, AfterStop
}
}

View file

@ -158,14 +158,12 @@ public void StartRecordingTimer()
lblTimer.ForeColor = Color.White;
borderColor = Color.FromArgb(0, 255, 0);
btnStart.Text = Resources.AutoCaptureForm_Execute_Stop;
Refresh();
Timer.Reset();
Timer.Start();
timerRefresh.Start();
UpdateTimer();
IsRecording = true;
}
private void UpdateTimer()
@ -263,6 +261,10 @@ public void ChangeState(ScreenRecordState state)
niTray.Text = trayTextAfterStart.Truncate(63);
niTray.Icon = Resources.control_record.ToIcon();
tsmiStart.Text = Resources.AutoCaptureForm_Execute_Stop;
btnStart.Text = Resources.AutoCaptureForm_Execute_Stop;
IsRecording = true;
break;
case ScreenRecordState.AfterRecordingStart:
StartRecordingTimer();
break;
case ScreenRecordState.AfterStop:

View file

@ -216,7 +216,8 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
if (!abortRequested)
{
screenRecorder = new ScreenRecorder(outputType, options, captureRectangle);
screenRecorder.RecordingStarted += () => recordForm.ChangeState(ScreenRecordState.AfterStart);
screenRecorder.RecordingStarted += () => recordForm.ChangeState(ScreenRecordState.AfterRecordingStart);
recordForm.ChangeState(ScreenRecordState.AfterStart);
screenRecorder.StartRecording();
if (recordForm.AbortRequested)