Auto crop won't automatically crop without user confirmation

This commit is contained in:
Jaex 2017-12-13 01:19:52 +03:00
parent 4fb70e864a
commit 8eaa3b198e
2 changed files with 10 additions and 9 deletions

View file

@ -1537,11 +1537,17 @@ private void ChangeCanvasSize()
private void AutoCropImage()
{
Bitmap bmp = ImageHelpers.AutoCropImage((Bitmap)Form.Canvas);
Rectangle source = new Rectangle(0, 0, Form.Canvas.Width, Form.Canvas.Height);
Rectangle rect = ImageHelpers.FindAutoCropRectangle((Bitmap)Form.Canvas);
if (bmp != null)
if (source != rect && rect.X >= 0 && rect.Y >= 0 && rect.Width > 0 && rect.Height > 0)
{
UpdateCanvas(bmp);
CurrentTool = ShapeType.ToolCrop;
CropTool tool = (CropTool)CreateShape(ShapeType.ToolCrop);
tool.Rectangle = rect.LocationOffset(Form.CanvasRectangle.Location);
tool.OnCreated();
AddShape(tool);
SelectCurrentShape();
}
}

View file

@ -82,12 +82,7 @@ public override void OnCreated()
private void ConfirmButton_MousePressed(object sender, MouseEventArgs e)
{
if (IsValidShape)
{
Rectangle = RectangleInsideCanvas;
Manager.CropArea(Rectangle);
}
Manager.CropArea(RectangleInsideCanvas);
Remove();
}