From 05d9783a24da34c7716012a492fff6e1c389a35f Mon Sep 17 00:00:00 2001 From: JKlingen Date: Sun, 2 Dec 2012 16:21:27 +0000 Subject: [PATCH] fixed issues with zoom positioning on multiscreen setup with negative screen coordinates git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2344 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Forms/CaptureForm.cs | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index d08faf2f8..814634664 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -134,7 +134,7 @@ namespace Greenshot.Forms { User32.ReleaseDC(hDCDesktop); LOG.DebugFormat("VRefresh {0}", vRefesh); - zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(zoomOffset, zoomSize), 20, EasingType.Quintic); + zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(zoomOffset, zoomSize), 20, EasingType.Quintic, EasingMode.EaseOut); // comment this out if the timer should not be used timer = new Timer(); @@ -492,11 +492,11 @@ namespace Greenshot.Forms { } if (isZooming && captureMode != CaptureMode.Window) { Rectangle zoomArea = zoomAnimator.Current; - zoomArea.Offset(lastPos); + zoomArea.Offset(lastPosOnBitmap); Invalidate(zoomArea); - zoomArea = AnimateZoomArea(cursorPos); - zoomArea.Offset(cursorPos); + zoomArea = AnimateZoomArea(cursorPosOnBitmap); + zoomArea.Offset(cursorPosOnBitmap); Invalidate(zoomArea); } // Force update "now" @@ -526,33 +526,35 @@ namespace Greenshot.Forms { /// Change direction if not. /// private Rectangle AnimateZoomArea(Point pos) { + Rectangle ret; Rectangle screenBounds = Screen.GetBounds(MousePosition); Rectangle targetRectangle = zoomAnimator.Last; targetRectangle.Offset(pos); - + screenBounds.Location = GetAbsoluteLocation(screenBounds.Location); if (screenBounds.Contains(targetRectangle)) { // All okay - return zoomAnimator.Next(); - } - - Point destinationLocation; - Rectangle tl = new Rectangle(pos.X - (zoomOffset.X + zoomSize.Width), pos.Y - (zoomOffset.Y + zoomSize.Height), zoomSize.Width, zoomSize.Height); - Rectangle tr = new Rectangle(pos.X + zoomOffset.X, pos.Y - (zoomOffset.Y + zoomSize.Height), zoomSize.Width, zoomSize.Height); - Rectangle bl = new Rectangle(pos.X - (zoomOffset.X + zoomSize.Width), pos.Y + zoomOffset.Y, zoomSize.Width, zoomSize.Height); - Rectangle br = new Rectangle(pos.X + zoomOffset.X, pos.Y + zoomOffset.Y, zoomSize.Width, zoomSize.Height); - if (screenBounds.Contains(br)) { - destinationLocation = new Point(zoomOffset.X, zoomOffset.Y); - } else if (screenBounds.Contains(bl)) { - destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, zoomOffset.Y); - } else if (screenBounds.Contains(tr)) { - destinationLocation = new Point(zoomOffset.X, -zoomOffset.Y - zoomSize.Width); + ret = zoomAnimator.Next(); } else { - destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, -zoomOffset.Y - zoomSize.Width); + Point destinationLocation; + Rectangle tl = new Rectangle(pos.X - (zoomOffset.X + zoomSize.Width), pos.Y - (zoomOffset.Y + zoomSize.Height), zoomSize.Width, zoomSize.Height); + Rectangle tr = new Rectangle(pos.X + zoomOffset.X, pos.Y - (zoomOffset.Y + zoomSize.Height), zoomSize.Width, zoomSize.Height); + Rectangle bl = new Rectangle(pos.X - (zoomOffset.X + zoomSize.Width), pos.Y + zoomOffset.Y, zoomSize.Width, zoomSize.Height); + Rectangle br = new Rectangle(pos.X + zoomOffset.X, pos.Y + zoomOffset.Y, zoomSize.Width, zoomSize.Height); + if (screenBounds.Contains(br)) { + destinationLocation = new Point(zoomOffset.X, zoomOffset.Y); + } else if (screenBounds.Contains(bl)) { + destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, zoomOffset.Y); + } else if (screenBounds.Contains(tr)) { + destinationLocation = new Point(zoomOffset.X, -zoomOffset.Y - zoomSize.Width); + } else { + destinationLocation = new Point(-zoomOffset.X - zoomSize.Width, -zoomOffset.Y - zoomSize.Width); + } + zoomAnimator.ChangeDestination(new Rectangle(new Point(-10, -10), new Size(20, 20))); + zoomAnimator.QueueDestination(new Rectangle(destinationLocation, zoomSize)); + ret = zoomAnimator.Next(); } - zoomAnimator.ChangeDestination(new Rectangle(new Point(-10, -10), new Size(20, 20))); - zoomAnimator.QueueDestination(new Rectangle(destinationLocation, zoomSize)); - return zoomAnimator.Next(); + return ret; } /// @@ -789,7 +791,7 @@ namespace Greenshot.Forms { Rectangle sourceRectangle = new Rectangle(cursorPosOnBitmap.X - (zoomSourceWidth / 2), cursorPosOnBitmap.Y - (zoomSourceHeight / 2), zoomSourceWidth, zoomSourceHeight); Rectangle destinationRectangle = zoomAnimator.Current; - destinationRectangle.Offset(cursorPos); + destinationRectangle.Offset(cursorPosOnBitmap); DrawZoom(graphics, sourceRectangle, destinationRectangle); }