mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-24 01:00:27 +12:00
Added scrolling capture status indicator
This commit is contained in:
parent
0da0fde419
commit
b6f9fbc346
|
@ -364,4 +364,11 @@ public enum ScreenRecordingStatus
|
||||||
Stopped,
|
Stopped,
|
||||||
Aborted
|
Aborted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ScrollingCaptureStatus
|
||||||
|
{
|
||||||
|
Failed,
|
||||||
|
PartiallySuccessful,
|
||||||
|
Successful
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -21,8 +21,10 @@ private void InitializeComponent()
|
||||||
this.btnOptions = new System.Windows.Forms.Button();
|
this.btnOptions = new System.Windows.Forms.Button();
|
||||||
this.btnUpload = new System.Windows.Forms.Button();
|
this.btnUpload = new System.Windows.Forms.Button();
|
||||||
this.lblResultSize = new System.Windows.Forms.Label();
|
this.lblResultSize = new System.Windows.Forms.Label();
|
||||||
|
this.pbStatus = new System.Windows.Forms.PictureBox();
|
||||||
this.pOutput.SuspendLayout();
|
this.pOutput.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbOutput)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pbOutput)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pbStatus)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// btnCapture
|
// btnCapture
|
||||||
|
@ -84,17 +86,27 @@ private void InitializeComponent()
|
||||||
// lblResultSize
|
// lblResultSize
|
||||||
//
|
//
|
||||||
this.lblResultSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.lblResultSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.lblResultSize.Location = new System.Drawing.Point(872, 18);
|
this.lblResultSize.Location = new System.Drawing.Point(848, 18);
|
||||||
this.lblResultSize.Name = "lblResultSize";
|
this.lblResultSize.Name = "lblResultSize";
|
||||||
this.lblResultSize.Size = new System.Drawing.Size(108, 24);
|
this.lblResultSize.Size = new System.Drawing.Size(108, 24);
|
||||||
this.lblResultSize.TabIndex = 4;
|
this.lblResultSize.TabIndex = 4;
|
||||||
this.lblResultSize.TextAlign = System.Drawing.ContentAlignment.BottomRight;
|
this.lblResultSize.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// pbStatus
|
||||||
|
//
|
||||||
|
this.pbStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.pbStatus.Location = new System.Drawing.Point(959, 23);
|
||||||
|
this.pbStatus.Name = "pbStatus";
|
||||||
|
this.pbStatus.Size = new System.Drawing.Size(16, 16);
|
||||||
|
this.pbStatus.TabIndex = 5;
|
||||||
|
this.pbStatus.TabStop = false;
|
||||||
//
|
//
|
||||||
// ScrollingCaptureForm
|
// ScrollingCaptureForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.ClientSize = new System.Drawing.Size(984, 661);
|
this.ClientSize = new System.Drawing.Size(984, 661);
|
||||||
|
this.Controls.Add(this.pbStatus);
|
||||||
this.Controls.Add(this.lblResultSize);
|
this.Controls.Add(this.lblResultSize);
|
||||||
this.Controls.Add(this.btnUpload);
|
this.Controls.Add(this.btnUpload);
|
||||||
this.Controls.Add(this.btnOptions);
|
this.Controls.Add(this.btnOptions);
|
||||||
|
@ -111,6 +123,7 @@ private void InitializeComponent()
|
||||||
this.pOutput.ResumeLayout(false);
|
this.pOutput.ResumeLayout(false);
|
||||||
this.pOutput.PerformLayout();
|
this.pOutput.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbOutput)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pbOutput)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pbStatus)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -123,5 +136,6 @@ private void InitializeComponent()
|
||||||
private System.Windows.Forms.Button btnOptions;
|
private System.Windows.Forms.Button btnOptions;
|
||||||
private System.Windows.Forms.Button btnUpload;
|
private System.Windows.Forms.Button btnUpload;
|
||||||
private System.Windows.Forms.Label lblResultSize;
|
private System.Windows.Forms.Label lblResultSize;
|
||||||
|
private System.Windows.Forms.PictureBox pbStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
using ShareX.HelpersLib;
|
||||||
|
using ShareX.ScreenCaptureLib.Properties;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -121,7 +122,20 @@ private async Task StartCapture()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await manager.StartCapture();
|
ScrollingCaptureStatus status = await manager.StartCapture();
|
||||||
|
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case ScrollingCaptureStatus.Failed:
|
||||||
|
pbStatus.Image = Resources.control_record;
|
||||||
|
break;
|
||||||
|
case ScrollingCaptureStatus.PartiallySuccessful:
|
||||||
|
pbStatus.Image = Resources.control_record_yellow;
|
||||||
|
break;
|
||||||
|
case ScrollingCaptureStatus.Successful:
|
||||||
|
pbStatus.Image = Resources.control_record_green;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -239,7 +239,7 @@ internal class Resources {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap control_pause {
|
internal static System.Drawing.Bitmap control_pause {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("control-pause", resourceCulture);
|
object obj = ResourceManager.GetObject("control_pause", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,6 +254,16 @@ internal class Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap control_record_green {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("control_record_green", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -864,7 +874,7 @@ internal class Resources {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap keyboard_enter {
|
internal static System.Drawing.Bitmap keyboard_enter {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("keyboard-enter", resourceCulture);
|
object obj = ResourceManager.GetObject("keyboard_enter", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2209,16 +2219,6 @@ internal class Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap test_32 {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("test_32", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to This window will close before opening the keybinds web page. Do you want to continue?.
|
/// Looks up a localized string similar to This window will close before opening the keybinds web page. Do you want to continue?.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -367,9 +367,6 @@
|
||||||
<data name="Highlight" xml:space="preserve">
|
<data name="Highlight" xml:space="preserve">
|
||||||
<value>Highlight</value>
|
<value>Highlight</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="test_32" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\test_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="cross" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="cross" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -569,7 +566,7 @@
|
||||||
<data name="Pixelate" xml:space="preserve">
|
<data name="Pixelate" xml:space="preserve">
|
||||||
<value>Pixelate</value>
|
<value>Pixelate</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="keyboard-enter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="keyboard_enter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\keyboard-enter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\keyboard-enter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="layer_shape_line" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="layer_shape_line" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
@ -810,7 +807,7 @@ X: {4} Y: {5}</value>
|
||||||
<data name="smiley_cool" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="smiley_cool" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\smiley-cool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\smiley-cool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="control-pause" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="control_pause" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\control-pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\control-pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="WouldYouLikeToResetOptions" xml:space="preserve">
|
<data name="WouldYouLikeToResetOptions" xml:space="preserve">
|
||||||
|
@ -830,4 +827,7 @@ Would you like to save the changes before closing the image editor?</value>
|
||||||
<data name="arrow_circle_315" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="arrow_circle_315" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\arrow-circle-315.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\arrow-circle-315.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="control_record_green" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\control-record-green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
ShareX.ScreenCaptureLib/Resources/control-record-green.png
Normal file
BIN
ShareX.ScreenCaptureLib/Resources/control-record-green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 541 B |
Binary file not shown.
Before Width: | Height: | Size: 215 B |
|
@ -43,6 +43,7 @@ internal class ScrollingCaptureManager : IDisposable
|
||||||
private Bitmap lastScreenshot;
|
private Bitmap lastScreenshot;
|
||||||
private Bitmap previousScreenshot;
|
private Bitmap previousScreenshot;
|
||||||
private bool stopRequested;
|
private bool stopRequested;
|
||||||
|
private ScrollingCaptureStatus status;
|
||||||
private int bestMatchCount, bestMatchIndex;
|
private int bestMatchCount, bestMatchIndex;
|
||||||
private WindowInfo selectedWindow;
|
private WindowInfo selectedWindow;
|
||||||
private Rectangle selectedRectangle;
|
private Rectangle selectedRectangle;
|
||||||
|
@ -78,12 +79,13 @@ private void Reset(bool keepResult = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartCapture()
|
public async Task<ScrollingCaptureStatus> StartCapture()
|
||||||
{
|
{
|
||||||
if (!IsCapturing && selectedWindow != null && !selectedRectangle.IsEmpty)
|
if (!IsCapturing && selectedWindow != null && !selectedRectangle.IsEmpty)
|
||||||
{
|
{
|
||||||
IsCapturing = true;
|
IsCapturing = true;
|
||||||
stopRequested = false;
|
stopRequested = false;
|
||||||
|
status = ScrollingCaptureStatus.Failed;
|
||||||
bestMatchCount = 0;
|
bestMatchCount = 0;
|
||||||
bestMatchIndex = 0;
|
bestMatchIndex = 0;
|
||||||
Reset();
|
Reset();
|
||||||
|
@ -175,6 +177,8 @@ public async Task StartCapture()
|
||||||
IsCapturing = false;
|
IsCapturing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopCapture()
|
public void StopCapture()
|
||||||
|
@ -223,6 +227,8 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage)
|
||||||
{
|
{
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
|
status = ScrollingCaptureStatus.Successful;
|
||||||
|
|
||||||
return (Bitmap)currentImage.Clone();
|
return (Bitmap)currentImage.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,10 +279,13 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage)
|
||||||
result.UnlockBits(bdResult);
|
result.UnlockBits(bdResult);
|
||||||
currentImage.UnlockBits(bdCurrentImage);
|
currentImage.UnlockBits(bdCurrentImage);
|
||||||
|
|
||||||
|
bool bestGuess = false;
|
||||||
|
|
||||||
if (matchCount == 0 && bestMatchCount > 0)
|
if (matchCount == 0 && bestMatchCount > 0)
|
||||||
{
|
{
|
||||||
matchCount = bestMatchCount;
|
matchCount = bestMatchCount;
|
||||||
matchIndex = bestMatchIndex;
|
matchIndex = bestMatchIndex;
|
||||||
|
bestGuess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchCount > 0)
|
if (matchCount > 0)
|
||||||
|
@ -304,10 +313,21 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage)
|
||||||
new Rectangle(0, matchIndex + 1, currentImage.Width, matchHeight), GraphicsUnit.Pixel);
|
new Rectangle(0, matchIndex + 1, currentImage.Width, matchHeight), GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bestGuess)
|
||||||
|
{
|
||||||
|
status = ScrollingCaptureStatus.PartiallySuccessful;
|
||||||
|
}
|
||||||
|
else if (status != ScrollingCaptureStatus.PartiallySuccessful)
|
||||||
|
{
|
||||||
|
status = ScrollingCaptureStatus.Successful;
|
||||||
|
}
|
||||||
|
|
||||||
return newResult;
|
return newResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = ScrollingCaptureStatus.Failed;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue