change control tag to be metadata class

This commit is contained in:
Jonathan Jenne
2019-10-17 13:54:26 +02:00
parent 0ec31f0cc3
commit 037b7c6748
4 changed files with 112 additions and 67 deletions

View File

@@ -42,6 +42,12 @@ Public Class ClassControlCreator
Public Location As Point
Public [Font] As Font
Public [Color] As Color
Public [ReadOnly] As Boolean
End Class
Public Class ControlMetadata
Public Guid As Integer
Public [ReadOnly] As Boolean
End Class
Private Shared Function TransformDataRow(row As DataRow) As ControlDBProps
@@ -52,25 +58,31 @@ Public Class ClassControlCreator
Dim familyString As String = NotNull(row.Item("FONT_FAMILY"), DEFAULT_FONT_FAMILY)
Dim family As FontFamily = New FontFamily(familyString)
Dim Guid As Integer = row.Item("GUID")
Dim Name As String = row.Item("NAME")
Dim Location As New Point(x, y)
Dim Font As New Font(family, size, style, GraphicsUnit.Point)
Dim Color As Color = IntToColor(NotNull(row.Item("FONT_COLOR"), DEFAULT_COLOR))
Dim oGuid As Integer = row.Item("GUID")
Dim oName As String = row.Item("NAME")
Dim oLocation As New Point(x, y)
Dim oFont As New Font(family, size, style, GraphicsUnit.Point)
Dim oColor As Color = IntToColor(NotNull(row.Item("FONT_COLOR"), DEFAULT_COLOR))
Dim oReadOnly As Boolean = row.Item("READ_ONLY")
Return New ControlDBProps() With {
.Guid = Guid,
.Name = Name,
.Location = Location,
.Font = Font,
.Color = Color
.Guid = oGuid,
.Name = oName,
.Location = oLocation,
.Font = oFont,
.Color = oColor,
.ReadOnly = oReadOnly
}
End Function
Public Shared Function CreateBaseControl(ctrl As Control, row As DataRow, designMode As Boolean) As Control
Dim props As ControlDBProps = TransformDataRow(row)
ctrl.Tag = props.Guid
ctrl.Tag = New ControlMetadata() With {
.Guid = props.Guid,
.ReadOnly = props.ReadOnly
}
'ctrl.Tag = props.Guid
ctrl.Name = props.Name
ctrl.Location = props.Location
ctrl.Font = props.Font
@@ -80,6 +92,10 @@ Public Class ClassControlCreator
ctrl.Cursor = Cursors.Hand
End If
If props.ReadOnly Then
ctrl.BackColor = Color.Gray
End If
Return ctrl
End Function