move clientsuite to GUIs.ClientSuite folder
This commit is contained in:
40
GUIs.ClientSuite/ClassControlPatcher.vb
Normal file
40
GUIs.ClientSuite/ClassControlPatcher.vb
Normal file
@@ -0,0 +1,40 @@
|
||||
''' <summary>
|
||||
''' Applies Modifications to a certain type of controls
|
||||
''' </summary>
|
||||
''' <example>
|
||||
''' Dim oGridPatcher = New ClassControlPatcher(Of GridControl)(Me)
|
||||
''' oGridPatcher.
|
||||
''' ProcessContainer(AddressOf ClassGridControl.DefaultGridSettings).
|
||||
''' ProcessContainer(AddressOf ClassGridControl.ReadOnlyGridSettings).
|
||||
''' ProcessControl(AddressOf ClassGridControl.CheckboxSelectGridSettings, GridNotAssignedToParent).
|
||||
''' ProcessControl(AddressOf ClassGridControl.CheckboxSelectGridSettings, GridAssignedToParent)
|
||||
''' </example>
|
||||
''' <typeparam name="T">The control to Patch</typeparam>
|
||||
Public Class ClassControlPatcher(Of T As Control)
|
||||
Private ReadOnly _Container As Control
|
||||
|
||||
Public Sub New(Container As Control)
|
||||
_Container = Container
|
||||
End Sub
|
||||
|
||||
Public Function ProcessContainer(Action As Action(Of T, Control)) As ClassControlPatcher(Of T)
|
||||
Return ProcessContainer(_Container, Action)
|
||||
End Function
|
||||
|
||||
Public Function ProcessControl(Action As Action(Of T, Control), ByVal Control As Control) As ClassControlPatcher(Of T)
|
||||
Action(Control, _Container)
|
||||
Return Me
|
||||
End Function
|
||||
Private Function ProcessContainer(ByVal Container As Control, Action As Action(Of T, Control)) As ClassControlPatcher(Of T)
|
||||
For Each oControl As Control In Container.Controls
|
||||
|
||||
If oControl.[GetType]() = GetType(T) Then
|
||||
Action(oControl, Container)
|
||||
Else
|
||||
ProcessContainer(oControl, Action)
|
||||
End If
|
||||
Next
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user