mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Removed CaptureTaskHelpers and instead added capture classes
This commit is contained in:
parent
1ade3b957c
commit
d7dba60a14
17 changed files with 736 additions and 442 deletions
|
@ -1,4 +1,29 @@
|
|||
using Newtonsoft.Json;
|
||||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using ShareX.HelpersLib;
|
||||
using ShareX.UploadersLib.Properties;
|
||||
using System;
|
||||
|
|
|
@ -1,4 +1,29 @@
|
|||
namespace ShareX.UploadersLib.FileUploaders
|
||||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
namespace ShareX.UploadersLib.FileUploaders
|
||||
{
|
||||
public class PlikSettings
|
||||
{
|
||||
|
|
38
ShareX/CaptureHelpers/CaptureActiveMonitor.cs
Normal file
38
ShareX/CaptureHelpers/CaptureActiveMonitor.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureActiveMonitor : CaptureBase
|
||||
{
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureActiveMonitor();
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
}
|
65
ShareX/CaptureHelpers/CaptureActiveWindow.cs
Normal file
65
ShareX/CaptureHelpers/CaptureActiveWindow.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureActiveWindow : CaptureBase
|
||||
{
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
Image img;
|
||||
string activeWindowTitle = NativeMethods.GetForegroundWindowText();
|
||||
string activeProcessName = null;
|
||||
|
||||
using (Process process = NativeMethods.GetForegroundWindowProcess())
|
||||
{
|
||||
if (process != null)
|
||||
{
|
||||
activeProcessName = process.ProcessName;
|
||||
}
|
||||
}
|
||||
|
||||
if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea)
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureActiveWindowTransparent();
|
||||
}
|
||||
else
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureActiveWindow();
|
||||
}
|
||||
|
||||
return new ImageInfo()
|
||||
{
|
||||
Image = img,
|
||||
WindowTitle = activeWindowTitle,
|
||||
ProcessName = activeProcessName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
119
ShareX/CaptureHelpers/CaptureBase.cs
Normal file
119
ShareX/CaptureHelpers/CaptureBase.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public abstract class CaptureBase
|
||||
{
|
||||
public bool AllowAutoHideForm { get; set; } = true;
|
||||
|
||||
protected abstract ImageInfo Execute(TaskSettings taskSettings);
|
||||
|
||||
public void Capture(bool autoHideForm)
|
||||
{
|
||||
Capture(null, autoHideForm);
|
||||
}
|
||||
|
||||
public void Capture(TaskSettings taskSettings = null, bool autoHideForm = false)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
if (taskSettings.CaptureSettings.IsDelayScreenshot && taskSettings.CaptureSettings.DelayScreenshot > 0)
|
||||
{
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
int sleep = (int)(taskSettings.CaptureSettings.DelayScreenshot * 1000);
|
||||
Thread.Sleep(sleep);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
CaptureInternal(taskSettings, autoHideForm);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
CaptureInternal(taskSettings, autoHideForm);
|
||||
}
|
||||
}
|
||||
|
||||
private void CaptureInternal(TaskSettings taskSettings, bool autoHideForm)
|
||||
{
|
||||
if (autoHideForm && AllowAutoHideForm)
|
||||
{
|
||||
Program.MainForm.Hide();
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
|
||||
ImageInfo imageInfo = null;
|
||||
|
||||
try
|
||||
{
|
||||
imageInfo = Execute(taskSettings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugHelper.WriteException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (autoHideForm && AllowAutoHideForm)
|
||||
{
|
||||
Program.MainForm.ForceActivate();
|
||||
}
|
||||
|
||||
AfterCapture(imageInfo, taskSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void AfterCapture(ImageInfo imageInfo, TaskSettings taskSettings)
|
||||
{
|
||||
if (imageInfo != null && imageInfo.Image != null)
|
||||
{
|
||||
if (taskSettings.GeneralSettings.PlaySoundAfterCapture)
|
||||
{
|
||||
TaskHelpers.PlayCaptureSound(taskSettings);
|
||||
}
|
||||
|
||||
if (taskSettings.AdvancedSettings.UseShareXForAnnotation && taskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage) &&
|
||||
this.GetType() == typeof(CaptureRegion))
|
||||
{
|
||||
taskSettings.AfterCaptureJob = taskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AnnotateImage);
|
||||
}
|
||||
|
||||
if (taskSettings.ImageSettings.ImageEffectOnlyRegionCapture &&
|
||||
this.GetType() != typeof(CaptureRegion) && this.GetType() != typeof(CaptureLastRegion))
|
||||
{
|
||||
taskSettings.AfterCaptureJob = taskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AddImageEffects);
|
||||
}
|
||||
|
||||
UploadManager.RunImageTask(imageInfo, taskSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
39
ShareX/CaptureHelpers/CaptureCustomRegion.cs
Normal file
39
ShareX/CaptureHelpers/CaptureCustomRegion.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureCustomRegion : CaptureBase
|
||||
{
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
Rectangle regionBounds = taskSettings.CaptureSettings.CaptureCustomRegion;
|
||||
Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureRectangle(regionBounds);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
}
|
38
ShareX/CaptureHelpers/CaptureFullscreen.cs
Normal file
38
ShareX/CaptureHelpers/CaptureFullscreen.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureFullscreen : CaptureBase
|
||||
{
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen();
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
}
|
81
ShareX/CaptureHelpers/CaptureLastRegion.cs
Normal file
81
ShareX/CaptureHelpers/CaptureLastRegion.cs
Normal file
|
@ -0,0 +1,81 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using ShareX.ScreenCaptureLib;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureLastRegion : CaptureRegion
|
||||
{
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
switch (lastRegionCaptureType)
|
||||
{
|
||||
default:
|
||||
case RegionCaptureType.Default:
|
||||
if (RegionCaptureForm.LastRegionFillPath != null)
|
||||
{
|
||||
using (Image screenshot = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen())
|
||||
{
|
||||
Image img = RegionCaptureTasks.ApplyRegionPathToImage(screenshot, RegionCaptureForm.LastRegionFillPath);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ExecuteRegionCapture(taskSettings);
|
||||
}
|
||||
case RegionCaptureType.Light:
|
||||
if (!RegionCaptureLightForm.LastSelectionRectangle0Based.IsEmpty)
|
||||
{
|
||||
using (Image screenshot = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen())
|
||||
{
|
||||
Image img = ImageHelpers.CropImage(screenshot, RegionCaptureLightForm.LastSelectionRectangle0Based);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ExecuteRegionCaptureLight(taskSettings);
|
||||
}
|
||||
case RegionCaptureType.Transparent:
|
||||
if (!RegionCaptureTransparentForm.LastSelectionRectangle0Based.IsEmpty)
|
||||
{
|
||||
using (Image screenshot = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen())
|
||||
{
|
||||
Image img = ImageHelpers.CropImage(screenshot, RegionCaptureTransparentForm.LastSelectionRectangle0Based);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ExecuteRegionCaptureTransparent(taskSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
45
ShareX/CaptureHelpers/CaptureMonitor.cs
Normal file
45
ShareX/CaptureHelpers/CaptureMonitor.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureMonitor : CaptureBase
|
||||
{
|
||||
public Rectangle MonitorRectangle { get; private set; }
|
||||
|
||||
public CaptureMonitor(Rectangle monitorRectangle)
|
||||
{
|
||||
MonitorRectangle = monitorRectangle;
|
||||
}
|
||||
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
Image img = TaskHelpers.GetScreenshot().CaptureRectangle(MonitorRectangle);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
}
|
154
ShareX/CaptureHelpers/CaptureRegion.cs
Normal file
154
ShareX/CaptureHelpers/CaptureRegion.cs
Normal file
|
@ -0,0 +1,154 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using ShareX.ScreenCaptureLib;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureRegion : CaptureBase
|
||||
{
|
||||
protected static RegionCaptureType lastRegionCaptureType = RegionCaptureType.Default;
|
||||
|
||||
public RegionCaptureType RegionCaptureType { get; protected set; }
|
||||
|
||||
public CaptureRegion()
|
||||
{
|
||||
}
|
||||
|
||||
public CaptureRegion(RegionCaptureType regionCaptureType)
|
||||
{
|
||||
RegionCaptureType = regionCaptureType;
|
||||
}
|
||||
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
switch (RegionCaptureType)
|
||||
{
|
||||
default:
|
||||
case RegionCaptureType.Default:
|
||||
return ExecuteRegionCapture(taskSettings);
|
||||
case RegionCaptureType.Light:
|
||||
return ExecuteRegionCaptureLight(taskSettings);
|
||||
case RegionCaptureType.Transparent:
|
||||
return ExecuteRegionCaptureTransparent(taskSettings);
|
||||
}
|
||||
}
|
||||
|
||||
protected ImageInfo ExecuteRegionCapture(TaskSettings taskSettings)
|
||||
{
|
||||
ImageInfo imageInfo = new ImageInfo();
|
||||
|
||||
RegionCaptureMode mode;
|
||||
|
||||
if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation)
|
||||
{
|
||||
mode = RegionCaptureMode.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = RegionCaptureMode.Annotation;
|
||||
}
|
||||
|
||||
RegionCaptureForm form = new RegionCaptureForm(mode);
|
||||
|
||||
try
|
||||
{
|
||||
form.Config = taskSettings.CaptureSettingsReference.SurfaceOptions;
|
||||
Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen();
|
||||
form.Prepare(img);
|
||||
form.ShowDialog();
|
||||
|
||||
imageInfo.Image = form.GetResultImage();
|
||||
|
||||
if (imageInfo.Image != null)
|
||||
{
|
||||
if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern)
|
||||
{
|
||||
WindowInfo windowInfo = form.GetWindowInfo();
|
||||
|
||||
if (windowInfo != null)
|
||||
{
|
||||
imageInfo.WindowTitle = windowInfo.Text;
|
||||
imageInfo.ProcessName = windowInfo.ProcessName;
|
||||
}
|
||||
}
|
||||
|
||||
lastRegionCaptureType = RegionCaptureType.Default;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (form != null)
|
||||
{
|
||||
form.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return imageInfo;
|
||||
}
|
||||
|
||||
protected ImageInfo ExecuteRegionCaptureLight(TaskSettings taskSettings)
|
||||
{
|
||||
Image img = null;
|
||||
|
||||
using (RegionCaptureLightForm rectangleLight = new RegionCaptureLightForm(TaskHelpers.GetScreenshot(taskSettings)))
|
||||
{
|
||||
if (rectangleLight.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
img = rectangleLight.GetAreaImage();
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
lastRegionCaptureType = RegionCaptureType.Light;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
|
||||
protected ImageInfo ExecuteRegionCaptureTransparent(TaskSettings taskSettings)
|
||||
{
|
||||
Image img = null;
|
||||
|
||||
using (RegionCaptureTransparentForm rectangleTransparent = new RegionCaptureTransparentForm())
|
||||
{
|
||||
if (rectangleTransparent.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
img = rectangleTransparent.GetAreaImage(TaskHelpers.GetScreenshot(taskSettings));
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
lastRegionCaptureType = RegionCaptureType.Transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
}
|
68
ShareX/CaptureHelpers/CaptureWindow.cs
Normal file
68
ShareX/CaptureHelpers/CaptureWindow.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class CaptureWindow : CaptureBase
|
||||
{
|
||||
public IntPtr WindowHandle { get; private set; }
|
||||
|
||||
public CaptureWindow(IntPtr windowHandle)
|
||||
{
|
||||
WindowHandle = windowHandle;
|
||||
|
||||
AllowAutoHideForm = WindowHandle != Program.MainForm.Handle;
|
||||
}
|
||||
|
||||
protected override ImageInfo Execute(TaskSettings taskSettings)
|
||||
{
|
||||
if (NativeMethods.IsIconic(WindowHandle))
|
||||
{
|
||||
NativeMethods.RestoreWindow(WindowHandle);
|
||||
}
|
||||
|
||||
NativeMethods.SetForegroundWindow(WindowHandle);
|
||||
Thread.Sleep(250);
|
||||
|
||||
Image img;
|
||||
|
||||
if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea)
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureWindowTransparent(WindowHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureWindow(WindowHandle);
|
||||
}
|
||||
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,416 +0,0 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2017 ShareX Team
|
||||
|
||||
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)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using ShareX.ScreenCaptureLib;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public static class CaptureTaskHelpers
|
||||
{
|
||||
private delegate ImageInfo ScreenCaptureDelegate();
|
||||
|
||||
private enum LastRegionCaptureType { Default, Light, Transparent }
|
||||
|
||||
private static LastRegionCaptureType lastRegionCaptureType = LastRegionCaptureType.Default;
|
||||
|
||||
public static void CaptureScreenshot(CaptureType captureType, TaskSettings taskSettings = null, bool autoHideForm = true)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
switch (captureType)
|
||||
{
|
||||
case CaptureType.Fullscreen:
|
||||
CaptureFullscreen(taskSettings, autoHideForm);
|
||||
break;
|
||||
case CaptureType.ActiveWindow:
|
||||
CaptureActiveWindow(taskSettings, autoHideForm);
|
||||
break;
|
||||
case CaptureType.ActiveMonitor:
|
||||
CaptureActiveMonitor(taskSettings, autoHideForm);
|
||||
break;
|
||||
case CaptureType.Region:
|
||||
CaptureRegion(taskSettings, autoHideForm);
|
||||
break;
|
||||
case CaptureType.CustomRegion:
|
||||
CaptureCustomRegion(taskSettings, autoHideForm);
|
||||
break;
|
||||
case CaptureType.LastRegion:
|
||||
CaptureLastRegion(taskSettings, autoHideForm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DoCapture(ScreenCaptureDelegate capture, CaptureType captureType, TaskSettings taskSettings = null, bool autoHideForm = true)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
if (taskSettings.CaptureSettings.IsDelayScreenshot && taskSettings.CaptureSettings.DelayScreenshot > 0)
|
||||
{
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
int sleep = (int)(taskSettings.CaptureSettings.DelayScreenshot * 1000);
|
||||
Thread.Sleep(sleep);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
DoCaptureWork(capture, captureType, taskSettings, autoHideForm);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
DoCaptureWork(capture, captureType, taskSettings, autoHideForm);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DoCaptureWork(ScreenCaptureDelegate capture, CaptureType captureType, TaskSettings taskSettings, bool autoHideForm = true)
|
||||
{
|
||||
if (autoHideForm)
|
||||
{
|
||||
Program.MainForm.Hide();
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
|
||||
ImageInfo imageInfo = null;
|
||||
|
||||
try
|
||||
{
|
||||
imageInfo = capture();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugHelper.WriteException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (autoHideForm)
|
||||
{
|
||||
Program.MainForm.ForceActivate();
|
||||
}
|
||||
|
||||
AfterCapture(imageInfo, captureType, taskSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AfterCapture(ImageInfo imageInfo, CaptureType captureType, TaskSettings taskSettings)
|
||||
{
|
||||
if (imageInfo != null && imageInfo.Image != null)
|
||||
{
|
||||
if (taskSettings.GeneralSettings.PlaySoundAfterCapture)
|
||||
{
|
||||
TaskHelpers.PlayCaptureSound(taskSettings);
|
||||
}
|
||||
|
||||
if (taskSettings.AdvancedSettings.UseShareXForAnnotation && taskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage)
|
||||
&& captureType == CaptureType.Region)
|
||||
{
|
||||
taskSettings.AfterCaptureJob = taskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AnnotateImage);
|
||||
}
|
||||
|
||||
if (taskSettings.ImageSettings.ImageEffectOnlyRegionCapture && !IsRegionCapture(captureType))
|
||||
{
|
||||
taskSettings.AfterCaptureJob = taskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AddImageEffects);
|
||||
}
|
||||
|
||||
UploadManager.RunImageTask(imageInfo, taskSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsRegionCapture(CaptureType captureType)
|
||||
{
|
||||
return captureType.HasFlagAny(CaptureType.Region, CaptureType.LastRegion);
|
||||
}
|
||||
|
||||
public static void CaptureFullscreen(TaskSettings taskSettings, bool autoHideForm = true)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen();
|
||||
return new ImageInfo(img);
|
||||
}, CaptureType.Fullscreen, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureWindow(IntPtr handle, TaskSettings taskSettings = null, bool autoHideForm = true)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
autoHideForm = autoHideForm && handle != Program.MainForm.Handle;
|
||||
|
||||
DoCapture(() =>
|
||||
{
|
||||
if (NativeMethods.IsIconic(handle))
|
||||
{
|
||||
NativeMethods.RestoreWindow(handle);
|
||||
}
|
||||
|
||||
NativeMethods.SetForegroundWindow(handle);
|
||||
Thread.Sleep(250);
|
||||
|
||||
Image img;
|
||||
|
||||
if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea)
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureWindowTransparent(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureWindow(handle);
|
||||
}
|
||||
|
||||
return new ImageInfo(img);
|
||||
}, CaptureType.Window, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureActiveWindow(TaskSettings taskSettings, bool autoHideForm = true)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
Image img;
|
||||
string activeWindowTitle = NativeMethods.GetForegroundWindowText();
|
||||
string activeProcessName = null;
|
||||
|
||||
using (Process process = NativeMethods.GetForegroundWindowProcess())
|
||||
{
|
||||
if (process != null)
|
||||
{
|
||||
activeProcessName = process.ProcessName;
|
||||
}
|
||||
}
|
||||
|
||||
if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea)
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureActiveWindowTransparent();
|
||||
}
|
||||
else
|
||||
{
|
||||
img = TaskHelpers.GetScreenshot(taskSettings).CaptureActiveWindow();
|
||||
}
|
||||
|
||||
return new ImageInfo()
|
||||
{
|
||||
Image = img,
|
||||
WindowTitle = activeWindowTitle,
|
||||
ProcessName = activeProcessName
|
||||
};
|
||||
}, CaptureType.ActiveWindow, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureMonitor(Rectangle rect, TaskSettings taskSettings = null, bool autoHideForm = true)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
Image img = TaskHelpers.GetScreenshot().CaptureRectangle(rect);
|
||||
return new ImageInfo(img);
|
||||
}, CaptureType.Monitor, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureActiveMonitor(TaskSettings taskSettings, bool autoHideForm)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureActiveMonitor();
|
||||
return new ImageInfo(img);
|
||||
}, CaptureType.ActiveMonitor, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureCustomRegion(TaskSettings taskSettings, bool autoHideForm)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
Rectangle regionBounds = taskSettings.CaptureSettings.CaptureCustomRegion;
|
||||
Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureRectangle(regionBounds);
|
||||
return new ImageInfo(img);
|
||||
}, CaptureType.CustomRegion, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureRegion(TaskSettings taskSettings, bool autoHideForm = true)
|
||||
{
|
||||
RegionCaptureMode mode;
|
||||
|
||||
if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation)
|
||||
{
|
||||
mode = RegionCaptureMode.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = RegionCaptureMode.Annotation;
|
||||
}
|
||||
|
||||
RegionCaptureForm form = new RegionCaptureForm(mode);
|
||||
|
||||
DoCapture(() =>
|
||||
{
|
||||
ImageInfo imageInfo = new ImageInfo();
|
||||
|
||||
try
|
||||
{
|
||||
form.Config = taskSettings.CaptureSettingsReference.SurfaceOptions;
|
||||
form.Prepare(TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen());
|
||||
form.ShowDialog();
|
||||
|
||||
imageInfo.Image = form.GetResultImage();
|
||||
|
||||
if (imageInfo.Image != null)
|
||||
{
|
||||
if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern)
|
||||
{
|
||||
WindowInfo windowInfo = form.GetWindowInfo();
|
||||
|
||||
if (windowInfo != null)
|
||||
{
|
||||
imageInfo.WindowTitle = windowInfo.Text;
|
||||
imageInfo.ProcessName = windowInfo.ProcessName;
|
||||
}
|
||||
}
|
||||
|
||||
lastRegionCaptureType = LastRegionCaptureType.Default;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (form != null)
|
||||
{
|
||||
form.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return imageInfo;
|
||||
}, CaptureType.Region, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureRectangleLight(TaskSettings taskSettings = null, bool autoHideForm = true)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
DoCapture(() =>
|
||||
{
|
||||
Image img = null;
|
||||
|
||||
using (RegionCaptureLightForm rectangleLight = new RegionCaptureLightForm(TaskHelpers.GetScreenshot(taskSettings)))
|
||||
{
|
||||
if (rectangleLight.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
img = rectangleLight.GetAreaImage();
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
lastRegionCaptureType = LastRegionCaptureType.Light;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ImageInfo(img);
|
||||
}, CaptureType.Region, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureRectangleTransparent(TaskSettings taskSettings = null, bool autoHideForm = true)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
DoCapture(() =>
|
||||
{
|
||||
Image img = null;
|
||||
|
||||
using (RegionCaptureTransparentForm rectangleTransparent = new RegionCaptureTransparentForm())
|
||||
{
|
||||
if (rectangleTransparent.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
img = rectangleTransparent.GetAreaImage(TaskHelpers.GetScreenshot(taskSettings));
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
lastRegionCaptureType = LastRegionCaptureType.Transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ImageInfo(img);
|
||||
}, CaptureType.Region, taskSettings, autoHideForm);
|
||||
}
|
||||
|
||||
public static void CaptureLastRegion(TaskSettings taskSettings, bool autoHideForm = true)
|
||||
{
|
||||
switch (lastRegionCaptureType)
|
||||
{
|
||||
case LastRegionCaptureType.Default:
|
||||
if (RegionCaptureForm.LastRegionFillPath != null)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
using (Image screenshot = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen())
|
||||
{
|
||||
Image img = RegionCaptureTasks.ApplyRegionPathToImage(screenshot, RegionCaptureForm.LastRegionFillPath);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}, CaptureType.LastRegion, taskSettings, autoHideForm);
|
||||
}
|
||||
else
|
||||
{
|
||||
CaptureRegion(taskSettings, autoHideForm);
|
||||
}
|
||||
break;
|
||||
case LastRegionCaptureType.Light:
|
||||
if (!RegionCaptureLightForm.LastSelectionRectangle0Based.IsEmpty)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
using (Image screenshot = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen())
|
||||
{
|
||||
Image img = ImageHelpers.CropImage(screenshot, RegionCaptureLightForm.LastSelectionRectangle0Based);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}, CaptureType.LastRegion, taskSettings, autoHideForm);
|
||||
}
|
||||
else
|
||||
{
|
||||
CaptureRectangleLight(taskSettings, autoHideForm);
|
||||
}
|
||||
break;
|
||||
case LastRegionCaptureType.Transparent:
|
||||
if (!RegionCaptureTransparentForm.LastSelectionRectangle0Based.IsEmpty)
|
||||
{
|
||||
DoCapture(() =>
|
||||
{
|
||||
using (Image screenshot = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen())
|
||||
{
|
||||
Image img = ImageHelpers.CropImage(screenshot, RegionCaptureTransparentForm.LastSelectionRectangle0Based);
|
||||
return new ImageInfo(img);
|
||||
}
|
||||
}, CaptureType.LastRegion, taskSettings, autoHideForm);
|
||||
}
|
||||
else
|
||||
{
|
||||
CaptureRectangleTransparent(taskSettings, autoHideForm);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -247,4 +247,9 @@ public enum ScreenRecordState
|
|||
{
|
||||
Waiting, BeforeStart, AfterStart, AfterRecordingStart, AfterStop
|
||||
}
|
||||
|
||||
public enum RegionCaptureType
|
||||
{
|
||||
Default, Light, Transparent
|
||||
}
|
||||
}
|
|
@ -1261,7 +1261,7 @@ private void pbPatreonHide_Click(object sender, EventArgs e)
|
|||
|
||||
private void tsmiFullscreen_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.Fullscreen);
|
||||
new CaptureFullscreen().Capture(true);
|
||||
}
|
||||
|
||||
private void tsddbCapture_DropDownOpening(object sender, EventArgs e)
|
||||
|
@ -1275,7 +1275,7 @@ private void tsmiWindowItems_Click(object sender, EventArgs e)
|
|||
WindowInfo wi = tsi.Tag as WindowInfo;
|
||||
if (wi != null)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureWindow(wi.Handle);
|
||||
new CaptureWindow(wi.Handle).Capture(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1285,28 +1285,28 @@ private void tsmiMonitorItems_Click(object sender, EventArgs e)
|
|||
Rectangle rect = (Rectangle)tsi.Tag;
|
||||
if (!rect.IsEmpty)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureMonitor(rect);
|
||||
new CaptureMonitor(rect).Capture(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void tsmiRectangle_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.Region);
|
||||
new CaptureRegion().Capture(true);
|
||||
}
|
||||
|
||||
private void tsmiRectangleLight_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureRectangleLight();
|
||||
new CaptureRegion(RegionCaptureType.Light).Capture(true);
|
||||
}
|
||||
|
||||
private void tsmiRectangleTransparent_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureRectangleTransparent();
|
||||
new CaptureRegion(RegionCaptureType.Transparent).Capture(true);
|
||||
}
|
||||
|
||||
private void tsmiLastRegion_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.LastRegion);
|
||||
new CaptureLastRegion().Capture(true);
|
||||
}
|
||||
|
||||
private void tsmiScreenRecordingFFmpeg_Click(object sender, EventArgs e)
|
||||
|
@ -1614,7 +1614,7 @@ private void cmsTray_Opened(object sender, EventArgs e)
|
|||
|
||||
private void tsmiTrayFullscreen_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.Fullscreen, null, false);
|
||||
new CaptureFullscreen().Capture();
|
||||
}
|
||||
|
||||
private void tsmiCapture_DropDownOpening(object sender, EventArgs e)
|
||||
|
@ -1628,7 +1628,7 @@ private void tsmiTrayWindowItems_Click(object sender, EventArgs e)
|
|||
WindowInfo wi = tsi.Tag as WindowInfo;
|
||||
if (wi != null)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureWindow(wi.Handle, null, false);
|
||||
new CaptureWindow(wi.Handle).Capture();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1638,28 +1638,28 @@ private void tsmiTrayMonitorItems_Click(object sender, EventArgs e)
|
|||
Rectangle rect = (Rectangle)tsi.Tag;
|
||||
if (!rect.IsEmpty)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureMonitor(rect, null, false);
|
||||
new CaptureMonitor(rect).Capture();
|
||||
}
|
||||
}
|
||||
|
||||
private void tsmiTrayRectangle_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.Region, null, false);
|
||||
new CaptureRegion().Capture();
|
||||
}
|
||||
|
||||
private void tsmiTrayRectangleLight_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureRectangleLight(null, false);
|
||||
new CaptureRegion(RegionCaptureType.Light).Capture();
|
||||
}
|
||||
|
||||
private void tsmiTrayRectangleTransparent_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureRectangleTransparent(null, false);
|
||||
new CaptureRegion(RegionCaptureType.Transparent).Capture();
|
||||
}
|
||||
|
||||
private void tsmiTrayLastRegion_Click(object sender, EventArgs e)
|
||||
{
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.LastRegion, null, false);
|
||||
new CaptureLastRegion().Capture();
|
||||
}
|
||||
|
||||
private void tsmiTrayTextCapture_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -102,7 +102,15 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CaptureTaskHelpers.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureActiveMonitor.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureActiveWindow.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureBase.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureCustomRegion.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureFullscreen.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureLastRegion.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureMonitor.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureRegion.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureWindow.cs" />
|
||||
<Compile Include="Controls\BeforeUploadControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -94,28 +94,28 @@ public static void ExecuteJob(TaskSettings taskSettings, HotkeyType job, CLIComm
|
|||
break;
|
||||
// Screen capture
|
||||
case HotkeyType.PrintScreen:
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.Fullscreen, safeTaskSettings, false);
|
||||
new CaptureFullscreen().Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.ActiveWindow:
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.ActiveWindow, safeTaskSettings, false);
|
||||
new CaptureActiveWindow().Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.ActiveMonitor:
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.ActiveMonitor, safeTaskSettings, false);
|
||||
new CaptureActiveMonitor().Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.RectangleRegion:
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.Region, safeTaskSettings, false);
|
||||
new CaptureRegion().Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.RectangleLight:
|
||||
CaptureTaskHelpers.CaptureRectangleLight(safeTaskSettings, false);
|
||||
new CaptureRegion(RegionCaptureType.Light).Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.RectangleTransparent:
|
||||
CaptureTaskHelpers.CaptureRectangleTransparent(safeTaskSettings, false);
|
||||
new CaptureRegion(RegionCaptureType.Transparent).Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.CustomRegion:
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.CustomRegion, safeTaskSettings, false);
|
||||
new CaptureCustomRegion().Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.LastRegion:
|
||||
CaptureTaskHelpers.CaptureScreenshot(CaptureType.LastRegion, safeTaskSettings, false);
|
||||
new CaptureLastRegion().Capture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.ScrollingCapture:
|
||||
OpenScrollingCapture(safeTaskSettings, true);
|
||||
|
|
Loading…
Reference in a new issue