This commit is contained in:
SchreiberM
2016-04-19 11:10:28 +02:00
10 changed files with 378 additions and 315 deletions

View File

@@ -82,6 +82,40 @@ Public Class ClassControlBuilder
End If
End Sub
Private Sub OnEnabledChanged(sender As Object, e As EventArgs)
Dim control As Control = DirectCast(sender, Control)
' Checkbox, radiobutton, label ist sonderfall
If control.GetType() = GetType(CheckBox) Or _
control.GetType() = GetType(RadioButton) Or _
control.GetType() = GetType(Label) Then
' Hier wird nur die vordergrund-farbe geändert
control.ForeColor = Color.Black
Exit Sub
End If
If control.Enabled Then
control.BackColor = Color.White
control.ForeColor = Color.Black
ElseIf control.Enabled = False Then
control.BackColor = System.Drawing.SystemColors.Info
control.ForeColor = Color.Black 'System.Drawing.SystemColors.InfoText
End If
End Sub
' Wie OnEnabledChanged, nur für TextBVi
Private Sub OnReadOnlyChanged(sender As Object, e As EventArgs)
Dim control As TextBox = DirectCast(sender, TextBox)
If control.ReadOnly = False Then
control.BackColor = Color.White
control.ForeColor = Color.Black
ElseIf control.ReadOnly = True Then
control.BackColor = System.Drawing.SystemColors.Info
control.ForeColor = Color.Black 'System.Drawing.SystemColors.InfoText
End If
End Sub
Public Sub OnTextBoxFocus(sender As Object, ByVal e As EventArgs)
Dim box As TextBox = sender
box.BackColor = Color.LemonChiffon
@@ -96,11 +130,11 @@ Public Class ClassControlBuilder
End Sub
Public Sub OnComboBoxFocus(sender As Object, ByVal e As EventArgs)
Dim combo As ComboBox = sender
Dim combo As CustomComboBox = sender
combo.BackColor = Color.LemonChiffon
End Sub
Public Sub OnComboBoxLostFocus(sender As Object, ByVal e As EventArgs)
Dim combo As ComboBox = sender
Dim combo As CustomComboBox = sender
combo.BackColor = Color.White
End Sub
Dim CONTROL_ID
@@ -115,11 +149,11 @@ Public Class ClassControlBuilder
Dim value
Select Case control.GetType()
Case GetType(ComboBox)
If IsNothing(DirectCast(control, ComboBox).ValueMember) Then
value = DirectCast(control, ComboBox).Text
Case GetType(CustomComboBox)
If IsNothing(DirectCast(control, CustomComboBox).ValueMember) Then
value = DirectCast(control, CustomComboBox).Text
Else
value = DirectCast(control, ComboBox).SelectedValue
value = DirectCast(control, CustomComboBox).SelectedValue
End If
Case Else
Exit Sub
@@ -159,11 +193,11 @@ Public Class ClassControlBuilder
Dim dt As DataTable = ClassDatabase.Return_Datatable(sqlcommand)
Dim obj
obj = dependingControl.GetType.ToString
Select Case dependingControl.GetType.ToString
Select Case dependingControl.GetType().Name
Case "System.Windows.Forms.ComboBox"
ControlLoader.Combobox.SetDataSource(DirectCast(dependingControl, ComboBox), dt)
Case "System.Windows.Forms.Label"
Case "ComboBox"
ControlLoader.Combobox.SetDataSource(DirectCast(dependingControl, CustomComboBox), dt)
Case "Label"
If dt.Rows.Count = 1 Then
Try
ControlLoader.Label.LoadValue(DirectCast(dependingControl, Label), 9999, 9999, dt.Rows(0).Item(0).ToString, True)
@@ -171,7 +205,7 @@ Public Class ClassControlBuilder
ClassLogger.Add(ex.Message)
End Try
End If
Case "System.Windows.Forms.TextBox"
Case "TextBox"
If dt.Rows.Count = 1 Then
Try
Dim value1 As String = dt.Rows(0).Item(0)
@@ -228,7 +262,7 @@ Public Class ClassControlBuilder
' Dim dependingControlId As Integer = datatable.Rows(0).Item("GUID")
' Dim panel As Panel = DirectCast(control.Parent, Panel)
' ' Über die Id das Control finden
' Dim dependingControl As ComboBox = panel.Controls.OfType(Of ComboBox)().Where(Function(c As ComboBox)
' Dim dependingControl As CustomComboBox = panel.Controls.OfType(Of CustomComboBox)().Where(Function(c As CustomComboBox)
' Return DirectCast(c.Tag, ClassControlMetadata).Id = dependingControlId
' End Function).SingleOrDefault()
@@ -267,43 +301,64 @@ Public Class ClassControlBuilder
AddHandler control.MouseHover, AddressOf MouseHover
Select Case type
Case "Label"
Dim label As Label = CType(control, Label)
AddHandler label.EnabledChanged, AddressOf OnEnabledChanged
Case "TextBox"
Dim textbox As TextBox = CType(control, TextBox)
AddHandler textbox.TextChanged, AddressOf RecordChanged
AddHandler textbox.GotFocus, AddressOf OnTextBoxFocus
AddHandler textbox.LostFocus, AddressOf OnTextBoxLostFocus
AddHandler textbox.TextChanged, AddressOf OnTextBoxTextChanged
AddHandler textbox.ReadOnlyChanged, AddressOf OnReadOnlyChanged
Case "ComboBox"
Dim combo As ComboBox = CType(control, ComboBox)
Dim combo As CustomComboBox = CType(control, CustomComboBox)
AddHandler combo.SelectedValueChanged, AddressOf RecordChanged
AddHandler combo.SelectedValueChanged, AddressOf OnComboBoxValueChanged
AddHandler combo.TextChanged, AddressOf RecordChanged
AddHandler combo.GotFocus, AddressOf OnComboBoxFocus
AddHandler combo.LostFocus, AddressOf OnComboBoxLostFocus
'AddHandler combo.GotFocus, AddressOf OnComboBoxFocus
'AddHandler combo.LostFocus, AddressOf OnComboBoxLostFocus
AddHandler combo.EnabledChanged, AddressOf OnEnabledChanged
Case "RadioButton"
Dim radiobutton As RadioButton = CType(control, RadioButton)
AddHandler radiobutton.CheckedChanged, AddressOf RecordChanged
AddHandler radiobutton.EnabledChanged, AddressOf OnEnabledChanged
Case "CheckBox"
Dim checkbox As CheckBox = CType(control, CheckBox)
AddHandler checkbox.CheckedChanged, AddressOf RecordChanged
AddHandler checkbox.EnabledChanged, AddressOf OnEnabledChanged
Case "PictureBox"
Dim picturebox As PictureBox = CType(control, PictureBox)
AddHandler picturebox.BackgroundImageChanged, AddressOf RecordChanged
AddHandler picturebox.EnabledChanged, AddressOf OnEnabledChanged
Case "DateEdit"
Dim datetimepick As DevExpress.XtraEditors.DateEdit = CType(control, DevExpress.XtraEditors.DateEdit)
AddHandler datetimepick.DateTimeChanged, AddressOf RecordChanged
AddHandler datetimepick.EnabledChanged, AddressOf OnEnabledChanged
Case "ListBoxControl"
Dim listbox As DevExpress.XtraEditors.ListBoxControl = CType(control, DevExpress.XtraEditors.ListBoxControl)
AddHandler listbox.SelectedValueChanged, AddressOf RecordChanged
AddHandler listbox.EnabledChanged, AddressOf OnEnabledChanged
Case "CheckedListBoxControl"
Dim chklistbox As DevExpress.XtraEditors.CheckedListBoxControl = CType(control, DevExpress.XtraEditors.CheckedListBoxControl)
AddHandler chklistbox.ItemCheck, AddressOf RecordChanged
AddHandler chklistbox.EnabledChanged, AddressOf OnEnabledChanged
Case "DataGridView"
Dim gridview As DataGridView = CType(control, DataGridView)
AddHandler gridview.RowsAdded, AddressOf RecordChanged
AddHandler gridview.CellValueChanged, AddressOf RecordChanged
AddHandler gridview.RowsRemoved, AddressOf RecordChanged
AddHandler gridview.EnabledChanged, AddressOf OnEnabledChanged
End Select
End Sub
@@ -480,7 +535,7 @@ Public Class ClassControlBuilder
End If
End Sub
Private Sub AddComboHandler(control As ComboBox, format As String)
Private Sub AddComboHandler(control As CustomComboBox, format As String)
If format = "Currency" Then
AddHandler control.Leave, AddressOf Combo_Currency_Handler
ElseIf format = "Decimal" Then
@@ -510,7 +565,7 @@ Public Class ClassControlBuilder
End Sub
Private Sub Combo_Currency_Handler(sender As Object, e As EventArgs)
Dim control As ComboBox = DirectCast(sender, ComboBox)
Dim control As CustomComboBox = DirectCast(sender, CustomComboBox)
Dim value As Decimal
If Decimal.TryParse(control.Text.Trim(), value) Then
control.Text = value.ToString("c")
@@ -521,7 +576,7 @@ Public Class ClassControlBuilder
End Sub
Private Sub Combo_Decimal_Handler(sender As Object, e As EventArgs)
Dim control As ComboBox = DirectCast(sender, ComboBox)
Dim control As CustomComboBox = DirectCast(sender, CustomComboBox)
Dim value As Decimal
If Decimal.TryParse(control.Text.Trim(), value) Then
control.Text = value.ToString("###,###")
@@ -544,31 +599,32 @@ Public Class ClassControlBuilder
Public Sub SetActiveColor(ActiveControl As Control)
Dim ActiveColor As Color = Color.DarkOrange
Dim CurrentType As String = ActiveControl.GetType.ToString
Dim CurrentType As String = ActiveControl.GetType().Name
Select Case CurrentType
Case "System.Windows.Forms.TextBox"
Case "TextBox"
ActiveControl.BackColor = ActiveColor
Case "System.Windows.Forms.ComboBox"
Case "ComboBox"
'Case "System.Windows.Forms.ComboBox"
ActiveControl.BackColor = ActiveColor
Case "System.Windows.Forms.Label"
Case "Label"
ActiveControl.BackColor = ActiveColor
Case "System.Windows.Forms.CheckBox"
Case "CheckBox"
ActiveControl.BackColor = ActiveColor
Case "System.Windows.Forms.Button"
Case "Button"
ActiveControl.BackColor = ActiveColor
Case "System.Windows.Forms.DataGridView"
Case "DataGridView"
Dim current As DataGridView = DirectCast(ActiveControl, DataGridView)
current.BackgroundColor = ActiveColor
Case "DevExpress.XtraEditors.DateEdit"
Case "DateEdit"
ActiveControl.BackColor = ActiveColor
Case "System.Window.Forms.GroupBox"
Case "GroupBox"
ActiveControl.BackColor = ActiveColor
Case "System.Windows.Forms.PictureBox"
Case "PictureBox"
ActiveControl.BackColor = ActiveColor
Case "DevExpress.XtraEditors.CheckedListBoxControl"
Case "CheckedListBoxControl"
ActiveControl.BackColor = ActiveColor
Case "DevExpress.XtraEditors.ListBoxControl"
Case "ListBoxControl"
ActiveControl.BackColor = ActiveColor
End Select
End Sub
@@ -576,56 +632,58 @@ Public Class ClassControlBuilder
Public Sub ResetActiveColor(ActiveControl As Control)
For Each inctrl As Control In Me._master_panel.Controls
If inctrl.Name <> ActiveControl.Name Then
Dim Type As String = inctrl.GetType.ToString
Dim Type As String = inctrl.GetType().Name
Select Case Type
Case "System.Windows.Forms.TextBox"
Case "TextBox"
inctrl.BackColor = Color.White
Case "System.Windows.Forms.ComboBox"
Case "ComboBox"
'Case "System.Windows.Forms.ComboBox"
inctrl.BackColor = Color.White
Case "System.Windows.Forms.Label"
Case "Label"
inctrl.BackColor = Color.Transparent
Case "System.Windows.Forms.CheckBox"
Case "CheckBox"
inctrl.BackColor = Color.Transparent
Case "System.Windows.Forms.DataGridView"
Case "DataGridView"
Dim ctrl As DataGridView = DirectCast(inctrl, DataGridView)
ctrl.BackgroundColor = SystemColors.ControlDark
Case "DevExpress.XtraEditors.DateEdit"
Case "DateEdit"
inctrl.BackColor = Color.White
Case "System.Windows.Forms.Button"
Case "Button"
inctrl.BackColor = SystemColors.Control
Case "System.Windows.Forms.GroupBox"
Case "GroupBox"
inctrl.BackColor = SystemColors.Control
Case "DevExpress.XtraEditors.CheckedListBoxControl"
Case "CheckedListBoxControl"
inctrl.BackColor = Color.White
Case "DevExpress.XtraEditors.ListBoxControl"
Case "ListBoxControl"
inctrl.BackColor = Color.White
Case "System.Windows.Forms.PictureBox"
Case "PictureBox"
inctrl.BackColor = SystemColors.ControlDark
For Each gbctrl As Control In inctrl.Controls
If gbctrl.Name <> ActiveControl.Name Then
Dim gbType As String = gbctrl.GetType.ToString
Select Case gbType
Case "System.Windows.Forms.TextBox"
Case "TextBox"
gbctrl.BackColor = Color.White
Case "System.Windows.Forms.ComboBox"
Case "ComboBox"
'Case "System.Windows.Forms.ComboBox"
gbctrl.BackColor = Color.White
Case "System.Windows.Forms.Label"
Case "Label"
gbctrl.BackColor = Color.Transparent
Case "System.Windows.Forms.CheckBox"
Case "CheckBox"
gbctrl.BackColor = Color.Transparent
Case "System.Windows.Forms.DataGridView"
Case "DataGridView"
Dim ctrl As DataGridView = DirectCast(gbctrl, DataGridView)
ctrl.BackgroundColor = SystemColors.ControlDark
Case "DevExpress.XtraEditors.DateEdit"
Case "DateEdit"
gbctrl.BackColor = Color.White
Case "System.Windows.Forms.Button"
Case "Button"
gbctrl.BackColor = SystemColors.Control
Case "System.Windows.Forms.PictureBox"
Case "PictureBox"
inctrl.BackColor = SystemColors.ControlDark
Case "DevExpress.XtraEditors.CheckedListBoxControl"
Case "CheckedListBoxControl"
inctrl.BackColor = Color.White
Case "DevExpress.XtraEditors.ListBoxControl"
Case "ListBoxControl"
inctrl.BackColor = Color.White
End Select
End If
@@ -988,7 +1046,9 @@ Public Class ClassControlBuilder
Optional parent As GroupBox = Nothing,
Optional _designMode As Boolean = False)
Try
Dim control As New ComboBox
Dim _control As New ComboBox
Dim control As New CustomComboBox
Dim defaultSize As Size = New Size(120, 24)
Dim metadata As New ClassControlMetadata()
@@ -1036,7 +1096,7 @@ Public Class ClassControlBuilder
End If
Me.SetEventHandlers(control)
Me.CurrentControl = DirectCast(control, ComboBox)
Me.CurrentControl = DirectCast(control, CustomComboBox)
If Not IsNothing(parent) Then
control.Parent = parent
Me.AddToGroupBox(parent, control)
@@ -1049,7 +1109,7 @@ Public Class ClassControlBuilder
End Try
End Sub
Public Sub AutoCompleteCombo_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs)
Public Sub AutoCompleteCombo_KeyUp(ByVal cbo As CustomComboBox, ByVal e As KeyEventArgs)
''Allow select keys without Autocompleting
Select Case e.KeyCode
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down
@@ -1093,7 +1153,7 @@ Public Class ClassControlBuilder
'End If
End Sub
Public Sub AutoCompleteCombo_Leave(ByVal cbo As ComboBox)
Public Sub AutoCompleteCombo_Leave(ByVal cbo As CustomComboBox)
Dim iFoundIndex As Integer
iFoundIndex = cbo.FindStringExact(cbo.Text)
cbo.SelectedIndex = iFoundIndex