From 3d62f9c279f0e07f54f5c4695a5ad5d00f34e51e Mon Sep 17 00:00:00 2001 From: RKrom Date: Sat, 24 Nov 2012 10:29:39 +0000 Subject: [PATCH] This fixes a bug where the AutoCrop can't be undone, there is still a bug where a redo of a crop (auto or normal) doesn't update the bindings. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2310 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Drawing/Surface.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index 3b0a04070..c9944ef84 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -734,15 +734,19 @@ namespace Greenshot.Drawing { public bool AutoCrop() { Rectangle cropRectangle = ImageHelper.FindAutoCropRectangle(Image, conf.AutoCropDifference); if (isCropPossible(ref cropRectangle)) { - DrawingMode = DrawingModes.Crop; - cropContainer = new CropContainer(this); - cropContainer.Left = cropRectangle.X; - cropContainer.Top = cropRectangle.Y; - cropContainer.Width = cropRectangle.Width; - cropContainer.Height = cropRectangle.Height; DeselectAllElements(); - AddElement(cropContainer); - SelectElement(cropContainer); + // Maybe a bit obscure, but the following line creates a drop container + // It's available as "undrawnElement" + DrawingMode = DrawingModes.Crop; + undrawnElement.Left = cropRectangle.X; + undrawnElement.Top = cropRectangle.Y; + undrawnElement.Width = cropRectangle.Width; + undrawnElement.Height = cropRectangle.Height; + undrawnElement.Status = EditStatus.UNDRAWN; + AddElement(undrawnElement); + SelectElement(undrawnElement); + drawingElement = null; + undrawnElement = null; return true; } return false; @@ -970,7 +974,7 @@ namespace Greenshot.Drawing { if (drawingElement == null && DrawingMode != DrawingModes.None) { if (undrawnElement == null) { DeselectAllElements(); - if(undrawnElement == null) { + if (undrawnElement == null) { CreateUndrawnElement(); } }