diff --git a/src/Greenshot.Editor/Drawing/Adorners/ResizeAdorner.cs b/src/Greenshot.Editor/Drawing/Adorners/ResizeAdorner.cs
index 052abaaa4..483abe0d7 100644
--- a/src/Greenshot.Editor/Drawing/Adorners/ResizeAdorner.cs
+++ b/src/Greenshot.Editor/Drawing/Adorners/ResizeAdorner.cs
@@ -109,7 +109,8 @@ namespace Greenshot.Editor.Drawing.Adorners
_boundsAfterResize.Height = _boundsBeforeResize.Height;
// calculate scaled rectangle
- ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
+ var scaleOptions = (Owner as IHasScaleOptions)?.GetScaleOptions() ?? ScaleHelper.GetScaleOptions();
+ ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), scaleOptions);
// apply scaled bounds to this DrawableContainer
Owner.ApplyBounds(_boundsAfterResize);
diff --git a/src/Greenshot.Editor/Drawing/DrawableContainer.cs b/src/Greenshot.Editor/Drawing/DrawableContainer.cs
index b7202b23e..f51743ba0 100644
--- a/src/Greenshot.Editor/Drawing/DrawableContainer.cs
+++ b/src/Greenshot.Editor/Drawing/DrawableContainer.cs
@@ -512,13 +512,14 @@ namespace Greenshot.Editor.Drawing
{
Invalidate();
- // reset "workrbench" rectangle to current bounds
+ // reset "workbench" rectangle to current bounds
_boundsAfterResize.X = _boundsBeforeResize.Left;
_boundsAfterResize.Y = _boundsBeforeResize.Top;
_boundsAfterResize.Width = x - _boundsAfterResize.Left;
_boundsAfterResize.Height = y - _boundsAfterResize.Top;
-
- ScaleHelper.Scale(_boundsBeforeResize, x, y, ref _boundsAfterResize, GetAngleRoundProcessor());
+
+ var scaleOptions = (this as IHasScaleOptions)?.GetScaleOptions() ?? null;
+ ScaleHelper.Scale(_boundsBeforeResize, x, y, ref _boundsAfterResize, GetAngleRoundProcessor(), scaleOptions);
// apply scaled bounds to this DrawableContainer
ApplyBounds(_boundsAfterResize);
diff --git a/src/Greenshot.Editor/Drawing/EmojiContainer.cs b/src/Greenshot.Editor/Drawing/EmojiContainer.cs
index 6cb356271..84a64b813 100644
--- a/src/Greenshot.Editor/Drawing/EmojiContainer.cs
+++ b/src/Greenshot.Editor/Drawing/EmojiContainer.cs
@@ -33,6 +33,7 @@ using System.Windows.Media.Imaging;
using Greenshot.Base.Core;
using Greenshot.Base.Interfaces.Drawing;
using Greenshot.Editor.Controls;
+using Greenshot.Editor.Drawing.Adorners;
using Greenshot.Editor.Helpers;
using Image = System.Drawing.Image;
using Matrix = System.Drawing.Drawing2D.Matrix;
@@ -44,7 +45,7 @@ namespace Greenshot.Editor.Drawing
/// Description of EmojiContainer.
///
[Serializable]
- public class EmojiContainer : DrawableContainer, IEmojiContainer
+ public class EmojiContainer : DrawableContainer, IEmojiContainer, IHasScaleOptions
{
[NonSerialized] private static EmojiContainer _currentContainer;
[NonSerialized] private static ElementHost _emojiPickerHost;
@@ -135,7 +136,10 @@ namespace Greenshot.Editor.Drawing
private void Init()
{
- CreateDefaultAdorners();
+ Adorners.Add(new ResizeAdorner(this, Positions.TopLeft));
+ Adorners.Add(new ResizeAdorner(this, Positions.TopRight));
+ Adorners.Add(new ResizeAdorner(this, Positions.BottomLeft));
+ Adorners.Add(new ResizeAdorner(this, Positions.BottomRight));
PropertyChanged += OnPropertyChanged;
}
@@ -223,6 +227,11 @@ namespace Greenshot.Editor.Drawing
_cachedImage?.Dispose();
_cachedImage = null;
}
+
+ public ScaleHelper.ScaleOptions GetScaleOptions()
+ {
+ return ScaleHelper.ScaleOptions.Rational;
+ }
}
internal static class PickerExtensions
diff --git a/src/Greenshot.Editor/Helpers/ScaleHelper.cs b/src/Greenshot.Editor/Helpers/ScaleHelper.cs
index 423fdf075..4a59eff14 100644
--- a/src/Greenshot.Editor/Helpers/ScaleHelper.cs
+++ b/src/Greenshot.Editor/Helpers/ScaleHelper.cs
@@ -26,6 +26,11 @@ using Greenshot.Editor.Drawing;
namespace Greenshot.Editor.Helpers
{
+ public interface IHasScaleOptions
+ {
+ ScaleHelper.ScaleOptions GetScaleOptions();
+ }
+
///
/// Offers a few helper functions for scaling/aligning an element with another element
///
@@ -280,23 +285,23 @@ namespace Greenshot.Editor.Helpers
return newSize;
}
- public static void Scale(Rectangle boundsBeforeResize, int cursorX, int cursorY, ref RectangleF boundsAfterResize)
+ public static void Scale(Rectangle boundsBeforeResize, int cursorX, int cursorY, ref RectangleF boundsAfterResize, ScaleOptions? options)
{
- Scale(boundsBeforeResize, cursorX, cursorY, ref boundsAfterResize, null);
+ Scale(boundsBeforeResize, cursorX, cursorY, ref boundsAfterResize, null, options);
}
- public static void Scale(Rectangle boundsBeforeResize, int cursorX, int cursorY, ref RectangleF boundsAfterResize, IDoubleProcessor angleRoundBehavior)
+ public static void Scale(Rectangle boundsBeforeResize, int cursorX, int cursorY, ref RectangleF boundsAfterResize, IDoubleProcessor angleRoundBehavior, ScaleOptions? options)
{
- Scale(boundsBeforeResize, Positions.TopLeft, cursorX, cursorY, ref boundsAfterResize, angleRoundBehavior);
+ Scale(boundsBeforeResize, Positions.TopLeft, cursorX, cursorY, ref boundsAfterResize, angleRoundBehavior, options);
}
public static void Scale(Rectangle boundsBeforeResize, Positions gripperPosition, int cursorX, int cursorY, ref RectangleF boundsAfterResize,
- IDoubleProcessor angleRoundBehavior)
+ IDoubleProcessor angleRoundBehavior, ScaleOptions? options)
{
- ScaleOptions opts = GetScaleOptions();
+ options ??= GetScaleOptions();
- bool rationalScale = (opts & ScaleOptions.Rational) == ScaleOptions.Rational;
- bool centeredScale = (opts & ScaleOptions.Centered) == ScaleOptions.Centered;
+ bool rationalScale = (options & ScaleOptions.Rational) == ScaleOptions.Rational;
+ bool centeredScale = (options & ScaleOptions.Centered) == ScaleOptions.Centered;
if (rationalScale)
{
@@ -324,12 +329,13 @@ namespace Greenshot.Editor.Helpers
}
}
+ ///
/// the current ScaleOptions depending on modifier keys held down
public static ScaleOptions GetScaleOptions()
{
bool anchorAtCenter = (Control.ModifierKeys & Keys.Control) != 0;
bool maintainAspectRatio = (Control.ModifierKeys & Keys.Shift) != 0;
- ScaleOptions opts = ScaleOptions.Default;
+ var opts = ScaleOptions.Default;
if (anchorAtCenter) opts |= ScaleOptions.Centered;
if (maintainAspectRatio) opts |= ScaleOptions.Rational;
return opts;