80 lines
2.4 KiB
VB.net
80 lines
2.4 KiB
VB.net
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
|