More Logging for Config Module, Add ControlPatcher, Add More UIConfig Items

This commit is contained in:
Jonathan Jenne
2019-02-22 15:13:26 +01:00
parent c6537536f5
commit bad7cea8d6
16 changed files with 276 additions and 94 deletions

View 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)) As ClassControlPatcher(Of T)
Return ProcessContainer(_Container, Action)
End Function
Public Function ProcessControl(Action As Action(Of T), ByVal Control As Control) As ClassControlPatcher(Of T)
Action(Control)
Return Me
End Function
Private Function ProcessContainer(ByVal Container As Control, Action As Action(Of T)) As ClassControlPatcher(Of T)
For Each oControl As Control In Container.Controls
If oControl.[GetType]() = GetType(T) Then
Action(oControl)
Else
ProcessContainer(oControl, Action)
End If
Next
Return Me
End Function
End Class