diff --git a/ShareX.ScreenCaptureLib/Enums.cs b/ShareX.ScreenCaptureLib/Enums.cs index 20a9915e9..f7121828c 100644 --- a/ShareX.ScreenCaptureLib/Enums.cs +++ b/ShareX.ScreenCaptureLib/Enums.cs @@ -364,4 +364,11 @@ public enum ScreenRecordingStatus Stopped, Aborted } + + public enum ScrollingCaptureStatus + { + Failed, + PartiallySuccessful, + Successful + } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.Designer.cs b/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.Designer.cs index 2f00fda3a..17bed4ed2 100644 --- a/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.Designer.cs +++ b/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.Designer.cs @@ -21,8 +21,10 @@ private void InitializeComponent() 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 @@ private void InitializeComponent() // 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 @@ private void InitializeComponent() 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 void InitializeComponent() private System.Windows.Forms.Button btnOptions; private System.Windows.Forms.Button btnUpload; private System.Windows.Forms.Label lblResultSize; + private System.Windows.Forms.PictureBox pbStatus; } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs b/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs index b8ccf2406..c8cef61ba 100644 --- a/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs @@ -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 @@ private async Task StartCapture() 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) { diff --git a/ShareX.ScreenCaptureLib/Properties/Resources.Designer.cs b/ShareX.ScreenCaptureLib/Properties/Resources.Designer.cs index 5dcad78fb..d546dad3e 100644 --- a/ShareX.ScreenCaptureLib/Properties/Resources.Designer.cs +++ b/ShareX.ScreenCaptureLib/Properties/Resources.Designer.cs @@ -239,7 +239,7 @@ internal class Resources { /// 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 @@ internal class Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap control_record_green { + get { + object obj = ResourceManager.GetObject("control_record_green", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -864,7 +874,7 @@ internal class Resources { /// 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 @@ internal class Resources { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap test_32 { - get { - object obj = ResourceManager.GetObject("test_32", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Looks up a localized string similar to This window will close before opening the keybinds web page. Do you want to continue?. /// diff --git a/ShareX.ScreenCaptureLib/Properties/Resources.resx b/ShareX.ScreenCaptureLib/Properties/Resources.resx index 1ac56b962..63d47625e 100644 --- a/ShareX.ScreenCaptureLib/Properties/Resources.resx +++ b/ShareX.ScreenCaptureLib/Properties/Resources.resx @@ -367,9 +367,6 @@ Highlight - - ..\Resources\test_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -569,7 +566,7 @@ Pixelate - + ..\Resources\keyboard-enter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -810,7 +807,7 @@ X: {4} Y: {5} ..\Resources\smiley-cool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\control-pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -830,4 +827,7 @@ Would you like to save the changes before closing the image editor? ..\Resources\arrow-circle-315.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\control-record-green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Resources/control-record-green.png b/ShareX.ScreenCaptureLib/Resources/control-record-green.png new file mode 100644 index 000000000..67f9b2886 Binary files /dev/null and b/ShareX.ScreenCaptureLib/Resources/control-record-green.png differ diff --git a/ShareX.ScreenCaptureLib/Resources/test_32.png b/ShareX.ScreenCaptureLib/Resources/test_32.png deleted file mode 100644 index d4dd37fe1..000000000 Binary files a/ShareX.ScreenCaptureLib/Resources/test_32.png and /dev/null differ diff --git a/ShareX.ScreenCaptureLib/ScrollingCaptureManager.cs b/ShareX.ScreenCaptureLib/ScrollingCaptureManager.cs index 246a1d89e..df154c44d 100644 --- a/ShareX.ScreenCaptureLib/ScrollingCaptureManager.cs +++ b/ShareX.ScreenCaptureLib/ScrollingCaptureManager.cs @@ -43,6 +43,7 @@ internal class ScrollingCaptureManager : IDisposable 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 @@ private void Reset(bool keepResult = false) } } - public async Task StartCapture() + public async Task StartCapture() { if (!IsCapturing && selectedWindow != null && !selectedRectangle.IsEmpty) { IsCapturing = true; stopRequested = false; + status = ScrollingCaptureStatus.Failed; bestMatchCount = 0; bestMatchIndex = 0; Reset(); @@ -175,6 +177,8 @@ public async Task StartCapture() IsCapturing = false; } } + + return status; } public void StopCapture() @@ -223,6 +227,8 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage) { if (result == null) { + status = ScrollingCaptureStatus.Successful; + return (Bitmap)currentImage.Clone(); } @@ -273,10 +279,13 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage) 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 @@ private Bitmap CombineImages(Bitmap result, Bitmap currentImage) 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; } }