Table of Contents

Class ControlExtensions

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

Provides extension methods for Controls.

public static class ControlExtensions
Inheritance
ControlExtensions

Methods

ApplyScale(Size, ContainerControl)

Scales a 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 AutoScaleDimensions of 6, 13 for Font or 96, 96 for Dpi. Unlike AutoScaleFactor this will retain the correct factor even after 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