Patterns: Improve control values modules, accept list of controls
This commit is contained in:
parent
ef2bb08ddc
commit
960c7ecb27
@ -20,33 +20,66 @@ Namespace Modules
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Function Replace(pInput As String, pPanel As Panel) As String
|
Public Function Replace(pInput As String, pPanel As Panel) As String
|
||||||
|
Dim oControls As List(Of Control) = pPanel.Controls.Cast(Of Control).ToList()
|
||||||
|
Return Replace(pInput, oControls)
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function Replace(pInput As String, pControls As List(Of Control)) As String
|
||||||
Dim oResult = pInput
|
Dim oResult = pInput
|
||||||
Dim oCounter = 0
|
Dim oCounter = 0
|
||||||
|
|
||||||
While ContainsPattern(oResult, PatternIdentifier)
|
While ContainsPattern(oResult, PatternIdentifier)
|
||||||
Try
|
Try
|
||||||
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
|
||||||
Dim oControl As Control = pPanel.Controls.Find(oControlName, False).FirstOrDefault()
|
|
||||||
|
Dim oControl As Control = pControls.
|
||||||
|
Where(Function(control) control.Name = oControlName).
|
||||||
|
FirstOrDefault()
|
||||||
|
|
||||||
If oControl IsNot Nothing Then
|
If oControl IsNot Nothing Then
|
||||||
Dim oReplaceValue As String
|
Dim oReplaceValue As String
|
||||||
Select Case oControl.GetType.ToString
|
Select Case oControl.GetType
|
||||||
Case GetType(TextBox).ToString
|
Case GetType(TextBox)
|
||||||
oReplaceValue = oControl.Text
|
oReplaceValue = oControl.Text
|
||||||
Case GetType(LookupControl3).ToString
|
|
||||||
|
Case GetType(DevExpress.XtraEditors.TextEdit)
|
||||||
|
Dim oTextEdit As DevExpress.XtraEditors.TextEdit = oControl
|
||||||
|
oReplaceValue = oTextEdit.EditValue
|
||||||
|
|
||||||
|
Case GetType(DevExpress.XtraEditors.DateEdit)
|
||||||
|
Dim oDateEdit As DevExpress.XtraEditors.DateEdit = oControl
|
||||||
|
oReplaceValue = oDateEdit.EditValue
|
||||||
|
|
||||||
|
Case GetType(DevExpress.XtraEditors.LookUpEdit)
|
||||||
|
Dim oLookupEdit As DevExpress.XtraEditors.LookUpEdit = oControl
|
||||||
|
oReplaceValue = oLookupEdit.EditValue
|
||||||
|
|
||||||
|
Case GetType(LookupControl3)
|
||||||
Dim oLookupControl3 As LookupControl3 = oControl
|
Dim oLookupControl3 As LookupControl3 = oControl
|
||||||
If oLookupControl3.Properties.SelectedValues.Count = 1 Then
|
If oLookupControl3.Properties.SelectedValues.Count = 1 Then
|
||||||
oReplaceValue = oLookupControl3.Properties.SelectedValues.Item(0)
|
oReplaceValue = oLookupControl3.Properties.SelectedValues.Item(0)
|
||||||
Else
|
Else
|
||||||
oReplaceValue = "0"
|
oReplaceValue = "0"
|
||||||
End If
|
End If
|
||||||
Case GetType(ComboBox).ToString
|
|
||||||
|
Case GetType(ComboBox)
|
||||||
oReplaceValue = oControl.Text
|
oReplaceValue = oControl.Text
|
||||||
Case GetType(CheckBox).ToString
|
|
||||||
|
Case GetType(DevExpress.XtraEditors.ComboBoxEdit)
|
||||||
|
Dim oCombobox As DevExpress.XtraEditors.ComboBoxEdit = oControl
|
||||||
|
oReplaceValue = oCombobox.EditValue
|
||||||
|
|
||||||
|
Case GetType(CheckBox)
|
||||||
Dim oCheckBox As CheckBox = oControl
|
Dim oCheckBox As CheckBox = oControl
|
||||||
oReplaceValue = oCheckBox.Checked
|
oReplaceValue = oCheckBox.Checked
|
||||||
|
|
||||||
|
Case GetType(DevExpress.XtraEditors.CheckEdit)
|
||||||
|
Dim oCheckEdit As DevExpress.XtraEditors.CheckEdit = oControl
|
||||||
|
oReplaceValue = oCheckEdit.Checked
|
||||||
|
|
||||||
Case Else
|
Case Else
|
||||||
oReplaceValue = "0"
|
oReplaceValue = "0"
|
||||||
|
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue)
|
oResult = ReplacePattern(oResult, PatternIdentifier, oReplaceValue)
|
||||||
@ -61,5 +94,6 @@ Namespace Modules
|
|||||||
|
|
||||||
Return oResult
|
Return oResult
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
End Namespace
|
End Namespace
|
||||||
|
|||||||
@ -77,6 +77,18 @@ Public Class Patterns2
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function ReplaceControlValues(pInput As String, pControls As List(Of Control)) As String
|
||||||
|
Try
|
||||||
|
Logger.Debug("Replacing Control Values")
|
||||||
|
Dim oModule = New Modules.Controls(LogConfig)
|
||||||
|
Return oModule.Replace(pInput, pControls)
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Warn("Error occurred while replacing Control Values")
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return pInput
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function ReplaceWindreamValues(pInput As String, pWMObject As WMObject) As String
|
Public Function ReplaceWindreamValues(pInput As String, pWMObject As WMObject) As String
|
||||||
Try
|
Try
|
||||||
Logger.Debug("Replacing Windream Values")
|
Logger.Debug("Replacing Windream Values")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user