Table of Contents

Class ControlExtensions

Namespace
NanoByte.Common.Controls
Assembly
NanoByte.Common.WinForms.dll

Provides extension methods for System.Windows.Forms.Controls.

public static class ControlExtensions
Inheritance
object
ControlExtensions

Methods

ApplyScale(Size, ContainerControl)

Scales a System.Drawing.Size according to the current auto-scaling factor.

public static Size ApplyScale(this Size size, ContainerControl control)

Parameters

size Size

The size to scale.

control ContainerControl

The control to get the scaling factor from.

Returns

Size

BeginInvoke(Control, Action)

Executes the given action on the thread that owns this control and returns immediately.

public static void BeginInvoke(this Control control, Action action)

Parameters

control Control
action Action

GetScaleFactor(ContainerControl)

Returns the current auto-scaling factor.

public static SizeF GetScaleFactor(this ContainerControl control)

Parameters

control ContainerControl

Returns

SizeF

Remarks

Assumes the default System.Windows.Forms.ContainerControl.AutoScaleDimensions of 6, 13 for System.Windows.Forms.AutoScaleMode.Font or 96, 96 for System.Windows.Forms.AutoScaleMode.Dpi. Unlike System.Windows.Forms.ContainerControl.AutoScaleFactor this will retain the correct factor even after System.Windows.Forms.ContainerControl.PerformAutoScale() has run.

Invoke(Control, Action)

Executes the given action on the thread that owns this control and blocks until it is complete.

public static void Invoke(this Control control, Action action)

Parameters

control Control
action Action

Invoke<T>(Control, Func<T>)

Executes the given action on the thread that owns this control and blocks until it is complete.

public static T Invoke<T>(this Control control, Func<T> action)

Parameters

control Control
action Func<T>

Returns

T

The return value of the action.

Type Parameters

T