Loading Form, center integer columns, use sequence field, simplify, fix layout
This commit is contained in:
79
GUIs.Monitor/Validator.vb
Normal file
79
GUIs.Monitor/Validator.vb
Normal file
@@ -0,0 +1,79 @@
|
||||
Imports DevExpress.Utils
|
||||
Imports DevExpress.Utils.VisualEffects
|
||||
Imports DevExpress.XtraLayout
|
||||
Imports DigitalData.GUIs.Common
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Validator
|
||||
Inherits BaseClass
|
||||
Public Sub New(pLogConfig As LogConfig, pLayoutControl As LayoutControl, pAdornerUIManager As AdornerUIManager, pControlHelper As ControlHelper)
|
||||
MyBase.New(pLogConfig)
|
||||
Me.LayoutControl = pLayoutControl
|
||||
Me.AdornerUIManager = pAdornerUIManager
|
||||
Me.ControlHelper = pControlHelper
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property LayoutControl As LayoutControl
|
||||
Public ReadOnly Property AdornerUIManager As AdornerUIManager
|
||||
Public ReadOnly Property ControlHelper As ControlHelper
|
||||
|
||||
Public Function Validate(pSearch As Search) As Boolean
|
||||
With AdornerUIManager.ValidationHintProperties
|
||||
.State = ValidationHintState.Invalid
|
||||
.InvalidState.ShowBorder = True
|
||||
.InvalidState.ShowBackgroundMode = ValidationHintBackgroundMode.Target
|
||||
End With
|
||||
|
||||
AdornerUIManager.Hide()
|
||||
AdornerUIManager.Elements.Clear()
|
||||
|
||||
Dim oMissingParams As Boolean = False
|
||||
Dim oControls As New List(Of Control)
|
||||
|
||||
For Each oItem As Control In LayoutControl.Controls
|
||||
|
||||
Dim oParam = pSearch.Parameters.
|
||||
Where(Function(param) param.PatternTitle = oItem.Name).
|
||||
FirstOrDefault()
|
||||
|
||||
If oParam Is Nothing Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
oControls.Add(oItem)
|
||||
|
||||
If oParam.Required And Not ControlHelper.HasValue(oItem) Then
|
||||
AdornerUIManager.Elements.Add(New ValidationHint With {
|
||||
.TargetElement = oItem,
|
||||
.Visible = True
|
||||
})
|
||||
oMissingParams = True
|
||||
End If
|
||||
Next
|
||||
|
||||
AdornerUIManager.Show()
|
||||
|
||||
Return oMissingParams
|
||||
End Function
|
||||
|
||||
Public Function GetControlsWithParams(pSearch As Search) As List(Of Control)
|
||||
Dim oControls As New List(Of Control)
|
||||
|
||||
For Each oItem As Control In LayoutControl.Controls
|
||||
|
||||
Dim oParam = pSearch.Parameters.
|
||||
Where(Function(param) param.PatternTitle = oItem.Name).
|
||||
FirstOrDefault()
|
||||
|
||||
If oParam Is Nothing Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
oControls.Add(oItem)
|
||||
|
||||
Next
|
||||
|
||||
Return oControls
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user