mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 22:21:23 +12:00
Allow stop/kill before recording start
This commit is contained in:
parent
c34a5b5619
commit
5e00cff459
|
@ -35,7 +35,7 @@ public abstract class ExternalCLIManager : IDisposable
|
||||||
public event DataReceivedEventHandler OutputDataReceived;
|
public event DataReceivedEventHandler OutputDataReceived;
|
||||||
public event DataReceivedEventHandler ErrorDataReceived;
|
public event DataReceivedEventHandler ErrorDataReceived;
|
||||||
|
|
||||||
private Process process;
|
protected Process process;
|
||||||
|
|
||||||
public virtual int Open(string path, string args = null)
|
public virtual int Open(string path, string args = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -180,9 +180,9 @@ public DirectShowDevices GetDirectShowDevices()
|
||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
{
|
{
|
||||||
if (closeTryCount >= 3)
|
if (closeTryCount >= 2)
|
||||||
{
|
{
|
||||||
base.Close();
|
process.Kill();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -241,6 +241,6 @@ public enum ImagePreviewVisibility
|
||||||
|
|
||||||
public enum ScreenRecordState
|
public enum ScreenRecordState
|
||||||
{
|
{
|
||||||
Waiting, BeforeStart, AfterStart, AfterStop
|
Waiting, BeforeStart, AfterStart, AfterRecordingStart, AfterStop
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -158,14 +158,12 @@ public void StartRecordingTimer()
|
||||||
|
|
||||||
lblTimer.ForeColor = Color.White;
|
lblTimer.ForeColor = Color.White;
|
||||||
borderColor = Color.FromArgb(0, 255, 0);
|
borderColor = Color.FromArgb(0, 255, 0);
|
||||||
btnStart.Text = Resources.AutoCaptureForm_Execute_Stop;
|
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
Timer.Reset();
|
Timer.Reset();
|
||||||
Timer.Start();
|
Timer.Start();
|
||||||
timerRefresh.Start();
|
timerRefresh.Start();
|
||||||
UpdateTimer();
|
UpdateTimer();
|
||||||
IsRecording = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTimer()
|
private void UpdateTimer()
|
||||||
|
@ -263,6 +261,10 @@ public void ChangeState(ScreenRecordState state)
|
||||||
niTray.Text = trayTextAfterStart.Truncate(63);
|
niTray.Text = trayTextAfterStart.Truncate(63);
|
||||||
niTray.Icon = Resources.control_record.ToIcon();
|
niTray.Icon = Resources.control_record.ToIcon();
|
||||||
tsmiStart.Text = Resources.AutoCaptureForm_Execute_Stop;
|
tsmiStart.Text = Resources.AutoCaptureForm_Execute_Stop;
|
||||||
|
btnStart.Text = Resources.AutoCaptureForm_Execute_Stop;
|
||||||
|
IsRecording = true;
|
||||||
|
break;
|
||||||
|
case ScreenRecordState.AfterRecordingStart:
|
||||||
StartRecordingTimer();
|
StartRecordingTimer();
|
||||||
break;
|
break;
|
||||||
case ScreenRecordState.AfterStop:
|
case ScreenRecordState.AfterStop:
|
||||||
|
|
|
@ -216,7 +216,8 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
|
||||||
if (!abortRequested)
|
if (!abortRequested)
|
||||||
{
|
{
|
||||||
screenRecorder = new ScreenRecorder(outputType, options, captureRectangle);
|
screenRecorder = new ScreenRecorder(outputType, options, captureRectangle);
|
||||||
screenRecorder.RecordingStarted += () => recordForm.ChangeState(ScreenRecordState.AfterStart);
|
screenRecorder.RecordingStarted += () => recordForm.ChangeState(ScreenRecordState.AfterRecordingStart);
|
||||||
|
recordForm.ChangeState(ScreenRecordState.AfterStart);
|
||||||
screenRecorder.StartRecording();
|
screenRecorder.StartRecording();
|
||||||
|
|
||||||
if (recordForm.AbortRequested)
|
if (recordForm.AbortRequested)
|
||||||
|
|
Loading…
Reference in a new issue