Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - ' ***********************************************************************
 - ' Author : Elektro
 - ' Last Modified On : 09-15-2014
 - ' ***********************************************************************
 - ' <copyright file="Control Iterator.vb" company="Elektro Studios">
 - ' Copyright (c) Elektro Studios. All rights reserved.
 - ' </copyright>
 - ' ***********************************************************************
 - #Region " Info "
 - ' Synchronous Methods:
 - ' --------------------
 - ' Enable
 - ' Disable
 - ' Dispose
 - ' Show
 - ' Hide
 - ' Check
 - ' Uncheck
 - ' ToggleChecked
 - ' ToggleEnabled
 - ' ToggleVisible
 - ' PerformAction
 - ' Asynchronous Methods:
 - ' ---------------------
 - ' AsyncEnable
 - ' AsyncDisable
 - ' AsyncDispose
 - ' AsyncShow
 - ' AsyncHide
 - ' AsyncCheck
 - ' AsyncUncheck
 - ' AsyncToggleChecked
 - ' AsyncToggleEnabled
 - ' AsyncToggleVisible
 - ' AsyncPerformAction
 - #End Region
 - #Region " Usage Examples "
 - ' ControlIterator.Disable(CheckBox1)
 - '
 - ' ControlIterator.Enable({CheckBox1, CheckBox2})
 - '
 - ' ControlIterator.Dispose({CheckBox1, CheckBox2})
 - '
 - ' ControlIterator.Check(Of CheckBox)(Me)
 - '
 - ' ControlIterator.Uncheck(Of CheckBox)(Me.GroupBox1)
 - '
 - ' ControlIterator.Hide(Of CheckBox)("1")
 - '
 - ' ControlIterator.Show(Of CheckBox)("1")
 - '
 - ' ControlIterator.PerformAction(Of CheckBox)(Sub(ctrl As CheckBox) ctrl.Visible = True)
 - '
 - ' ControlIterator.PerformAction(Me.Controls, Sub(c As Control)
 - ' c.BackColor = Color.Green
 - ' End Sub)
 - '
 - 'ControlIterator.PerformAction(Of TextBox)(Me.Controls,
 - ' Sub(tb As TextBox)
 - ' tb.Tag = 2I
 - ' End Sub,
 - ' ContainsName:="TextBox_Pattern")
 - '
 - ' ControlIterator.AsyncPerformAction(RichTextBox1,
 - ' Sub(rb As RichTextBox)
 - ' For n As Integer = 0 To 9
 - ' rb.AppendText(CStr(n))
 - ' Next
 - ' End Sub)
 - '
 - #End Region
 - #Region " Control Iterator "
 - ''' <summary>
 - ''' Iterates a serie of Controls to perform an specific operation.
 - ''' </summary>
 - Public Class ControlIterator
 - #Region " Public Methods "
 - #Region " Enable "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Enable an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to enable.</param>
 - Public Shared Function Enable(ByVal Control As Object) As Boolean
 - Return EnableOrDisable({Control}, True)
 - End Function
 - ''' <summary>
 - ''' Enable multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to enable.</param>
 - Public Shared Function Enable(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return EnableOrDisable(Controls, True)
 - End Function
 - ''' <summary>
 - ''' Enable all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Enable(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return EnableOrDisable(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Enabled), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Enable all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Enable(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return EnableOrDisable(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Enabled), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Enable all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Enable(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return EnableOrDisable(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Enabled), True, ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Enable an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to enable.</param>
 - Public Shared Function AsyncEnable(ByVal Control As Object) As Boolean
 - Return AsyncEnableOrDisable({Control}, True)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Enable multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to enable.</param>
 - Public Shared Function AsyncEnable(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return AsyncEnableOrDisable(Controls, True)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Enable all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncEnable(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncEnableOrDisable(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Enabled), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Enable all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncEnable(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncEnableOrDisable(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Enabled), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Enable all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Function AsyncEnable(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncEnableOrDisable(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Enabled), True, ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Disable "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Disable an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to disable.</param>
 - Public Shared Function Disable(ByVal Control As Object) As Boolean
 - Return EnableOrDisable({Control}, False)
 - End Function
 - ''' <summary>
 - ''' Disable multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to disable.</param>
 - Public Shared Function Disable(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return EnableOrDisable(Controls, False)
 - End Function
 - ''' <summary>
 - ''' Disable all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Disable(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return EnableOrDisable(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Enabled), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Disable all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Disable(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return EnableOrDisable(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Enabled), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Disable all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Disable(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return EnableOrDisable(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Enabled), False, ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Disable an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to disable.</param>
 - Public Shared Function AsyncDisable(ByVal Control As Object) As Boolean
 - Return AsyncEnableOrDisable({Control}, False)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Disable multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to disable.</param>
 - Public Shared Function AsyncDisable(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return AsyncEnableOrDisable(Controls, False)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Disable all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncDisable(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncEnableOrDisable(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Enabled), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Disable all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncDisable(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncEnableOrDisable(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Enabled), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Disable all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncDisable(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncEnableOrDisable(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Enabled), False, ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Show "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Show an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to show.</param>
 - Public Shared Function Show(ByVal Control As Object) As Boolean
 - Return ShowOrHide({Control}, True)
 - End Function
 - ''' <summary>
 - ''' Show multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to show.</param>
 - Public Shared Function Show(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return ShowOrHide(Controls, True)
 - End Function
 - ''' <summary>
 - ''' Show all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Show(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return ShowOrHide(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Visible), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Show all the Controls of the specified Type on the specified Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Show(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return ShowOrHide(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Visible), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Show all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Show(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return ShowOrHide(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Visible), True, ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Show an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to show.</param>
 - Public Shared Function AsyncShow(ByVal Control As Object) As Boolean
 - Return AsyncShowOrHide({Control}, True)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Show multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to show.</param>
 - Public Shared Function AsyncShow(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return AsyncShowOrHide(Controls, True)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Show all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncShow(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncShowOrHide(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Visible), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Show all the Controls of the specified Type on the specified Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncShow(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncShowOrHide(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Visible), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Show all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncShow(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncShowOrHide(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Visible), True, ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Hide "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Hide an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to hide.</param>
 - Public Shared Function Hide(ByVal Control As Object) As Boolean
 - Return ShowOrHide({Control}, False)
 - End Function
 - ''' <summary>
 - ''' Hide multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to hide.</param>
 - Public Shared Function Hide(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return ShowOrHide(Controls, False)
 - End Function
 - ''' <summary>
 - ''' Hide all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Hide(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return ShowOrHide(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Visible), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Hide all the Controls of the specified Type on the specified Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Hide(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return ShowOrHide(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Visible), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Hide all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Hide(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return ShowOrHide(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Visible), False, ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Hide an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to hide.</param>
 - Public Shared Function AsyncHide(ByVal Control As Object) As Boolean
 - Return AsyncShowOrHide({Control}, False)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Hide multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to hide.</param>
 - Public Shared Function AsyncHide(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return AsyncShowOrHide(Controls, False)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Hide all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncHide(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncShowOrHide(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Visible), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Hide all the Controls of the specified Type on the specified Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncHide(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncShowOrHide(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Visible), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Hide all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncHide(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncShowOrHide(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Visible), False, ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Check "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Check an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to check.</param>
 - Public Shared Function Check(ByVal Control As Object) As Boolean
 - Return CheckOrUncheck({Control}, True)
 - End Function
 - ''' <summary>
 - ''' Check multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to check.</param>
 - Public Shared Function Check(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return CheckOrUncheck(Controls, True)
 - End Function
 - ''' <summary>
 - ''' Check all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Check(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return CheckOrUncheck(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Checked), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Check all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Check(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return CheckOrUncheck(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Checked), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Check all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Check(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return CheckOrUncheck(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Checked), True, ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Check an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to check.</param>
 - Public Shared Function AsyncCheck(ByVal Control As Object) As Boolean
 - Return AsyncCheckOrUncheck({Control}, True)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Check multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to check.</param>
 - Public Shared Function AsyncCheck(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return AsyncCheckOrUncheck(Controls, True)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Check all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncCheck(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncCheckOrUncheck(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Checked), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Check all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncCheck(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncCheckOrUncheck(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Checked), True, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Check all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncCheck(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncCheckOrUncheck(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).Checked), True, ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Uncheck "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Uncheck an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to uncheck.</param>
 - Public Shared Function Uncheck(ByVal Control As Object) As Boolean
 - Return CheckOrUncheck({Control}, False)
 - End Function
 - ''' <summary>
 - ''' Uncheck multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to uncheck.</param>
 - Public Shared Function Uncheck(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return CheckOrUncheck(Controls, False)
 - End Function
 - ''' <summary>
 - ''' Uncheck all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Uncheck(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return CheckOrUncheck(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Checked), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Uncheck all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Uncheck(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return CheckOrUncheck(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Checked), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Uncheck all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Uncheck(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return CheckOrUncheck(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Checked), False, ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Uncheck an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to uncheck.</param>
 - Public Shared Function AsyncUncheck(ByVal Control As Object) As Boolean
 - Return AsyncCheckOrUncheck({Control}, False)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Uncheck multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to uncheck.</param>
 - Public Shared Function AsyncUncheck(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return AsyncCheckOrUncheck(Controls, False)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Uncheck all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncUncheck(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncCheckOrUncheck(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Checked), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Uncheck all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncUncheck(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncCheckOrUncheck(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Checked), False, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Uncheck all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncUncheck(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncCheckOrUncheck(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) CType(ctrl, Object).Checked), False, ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Dispose "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Dispose an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to dispose.</param>
 - Public Shared Function Dispose(ByVal Control As Object) As Boolean
 - Return DisposeControls({Control})
 - End Function
 - ''' <summary>
 - ''' Dispose multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to dispose.</param>
 - Public Shared Function Dispose(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return DisposeControls(Controls)
 - End Function
 - ''' <summary>
 - ''' Dispose all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Dispose(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return DisposeControls(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).IsDisposed), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Dispose all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Dispose(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return DisposeControls(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).IsDisposed), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Dispose all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function Dispose(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return DisposeControls(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).IsDisposed), ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Dispose an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to dispose.</param>
 - Public Shared Function AsyncDispose(ByVal Control As Object) As Boolean
 - Return AsyncDisposeControls({Control})
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Dispose multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to dispose.</param>
 - Public Shared Function AsyncDispose(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return AsyncDisposeControls(Controls)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Dispose all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncDispose(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncDisposeControls(Form.ActiveForm.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).IsDisposed), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Dispose all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncDispose(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncDisposeControls(ControlContainer.Controls.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).IsDisposed), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Dispose all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncDispose(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncDisposeControls(ControlCollection.OfType(Of T).
 - Where(Function(ctrl) Not CType(ctrl, Object).IsDisposed), ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Toggle Enabled "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Toggle the enabled state of an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to toggle their enabled state.</param>
 - Public Shared Function ToggleEnabled(ByVal Control As Object) As Boolean
 - Return _ToggleEnabled({Control})
 - End Function
 - ''' <summary>
 - ''' Toggle the enabled state of multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to toggle their enabled state.</param>
 - Public Shared Function ToggleEnabled(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return _ToggleEnabled(Controls)
 - End Function
 - ''' <summary>
 - ''' Toggle the enabled state of all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleEnabled(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleEnabled(Form.ActiveForm.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Toggle the enabled state of all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleEnabled(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleEnabled(ControlContainer.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Toggle the enabled state of all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleEnabled(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleEnabled(ControlCollection.OfType(Of T), ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Toggle the enabled state of an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to toggle their enabled state.</param>
 - Public Shared Function AsyncToggleEnabled(ByVal Control As Object) As Boolean
 - Return _AsyncToggleEnabled({Control})
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the enabled state of multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to toggle their enabled state.</param>
 - Public Shared Function AsyncToggleEnabled(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return _AsyncToggleEnabled(Controls)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the enabled state of all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleEnabled(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleEnabled(Form.ActiveForm.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the enabled state of all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleEnabled(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleEnabled(ControlContainer.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the enabled state of all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleEnabled(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleEnabled(ControlCollection.OfType(Of T), ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Toggle Visible "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Toggle the visible state of an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to toggle their visible state.</param>
 - Public Shared Function ToggleVisible(ByVal Control As Object) As Boolean
 - Return _ToggleVisible({Control})
 - End Function
 - ''' <summary>
 - ''' Toggle the visible state of multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to toggle their visible state.</param>
 - Public Shared Function ToggleVisible(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return _ToggleVisible(Controls)
 - End Function
 - ''' <summary>
 - ''' Toggle the visible state of all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleVisible(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleVisible(Form.ActiveForm.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Toggle the visible state of all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleVisible(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleVisible(ControlContainer.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Toggle the visible state of all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleVisible(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleVisible(ControlCollection.OfType(Of T), ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Toggle the visible state of an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to toggle their visible state.</param>
 - Public Shared Function AsyncToggleVisible(ByVal Control As Object) As Boolean
 - Return _AsyncToggleVisible({Control})
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the visible state of multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to toggle their visible state.</param>
 - Public Shared Function AsyncToggleVisible(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return _AsyncToggleVisible(Controls)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the visible state of all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleVisible(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleVisible(Form.ActiveForm.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the visible state of all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleVisible(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleVisible(ControlContainer.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the visible state of all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleVisible(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleVisible(ControlCollection.OfType(Of T), ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Toggle Checked "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Toggle the checked state of an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to toggle their checked state.</param>
 - Public Shared Function ToggleChecked(ByVal Control As Object) As Boolean
 - Return _ToggleChecked({Control})
 - End Function
 - ''' <summary>
 - ''' Toggle the checked state of multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to toggle their checked state.</param>
 - Public Shared Function ToggleChecked(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return _ToggleChecked(Controls)
 - End Function
 - ''' <summary>
 - ''' Toggle the checked state of all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleChecked(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleChecked(Form.ActiveForm.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Toggle the checked state of all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleChecked(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleChecked(ControlContainer.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Toggle the checked state of all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function ToggleChecked(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _ToggleChecked(ControlCollection.OfType(Of T), ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Asynchronouslly Toggle the checked state of an specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to toggle their checked state.</param>
 - Public Shared Function AsyncToggleChecked(ByVal Control As Object) As Boolean
 - Return _AsyncToggleChecked({Control})
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the checked state of multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to toggle their checked state.</param>
 - Public Shared Function AsyncToggleChecked(ByVal Controls As IEnumerable(Of Object)) As Boolean
 - Return _AsyncToggleChecked(Controls)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the checked state of all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleChecked(Of T)(Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleChecked(Form.ActiveForm.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the checked state of all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleChecked(Of T)(ByVal ControlContainer As Control,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleChecked(ControlContainer.Controls.OfType(Of T), ContainsName)
 - End Function
 - ''' <summary>
 - ''' Asynchronouslly Toggle the checked state of all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncToggleChecked(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return _AsyncToggleChecked(ControlCollection.OfType(Of T), ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #Region " Perform Action "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Perform an operation on a specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to perform the Action.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the control.</param>
 - Public Shared Function PerformAction(ByVal Control As Object,
 - ByVal Operation As [Delegate])
 - Return PerformActionOnControls({Control}, Operation)
 - End Function
 - ''' <summary>
 - ''' Perform an operation on multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to perform the Action.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the controls.</param>
 - Public Shared Function PerformAction(ByVal Controls As IEnumerable(Of Object),
 - ByVal Operation As [Delegate])
 - Return PerformActionOnControls(Controls, Operation)
 - End Function
 - ''' <summary>
 - ''' Perform an operation on all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function PerformAction(Of T)(ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return PerformActionOnControls(Form.ActiveForm.Controls.OfType(Of T), Operation, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Perform an operation on all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function PerformAction(Of T)(ByVal ControlContainer As Control,
 - ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return PerformActionOnControls(ControlContainer.Controls.OfType(Of T), Operation, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Perform an operation on all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function PerformAction(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return PerformActionOnControls(ControlCollection.OfType(Of T), Operation, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Perform an operation on all the Controls on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function PerformAction(ByVal ControlCollection As Control.ControlCollection,
 - ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return PerformActionOnControls((From c As Object In ControlCollection), Operation, ContainsName)
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Perform an asynchronous operation on a specific Control.
 - ''' </summary>
 - ''' <param name="Control">Indicates the Control to perform the Action.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the control.</param>
 - Public Shared Function AsyncPerformAction(ByVal Control As Object,
 - ByVal Operation As [Delegate])
 - Return AsyncPerformActionOnControls({Control}, Operation)
 - End Function
 - ''' <summary>
 - ''' Perform an asynchronous operation on multiple Controls at once.
 - ''' </summary>
 - ''' <param name="Controls">Indicates the Controls to perform the Action.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the controls.</param>
 - Public Shared Function AsyncPerformAction(ByVal Controls As IEnumerable(Of Object),
 - ByVal Operation As [Delegate])
 - Return AsyncPerformActionOnControls(Controls, Operation)
 - End Function
 - ''' <summary>
 - ''' Perform an asynchronous operation on all the Controls of the specified Type on the active Formulary.
 - ''' </summary>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncPerformAction(Of T)(ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncPerformActionOnControls(Form.ActiveForm.Controls.OfType(Of T), Operation, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Perform an asynchronous operation on all the Controls of the specified Type on the specified Control Container.
 - ''' </summary>
 - ''' <param name="ControlContainer">Indicates the control container where to find the controls.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncPerformAction(Of T)(ByVal ControlContainer As Control,
 - ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncPerformActionOnControls(ControlContainer.Controls.OfType(Of T), Operation, ContainsName)
 - End Function
 - ''' <summary>
 - ''' Perform an asynchronous operation on all the Controls of the specified Type on the specified Control Collection.
 - ''' </summary>
 - ''' <param name="ControlCollection">Indicates the control collection where to find the controls.</param>
 - ''' <param name="Operation">Indicates the Action to perform on the controls.</param>
 - ''' <param name="ContainsName">Indicates that only controls containing name should be collected.</param>
 - Public Shared Function AsyncPerformAction(Of T)(ByVal ControlCollection As Control.ControlCollection,
 - ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - Return AsyncPerformActionOnControls(ControlCollection.OfType(Of T), Operation, ContainsName)
 - End Function
 - #End Region
 - #End Region
 - #End Region
 - #Region " Private Methods "
 - #Region " Synchronous "
 - ''' <summary>
 - ''' Enable or disable controls.
 - ''' </summary>
 - Private Shared Function EnableOrDisable(ByVal Controls As IEnumerable(Of Object),
 - ByVal Enabled As Boolean,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - If [control].InvokeRequired Then
 - [control].Invoke(Sub() [control].Enabled = Enabled)
 - Else
 - [control].Enabled = Enabled
 - End If
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Show or hide controls.
 - ''' </summary>
 - Private Shared Function ShowOrHide(ByVal Controls As IEnumerable(Of Object),
 - ByVal Visible As Boolean,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - If [control].InvokeRequired Then
 - [control].Invoke(Sub() [control].Visible = Visible)
 - Else
 - [control].Visible = Visible
 - End If
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Check or uncheck controls.
 - ''' </summary>
 - Private Shared Function CheckOrUncheck(ByVal Controls As IEnumerable(Of Object),
 - ByVal Checked As Boolean,
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - If [control].InvokeRequired Then
 - [control].Invoke(Sub() [control].Checked = Checked)
 - Else
 - [control].Checked = Checked
 - End If
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Toggle the Enabled state of controls.
 - ''' </summary>
 - Private Shared Function _ToggleEnabled(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - If [control].InvokeRequired Then
 - [control].Invoke(Sub() [control].Enabled = Not [control].Enabled)
 - Else
 - [control].Enabled = Not [control].Enabled
 - End If
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Toggle the Visible state of controls.
 - ''' </summary>
 - Private Shared Function _ToggleVisible(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - If [control].InvokeRequired Then
 - [control].Invoke(Sub() [control].Visible = Not [control].Visible)
 - Else
 - [control].Visible = Not [control].Visible
 - End If
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Toggle the Checked state of controls.
 - ''' </summary>
 - Private Shared Function _ToggleChecked(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - If [control].InvokeRequired Then
 - [control].Invoke(Sub() [control].Checked = Not [control].Checked)
 - Else
 - [control].Checked = Not [control].Checked
 - End If
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Dispose controls.
 - ''' </summary>
 - Private Shared Function DisposeControls(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - If [control].InvokeRequired Then
 - [control].Invoke(Sub() [control].Dispose())
 - Else
 - [control].Dispose()
 - End If
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Perform an operation on Controls.
 - ''' </summary>
 - Private Shared Function PerformActionOnControls(ByVal Controls As IEnumerable(Of Object),
 - ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing) As Boolean
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [Control] As Object In Controls
 - If [Control].InvokeRequired Then
 - [Control].Invoke(Operation, New Object() {[Control]})
 - Else
 - Operation.Method.Invoke(Operation, New Object() {[Control]})
 - End If
 - Next [Control]
 - Return True
 - End Function
 - #End Region
 - #Region " Asynchronous "
 - ''' <summary>
 - ''' Enable or disable controls asynchronouslly.
 - ''' </summary>
 - Private Shared Function AsyncEnableOrDisable(ByVal Controls As IEnumerable(Of Object),
 - ByVal Enabled As Boolean,
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - [control].BeginInvoke(Sub() [control].Enabled = Enabled)
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Show or hide controls asynchronouslly.
 - ''' </summary>
 - Private Shared Function AsyncShowOrHide(ByVal Controls As IEnumerable(Of Object),
 - ByVal Visible As Boolean,
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - [control].BeginInvoke(Sub() [control].Visible = Visible)
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Check or uncheck controls asynchronouslly.
 - ''' </summary>
 - Private Shared Function AsyncCheckOrUncheck(ByVal Controls As IEnumerable(Of Object),
 - ByVal Checked As Boolean,
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - [control].BeginInvoke(Sub() [control].Checked = Checked)
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Toggle the Enabled state of controls asynchronouslly.
 - ''' </summary>
 - Private Shared Function _AsyncToggleEnabled(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - [control].BeginInvoke(Sub() [control].Enabled = Not [control].Enabled)
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Toggle the Visible state of controls asynchronouslly.
 - ''' </summary>
 - Private Shared Function _AsyncToggleVisible(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - [control].BeginInvoke(Sub() [control].Visible = Not [control].Visible)
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Toggle the Checked state of controls asynchronouslly.
 - ''' </summary>
 - Private Shared Function _AsyncToggleChecked(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - [control].BeginInvoke(Sub() [control].Checked = Not [control].Checked)
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Dispose controls asynchronouslly.
 - ''' </summary>
 - Private Shared Function AsyncDisposeControls(ByVal Controls As IEnumerable(Of Object),
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [control] As Object In Controls
 - [control].BeginInvoke(Sub() [control].Dispose())
 - Next [control]
 - Return True
 - End Function
 - ''' <summary>
 - ''' Perform an asynchronous operation on Controls.
 - ''' </summary>
 - Private Shared Function AsyncPerformActionOnControls(ByVal Controls As IEnumerable(Of Object),
 - ByVal Operation As [Delegate],
 - Optional ByVal ContainsName As String = Nothing)
 - If ContainsName IsNot Nothing Then
 - Controls = Controls.Where(Function(ctrl) ctrl.name.contains(ContainsName))
 - If Controls.Count = 0 Then Return False
 - End If
 - For Each [Control] As Object In Controls
 - If [Control].InvokeRequired Then
 - [Control].BeginInvoke(Operation, New Object() {[Control]})
 - Else
 - [Control].BeginInvoke(Operation.Method.Invoke(Operation, New Object() {[Control]}))
 - End If
 - Next [Control]
 - Return True
 - End Function
 - #End Region
 - #End Region
 - End Class
 - #End Region
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment