2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2023-01-10 09:31:02 +13:00
|
|
|
|
Copyright (c) 2007-2023 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
2021-04-30 15:20:19 +12:00
|
|
|
|
using ShareX.ScreenCaptureLib.Properties;
|
2015-01-20 02:38:53 +13:00
|
|
|
|
using System;
|
2015-09-08 00:29:27 +12:00
|
|
|
|
using System.Diagnostics;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2021-04-30 15:20:19 +12:00
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-02-26 09:55:54 +13:00
|
|
|
|
public partial class ScreenRecordForm : Form
|
2015-09-08 00:29:27 +12:00
|
|
|
|
{
|
|
|
|
|
public event Action StopRequested;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2022-09-04 02:47:08 +12:00
|
|
|
|
private ScreenRecordingStatus status;
|
|
|
|
|
|
|
|
|
|
public ScreenRecordingStatus Status
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
status = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
public TimeSpan Countdown { get; set; }
|
2022-09-04 03:23:44 +12:00
|
|
|
|
public bool IsCountdown { get; private set; }
|
2015-09-08 00:29:27 +12:00
|
|
|
|
public Stopwatch Timer { get; private set; }
|
|
|
|
|
public ManualResetEvent RecordResetEvent { get; set; }
|
|
|
|
|
|
2021-04-30 15:20:19 +12:00
|
|
|
|
public bool ActivateWindow { get; set; } = true;
|
|
|
|
|
public float Duration { get; set; } = 0;
|
|
|
|
|
public bool AskConfirmationOnAbort { get; set; } = false;
|
|
|
|
|
|
2022-09-09 11:06:12 +12:00
|
|
|
|
public Rectangle RecordingRegion
|
2022-09-04 09:56:10 +12:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-09-09 11:06:12 +12:00
|
|
|
|
return GetRecordingRegion(Location);
|
2022-09-04 09:56:10 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-06 06:28:25 +12:00
|
|
|
|
protected override bool ShowWithoutActivation
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return !ActivateWindow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override CreateParams CreateParams
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
CreateParams createParams = base.CreateParams;
|
|
|
|
|
createParams.ExStyle |= (int)(WindowStyles.WS_EX_TOPMOST | WindowStyles.WS_EX_TOOLWINDOW);
|
|
|
|
|
return createParams;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
private Color borderColor = Color.Red;
|
|
|
|
|
private Rectangle borderRectangle;
|
|
|
|
|
private Rectangle borderRectangle0Based;
|
2022-09-04 12:26:41 +12:00
|
|
|
|
private bool dragging;
|
|
|
|
|
private Point initialLocation;
|
2020-10-01 12:39:49 +13:00
|
|
|
|
private static int lastIconStatus = -1;
|
2022-09-04 05:09:12 +12:00
|
|
|
|
private const int panelOffset = 3;
|
2015-09-08 00:29:27 +12:00
|
|
|
|
|
2021-04-30 15:20:19 +12:00
|
|
|
|
public ScreenRecordForm(Rectangle regionRectangle)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-09-08 00:29:27 +12:00
|
|
|
|
InitializeComponent();
|
2022-09-03 23:32:33 +12:00
|
|
|
|
ShareXResources.ApplyTheme(this);
|
2016-01-20 06:33:13 +13:00
|
|
|
|
niTray.Icon = ShareXResources.Icon;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
borderRectangle = regionRectangle.Offset(1);
|
|
|
|
|
borderRectangle0Based = new Rectangle(0, 0, borderRectangle.Width, borderRectangle.Height);
|
2015-08-14 09:51:58 +12:00
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
Location = borderRectangle.Location;
|
|
|
|
|
int windowWidth = Math.Max(borderRectangle.Width, pInfo.Width);
|
2022-09-04 05:09:12 +12:00
|
|
|
|
Size = new Size(windowWidth, borderRectangle.Height + panelOffset + pInfo.Height);
|
|
|
|
|
pInfo.Location = new Point(0, borderRectangle.Height + panelOffset);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
Region region = new Region(ClientRectangle);
|
|
|
|
|
region.Exclude(borderRectangle0Based.Offset(-1));
|
2022-09-04 05:09:12 +12:00
|
|
|
|
region.Exclude(new Rectangle(0, borderRectangle.Height, windowWidth, panelOffset));
|
2015-09-08 00:29:27 +12:00
|
|
|
|
if (borderRectangle.Width < pInfo.Width)
|
|
|
|
|
{
|
|
|
|
|
region.Exclude(new Rectangle(borderRectangle.Width, 0, pInfo.Width - borderRectangle.Width, borderRectangle.Height));
|
|
|
|
|
}
|
|
|
|
|
else if (borderRectangle.Width > pInfo.Width)
|
|
|
|
|
{
|
2022-09-04 05:09:12 +12:00
|
|
|
|
region.Exclude(new Rectangle(pInfo.Width, borderRectangle.Height + panelOffset, borderRectangle.Width - pInfo.Width, pInfo.Height));
|
2015-09-08 00:29:27 +12:00
|
|
|
|
}
|
|
|
|
|
Region = region;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
Timer = new Stopwatch();
|
2015-09-08 02:14:44 +12:00
|
|
|
|
UpdateTimer();
|
|
|
|
|
|
|
|
|
|
RecordResetEvent = new ManualResetEvent(false);
|
|
|
|
|
|
|
|
|
|
ChangeState(ScreenRecordState.Waiting);
|
2015-08-26 09:38:28 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 01:29:37 +12:00
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (disposing)
|
|
|
|
|
{
|
|
|
|
|
if (components != null)
|
|
|
|
|
{
|
|
|
|
|
components.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RecordResetEvent != null)
|
|
|
|
|
{
|
|
|
|
|
RecordResetEvent.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-09 11:06:12 +12:00
|
|
|
|
private Rectangle GetRecordingRegion(Point windowLocation)
|
|
|
|
|
{
|
|
|
|
|
return new Rectangle(windowLocation.X + 1, windowLocation.Y + 1, borderRectangle.Width - 2, borderRectangle.Height - 2);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-06 06:28:25 +12:00
|
|
|
|
public void StartStopRecording()
|
2015-08-26 09:38:28 +12:00
|
|
|
|
{
|
2022-09-06 06:28:25 +12:00
|
|
|
|
if (Status == ScreenRecordingStatus.Working)
|
2015-08-26 09:38:28 +12:00
|
|
|
|
{
|
2022-09-06 06:28:25 +12:00
|
|
|
|
AbortRecording();
|
|
|
|
|
}
|
|
|
|
|
else if (Status == ScreenRecordingStatus.Recording)
|
|
|
|
|
{
|
|
|
|
|
Status = ScreenRecordingStatus.Stopped;
|
|
|
|
|
OnStopRequested();
|
|
|
|
|
}
|
|
|
|
|
else if (Status == ScreenRecordingStatus.Paused)
|
|
|
|
|
{
|
|
|
|
|
Status = ScreenRecordingStatus.Stopped;
|
|
|
|
|
RecordResetEvent?.Set();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RecordResetEvent?.Set();
|
2015-08-26 09:38:28 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-06 06:28:25 +12:00
|
|
|
|
public void PauseResumeRecording()
|
2017-11-01 19:29:36 +13:00
|
|
|
|
{
|
2022-09-06 06:28:25 +12:00
|
|
|
|
if (Status == ScreenRecordingStatus.Recording)
|
2017-11-01 19:29:36 +13:00
|
|
|
|
{
|
2022-09-06 06:28:25 +12:00
|
|
|
|
Status = ScreenRecordingStatus.Paused;
|
|
|
|
|
RecordResetEvent?.Reset();
|
|
|
|
|
OnStopRequested();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RecordResetEvent?.Set();
|
2017-11-01 19:29:36 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-06 06:28:25 +12:00
|
|
|
|
public void AbortRecording()
|
|
|
|
|
{
|
|
|
|
|
Status = ScreenRecordingStatus.Aborted;
|
|
|
|
|
OnStopRequested();
|
|
|
|
|
RecordResetEvent?.Set();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
protected void OnStopRequested()
|
2014-11-14 08:59:34 +13:00
|
|
|
|
{
|
2021-06-10 10:14:01 +12:00
|
|
|
|
StopRequested?.Invoke();
|
2014-11-14 08:59:34 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
public void StartCountdown(int milliseconds)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2022-09-04 03:23:44 +12:00
|
|
|
|
IsCountdown = true;
|
2015-09-08 00:29:27 +12:00
|
|
|
|
Countdown = TimeSpan.FromMilliseconds(milliseconds);
|
2015-06-04 21:07:43 +12:00
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
Timer.Start();
|
|
|
|
|
timerRefresh.Start();
|
|
|
|
|
UpdateTimer();
|
|
|
|
|
}
|
2015-06-04 21:07:43 +12:00
|
|
|
|
|
2015-09-08 01:29:37 +12:00
|
|
|
|
public void StartRecordingTimer()
|
2015-09-08 00:29:27 +12:00
|
|
|
|
{
|
2022-09-04 04:30:36 +12:00
|
|
|
|
if (IsCountdown)
|
|
|
|
|
{
|
|
|
|
|
Timer.Reset();
|
|
|
|
|
IsCountdown = false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-04 02:47:08 +12:00
|
|
|
|
if (Duration > 0)
|
|
|
|
|
{
|
2022-09-04 03:23:44 +12:00
|
|
|
|
IsCountdown = true;
|
2022-09-04 04:30:36 +12:00
|
|
|
|
Countdown = TimeSpan.FromSeconds(Duration);
|
2022-09-04 02:47:08 +12:00
|
|
|
|
}
|
2022-09-04 03:23:44 +12:00
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
borderColor = Color.FromArgb(0, 255, 0);
|
|
|
|
|
Refresh();
|
|
|
|
|
|
|
|
|
|
Timer.Start();
|
|
|
|
|
timerRefresh.Start();
|
|
|
|
|
UpdateTimer();
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-04 01:52:42 +12:00
|
|
|
|
public void StopRecordingTimer()
|
|
|
|
|
{
|
|
|
|
|
Timer.Stop();
|
|
|
|
|
timerRefresh.Stop();
|
|
|
|
|
UpdateTimer();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
private void UpdateTimer()
|
|
|
|
|
{
|
|
|
|
|
if (!IsDisposed)
|
2014-04-20 03:39:17 +12:00
|
|
|
|
{
|
2015-09-08 00:29:27 +12:00
|
|
|
|
TimeSpan timer;
|
|
|
|
|
|
2022-09-04 03:23:44 +12:00
|
|
|
|
if (IsCountdown)
|
2014-04-20 03:39:17 +12:00
|
|
|
|
{
|
2015-09-08 00:29:27 +12:00
|
|
|
|
timer = Countdown - Timer.Elapsed;
|
|
|
|
|
if (timer.Ticks < 0) timer = TimeSpan.Zero;
|
2014-04-20 03:39:17 +12:00
|
|
|
|
}
|
2015-09-08 00:29:27 +12:00
|
|
|
|
else
|
2014-04-20 03:39:17 +12:00
|
|
|
|
{
|
2015-09-08 00:29:27 +12:00
|
|
|
|
timer = Timer.Elapsed;
|
2014-04-20 03:39:17 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
lblTimer.Text = timer.ToString("mm\\:ss\\:ff");
|
2015-06-04 21:07:43 +12:00
|
|
|
|
}
|
2015-09-08 00:29:27 +12:00
|
|
|
|
}
|
2015-06-04 21:07:43 +12:00
|
|
|
|
|
2022-09-04 12:26:41 +12:00
|
|
|
|
private void UpdateUI()
|
|
|
|
|
{
|
|
|
|
|
if (Status == ScreenRecordingStatus.Waiting || Status == ScreenRecordingStatus.Paused)
|
|
|
|
|
{
|
2022-10-03 05:52:50 +13:00
|
|
|
|
btnPause.Text = Resources.Resume;
|
2022-09-04 12:26:41 +12:00
|
|
|
|
lblTimer.Cursor = Cursors.SizeAll;
|
|
|
|
|
borderColor = Color.FromArgb(241, 196, 27);
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
2022-09-06 06:28:25 +12:00
|
|
|
|
else if (Status == ScreenRecordingStatus.Recording)
|
2022-09-04 12:26:41 +12:00
|
|
|
|
{
|
2022-10-03 05:52:50 +13:00
|
|
|
|
btnPause.Text = Resources.Pause;
|
2022-09-04 12:26:41 +12:00
|
|
|
|
lblTimer.Cursor = Cursors.Default;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
public void ChangeState(ScreenRecordState state)
|
|
|
|
|
{
|
2015-09-08 01:29:37 +12:00
|
|
|
|
this.InvokeSafe(() =>
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-09-08 01:29:37 +12:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ScreenRecordState.Waiting:
|
|
|
|
|
string trayTextWaiting = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Waiting___;
|
|
|
|
|
niTray.Text = trayTextWaiting.Truncate(63);
|
|
|
|
|
niTray.Icon = Resources.control_record_yellow.ToIcon();
|
|
|
|
|
cmsMain.Enabled = false;
|
|
|
|
|
niTray.Visible = true;
|
|
|
|
|
break;
|
|
|
|
|
case ScreenRecordState.BeforeStart:
|
|
|
|
|
string trayTextBeforeStart = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Click_tray_icon_to_start_recording_;
|
|
|
|
|
niTray.Text = trayTextBeforeStart.Truncate(63);
|
2021-04-30 15:20:19 +12:00
|
|
|
|
tsmiStart.Text = Resources.ScreenRecordForm_Start;
|
2015-09-08 00:29:27 +12:00
|
|
|
|
cmsMain.Enabled = true;
|
2022-09-04 12:26:41 +12:00
|
|
|
|
UpdateUI();
|
2015-09-08 01:29:37 +12:00
|
|
|
|
break;
|
|
|
|
|
case ScreenRecordState.AfterStart:
|
2022-09-04 12:26:41 +12:00
|
|
|
|
dragging = false;
|
2022-09-04 02:47:08 +12:00
|
|
|
|
Status = ScreenRecordingStatus.Working;
|
2015-09-08 01:29:37 +12:00
|
|
|
|
string trayTextAfterStart = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Click_tray_icon_to_stop_recording_;
|
|
|
|
|
niTray.Text = trayTextAfterStart.Truncate(63);
|
|
|
|
|
niTray.Icon = Resources.control_record.ToIcon();
|
2021-04-30 15:20:19 +12:00
|
|
|
|
tsmiStart.Text = Resources.ScreenRecordForm_Stop;
|
|
|
|
|
btnStart.Text = Resources.ScreenRecordForm_Stop;
|
2022-09-04 12:26:41 +12:00
|
|
|
|
UpdateUI();
|
2015-09-15 19:00:38 +12:00
|
|
|
|
break;
|
|
|
|
|
case ScreenRecordState.AfterRecordingStart:
|
2022-09-04 02:47:08 +12:00
|
|
|
|
Status = ScreenRecordingStatus.Recording;
|
2015-09-08 01:29:37 +12:00
|
|
|
|
StartRecordingTimer();
|
2022-09-06 06:28:25 +12:00
|
|
|
|
UpdateUI();
|
2015-09-08 01:29:37 +12:00
|
|
|
|
break;
|
2022-09-04 01:52:42 +12:00
|
|
|
|
case ScreenRecordState.RecordingEnd:
|
|
|
|
|
StopRecordingTimer();
|
2022-09-04 12:26:41 +12:00
|
|
|
|
UpdateUI();
|
2022-09-04 01:52:42 +12:00
|
|
|
|
break;
|
2018-11-01 23:49:27 +13:00
|
|
|
|
case ScreenRecordState.Encoding:
|
2015-09-08 01:29:37 +12:00
|
|
|
|
Hide();
|
|
|
|
|
string trayTextAfterStop = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Encoding___;
|
|
|
|
|
niTray.Text = trayTextAfterStop.Truncate(63);
|
2021-04-30 15:20:19 +12:00
|
|
|
|
niTray.Icon = Resources.camcorder__pencil.ToIcon();
|
2015-09-08 00:29:27 +12:00
|
|
|
|
cmsMain.Enabled = false;
|
2015-09-08 01:29:37 +12:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2015-08-26 09:38:28 +12:00
|
|
|
|
|
2015-09-08 00:29:27 +12:00
|
|
|
|
public void ChangeStateProgress(int progress)
|
2015-08-26 09:38:28 +12:00
|
|
|
|
{
|
2019-11-28 05:10:49 +13:00
|
|
|
|
niTray.Text = $"ShareX - {Resources.ScreenRecordForm_StartRecording_Encoding___} {progress}%";
|
2020-10-01 12:39:49 +13:00
|
|
|
|
|
|
|
|
|
if (niTray.Visible && lastIconStatus != progress)
|
|
|
|
|
{
|
|
|
|
|
Icon icon;
|
|
|
|
|
|
|
|
|
|
if (progress >= 0)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-30 15:20:19 +12:00
|
|
|
|
icon = Helpers.GetProgressIcon(progress, Color.FromArgb(140, 0, 36));
|
2020-10-01 12:39:49 +13:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteException(e);
|
|
|
|
|
progress = -1;
|
|
|
|
|
if (lastIconStatus == progress) return;
|
2021-04-30 15:20:19 +12:00
|
|
|
|
icon = Resources.camcorder__pencil.ToIcon();
|
2020-10-01 12:39:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-04-30 15:20:19 +12:00
|
|
|
|
icon = Resources.camcorder__pencil.ToIcon();
|
2020-10-01 12:39:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (Icon oldIcon = niTray.Icon)
|
|
|
|
|
{
|
|
|
|
|
niTray.Icon = icon;
|
|
|
|
|
oldIcon.DisposeHandle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastIconStatus = progress;
|
|
|
|
|
}
|
2015-08-26 09:38:28 +12:00
|
|
|
|
}
|
2022-09-06 06:28:25 +12:00
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (Pen pen1 = new Pen(ShareXResources.UseCustomTheme ? ShareXResources.Theme.BorderColor : Color.Black) { DashPattern = new float[] { 5, 5 } })
|
|
|
|
|
using (Pen pen2 = new Pen(borderColor) { DashPattern = new float[] { 5, 5 }, DashOffset = 5 })
|
|
|
|
|
{
|
|
|
|
|
e.Graphics.DrawRectangleProper(pen1, borderRectangle0Based);
|
|
|
|
|
e.Graphics.DrawRectangleProper(pen2, borderRectangle0Based);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnPaint(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ScreenRegionForm_Shown(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ActivateWindow)
|
|
|
|
|
{
|
|
|
|
|
this.ForceActivate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ScreenRecordForm_FormClosed(object sender, FormClosedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Status != ScreenRecordingStatus.Stopped)
|
|
|
|
|
{
|
|
|
|
|
AbortRecording();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void timerRefresh_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnStart_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
StartStopRecording();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPause_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
PauseResumeRecording();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnAbort_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
if (!AskConfirmationOnAbort || MessageBox.Show(Resources.ScreenRecordForm_ConfirmCancel, "ShareX", MessageBoxButtons.YesNo,
|
|
|
|
|
MessageBoxIcon.Warning) == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
AbortRecording();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lblTimer_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left && (Status == ScreenRecordingStatus.Waiting || Status == ScreenRecordingStatus.Paused))
|
|
|
|
|
{
|
|
|
|
|
dragging = true;
|
|
|
|
|
initialLocation = e.Location;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lblTimer_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (dragging)
|
|
|
|
|
{
|
2022-09-09 11:06:12 +12:00
|
|
|
|
Point newLocation = new Point(Location.X + e.X - initialLocation.X, Location.Y + e.Y - initialLocation.Y);
|
|
|
|
|
Rectangle recordingRegion = GetRecordingRegion(newLocation);
|
|
|
|
|
if (CaptureHelpers.GetScreenBounds().Contains(recordingRegion))
|
|
|
|
|
{
|
|
|
|
|
Location = newLocation;
|
|
|
|
|
Update();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
initialLocation = e.Location;
|
|
|
|
|
}
|
2022-09-06 06:28:25 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lblTimer_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
dragging = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|