diff --git a/Greenshot/Drawing/Adorners/AbstractAdorner.cs b/Greenshot/Drawing/Adorners/AbstractAdorner.cs
index f6032d62f..ecf0ce53d 100644
--- a/Greenshot/Drawing/Adorners/AbstractAdorner.cs
+++ b/Greenshot/Drawing/Adorners/AbstractAdorner.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -32,11 +32,12 @@ namespace Greenshot.Drawing.Adorners
{
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
- private static readonly Size defaultSize = new Size(6, 6);
- protected Size _size = defaultSize;
+ private static readonly Size DefaultSize = new Size(6, 6);
+ protected Size _size;
public AbstractAdorner(IDrawableContainer owner)
{
+ _size = DpiHelper.ScaleWithDpi(DefaultSize, 0);
Owner = owner;
}
@@ -144,10 +145,10 @@ namespace Greenshot.Drawing.Adorners
///
/// Adjust UI elements to the supplied DPI settings
///
- ///
+ /// uint
public void AdjustToDpi(uint dpi)
{
- _size = DpiHelper.ScaleWithDpi(defaultSize, dpi);
+ _size = DpiHelper.ScaleWithDpi(DefaultSize, dpi);
}
///
diff --git a/Greenshot/Drawing/DrawableContainer.cs b/Greenshot/Drawing/DrawableContainer.cs
index a85cee791..87b555914 100644
--- a/Greenshot/Drawing/DrawableContainer.cs
+++ b/Greenshot/Drawing/DrawableContainer.cs
@@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
+using System.Linq;
using System.Runtime.Serialization;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
@@ -205,10 +206,8 @@ namespace Greenshot.Drawing
}
public Size Size {
- get {
- return new Size(width, height);
- }
- set {
+ get => new Size(width, height);
+ set {
width = value.Width;
height = value.Height;
}
@@ -219,15 +218,9 @@ namespace Greenshot.Drawing
///
[NonSerialized]
private IList _adorners = new List();
- public IList Adorners
- {
- get
- {
- return _adorners;
- }
- }
+ public IList Adorners => _adorners;
- [NonSerialized]
+ [NonSerialized]
// will store current bounds of this DrawableContainer before starting a resize
protected Rectangle _boundsBeforeResize = Rectangle.Empty;
@@ -236,8 +229,8 @@ namespace Greenshot.Drawing
protected RectangleF _boundsAfterResize = RectangleF.Empty;
public Rectangle Bounds {
- get { return GuiRectangle.GetGuiRectangle(Left, Top, Width, Height); }
- set {
+ get => GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
+ set {
Left = Round(value.Left);
Top = Round(value.Top);
Width = Round(value.Width);
@@ -279,8 +272,12 @@ namespace Greenshot.Drawing
return new Rectangle(Point.Empty, _parent.Image.Size);
}
}
- // Take a base safetymargin
+ // Take a base safety margin
int lineThickness = 5;
+
+ // add adorner size
+ lineThickness += Adorners.Max(adorner => Math.Max(adorner.Bounds.Width, adorner.Bounds.Height));
+
if (HasField(FieldType.LINE_THICKNESS)) {
lineThickness += GetFieldValueAsInt(FieldType.LINE_THICKNESS);
}
@@ -372,10 +369,10 @@ namespace Greenshot.Drawing
///
/// Adjust UI elements to the supplied DPI settings
///
- ///
+ /// uint with dpi value
public void AdjustToDpi(uint dpi)
{
- foreach(var adorner in Adorners)
+ foreach(var adorner in Adorners)
{
adorner.AdjustToDpi(dpi);
}
diff --git a/GreenshotPlugin/Core/DpiHelper.cs b/GreenshotPlugin/Core/DpiHelper.cs
index 2c67eb1b5..171cf19ee 100644
--- a/GreenshotPlugin/Core/DpiHelper.cs
+++ b/GreenshotPlugin/Core/DpiHelper.cs
@@ -35,6 +35,10 @@ namespace GreenshotPlugin.Core
/// double
public static float DpiScaleFactor(uint dpi)
{
+ if (dpi == 0)
+ {
+ dpi = Dpi;
+ }
return (float)dpi / DefaultScreenDpi;
}
diff --git a/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs b/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs
index b8e087101..5d729376c 100644
--- a/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs
+++ b/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -32,6 +32,11 @@ namespace GreenshotPlugin.Interfaces.Drawing.Adorners
///
bool IsActive { get; }
+ ///
+ /// These are the bounds of the adorner
+ ///
+ Rectangle Bounds { get; }
+
///
/// The current edit status, this is needed to locate the adorner to send events to
///
@@ -44,7 +49,7 @@ namespace GreenshotPlugin.Interfaces.Drawing.Adorners
///
/// Is the current point "over" the Adorner?
- /// If this is the case, the
+ /// If this is the case, the
///
/// Point to test
/// true if so
diff --git a/GreenshotPlugin/Interfaces/Drawing/Container.cs b/GreenshotPlugin/Interfaces/Drawing/Container.cs
index c8d85bdd7..0044a0bb0 100644
--- a/GreenshotPlugin/Interfaces/Drawing/Container.cs
+++ b/GreenshotPlugin/Interfaces/Drawing/Container.cs
@@ -1,20 +1,20 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
+ *
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -124,7 +124,7 @@ namespace GreenshotPlugin.Interfaces.Drawing
///
/// Adjust UI elements to the supplied DPI settings
///
- ///
+ /// uint
void AdjustToDpi(uint dpi);
}