Modules/GUIs.ZooFlow/Administration/ClassDetailPage.vb
2021-04-22 16:57:16 +02:00

93 lines
3.2 KiB
VB.net

Imports DevExpress.XtraEditors
Imports DevExpress.XtraLayout
Imports DevExpress.XtraTab
Public Class ClassDetailPages
Public Items As New Dictionary(Of String, DetailPage)
Public CurrentPage As DetailPage
Public Event AnyControl_Focus As EventHandler(Of DetailPageEventArgs)
Public Event AnyControl_Changed As EventHandler(Of DetailPageEventArgs)
Public Class DetailPageEventArgs
Public Property Page As DetailPage
End Class
Public Class DetailPage
Public IsPrimary As Boolean = False
Public TabPage As XtraTabPage
Public Name As String
Public BindingSource As BindingSource
Public DataTable As DataTable
Public AddedWhoEdit As TextEdit
Public ChangedWhoEdit As TextEdit
End Class
Public Sub New(LayoutControls As List(Of LayoutControl))
For Each oLayoutControl In LayoutControls
For Each oContainer As LayoutControlItem In oLayoutControl.Root.Items
Dim oControl As BaseEdit = oContainer.Control
AddHandler oControl.GotFocus, AddressOf Handle_Focus
AddHandler oControl.EditValueChanged, AddressOf Handle_EditValueChanged
Next
Next
End Sub
Public Sub Add(Page As DetailPage)
Items.Add(Page.TabPage.Name, Page)
End Sub
Public Sub AddRange(ParamArray Pages As DetailPage())
For Each oPage In Pages
Add(oPage)
Next
End Sub
Private Sub Handle_Focus(sender As BaseEdit, e As EventArgs)
Dim oControl As BaseEdit = sender
' Get the Layout Control containing the Edit Contol
If TypeOf oControl.Parent Is LayoutControl Then
Dim oLayoutControl As LayoutControl = oControl.Parent
' Get the TabPage containing the Layout Control
If TypeOf oLayoutControl.Parent Is XtraTabPage Then
Dim oTabPage As XtraTabPage = oLayoutControl.Parent
If Items.ContainsKey(oTabPage.Name) Then
CurrentPage = Items.Item(oTabPage.Name)
Dim oData As New DetailPageEventArgs With {.Page = Items.Item(oTabPage.Name)}
RaiseEvent AnyControl_Focus(oControl, oData)
Else
CurrentPage = Nothing
RaiseEvent AnyControl_Focus(oControl, Nothing)
End If
End If
End If
End Sub
Private Sub Handle_EditValueChanged(sender As BaseEdit, e As EventArgs)
Dim oControl As BaseEdit = sender
' Get the Layout Control containing the Edit Contol
If TypeOf oControl.Parent Is LayoutControl Then
Dim oLayoutControl As LayoutControl = oControl.Parent
' Get the TabPage containing the Layout Control
If TypeOf oLayoutControl.Parent Is XtraTabPage Then
Dim oTabPage As XtraTabPage = oLayoutControl.Parent
If Items.ContainsKey(oTabPage.Name) Then
Dim oData As New DetailPageEventArgs With {.Page = Items.Item(oTabPage.Name)}
RaiseEvent AnyControl_Changed(oControl, oData)
Else
RaiseEvent AnyControl_Changed(oControl, Nothing)
End If
End If
End If
End Sub
End Class