Propagate DPI Changes down to Drawable Containers and Adorners and Resize Grippers Accordingly

This commit is contained in:
Greenshot-AppVeyor 2020-04-26 13:58:05 +02:00
commit 68d8082c17
7 changed files with 62 additions and 2 deletions

View file

@ -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(4, 4);
protected Size _size = defaultSize;
public AbstractAdorner(IDrawableContainer owner)
{
@ -127,6 +129,15 @@ namespace Greenshot.Drawing.Adorners
}
}
/// <summary>
/// Adjust UI elements to the supplied DPI settings
/// </summary>
/// <param name="dpi"></param>
public void AdjustToDpi(uint dpi)
{
_size = DpiHelper.ScaleWithDpi(defaultSize, dpi);
}
/// <summary>
/// Draw the adorner
/// </summary>

View file

@ -397,6 +397,18 @@ namespace Greenshot.Drawing
Draw(graphics, renderMode);
}
/// <summary>
/// Adjust UI elements to the supplied DPI settings
/// </summary>
/// <param name="dpi"></param>
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);
}

View file

@ -581,5 +581,16 @@ namespace Greenshot.Drawing {
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
}
}
/// <summary>
/// Adjust UI elements to the supplied DPI settings
/// </summary>
/// <param name="dpi"></param>
public void AdjustToDpi(uint dpi)
{
foreach (var drawableContainer in this) {
drawableContainer.AdjustToDpi(dpi);
}
}
}
}

View file

@ -403,6 +403,17 @@ namespace Greenshot.Drawing
/// </summary>
public ICaptureDetails CaptureDetails { get; set; }
/// <summary>
/// Adjust UI elements to the supplied DPI settings
/// </summary>
/// <param name="dpi"></param>
public void AdjustToDpi(uint dpi)
{
foreach (var element in this._elements) {
element.AdjustToDpi(dpi);
}
}
/// <summary>
/// Base Surface constructor
/// </summary>

View file

@ -96,6 +96,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)

View file

@ -87,5 +87,11 @@ namespace GreenshotPlugin.Interfaces.Drawing.Adorners
/// </summary>
/// <param name="matrix">Matrix</param>
void Transform(Matrix matrix);
/// <summary>
/// Adjust UI elements to the supplied DPI settings
/// </summary>
/// <param name="dpi"></param>
void AdjustToDpi(uint dpi);
}
}

View file

@ -121,6 +121,12 @@ namespace GreenshotPlugin.Interfaces.Drawing
/// Available adorners for the DrawableContainer
/// </summary>
IList<IAdorner> Adorners { get; }
/// <summary>
/// Adjust UI elements to the supplied DPI settings
/// </summary>
/// <param name="dpi"></param>
void AdjustToDpi(uint dpi);
}
public interface IDrawableContainerList : IList<IDrawableContainer>, IDisposable
@ -164,6 +170,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