mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Auto detect scroll end option and remove duplicates
This commit is contained in:
parent
e75b0b03fc
commit
fc01a41468
3 changed files with 64 additions and 20 deletions
|
@ -33,6 +33,8 @@ private void InitializeComponent()
|
|||
this.lblMaximumScrollCount = new System.Windows.Forms.Label();
|
||||
this.tcScrollingCapture = new System.Windows.Forms.TabControl();
|
||||
this.tpCapture = new System.Windows.Forms.TabPage();
|
||||
this.lblScrollMethod = new System.Windows.Forms.Label();
|
||||
this.cbScrollMethod = new System.Windows.Forms.ComboBox();
|
||||
this.tpOutput = new System.Windows.Forms.TabPage();
|
||||
this.btnResetCombine = new System.Windows.Forms.Button();
|
||||
this.btnGuessCombineAdjustments = new System.Windows.Forms.Button();
|
||||
|
@ -55,8 +57,7 @@ private void InitializeComponent()
|
|||
this.nudTrimRight = new System.Windows.Forms.NumericUpDown();
|
||||
this.pOutput = new System.Windows.Forms.Panel();
|
||||
this.pbOutput = new System.Windows.Forms.PictureBox();
|
||||
this.cbScrollMethod = new System.Windows.Forms.ComboBox();
|
||||
this.lblScrollMethod = new System.Windows.Forms.Label();
|
||||
this.cbAutoDetectScrollEnd = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudScrollDelay)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudMaximumScrollCount)).BeginInit();
|
||||
this.tcScrollingCapture.SuspendLayout();
|
||||
|
@ -95,7 +96,7 @@ private void InitializeComponent()
|
|||
// btnCapture
|
||||
//
|
||||
this.btnCapture.Enabled = false;
|
||||
this.btnCapture.Location = new System.Drawing.Point(16, 128);
|
||||
this.btnCapture.Location = new System.Drawing.Point(16, 144);
|
||||
this.btnCapture.Name = "btnCapture";
|
||||
this.btnCapture.Size = new System.Drawing.Size(152, 23);
|
||||
this.btnCapture.TabIndex = 2;
|
||||
|
@ -161,6 +162,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// tpCapture
|
||||
//
|
||||
this.tpCapture.Controls.Add(this.cbAutoDetectScrollEnd);
|
||||
this.tpCapture.Controls.Add(this.lblScrollMethod);
|
||||
this.tpCapture.Controls.Add(this.cbScrollMethod);
|
||||
this.tpCapture.Controls.Add(this.btnSelectHandle);
|
||||
|
@ -178,6 +180,24 @@ private void InitializeComponent()
|
|||
this.tpCapture.Text = "Capture";
|
||||
this.tpCapture.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblScrollMethod
|
||||
//
|
||||
this.lblScrollMethod.AutoSize = true;
|
||||
this.lblScrollMethod.Location = new System.Drawing.Point(16, 48);
|
||||
this.lblScrollMethod.Name = "lblScrollMethod";
|
||||
this.lblScrollMethod.Size = new System.Drawing.Size(74, 13);
|
||||
this.lblScrollMethod.TabIndex = 8;
|
||||
this.lblScrollMethod.Text = "Scroll method:";
|
||||
//
|
||||
// cbScrollMethod
|
||||
//
|
||||
this.cbScrollMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cbScrollMethod.FormattingEnabled = true;
|
||||
this.cbScrollMethod.Location = new System.Drawing.Point(136, 44);
|
||||
this.cbScrollMethod.Name = "cbScrollMethod";
|
||||
this.cbScrollMethod.Size = new System.Drawing.Size(176, 21);
|
||||
this.cbScrollMethod.TabIndex = 7;
|
||||
//
|
||||
// tpOutput
|
||||
//
|
||||
this.tpOutput.Controls.Add(this.btnResetCombine);
|
||||
|
@ -438,23 +458,16 @@ private void InitializeComponent()
|
|||
this.pbOutput.TabIndex = 0;
|
||||
this.pbOutput.TabStop = false;
|
||||
//
|
||||
// cbScrollMethod
|
||||
// cbAutoDetectScrollEnd
|
||||
//
|
||||
this.cbScrollMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cbScrollMethod.FormattingEnabled = true;
|
||||
this.cbScrollMethod.Location = new System.Drawing.Point(136, 44);
|
||||
this.cbScrollMethod.Name = "cbScrollMethod";
|
||||
this.cbScrollMethod.Size = new System.Drawing.Size(176, 21);
|
||||
this.cbScrollMethod.TabIndex = 7;
|
||||
//
|
||||
// lblScrollMethod
|
||||
//
|
||||
this.lblScrollMethod.AutoSize = true;
|
||||
this.lblScrollMethod.Location = new System.Drawing.Point(16, 48);
|
||||
this.lblScrollMethod.Name = "lblScrollMethod";
|
||||
this.lblScrollMethod.Size = new System.Drawing.Size(74, 13);
|
||||
this.lblScrollMethod.TabIndex = 8;
|
||||
this.lblScrollMethod.Text = "Scroll method:";
|
||||
this.cbAutoDetectScrollEnd.AutoSize = true;
|
||||
this.cbAutoDetectScrollEnd.Location = new System.Drawing.Point(16, 120);
|
||||
this.cbAutoDetectScrollEnd.Name = "cbAutoDetectScrollEnd";
|
||||
this.cbAutoDetectScrollEnd.Size = new System.Drawing.Size(129, 17);
|
||||
this.cbAutoDetectScrollEnd.TabIndex = 9;
|
||||
this.cbAutoDetectScrollEnd.Text = "Auto detect scroll end";
|
||||
this.cbAutoDetectScrollEnd.UseVisualStyleBackColor = true;
|
||||
this.cbAutoDetectScrollEnd.CheckedChanged += new System.EventHandler(this.cbAutoDetectScrollEnd_CheckedChanged);
|
||||
//
|
||||
// ScrollingCaptureForm
|
||||
//
|
||||
|
@ -524,5 +537,6 @@ private void InitializeComponent()
|
|||
private Button btnResetCombine;
|
||||
private Label lblScrollMethod;
|
||||
private ComboBox cbScrollMethod;
|
||||
private CheckBox cbAutoDetectScrollEnd;
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@ public ScrollingCaptureForm(ScrollingCaptureOptions options)
|
|||
cbScrollMethod.SelectedIndex = (int)Options.ScrollMethod;
|
||||
nudScrollDelay.Value = Options.ScrollDelay;
|
||||
nudMaximumScrollCount.Value = Options.MaximumScrollCount;
|
||||
cbAutoDetectScrollEnd.Checked = options.AutoDetectScrollEnd;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
@ -154,6 +155,7 @@ private void StopCapture()
|
|||
this.ShowActivate();
|
||||
tcScrollingCapture.SelectedTab = tpOutput;
|
||||
btnGuessEdges.Enabled = btnGuessCombineAdjustments.Enabled = btnCombine.Enabled = images.Count > 1;
|
||||
RemoveLastDuplicates();
|
||||
ResetCombine();
|
||||
}
|
||||
|
||||
|
@ -175,6 +177,28 @@ private void Clean()
|
|||
}
|
||||
}
|
||||
|
||||
private void RemoveLastDuplicates()
|
||||
{
|
||||
if (images.Count > 1)
|
||||
{
|
||||
for (int i = images.Count - 1; i > 0; i--)
|
||||
{
|
||||
bool result = ImageHelpers.IsImagesEqual((Bitmap)images[i], (Bitmap)images[i - 1]);
|
||||
|
||||
if (result)
|
||||
{
|
||||
Image img = images[i];
|
||||
images.Remove(img);
|
||||
img.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void captureTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
Screenshot.CaptureCursor = false;
|
||||
|
@ -187,7 +211,7 @@ private void captureTimer_Tick(object sender, EventArgs e)
|
|||
|
||||
currentScrollCount++;
|
||||
|
||||
if (currentScrollCount == Options.MaximumScrollCount || IsScrollReachedBottom(selectedWindow.Handle))
|
||||
if (currentScrollCount == Options.MaximumScrollCount || (Options.AutoDetectScrollEnd && IsScrollReachedBottom(selectedWindow.Handle)))
|
||||
{
|
||||
StopCapture();
|
||||
}
|
||||
|
@ -217,6 +241,11 @@ private void nudMaximumScrollCount_ValueChanged(object sender, EventArgs e)
|
|||
Options.MaximumScrollCount = (int)nudMaximumScrollCount.Value;
|
||||
}
|
||||
|
||||
private void cbAutoDetectScrollEnd_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Options.AutoDetectScrollEnd = cbAutoDetectScrollEnd.Checked;
|
||||
}
|
||||
|
||||
private bool IsScrollReachedBottom(IntPtr handle)
|
||||
{
|
||||
SCROLLINFO scrollInfo = new SCROLLINFO();
|
||||
|
|
|
@ -36,6 +36,7 @@ public class ScrollingCaptureOptions
|
|||
public ScrollingCaptureScrollMethod ScrollMethod { get; set; } = ScrollingCaptureScrollMethod.SendMessageScroll;
|
||||
public int ScrollDelay { get; set; } = 250;
|
||||
public int MaximumScrollCount { get; set; } = 20;
|
||||
public bool AutoDetectScrollEnd { get; set; } = true;
|
||||
public int TrimLeftEdge { get; set; } = 0;
|
||||
public int TrimTopEdge { get; set; } = 0;
|
||||
public int TrimRightEdge { get; set; } = 0;
|
||||
|
|
Loading…
Reference in a new issue