mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 09:17:36 +13:00
Allow dragging form while waiting for recording to start
This commit is contained in:
parent
aa434258c5
commit
ee9639d960
4 changed files with 112 additions and 82 deletions
|
@ -42,6 +42,8 @@ private void InitializeComponent()
|
|||
resources.ApplyResources(this.lblTimer, "lblTimer");
|
||||
this.lblTimer.Name = "lblTimer";
|
||||
this.lblTimer.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblTimer_MouseDown);
|
||||
this.lblTimer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lblTimer_MouseMove);
|
||||
this.lblTimer.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lblTimer_MouseUp);
|
||||
//
|
||||
// timerRefresh
|
||||
//
|
||||
|
|
|
@ -71,6 +71,8 @@ public Rectangle RecordRectangle
|
|||
private Color borderColor = Color.Red;
|
||||
private Rectangle borderRectangle;
|
||||
private Rectangle borderRectangle0Based;
|
||||
private bool dragging;
|
||||
private Point initialLocation;
|
||||
private static int lastIconStatus = -1;
|
||||
private const int panelOffset = 3;
|
||||
|
||||
|
@ -272,10 +274,27 @@ private void btnAbort_MouseClick(object sender, MouseEventArgs e)
|
|||
|
||||
private void lblTimer_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left && Status == ScreenRecordingStatus.Paused)
|
||||
if (e.Button == MouseButtons.Left && (Status == ScreenRecordingStatus.Waiting || Status == ScreenRecordingStatus.Paused))
|
||||
{
|
||||
NativeMethods.ReleaseCapture();
|
||||
NativeMethods.SendMessage(Handle, (uint)WindowsMessages.NCLBUTTONDOWN, (IntPtr)WindowHitTestRegions.HTCAPTION, IntPtr.Zero);
|
||||
dragging = true;
|
||||
initialLocation = e.Location;
|
||||
}
|
||||
}
|
||||
|
||||
private void lblTimer_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
Location = new Point(Location.X + e.X - initialLocation.X, Location.Y + e.Y - initialLocation.Y);
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
private void lblTimer_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
dragging = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,6 +342,24 @@ public void AbortRecording()
|
|||
StartStopRecording();
|
||||
}
|
||||
|
||||
private void UpdateUI()
|
||||
{
|
||||
if (Status == ScreenRecordingStatus.Waiting || Status == ScreenRecordingStatus.Paused)
|
||||
{
|
||||
// TODO: Translate
|
||||
btnPause.Text = "Resume";
|
||||
lblTimer.Cursor = Cursors.SizeAll;
|
||||
borderColor = Color.FromArgb(241, 196, 27);
|
||||
Refresh();
|
||||
}
|
||||
else if (Status == ScreenRecordingStatus.Working || Status == ScreenRecordingStatus.Recording)
|
||||
{
|
||||
// TODO: Translate
|
||||
btnPause.Text = "Pause";
|
||||
lblTimer.Cursor = Cursors.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeState(ScreenRecordState state)
|
||||
{
|
||||
this.InvokeSafe(() =>
|
||||
|
@ -341,17 +378,17 @@ public void ChangeState(ScreenRecordState state)
|
|||
niTray.Text = trayTextBeforeStart.Truncate(63);
|
||||
tsmiStart.Text = Resources.ScreenRecordForm_Start;
|
||||
cmsMain.Enabled = true;
|
||||
UpdateUI();
|
||||
break;
|
||||
case ScreenRecordState.AfterStart:
|
||||
dragging = false;
|
||||
Status = ScreenRecordingStatus.Working;
|
||||
string trayTextAfterStart = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Click_tray_icon_to_stop_recording_;
|
||||
niTray.Text = trayTextAfterStart.Truncate(63);
|
||||
niTray.Icon = Resources.control_record.ToIcon();
|
||||
tsmiStart.Text = Resources.ScreenRecordForm_Stop;
|
||||
btnStart.Text = Resources.ScreenRecordForm_Stop;
|
||||
// TODO: Translate
|
||||
btnPause.Text = "Pause";
|
||||
lblTimer.Cursor = Cursors.Default;
|
||||
UpdateUI();
|
||||
break;
|
||||
case ScreenRecordState.AfterRecordingStart:
|
||||
Status = ScreenRecordingStatus.Recording;
|
||||
|
@ -359,14 +396,7 @@ public void ChangeState(ScreenRecordState state)
|
|||
break;
|
||||
case ScreenRecordState.RecordingEnd:
|
||||
StopRecordingTimer();
|
||||
if (Status == ScreenRecordingStatus.Paused)
|
||||
{
|
||||
// TODO: Translate
|
||||
btnPause.Text = "Resume";
|
||||
lblTimer.Cursor = Cursors.SizeAll;
|
||||
borderColor = Color.FromArgb(241, 196, 27);
|
||||
Refresh();
|
||||
}
|
||||
UpdateUI();
|
||||
break;
|
||||
case ScreenRecordState.Encoding:
|
||||
Hide();
|
||||
|
|
|
@ -288,6 +288,15 @@
|
|||
<metadata name="cmsMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>138, 17</value>
|
||||
</metadata>
|
||||
<data name="cmsMain.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 48</value>
|
||||
</data>
|
||||
<data name=">>cmsMain.Name" xml:space="preserve">
|
||||
<value>cmsMain</value>
|
||||
</data>
|
||||
<data name=">>cmsMain.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="tsmiStart.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>104, 22</value>
|
||||
</data>
|
||||
|
@ -300,15 +309,6 @@
|
|||
<data name="tsmiAbort.Text" xml:space="preserve">
|
||||
<value>Abort</value>
|
||||
</data>
|
||||
<data name="cmsMain.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 48</value>
|
||||
</data>
|
||||
<data name=">>cmsMain.Name" xml:space="preserve">
|
||||
<value>cmsMain</value>
|
||||
</data>
|
||||
<data name=">>cmsMain.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<metadata name="niTray.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>238, 17</value>
|
||||
</metadata>
|
||||
|
|
|
@ -221,9 +221,7 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
|
|||
FileHelpers.DeleteFile(tempPath);
|
||||
}
|
||||
|
||||
while (recordForm.Status == ScreenRecordingStatus.Waiting || recordForm.Status == ScreenRecordingStatus.Paused)
|
||||
{
|
||||
if (!abortRequested)
|
||||
while (!abortRequested && (recordForm.Status == ScreenRecordingStatus.Waiting || recordForm.Status == ScreenRecordingStatus.Paused))
|
||||
{
|
||||
recordForm.ChangeState(ScreenRecordState.BeforeStart);
|
||||
|
||||
|
@ -255,6 +253,8 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
|
|||
FileHelpers.RenameFile(path, concatPath);
|
||||
}
|
||||
|
||||
recordForm.ChangeState(ScreenRecordState.AfterStart);
|
||||
|
||||
captureRectangle = recordForm.RecordRectangle;
|
||||
|
||||
ScreenRecordingOptions options = new ScreenRecordingOptions()
|
||||
|
@ -276,7 +276,6 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
|
|||
screenRecorder = new ScreenRecorder(ScreenRecordOutput.FFmpeg, options, screenshot, captureRectangle);
|
||||
screenRecorder.RecordingStarted += ScreenRecorder_RecordingStarted;
|
||||
screenRecorder.EncodingProgressChanged += ScreenRecorder_EncodingProgressChanged;
|
||||
recordForm.ChangeState(ScreenRecordState.AfterStart);
|
||||
screenRecorder.StartRecording();
|
||||
recordForm.ChangeState(ScreenRecordState.RecordingEnd);
|
||||
|
||||
|
@ -297,7 +296,6 @@ private static void StartRecording(ScreenRecordOutput outputType, TaskSettings t
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugHelper.WriteException(e);
|
||||
|
|
Loading…
Reference in a new issue