Added scrolling capture status indicator

This commit is contained in:
Jaex 2024-04-11 03:47:06 +03:00
parent 0da0fde419
commit b6f9fbc346
8 changed files with 76 additions and 21 deletions

View File

@ -364,4 +364,11 @@ namespace ShareX.ScreenCaptureLib
Stopped,
Aborted
}
public enum ScrollingCaptureStatus
{
Failed,
PartiallySuccessful,
Successful
}
}

View File

@ -21,8 +21,10 @@
this.btnOptions = new System.Windows.Forms.Button();
this.btnUpload = new System.Windows.Forms.Button();
this.lblResultSize = new System.Windows.Forms.Label();
this.pbStatus = new System.Windows.Forms.PictureBox();
this.pOutput.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbOutput)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbStatus)).BeginInit();
this.SuspendLayout();
//
// btnCapture
@ -84,17 +86,27 @@
// lblResultSize
//
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.Size = new System.Drawing.Size(108, 24);
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(984, 661);
this.Controls.Add(this.pbStatus);
this.Controls.Add(this.lblResultSize);
this.Controls.Add(this.btnUpload);
this.Controls.Add(this.btnOptions);
@ -111,6 +123,7 @@
this.pOutput.ResumeLayout(false);
this.pOutput.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbOutput)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pbStatus)).EndInit();
this.ResumeLayout(false);
}
@ -123,5 +136,6 @@
private System.Windows.Forms.Button btnOptions;
private System.Windows.Forms.Button btnUpload;
private System.Windows.Forms.Label lblResultSize;
private System.Windows.Forms.PictureBox pbStatus;
}
}

View File

@ -24,6 +24,7 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using ShareX.ScreenCaptureLib.Properties;
using System;
using System.Drawing;
using System.Threading;
@ -121,7 +122,20 @@ namespace ShareX.ScreenCaptureLib
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)
{

View File

@ -239,7 +239,7 @@ namespace ShareX.ScreenCaptureLib.Properties {
/// </summary>
internal static System.Drawing.Bitmap control_pause {
get {
object obj = ResourceManager.GetObject("control-pause", resourceCulture);
object obj = ResourceManager.GetObject("control_pause", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@ -254,6 +254,16 @@ namespace ShareX.ScreenCaptureLib.Properties {
}
}
/// <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>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -864,7 +874,7 @@ namespace ShareX.ScreenCaptureLib.Properties {
/// </summary>
internal static System.Drawing.Bitmap keyboard_enter {
get {
object obj = ResourceManager.GetObject("keyboard-enter", resourceCulture);
object obj = ResourceManager.GetObject("keyboard_enter", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@ -2209,16 +2219,6 @@ namespace ShareX.ScreenCaptureLib.Properties {
}
}
/// <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>
/// Looks up a localized string similar to This window will close before opening the keybinds web page. Do you want to continue?.
/// </summary>

View File

@ -367,9 +367,6 @@
<data name="Highlight" xml:space="preserve">
<value>Highlight</value>
</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">
<value>..\Resources\cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -569,7 +566,7 @@
<data name="Pixelate" xml:space="preserve">
<value>Pixelate</value>
</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>
</data>
<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">
<value>..\Resources\smiley-cool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</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>
</data>
<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">
<value>..\Resources\arrow-circle-315.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

View File

@ -43,6 +43,7 @@ namespace ShareX.ScreenCaptureLib
private Bitmap lastScreenshot;
private Bitmap previousScreenshot;
private bool stopRequested;
private ScrollingCaptureStatus status;
private int bestMatchCount, bestMatchIndex;
private WindowInfo selectedWindow;
private Rectangle selectedRectangle;
@ -78,12 +79,13 @@ namespace ShareX.ScreenCaptureLib
}
}
public async Task StartCapture()
public async Task<ScrollingCaptureStatus> StartCapture()
{
if (!IsCapturing && selectedWindow != null && !selectedRectangle.IsEmpty)
{
IsCapturing = true;
stopRequested = false;
status = ScrollingCaptureStatus.Failed;
bestMatchCount = 0;
bestMatchIndex = 0;
Reset();
@ -175,6 +177,8 @@ namespace ShareX.ScreenCaptureLib
IsCapturing = false;
}
}
return status;
}
public void StopCapture()
@ -223,6 +227,8 @@ namespace ShareX.ScreenCaptureLib
{
if (result == null)
{
status = ScrollingCaptureStatus.Successful;
return (Bitmap)currentImage.Clone();
}
@ -273,10 +279,13 @@ namespace ShareX.ScreenCaptureLib
result.UnlockBits(bdResult);
currentImage.UnlockBits(bdCurrentImage);
bool bestGuess = false;
if (matchCount == 0 && bestMatchCount > 0)
{
matchCount = bestMatchCount;
matchIndex = bestMatchIndex;
bestGuess = true;
}
if (matchCount > 0)
@ -304,10 +313,21 @@ namespace ShareX.ScreenCaptureLib
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;
}
}
status = ScrollingCaptureStatus.Failed;
return null;
}
}