Class ControlExtensions
Provides extension methods for System.Windows.Forms.Controls.
public static class ControlExtensions
- Inheritance
-
objectControlExtensions
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
SizeThe size to scale.
control
ContainerControlThe 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
Controlaction
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
Controlaction
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
Controlaction
Func<T>
Returns
- T
The return value of the
action
.
Type Parameters
T