From d9a6922310a3ebd04553cd7a90383f42b0b077be Mon Sep 17 00:00:00 2001
From: k41c <51283438+k41c@users.noreply.github.com>
Date: Fri, 19 Feb 2021 13:57:38 +0100
Subject: [PATCH 1/4] Update ImageEditorForm.cs
---
Greenshot/Forms/ImageEditorForm.cs | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs
index 6e19df179..c67b434f0 100644
--- a/Greenshot/Forms/ImageEditorForm.cs
+++ b/Greenshot/Forms/ImageEditorForm.cs
@@ -898,13 +898,29 @@ namespace Greenshot {
}
}
}
-
+DateTime zoomStartTime = DateTime.Now;
///
/// This is a "work-around" for the MouseWheel event which doesn't get to the panel
///
///
///
private void PanelMouseWheel(object sender, MouseEventArgs e) {
+ if (System.Windows.Forms.Control.ModifierKeys.Equals(Keys.Control))
+ {
+ if (zoomStartTime.AddMilliseconds(100) < DateTime.Now) //waiting for next zoom step 100 ms
+ {
+ zoomStartTime = DateTime.Now;
+ if (e.Delta > 0)
+ {
+ ZoomInMenuItemClick(sender, e);
+ }
+ else if (e.Delta < 0)
+ {
+ ZoomOutMenuItemClick(sender, e);
+ }
+ }
+
+ }
panel1.Focus();
}
From a3e4f2f92e4db63bd622e92f3420997abc9223cb Mon Sep 17 00:00:00 2001
From: k41c <51283438+k41c@users.noreply.github.com>
Date: Fri, 19 Feb 2021 13:58:39 +0100
Subject: [PATCH 2/4] Update NonJumpingPanel.cs
---
Greenshot/Controls/NonJumpingPanel.cs | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/Greenshot/Controls/NonJumpingPanel.cs b/Greenshot/Controls/NonJumpingPanel.cs
index 51658a105..f8595c28a 100644
--- a/Greenshot/Controls/NonJumpingPanel.cs
+++ b/Greenshot/Controls/NonJumpingPanel.cs
@@ -38,16 +38,28 @@ namespace GreenshotPlugin.Controls {
///
/// MouseEventArgs
protected override void OnMouseWheel(MouseEventArgs e)
- {
- if (VScroll && (ModifierKeys & Keys.Shift) == Keys.Shift)
- {
+ {//Check if Scrollbars available and CTRL key pressed -> Zoom IN OUT
+ if((VScroll || HScroll)&& (ModifierKeys & Keys.Control) == Keys.Control)
+ {
VScroll = false;
+ HScroll = false;
base.OnMouseWheel(e);
VScroll = true;
+ HScroll = true;
}
- else
- {
- base.OnMouseWheel(e);
+ else
+ {
+ //Vertical Scoll with SHIFT key pressed
+ if (VScroll && (ModifierKeys & Keys.Shift) == Keys.Shift )
+ {
+ VScroll = false;
+ base.OnMouseWheel(e);
+ VScroll = true;
+ }
+ else
+ {
+ base.OnMouseWheel(e);
+ }
}
}
}
From ee9d1325b57a746371a56c476841ef69b9e975de Mon Sep 17 00:00:00 2001
From: Robin Krom
Date: Fri, 19 Feb 2021 23:06:41 +0100
Subject: [PATCH 3/4] Formatting fix
---
Greenshot/Controls/NonJumpingPanel.cs | 80 ++++++++++++++-------------
1 file changed, 42 insertions(+), 38 deletions(-)
diff --git a/Greenshot/Controls/NonJumpingPanel.cs b/Greenshot/Controls/NonJumpingPanel.cs
index f8595c28a..4d107da45 100644
--- a/Greenshot/Controls/NonJumpingPanel.cs
+++ b/Greenshot/Controls/NonJumpingPanel.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
@@ -22,45 +22,49 @@
using System.Drawing;
using System.Windows.Forms;
-namespace GreenshotPlugin.Controls {
- ///
- /// See: http://nickstips.wordpress.com/2010/03/03/c-panel-resets-scroll-position-after-focus-is-lost-and-regained/
- ///
- public class NonJumpingPanel : Panel {
- protected override Point ScrollToControl(Control activeControl) {
- // Returning the current location prevents the panel from
- // scrolling to the active control when the panel loses and regains focus
- return DisplayRectangle.Location;
- }
+namespace GreenshotPlugin.Controls
+{
+ ///
+ /// See: http://nickstips.wordpress.com/2010/03/03/c-panel-resets-scroll-position-after-focus-is-lost-and-regained/
+ ///
+ public class NonJumpingPanel : Panel
+ {
+ protected override Point ScrollToControl(Control activeControl)
+ {
+ // Returning the current location prevents the panel from
+ // scrolling to the active control when the panel loses and regains focus
+ return DisplayRectangle.Location;
+ }
- ///
- /// Add horizontal scrolling to the panel, when using the wheel and the shift key is pressed
- ///
- /// MouseEventArgs
- protected override void OnMouseWheel(MouseEventArgs e)
- {//Check if Scrollbars available and CTRL key pressed -> Zoom IN OUT
- if((VScroll || HScroll)&& (ModifierKeys & Keys.Control) == Keys.Control)
+ ///
+ /// Add horizontal scrolling to the panel, when using the wheel and the shift key is pressed
+ ///
+ /// MouseEventArgs
+ protected override void OnMouseWheel(MouseEventArgs e)
+ {
+ //Check if Scrollbars available and CTRL key pressed -> Zoom IN OUT
+ if ((VScroll || HScroll) && (ModifierKeys & Keys.Control) == Keys.Control)
{
- VScroll = false;
- HScroll = false;
- base.OnMouseWheel(e);
- VScroll = true;
- HScroll = true;
- }
+ VScroll = false;
+ HScroll = false;
+ base.OnMouseWheel(e);
+ VScroll = true;
+ HScroll = true;
+ }
else
{
- //Vertical Scoll with SHIFT key pressed
- if (VScroll && (ModifierKeys & Keys.Shift) == Keys.Shift )
- {
- VScroll = false;
- base.OnMouseWheel(e);
- VScroll = true;
- }
- else
- {
- base.OnMouseWheel(e);
- }
- }
- }
- }
+ //Vertical Scoll with SHIFT key pressed
+ if (VScroll && (ModifierKeys & Keys.Shift) == Keys.Shift)
+ {
+ VScroll = false;
+ base.OnMouseWheel(e);
+ VScroll = true;
+ }
+ else
+ {
+ base.OnMouseWheel(e);
+ }
+ }
+ }
+ }
}
From c8ade4258b572ef1f8abe9acee21224c7dee6645 Mon Sep 17 00:00:00 2001
From: Robin Krom
Date: Fri, 19 Feb 2021 23:12:15 +0100
Subject: [PATCH 4/4] Fixed formatting
---
Greenshot/Forms/ImageEditorForm.cs | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs
index c67b434f0..ece824bdb 100644
--- a/Greenshot/Forms/ImageEditorForm.cs
+++ b/Greenshot/Forms/ImageEditorForm.cs
@@ -66,6 +66,9 @@ namespace Greenshot {
// whether part of the editor controls are disabled depending on selected item(s)
private bool _controlsDisabledDueToConfirmable;
+ // Used for tracking the mouse scrollwheel changes
+ private DateTime _zoomStartTime = DateTime.Now;
+
///
/// All provided zoom values (in percents) in ascending order.
///
@@ -898,18 +901,24 @@ namespace Greenshot {
}
}
}
-DateTime zoomStartTime = DateTime.Now;
+
///
/// This is a "work-around" for the MouseWheel event which doesn't get to the panel
///
///
///
- private void PanelMouseWheel(object sender, MouseEventArgs e) {
+ ///
+ /// This is a "work-around" for the MouseWheel event which doesn't get to the panel
+ ///
+ ///
+ ///
+ private void PanelMouseWheel(object sender, MouseEventArgs e)
+ {
if (System.Windows.Forms.Control.ModifierKeys.Equals(Keys.Control))
- {
- if (zoomStartTime.AddMilliseconds(100) < DateTime.Now) //waiting for next zoom step 100 ms
- {
- zoomStartTime = DateTime.Now;
+ {
+ if (_zoomStartTime.AddMilliseconds(100) < DateTime.Now) //waiting for next zoom step 100 ms
+ {
+ _zoomStartTime = DateTime.Now;
if (e.Delta > 0)
{
ZoomInMenuItemClick(sender, e);
@@ -919,12 +928,12 @@ DateTime zoomStartTime = DateTime.Now;
ZoomOutMenuItemClick(sender, e);
}
}
-
- }
+
+ }
panel1.Focus();
}
- protected override bool ProcessKeyPreview(ref Message msg) {
+ protected override bool ProcessKeyPreview(ref Message msg) {
// disable default key handling if surface has requested a lock
if (!_surface.KeysLocked) {
return base.ProcessKeyPreview(ref msg);