ScaleHelper Class

A helper class containing members for high DPI scaling, especially when using per-monitor DPI awareness.

Definition

Namespace: KGySoft.WinForms
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
public static class ScaleHelper
Inheritance
Object    ScaleHelper

Properties

DefaultFont Practically gets the same value as Control.DefaultFont, but the result of this property is always in points that can be scaled correctly.
DefaultScale Gets the scale factor for 100% (1.0) scaling.
IsDefaultSystemScale Gets whether the SystemScale property returns the default 100% (1.0) scale factor.
IsProcessPerMonitorAware Gets whether the process is per-monitor DPI aware. Per-monitor DPI awareness is available on Windows 8.1 or later.
IsThreadPerMonitorAware Gets whether the current thread is per-monitor DPI aware. Thread-based per-monitor DPI awareness is available on Windows 10 Anniversary Update (1607) or later.
PerMonitorDpiAwarenessVersion Gets the version of per-monitor DPI awareness of the current thread. Per-monitor DPI awareness V1 is available on Windows 8.1 or later, whereas per-monitor DPI awareness V2 and is available on Windows 10 Anniversary Update (1607) or later.
SystemScale If the application is DPI aware, gets the scale factor of the primary display at the time of the application startup. Otherwise, it returns the default scale factor of 100% (1.0).

Methods

GetFontOrDefault Gets the specified font if it is not and is not equal to Control.DefaultFont; otherwise, returns the DefaultFont.
GetScale(Control) Gets the current scale factor of the specified control. If per-monitor DPI awareness is not enabled, it always returns SystemScale.
GetScale(Graphics) Gets the current scale factor of the specified Graphics object.
GetScale(IntPtr) Gets the current scale factor of the specified window handle. If the handle is invalid or per-monitor DPI awareness is not enabled, it always returns the same value as SystemScale.
GetScale(Screen) Gets the current scale factor of the specified Screen.
GetScrollBarSize(Control) Gets the recommended width and height of scrollbars matching the current scaling of the specified control.
GetScrollBarSize(IntPtr) Gets the recommended width and height of scrollbars matching the current scaling of the specified window handle.
HasDefaultScaling Gets whether the display that the specified control belongs to has the same DPI as the initial DPI of the primary display.
Scale(Int32, Single) Scales the specified size by the provided scale factor.
Scale(Padding, PointF) Scales the specified padding by the provided scale factor.
Scale(Size, PointF) Scales the specified size by the provided scale factor.
Scale(Size, Single) Scales the specified size by the provided scale factor.
ScaleF(Size, PointF) Scales the specified size by the provided scale factor.
ScaleF(Size, Single) Scales the specified size by the provided scale factor.
ScaleHeight Scales the specified height by the vertical scale factor of the control.
ScaleSize Scales the specified size by the scale factor of the control.
ScaleWidth Scales the specified width by the horizontal scale factor of the control.

See Also