Added some debug information for BUG-2017, this shows when D is pressed.

This commit is contained in:
Robin 2016-09-04 20:10:33 +02:00
parent d446127e19
commit 71aa131f78
2 changed files with 36 additions and 23 deletions

View file

@ -40,7 +40,7 @@ namespace Greenshot.Forms {
/// <summary> /// <summary>
/// The capture form is used to select a part of the capture /// The capture form is used to select a part of the capture
/// </summary> /// </summary>
public partial class CaptureForm : AnimatingForm { public sealed partial class CaptureForm : AnimatingForm {
private enum FixMode {None, Initiated, Horizontal, Vertical}; private enum FixMode {None, Initiated, Horizontal, Vertical};
private static readonly ILog LOG = LogManager.GetLogger(typeof(CaptureForm)); private static readonly ILog LOG = LogManager.GetLogger(typeof(CaptureForm));
@ -74,6 +74,7 @@ namespace Greenshot.Forms {
private RectangleAnimator _zoomAnimator; private RectangleAnimator _zoomAnimator;
private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1; private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1;
private bool _isCtrlPressed; private bool _isCtrlPressed;
private bool _showDebugInfo;
/// <summary> /// <summary>
/// Property to access the selected capture rectangle /// Property to access the selected capture rectangle
@ -108,9 +109,9 @@ namespace Greenshot.Forms {
protected override CreateParams CreateParams { protected override CreateParams CreateParams {
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
get { get {
CreateParams cp = base.CreateParams; CreateParams createParams = base.CreateParams;
cp.ExStyle |= 0x02000000; createParams.ExStyle |= 0x02000000;
return cp; return createParams;
} }
} }
@ -263,6 +264,14 @@ namespace Greenshot.Forms {
Invalidate(); Invalidate();
} }
break; break;
case Keys.D:
if (_captureMode == CaptureMode.Window)
{
// Toggle debug
_showDebugInfo = !_showDebugInfo;
Invalidate();
}
break;
case Keys.Space: case Keys.Space:
// Toggle capture mode // Toggle capture mode
switch (_captureMode) { switch (_captureMode) {
@ -394,7 +403,7 @@ namespace Greenshot.Forms {
/// </summary> /// </summary>
/// <param name="animator"></param> /// <param name="animator"></param>
/// <returns></returns> /// <returns></returns>
bool isAnimating(IAnimator animator) { private bool IsAnimating(IAnimator animator) {
if (animator == null) { if (animator == null) {
return false; return false;
} }
@ -408,7 +417,7 @@ namespace Greenshot.Forms {
Point lastPos = _cursorPos; Point lastPos = _cursorPos;
_cursorPos = _mouseMovePos; _cursorPos = _mouseMovePos;
if (_selectedCaptureWindow != null && lastPos.Equals(_cursorPos) && !isAnimating(_zoomAnimator) && !isAnimating(_windowAnimator)) { if (_selectedCaptureWindow != null && lastPos.Equals(_cursorPos) && !IsAnimating(_zoomAnimator) && !IsAnimating(_windowAnimator)) {
return; return;
} }
@ -515,8 +524,8 @@ namespace Greenshot.Forms {
// always animate the Window area through to the last frame, so we see the fade-in/out untill the end // always animate the Window area through to the last frame, so we see the fade-in/out untill the end
// Using a safety "offset" to make sure the text is invalidated too // Using a safety "offset" to make sure the text is invalidated too
const int safetySize = 30; const int safetySize = 30;
// Check if the // Check if the animation needs to be drawn
if (isAnimating(_windowAnimator)) { if (IsAnimating(_windowAnimator)) {
invalidateRectangle = _windowAnimator.Current; invalidateRectangle = _windowAnimator.Current;
invalidateRectangle.Inflate(safetySize, safetySize); invalidateRectangle.Inflate(safetySize, safetySize);
Invalidate(invalidateRectangle); Invalidate(invalidateRectangle);
@ -524,12 +533,12 @@ namespace Greenshot.Forms {
invalidateRectangle.Inflate(safetySize, safetySize); invalidateRectangle.Inflate(safetySize, safetySize);
Invalidate(invalidateRectangle); Invalidate(invalidateRectangle);
// Check if this was the last of the windows animations in the normal region capture. // Check if this was the last of the windows animations in the normal region capture.
if (_captureMode != CaptureMode.Window && !isAnimating(_windowAnimator)) { if (_captureMode != CaptureMode.Window && !IsAnimating(_windowAnimator)) {
Invalidate(); Invalidate();
} }
} }
if (_zoomAnimator != null && (isAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) { if (_zoomAnimator != null && (IsAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
// Make sure we invalidate the old zoom area // Make sure we invalidate the old zoom area
invalidateRectangle = _zoomAnimator.Current; invalidateRectangle = _zoomAnimator.Current;
invalidateRectangle.Offset(lastPos); invalidateRectangle.Offset(lastPos);
@ -540,11 +549,7 @@ namespace Greenshot.Forms {
} }
// The following logic is not needed, next always returns the current if there are no frames left // The following logic is not needed, next always returns the current if there are no frames left
// but it makes more sense if we want to change something in the logic // but it makes more sense if we want to change something in the logic
if (isAnimating(_zoomAnimator)) { invalidateRectangle = IsAnimating(_zoomAnimator) ? _zoomAnimator.Next() : _zoomAnimator.Current;
invalidateRectangle = _zoomAnimator.Next();
} else {
invalidateRectangle = _zoomAnimator.Current;
}
invalidateRectangle.Offset(_cursorPos); invalidateRectangle.Offset(_cursorPos);
Invalidate(invalidateRectangle); Invalidate(invalidateRectangle);
} }
@ -709,12 +714,12 @@ namespace Greenshot.Forms {
graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y); graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
} }
if (_mouseDown || _captureMode == CaptureMode.Window || isAnimating(_windowAnimator)) { if (_mouseDown || _captureMode == CaptureMode.Window || IsAnimating(_windowAnimator)) {
_captureRect.Intersect(new Rectangle(Point.Empty, _capture.ScreenBounds.Size)); // crop what is outside the screen _captureRect.Intersect(new Rectangle(Point.Empty, _capture.ScreenBounds.Size)); // crop what is outside the screen
Rectangle fixedRect; Rectangle fixedRect;
//if (captureMode == CaptureMode.Window) { //if (captureMode == CaptureMode.Window) {
if (isAnimating(_windowAnimator)) { if (IsAnimating(_windowAnimator)) {
// Use the animator // Use the animator
fixedRect = _windowAnimator.Current; fixedRect = _windowAnimator.Current;
} else { } else {
@ -818,6 +823,13 @@ namespace Greenshot.Forms {
using (Font newSizeFont = new Font(FontFamily.GenericSansSerif, newSize, FontStyle.Bold)) { using (Font newSizeFont = new Font(FontFamily.GenericSansSerif, newSize, FontStyle.Bold)) {
PointF sizeLocation = new PointF(fixedRect.X + _captureRect.Width / 2 - extent.Width / 2, fixedRect.Y + _captureRect.Height / 2 - newSizeFont.GetHeight() / 2); PointF sizeLocation = new PointF(fixedRect.X + _captureRect.Width / 2 - extent.Width / 2, fixedRect.Y + _captureRect.Height / 2 - newSizeFont.GetHeight() / 2);
graphics.DrawString(sizeText, newSizeFont, Brushes.LightSeaGreen, sizeLocation); graphics.DrawString(sizeText, newSizeFont, Brushes.LightSeaGreen, sizeLocation);
if (_showDebugInfo && _selectedCaptureWindow != null)
{
string title = string.Format("#{0:X}{1}{2}", _selectedCaptureWindow.Handle.ToInt64(), _selectedCaptureWindow.Text.Length > 0 ? " - ": "", _selectedCaptureWindow.Text);
PointF debugLocation = new PointF(fixedRect.X, fixedRect.Y);
graphics.DrawString(title, sizeFont, Brushes.DarkOrange, debugLocation);
}
} }
} }
} }
@ -848,7 +860,7 @@ namespace Greenshot.Forms {
} }
// Zoom // Zoom
if (_zoomAnimator != null && (isAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) { if (_zoomAnimator != null && (IsAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
const int zoomSourceWidth = 25; const int zoomSourceWidth = 25;
const int zoomSourceHeight = 25; const int zoomSourceHeight = 25;

View file

@ -1625,7 +1625,7 @@ namespace GreenshotPlugin.Core {
{ {
return false; return false;
} }
// Skip everything which is not rendered normally. // Skip everything which is not rendered "normally", trying to fix
if (!window.IsApp && (exWindowStyle & ExtendedWindowStyleFlags.WS_EX_NOREDIRECTIONBITMAP) != 0) if (!window.IsApp && (exWindowStyle & ExtendedWindowStyleFlags.WS_EX_NOREDIRECTIONBITMAP) != 0)
{ {
return false; return false;
@ -1637,6 +1637,7 @@ namespace GreenshotPlugin.Core {
} }
return window.Visible || window.Iconic; return window.Visible || window.Iconic;
} }
/// <summary> /// <summary>
/// Get all the top level windows /// Get all the top level windows
/// </summary> /// </summary>