mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
fixed #251: Added auto start recording setting, if it is not enabled then recording won't start automatically until start button is pressed. Also even when auto start is enabled still you can press start button to start early without waiting delay to end
This commit is contained in:
parent
3c31f3f606
commit
4471939cf8
5 changed files with 41 additions and 8 deletions
|
@ -139,7 +139,9 @@ public void StartRecording(TaskSettings taskSettings)
|
|||
string path = "";
|
||||
|
||||
float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0;
|
||||
|
||||
regionForm = ScreenRegionForm.Show(captureRectangle, StopRecording, duration);
|
||||
regionForm.RecordResetEvent = new ManualResetEvent(false);
|
||||
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
|
@ -178,11 +180,21 @@ public void StartRecording(TaskSettings taskSettings)
|
|||
|
||||
screenRecorder = new ScreenRecorder(options, captureRectangle, taskSettings.CaptureSettings.ScreenRecordOutput);
|
||||
|
||||
int delay = (int)(taskSettings.CaptureSettings.ScreenRecordStartDelay * 1000);
|
||||
|
||||
if (delay > 0)
|
||||
if (regionForm != null && regionForm.RecordResetEvent != null)
|
||||
{
|
||||
Thread.Sleep(delay);
|
||||
if (taskSettings.CaptureSettings.ScreenRecordAutoStart)
|
||||
{
|
||||
int delay = (int)(taskSettings.CaptureSettings.ScreenRecordStartDelay * 1000);
|
||||
|
||||
if (delay > 0)
|
||||
{
|
||||
regionForm.RecordResetEvent.WaitOne(delay);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
regionForm.RecordResetEvent.WaitOne();
|
||||
}
|
||||
}
|
||||
|
||||
TrayIcon.Text = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Click_tray_icon_to_stop_recording_;
|
||||
|
@ -205,6 +217,11 @@ public void StartRecording(TaskSettings taskSettings)
|
|||
|
||||
if (regionForm != null)
|
||||
{
|
||||
if (regionForm.RecordResetEvent != null)
|
||||
{
|
||||
regionForm.RecordResetEvent.Dispose();
|
||||
}
|
||||
|
||||
this.InvokeSafe(() => regionForm.Close());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,11 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using HelpersLib;
|
||||
using ShareX.Properties;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX
|
||||
|
@ -35,9 +37,11 @@ public partial class ScreenRegionForm : Form
|
|||
{
|
||||
public event Action StopRequested;
|
||||
|
||||
public bool IsRecording { get; set; }
|
||||
public bool IsCountdown { get; set; }
|
||||
public TimeSpan Countdown { get; set; }
|
||||
public Stopwatch Timer { get; private set; }
|
||||
public ManualResetEvent RecordResetEvent { get; set; }
|
||||
|
||||
private Color borderColor = Color.Red;
|
||||
private Rectangle borderRectangle;
|
||||
|
@ -76,11 +80,13 @@ public static ScreenRegionForm Show(Rectangle captureRectangle, Action stopReque
|
|||
{
|
||||
ScreenRegionForm regionForm = new ScreenRegionForm(captureRectangle);
|
||||
regionForm.StopRequested += stopRequested;
|
||||
|
||||
if (duration > 0)
|
||||
{
|
||||
regionForm.IsCountdown = true;
|
||||
regionForm.Countdown = TimeSpan.FromSeconds(duration);
|
||||
}
|
||||
|
||||
regionForm.UpdateTimer();
|
||||
regionForm.Show();
|
||||
return regionForm;
|
||||
|
@ -92,10 +98,12 @@ public static ScreenRegionForm Show(Rectangle captureRectangle, Action stopReque
|
|||
public void StartTimer()
|
||||
{
|
||||
borderColor = Color.FromArgb(0, 255, 0);
|
||||
btnStop.Text = Resources.AutoCaptureForm_Execute_Stop;
|
||||
Refresh();
|
||||
|
||||
Timer.Start();
|
||||
timerRefresh.Start();
|
||||
IsRecording = true;
|
||||
}
|
||||
|
||||
private void UpdateTimer()
|
||||
|
@ -137,7 +145,14 @@ private void timerRefresh_Tick(object sender, EventArgs e)
|
|||
|
||||
private void btnStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnStopRequested();
|
||||
if (IsRecording)
|
||||
{
|
||||
OnStopRequested();
|
||||
}
|
||||
else if (RecordResetEvent != null)
|
||||
{
|
||||
RecordResetEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -136,7 +136,7 @@
|
|||
<value>2</value>
|
||||
</data>
|
||||
<data name="btnStop.Text" xml:space="preserve">
|
||||
<value>Stop</value>
|
||||
<value>Start</value>
|
||||
</data>
|
||||
<data name=">>btnStop.Name" xml:space="preserve">
|
||||
<value>btnStop</value>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
@ -118,7 +118,7 @@
|
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="btnStop.Text" xml:space="preserve">
|
||||
<value>Dur</value>
|
||||
<value>Başlat</value>
|
||||
</data>
|
||||
<data name="$this.Text" xml:space="preserve">
|
||||
<value>Ekran alanı penceresi</value>
|
||||
|
|
|
@ -328,6 +328,7 @@ public class TaskSettingsCapture
|
|||
public bool ScreenRecordFixedDuration = false;
|
||||
public float ScreenRecordDuration = 3f;
|
||||
public float ScreenRecordStartDelay = 0.5f;
|
||||
public bool ScreenRecordAutoStart = true;
|
||||
public bool ScreenRecordAutoDisableAero = false;
|
||||
|
||||
#endregion Capture / Screen recorder
|
||||
|
|
Loading…
Reference in a new issue