diff --git a/Greenshot/Drawing/Adorners/AbstractAdorner.cs b/Greenshot/Drawing/Adorners/AbstractAdorner.cs
index 70a56f29e..f6032d62f 100644
--- a/Greenshot/Drawing/Adorners/AbstractAdorner.cs
+++ b/Greenshot/Drawing/Adorners/AbstractAdorner.cs
@@ -22,6 +22,7 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
+using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces.Drawing;
using GreenshotPlugin.Interfaces.Drawing.Adorners;
@@ -31,7 +32,8 @@ namespace Greenshot.Drawing.Adorners
{
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
- protected Size _size = new Size(4, 4);
+ private static readonly Size defaultSize = new Size(6, 6);
+ protected Size _size = defaultSize;
public AbstractAdorner(IDrawableContainer owner)
{
@@ -139,6 +141,15 @@ namespace Greenshot.Drawing.Adorners
}
}
+ ///
+ /// Adjust UI elements to the supplied DPI settings
+ ///
+ ///
+ public void AdjustToDpi(uint dpi)
+ {
+ _size = DpiHelper.ScaleWithDpi(defaultSize, dpi);
+ }
+
///
/// Draw the adorner
///
diff --git a/Greenshot/Drawing/Adorners/MoveAdorner.cs b/Greenshot/Drawing/Adorners/MoveAdorner.cs
index d07a25ef7..916d569f4 100644
--- a/Greenshot/Drawing/Adorners/MoveAdorner.cs
+++ b/Greenshot/Drawing/Adorners/MoveAdorner.cs
@@ -145,14 +145,12 @@ namespace Greenshot.Drawing.Adorners
var bounds = BoundsOnSurface;
GraphicsState state = targetGraphics.Save();
- targetGraphics.SmoothingMode = SmoothingMode.None;
targetGraphics.CompositingMode = CompositingMode.SourceCopy;
- targetGraphics.PixelOffsetMode = PixelOffsetMode.Half;
- targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
try
{
- targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width, bounds.Height);
+ targetGraphics.FillRectangle(Brushes.Black, bounds);
+ targetGraphics.DrawRectangle(new Pen(Brushes.White), bounds);
}
catch
{
diff --git a/Greenshot/Drawing/Adorners/ResizeAdorner.cs b/Greenshot/Drawing/Adorners/ResizeAdorner.cs
index dce78b461..d624add48 100644
--- a/Greenshot/Drawing/Adorners/ResizeAdorner.cs
+++ b/Greenshot/Drawing/Adorners/ResizeAdorner.cs
@@ -172,12 +172,10 @@ namespace Greenshot.Drawing.Adorners
var bounds = BoundsOnSurface;
GraphicsState state = targetGraphics.Save();
- targetGraphics.SmoothingMode = SmoothingMode.None;
targetGraphics.CompositingMode = CompositingMode.SourceCopy;
- targetGraphics.PixelOffsetMode = PixelOffsetMode.Half;
- targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
- targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width , bounds.Height);
+ targetGraphics.FillRectangle(Brushes.Black, bounds);
+ targetGraphics.DrawRectangle(new Pen(Brushes.White), bounds);
targetGraphics.Restore(state);
}
}
diff --git a/Greenshot/Drawing/Adorners/TargetAdorner.cs b/Greenshot/Drawing/Adorners/TargetAdorner.cs
index 67c01a533..542657c14 100644
--- a/Greenshot/Drawing/Adorners/TargetAdorner.cs
+++ b/Greenshot/Drawing/Adorners/TargetAdorner.cs
@@ -1,118 +1,119 @@
-/*
- * 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 .
- */
-
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Windows.Forms;
-using GreenshotPlugin.Interfaces.Drawing;
-
-namespace Greenshot.Drawing.Adorners
-{
- ///
- /// This implements the special "gripper" for the Speech-Bubble tail
- ///
- public class TargetAdorner : AbstractAdorner
- {
-
- public TargetAdorner(IDrawableContainer owner, Point location) : base(owner)
- {
- Location = location;
- }
-
- ///
- /// Handle the mouse down
- ///
- ///
- ///
- public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
- {
- EditStatus = EditStatus.MOVING;
- }
-
- ///
- /// Handle the mouse move
- ///
- ///
- ///
- public override void MouseMove(object sender, MouseEventArgs mouseEventArgs)
- {
- if (EditStatus != EditStatus.MOVING)
- {
- return;
- }
-
- Owner.Invalidate();
- Point newGripperLocation = new Point(mouseEventArgs.X, mouseEventArgs.Y);
- Rectangle imageBounds = new Rectangle(0, 0, Owner.Parent.Image.Width, Owner.Parent.Image.Height);
- // Check if gripper inside the parent (surface), if not we need to move it inside
- // This was made for BUG-1682
- if (!imageBounds.Contains(newGripperLocation))
- {
- if (newGripperLocation.X > imageBounds.Right)
- {
- newGripperLocation.X = imageBounds.Right - 5;
- }
- if (newGripperLocation.X < imageBounds.Left)
- {
- newGripperLocation.X = imageBounds.Left;
- }
- if (newGripperLocation.Y > imageBounds.Bottom)
- {
- newGripperLocation.Y = imageBounds.Bottom - 5;
- }
- if (newGripperLocation.Y < imageBounds.Top)
- {
- newGripperLocation.Y = imageBounds.Top;
- }
- }
-
- Location = newGripperLocation;
- Owner.Invalidate();
- }
-
- ///
- /// Draw the adorner
- ///
- /// PaintEventArgs
- public override void Paint(PaintEventArgs paintEventArgs)
- {
- Graphics targetGraphics = paintEventArgs.Graphics;
-
- var bounds = BoundsOnSurface;
- targetGraphics.FillRectangle(Brushes.Green, bounds.X, bounds.Y, bounds.Width, bounds.Height);
- }
-
- ///
- /// Made sure this adorner is transformed
- ///
- /// Matrix
- public override void Transform(Matrix matrix)
- {
- if (matrix == null)
- {
- return;
- }
- Point[] points = new[] { Location };
- matrix.TransformPoints(points);
- Location = points[0];
- }
- }
-}
+/*
+ * 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 .
+ */
+
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using GreenshotPlugin.Interfaces.Drawing;
+
+namespace Greenshot.Drawing.Adorners
+{
+ ///
+ /// This implements the special "gripper" for the Speech-Bubble tail
+ ///
+ public class TargetAdorner : AbstractAdorner
+ {
+
+ public TargetAdorner(IDrawableContainer owner, Point location) : base(owner)
+ {
+ Location = location;
+ }
+
+ ///
+ /// Handle the mouse down
+ ///
+ ///
+ ///
+ public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
+ {
+ EditStatus = EditStatus.MOVING;
+ }
+
+ ///
+ /// Handle the mouse move
+ ///
+ ///
+ ///
+ public override void MouseMove(object sender, MouseEventArgs mouseEventArgs)
+ {
+ if (EditStatus != EditStatus.MOVING)
+ {
+ return;
+ }
+
+ Owner.Invalidate();
+ Point newGripperLocation = new Point(mouseEventArgs.X, mouseEventArgs.Y);
+ Rectangle imageBounds = new Rectangle(0, 0, Owner.Parent.Image.Width, Owner.Parent.Image.Height);
+ // Check if gripper inside the parent (surface), if not we need to move it inside
+ // This was made for BUG-1682
+ if (!imageBounds.Contains(newGripperLocation))
+ {
+ if (newGripperLocation.X > imageBounds.Right)
+ {
+ newGripperLocation.X = imageBounds.Right - 5;
+ }
+ if (newGripperLocation.X < imageBounds.Left)
+ {
+ newGripperLocation.X = imageBounds.Left;
+ }
+ if (newGripperLocation.Y > imageBounds.Bottom)
+ {
+ newGripperLocation.Y = imageBounds.Bottom - 5;
+ }
+ if (newGripperLocation.Y < imageBounds.Top)
+ {
+ newGripperLocation.Y = imageBounds.Top;
+ }
+ }
+
+ Location = newGripperLocation;
+ Owner.Invalidate();
+ }
+
+ ///
+ /// Draw the adorner
+ ///
+ /// PaintEventArgs
+ public override void Paint(PaintEventArgs paintEventArgs)
+ {
+ Graphics targetGraphics = paintEventArgs.Graphics;
+
+ var bounds = BoundsOnSurface;
+ targetGraphics.FillRectangle(Brushes.Green, bounds);
+ targetGraphics.DrawRectangle(new Pen(Brushes.White), bounds);
+ }
+
+ ///
+ /// Made sure this adorner is transformed
+ ///
+ /// Matrix
+ public override void Transform(Matrix matrix)
+ {
+ if (matrix == null)
+ {
+ return;
+ }
+ Point[] points = new[] { Location };
+ matrix.TransformPoints(points);
+ Location = points[0];
+ }
+ }
+}
diff --git a/Greenshot/Drawing/DrawableContainer.cs b/Greenshot/Drawing/DrawableContainer.cs
index 33339ee00..a85cee791 100644
--- a/Greenshot/Drawing/DrawableContainer.cs
+++ b/Greenshot/Drawing/DrawableContainer.cs
@@ -369,6 +369,18 @@ namespace Greenshot.Drawing
Draw(graphics, renderMode);
}
+ ///
+ /// Adjust UI elements to the supplied DPI settings
+ ///
+ ///
+ public void AdjustToDpi(uint dpi)
+ {
+ foreach(var adorner in Adorners)
+ {
+ adorner.AdjustToDpi(dpi);
+ }
+ }
+
public virtual bool Contains(int x, int y) {
return Bounds.Contains(x , y);
}
diff --git a/Greenshot/Drawing/DrawableContainerList.cs b/Greenshot/Drawing/DrawableContainerList.cs
index 3d200598e..666986002 100644
--- a/Greenshot/Drawing/DrawableContainerList.cs
+++ b/Greenshot/Drawing/DrawableContainerList.cs
@@ -604,5 +604,16 @@ namespace Greenshot.Drawing {
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
}
- }
+
+ ///
+ /// Adjust UI elements to the supplied DPI settings
+ ///
+ ///
+ public void AdjustToDpi(uint dpi)
+ {
+ foreach (var drawableContainer in this) {
+ drawableContainer.AdjustToDpi(dpi);
+ }
+ }
+ }
}
diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs
index 6c89238f0..d7a4487fc 100644
--- a/Greenshot/Drawing/Surface.cs
+++ b/Greenshot/Drawing/Surface.cs
@@ -432,6 +432,17 @@ namespace Greenshot.Drawing
///
public ICaptureDetails CaptureDetails { get; set; }
+ ///
+ /// Adjust UI elements to the supplied DPI settings
+ ///
+ ///
+ public void AdjustToDpi(uint dpi)
+ {
+ foreach (var element in this._elements) {
+ element.AdjustToDpi(dpi);
+ }
+ }
+
///
/// Base Surface constructor
///
diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs
index d397b8bc8..ab7d037f7 100644
--- a/Greenshot/Forms/ImageEditorForm.cs
+++ b/Greenshot/Forms/ImageEditorForm.cs
@@ -101,6 +101,8 @@ namespace Greenshot {
destinationsToolStrip.ImageScalingSize = newSize;
propertiesToolStrip.ImageScalingSize = newSize;
propertiesToolStrip.MinimumSize = new Size(150, newSize.Height + 10);
+
+ _surface.AdjustToDpi(dpi);
}
public ImageEditorForm(ISurface iSurface, bool outputMade)
diff --git a/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs b/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs
index e35af2141..b8e087101 100644
--- a/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs
+++ b/GreenshotPlugin/Interfaces/Drawing/Adorners/IAdorner.cs
@@ -87,5 +87,11 @@ namespace GreenshotPlugin.Interfaces.Drawing.Adorners
///
/// Matrix
void Transform(Matrix matrix);
+
+ ///
+ /// Adjust UI elements to the supplied DPI settings
+ ///
+ ///
+ void AdjustToDpi(uint dpi);
}
}
diff --git a/GreenshotPlugin/Interfaces/Drawing/Container.cs b/GreenshotPlugin/Interfaces/Drawing/Container.cs
index f4065801a..c8d85bdd7 100644
--- a/GreenshotPlugin/Interfaces/Drawing/Container.cs
+++ b/GreenshotPlugin/Interfaces/Drawing/Container.cs
@@ -120,6 +120,12 @@ namespace GreenshotPlugin.Interfaces.Drawing
/// Available adorners for the DrawableContainer
///
IList Adorners { get; }
+
+ ///
+ /// Adjust UI elements to the supplied DPI settings
+ ///
+ ///
+ void AdjustToDpi(uint dpi);
}
public interface IDrawableContainerList : IList, IDisposable
@@ -167,6 +173,7 @@ namespace GreenshotPlugin.Interfaces.Drawing
void PushElementsToBottom(IDrawableContainerList elements);
void ShowContextMenu(MouseEventArgs e, ISurface surface);
void HandleFieldChangedEvent(object sender, FieldChangedEventArgs e);
+ void AdjustToDpi(uint dpi);
}
public interface ITextContainer : IDrawableContainer