jj: Anzeige der Controls anpassen, ClassControlCreator benutzen
This commit is contained in:
204
app/DD_PM_WINDREAM/ClassControlCreator.vb
Normal file
204
app/DD_PM_WINDREAM/ClassControlCreator.vb
Normal file
@@ -0,0 +1,204 @@
|
||||
Imports DD_LIB_Standards
|
||||
|
||||
Public Class ClassControlCreator
|
||||
|
||||
''' <summary>
|
||||
''' Konstanten
|
||||
''' </summary>
|
||||
Private Const LABEL_TEXT = "Bezeichnung definieren"
|
||||
|
||||
Private Const DEFAULT_FONT_SIZE As Integer = 10
|
||||
Private Const DEFAULT_FONT_FAMILY As String = "Arial"
|
||||
Private Const DEFAULT_FONT_STYLE As FontStyle = FontStyle.Regular
|
||||
Private Const DEFAULT_COLOR As Integer = 0
|
||||
Private Const DEFAULT_WIDTH As Integer = 170
|
||||
Private Const DEFAULT_HEIGHT As Integer = 20
|
||||
|
||||
Private Const PREFIX_TEXTBOX = "TXT"
|
||||
|
||||
''' <summary>
|
||||
''' Standard Eigenschaften für alle Controls
|
||||
''' </summary>
|
||||
Private Class ControlDBProps
|
||||
Public Guid As Integer
|
||||
Public Name As String
|
||||
Public Location As Point
|
||||
Public [Font] As Font
|
||||
Public [Color] As Color
|
||||
End Class
|
||||
|
||||
Private Shared Function TransformDataRow(row As DataRow) As ControlDBProps
|
||||
Dim x As Integer = row.Item("X_LOC")
|
||||
Dim y As Integer = row.Item("Y_LOC")
|
||||
Dim style As FontStyle = NotNull(row.Item("FONT_STYLE"), DEFAULT_FONT_STYLE)
|
||||
Dim size As Single = NotNull(row.Item("FONT_SIZE"), DEFAULT_FONT_SIZE)
|
||||
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))
|
||||
|
||||
Return New ControlDBProps() With {
|
||||
.Guid = Guid,
|
||||
.Name = Name,
|
||||
.Location = Location,
|
||||
.Font = Font,
|
||||
.Color = Color
|
||||
}
|
||||
End Function
|
||||
|
||||
Public Shared Function CreateBaseControl(ctrl As Control, row As DataRow) As Control
|
||||
Dim props As ControlDBProps = TransformDataRow(row)
|
||||
|
||||
ctrl.Tag = props.Guid
|
||||
ctrl.Name = props.Name
|
||||
ctrl.Location = props.Location
|
||||
ctrl.Font = props.Font
|
||||
ctrl.ForeColor = props.Color
|
||||
|
||||
Return ctrl
|
||||
End Function
|
||||
|
||||
' ----------------------- NEW CONTROLS -----------------------
|
||||
|
||||
Public Shared Function CreateNewTextBox(location As Point) As TextBox
|
||||
Dim control As New TextBox With {
|
||||
.Name = $"{PREFIX_TEXTBOX}_{clsTools.ShortGUID()}",
|
||||
.Size = New Size(DEFAULT_WIDTH, DEFAULT_HEIGHT),
|
||||
.Location = location,
|
||||
.ReadOnly = True,
|
||||
.BackColor = Color.White,
|
||||
.Cursor = Cursors.Hand
|
||||
}
|
||||
|
||||
Return control
|
||||
|
||||
End Function
|
||||
|
||||
' ----------------------- EXISITING CONTROLS -----------------------
|
||||
|
||||
Public Shared Function CreateExistingTextbox(row As DataRow, designMode As Boolean) As TextBox
|
||||
Dim control As TextBox = CreateBaseControl(New TextBox(), row)
|
||||
|
||||
control.BackColor = Color.White
|
||||
control.Cursor = Cursors.Hand
|
||||
|
||||
If row.Item("HEIGHT") > 27 Then
|
||||
control.Multiline = True
|
||||
|
||||
End If
|
||||
|
||||
control.Height = row.Item("HEIGHT")
|
||||
control.Width = row.Item("WIDTH")
|
||||
|
||||
If Not designMode Then
|
||||
control.AcceptsReturn = True
|
||||
control.ReadOnly = row.Item("READ_ONLY")
|
||||
control.TabStop = Not row.Item("READ_ONLY")
|
||||
Else
|
||||
control.ReadOnly = True
|
||||
End If
|
||||
|
||||
Return control
|
||||
End Function
|
||||
|
||||
Public Shared Function CreateExistingLabel(row As DataRow, designMode As Boolean) As Label
|
||||
Dim control As Label = CreateBaseControl(New Label(), row)
|
||||
|
||||
control.Text = row.Item("CTRL_TEXT")
|
||||
control.AutoSize = True
|
||||
control.Cursor = Cursors.Hand
|
||||
|
||||
Return control
|
||||
End Function
|
||||
|
||||
Public Shared Function CreateExistingCombobox(row As DataRow, designMode As Boolean) As ComboBox
|
||||
Dim control As ComboBox = CreateBaseControl(New ComboBox(), row)
|
||||
|
||||
control.Cursor = Cursors.Hand
|
||||
control.Size = New Size(row.Item("WIDTH"), row.Item("HEIGHT"))
|
||||
|
||||
If Not designMode Then
|
||||
control.Enabled = Not row.Item("READ_ONLY")
|
||||
control.TabStop = Not row.Item("READ_ONLY")
|
||||
|
||||
control.AutoCompleteMode = AutoCompleteMode.SuggestAppend
|
||||
control.AutoCompleteSource = AutoCompleteSource.ListItems
|
||||
|
||||
End If
|
||||
|
||||
Return control
|
||||
End Function
|
||||
|
||||
Public Shared Function CreateExistingDatepicker(row As DataRow, designMode As Boolean) As DateTimePicker
|
||||
Dim control As DateTimePicker = CreateBaseControl(New DateTimePicker(), row)
|
||||
|
||||
control.Cursor = Cursors.Hand
|
||||
control.Size = New Size(row.Item("WIDTH"), row.Item("HEIGHT"))
|
||||
control.Format = DateTimePickerFormat.Short
|
||||
|
||||
If Not designMode Then
|
||||
control.Enabled = Not row.Item("READ_ONLY")
|
||||
control.TabStop = Not row.Item("READ_ONLY")
|
||||
End If
|
||||
|
||||
Return control
|
||||
End Function
|
||||
|
||||
Public Shared Function CreateExisingCheckbox(row As DataRow, designMode As Boolean) As CheckBox
|
||||
Dim control As CheckBox = CreateBaseControl(New CheckBox(), row)
|
||||
|
||||
control.AutoSize = True
|
||||
control.Text = row.Item("CTRL_TEXT")
|
||||
control.Cursor = Cursors.Hand
|
||||
|
||||
Return control
|
||||
End Function
|
||||
|
||||
Public Shared Function CreateExistingDataGridView(row As DataRow, designMode As Boolean) As DataGridView
|
||||
Dim control As DataGridView = CreateBaseControl(New DataGridView(), row)
|
||||
|
||||
control.Size = New Size(row.Item("WIDTH"), row.Item("HEIGHT"))
|
||||
control.Cursor = Cursors.Hand
|
||||
control.AllowUserToAddRows = False
|
||||
control.AllowUserToDeleteRows = False
|
||||
control.AllowUserToResizeColumns = False
|
||||
control.AllowUserToResizeRows = False
|
||||
control.AlternatingRowsDefaultCellStyle.BackColor = Color.Aqua
|
||||
|
||||
Dim col As New DataGridViewTextBoxColumn
|
||||
col.HeaderText = ""
|
||||
col.Name = "column1"
|
||||
col.Width = control.Width - 30
|
||||
control.Columns.Add(col)
|
||||
|
||||
Return control
|
||||
End Function
|
||||
|
||||
Public Shared Function CreateExistingTable(row As DataRow, columns As List(Of DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow), designMode As Boolean) As DataGridView
|
||||
Dim control As DataGridView = CreateBaseControl(New DataGridView(), row)
|
||||
|
||||
control.Size = New Size(row.Item("WIDTH"), row.Item("HEIGHT"))
|
||||
control.Cursor = Cursors.Hand
|
||||
control.AllowUserToAddRows = False
|
||||
control.AllowUserToDeleteRows = False
|
||||
control.AllowUserToResizeColumns = False
|
||||
control.AllowUserToResizeRows = False
|
||||
|
||||
For Each column As DD_DMSLiteDataSet.TBPM_CONTROL_TABLERow In columns
|
||||
Dim col As New DataGridViewTextBoxColumn() With {
|
||||
.HeaderText = column.SPALTEN_HEADER,
|
||||
.Name = column.SPALTENNAME,
|
||||
.Width = column.SPALTENBREITE
|
||||
}
|
||||
|
||||
control.Columns.Add(col)
|
||||
Next
|
||||
|
||||
Return control
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user