diff --git a/src/Greenshot.Base/Interfaces/ISurface.cs b/src/Greenshot.Base/Interfaces/ISurface.cs
index cedb8f51c..4b39fb9b8 100644
--- a/src/Greenshot.Base/Interfaces/ISurface.cs
+++ b/src/Greenshot.Base/Interfaces/ISurface.cs
@@ -256,5 +256,13 @@ namespace Greenshot.Base.Interfaces
/// Image
/// Matrix
void UndoBackgroundChange(Image previous, Matrix matrix);
+
+ ///
+ /// The most recent DPI value that was used
+ ///
+ public int CurrentDpi
+ {
+ get;
+ }
}
}
\ No newline at end of file
diff --git a/src/Greenshot.Editor/Drawing/Adorners/AbstractAdorner.cs b/src/Greenshot.Editor/Drawing/Adorners/AbstractAdorner.cs
index aa023b19c..a2dd980a6 100644
--- a/src/Greenshot.Editor/Drawing/Adorners/AbstractAdorner.cs
+++ b/src/Greenshot.Editor/Drawing/Adorners/AbstractAdorner.cs
@@ -34,12 +34,17 @@ namespace Greenshot.Editor.Drawing.Adorners
{
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
- private static readonly NativeSize DefaultSize = new NativeSize(6, 6);
- protected NativeSize _size;
+ private static readonly NativeSize DefaultSize = new(6, 6);
+
+ protected NativeSize Size
+ {
+ get;
+ set;
+ }
public AbstractAdorner(IDrawableContainer owner)
{
- _size = DpiCalculator.ScaleWithDpi(DefaultSize, 0);
+ Size = DpiCalculator.ScaleWithDpi(DefaultSize, owner?.Parent?.CurrentDpi ?? 96);
Owner = owner;
}
@@ -51,7 +56,7 @@ namespace Greenshot.Editor.Drawing.Adorners
get { return Cursors.SizeAll; }
}
- public virtual IDrawableContainer Owner { get; set; }
+ public IDrawableContainer Owner { get; set; }
///
/// Test if the point is inside the adorner
@@ -105,7 +110,7 @@ namespace Greenshot.Editor.Drawing.Adorners
get
{
NativePoint location = Location;
- return new NativeRect(location.X - (_size.Width / 2), location.Y - (_size.Height / 2), _size.Width, _size.Height);
+ return new NativeRect(location.X - (Size.Width / 2), location.Y - (Size.Height / 2), Size.Width, Size.Height);
}
}
@@ -117,7 +122,7 @@ namespace Greenshot.Editor.Drawing.Adorners
get
{
NativePoint displayLocation = Owner.Parent.ToSurfaceCoordinates(Location);
- return new NativeRect(displayLocation.X - _size.Width / 2, displayLocation.Y - _size.Height / 2, _size.Width, _size.Height);
+ return new NativeRect(displayLocation.X - Size.Width / 2, displayLocation.Y - Size.Height / 2, Size.Width, Size.Height);
}
}
@@ -135,7 +140,7 @@ namespace Greenshot.Editor.Drawing.Adorners
/// uint
public void AdjustToDpi(int dpi)
{
- _size = DpiCalculator.ScaleWithDpi(DefaultSize, dpi);
+ Size = DpiCalculator.ScaleWithDpi(DefaultSize, dpi);
}
public Color OutlineColor { get; set; } = Color.White;
diff --git a/src/Greenshot.Editor/Drawing/Surface.cs b/src/Greenshot.Editor/Drawing/Surface.cs
index 399d60dad..f050374a6 100644
--- a/src/Greenshot.Editor/Drawing/Surface.cs
+++ b/src/Greenshot.Editor/Drawing/Surface.cs
@@ -145,6 +145,17 @@ namespace Greenshot.Editor.Drawing
remove => _shadowChanged -= value;
}
+
+ [NonSerialized] private int _currentDpi = 96;
+ ///
+ /// The most recent DPI value that was used
+ ///
+ public int CurrentDpi
+ {
+ get => _currentDpi;
+ set => _currentDpi = value;
+ }
+
///
/// inUndoRedo makes sure we don't undo/redo while in a undo/redo action
///
@@ -456,6 +467,7 @@ namespace Greenshot.Editor.Drawing
///
public void AdjustToDpi(int dpi)
{
+ CurrentDpi = dpi;
foreach (var element in this._elements)
{
element.AdjustToDpi(dpi);