New Form Designer \o/
This commit is contained in:
@@ -1,21 +1,109 @@
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraToolbox
|
||||
Imports DevExpress.XtraLayout
|
||||
Imports DevExpress.XtraLayout.Customization
|
||||
Imports DevExpress.XtraLayout.Dragging
|
||||
Imports DevExpress.XtraLayout.HitInfo
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
|
||||
Public Class frmFormDesigner
|
||||
Private Const CONTROL_TEXTEDIT = "TextBox"
|
||||
Private Const CONTROL_MEMOEDIT = "Memoedit"
|
||||
Private Const CONTROL_COMBOEDIT = "Combobox"
|
||||
Private Const CONTROL_CHECKEDIT = "Checkbox"
|
||||
Private Const CONTROL_RADIOEDIT = "Radiobutton"
|
||||
Private Const CONTROL_DATEEDIT = "Datepicker"
|
||||
#Region "Drag Helper"
|
||||
Private _DragItem As BaseLayoutItem
|
||||
Private _Window As DragFrameWindow
|
||||
Private _DragController As LayoutItemDragController = Nothing
|
||||
|
||||
Protected ReadOnly Property DragFrameWindow As DragFrameWindow
|
||||
Get
|
||||
If _Window Is Nothing Then
|
||||
_Window = New DragFrameWindow(LayoutControlMain)
|
||||
End If
|
||||
Return _Window
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Sub ShowDragHelper()
|
||||
DragFrameWindow.Visible = True
|
||||
End Sub
|
||||
|
||||
Private Sub HideDragHelper()
|
||||
DragFrameWindow.Reset()
|
||||
DragFrameWindow.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateDragHelper(p As Point)
|
||||
p = LayoutControlMain.PointToClient(p)
|
||||
_DragController = New LayoutItemDragController(_DragItem, LayoutControlMain.Root, New Point(p.X, p.Y))
|
||||
DragFrameWindow.DragController = _DragController
|
||||
End Sub
|
||||
#End Region
|
||||
#Region "Drag Drop Actions"
|
||||
Private Sub ToolboxControlMain_DragItemDrop(sender As Object, e As ToolboxDragItemDropEventArgs) Handles ToolboxControlMain.DragItemDrop
|
||||
Dim oPosition As Point = LayoutControlMain.PointToClient(MousePosition)
|
||||
Dim oHitInfo As BaseLayoutItemHitInfo = LayoutControlMain.CalcHitInfo(oPosition)
|
||||
Dim oLayoutControl As LayoutControlItem = DirectCast(_DragItem, LayoutControlItem)
|
||||
Dim oControlName As String = oLayoutControl.Tag & ClassUtils.ShortGUID()
|
||||
Dim oControl As Control = GetControl(oLayoutControl.Tag, oControlName)
|
||||
|
||||
If oLayoutControl IsNot Nothing Then
|
||||
HideDragHelper()
|
||||
oLayoutControl.Control = oControl
|
||||
|
||||
If (_DragController IsNot Nothing AndAlso _DragItem IsNot Nothing) Then
|
||||
If (_DragItem.Owner Is Nothing OrElse _DragItem.Parent Is Nothing) Then
|
||||
_DragController.DragWildItem()
|
||||
Else
|
||||
_DragController.Drag()
|
||||
End If
|
||||
Focus()
|
||||
End If
|
||||
HideDragHelper()
|
||||
_DragItem = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ToolboxControlMain_DragItemStart(sender As Object, e As ToolboxDragItemStartEventArgs) Handles ToolboxControlMain.DragItemStart
|
||||
_DragItem = CreateLayoutControlItem(e.Item.Tag)
|
||||
End Sub
|
||||
|
||||
Private Sub ToolboxControlMain_DragItemMove(sender As Object, e As DevExpress.XtraToolbox.ToolboxDragItemMoveEventArgs) Handles ToolboxControlMain.DragItemMove
|
||||
If (CType(LayoutControlMain, ILayoutControl)).EnableCustomizationMode OrElse Me.DesignMode Then Return
|
||||
Dim oFormPosition As Point = PointToClient(e.Location)
|
||||
Dim oLayoutPosition As Point = LayoutControlMain.PointToClient(e.Location)
|
||||
|
||||
If LayoutControlMain.Bounds.Contains(oFormPosition) Then
|
||||
|
||||
If Not DragFrameWindow.Visible Then
|
||||
DragFrameWindow.Visible = True
|
||||
Return
|
||||
End If
|
||||
|
||||
UpdateDragHelper(e.Location)
|
||||
Else
|
||||
DragFrameWindow.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
Private _FormId As Int64
|
||||
|
||||
Public Sub New()
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
_FormId = 104
|
||||
End Sub
|
||||
|
||||
Public Sub New(FormId As Int64)
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
_FormId = FormId
|
||||
End Sub
|
||||
|
||||
Private Sub frmFormDesigner_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
|
||||
Dim oFormId As Int64 = 104
|
||||
|
||||
My.Channel.CreateDatabaseRequest("Load Controls", True)
|
||||
|
||||
Dim oSQL As String = $"SELECT * FROM VWICM_FORMCONTROL WHERE FORMID = {oFormId}"
|
||||
Dim oSQL As String = $"SELECT * FROM VWICM_FORMCONTROL WHERE FORMID = {_FormId}"
|
||||
Dim oResult = My.Channel.ReturnDatatable(oSQL)
|
||||
Dim oTable = oResult.Table
|
||||
|
||||
@@ -28,33 +116,42 @@ Public Class frmFormDesigner
|
||||
LoadControls(oTable)
|
||||
End Sub
|
||||
|
||||
Private Function GetControl(Type As String, Name As String)
|
||||
Dim oEditor As BaseEdit = Nothing
|
||||
|
||||
Select Case Type
|
||||
Case ClassConstants.CONTROL_TEXTEDIT
|
||||
Dim oTextEdit As New TextEdit() With {.Name = Name}
|
||||
oEditor = oTextEdit
|
||||
Case ClassConstants.CONTROL_MEMOEDIT
|
||||
Dim oMemoEdit As New MemoEdit() With {.Name = Name}
|
||||
oEditor = oMemoEdit
|
||||
Case ClassConstants.CONTROL_DATEEDIT
|
||||
Dim oDateEdit As New DateEdit() With {.Name = Name}
|
||||
oEditor = oDateEdit
|
||||
Case ClassConstants.CONTROL_CHECKEDIT
|
||||
Dim oCheckEdit As New CheckEdit() With {.Name = Name}
|
||||
oEditor = oCheckEdit
|
||||
Case ClassConstants.CONTROL_COMBOEDIT
|
||||
Dim oComboEdit As New LookupControl2() With {.Name = Name}
|
||||
oEditor = oComboEdit
|
||||
Case Else
|
||||
oEditor = Nothing
|
||||
End Select
|
||||
|
||||
Return oEditor
|
||||
End Function
|
||||
|
||||
Private Function CreateLayoutControlItem(Id As String) As LayoutControlItem
|
||||
Return New LayoutControlItem() With {.Tag = Id}
|
||||
End Function
|
||||
|
||||
Private Sub LoadControls(Datatable As DataTable)
|
||||
For Each oRow As DataRow In Datatable.Rows
|
||||
|
||||
Dim oEditor As BaseEdit = Nothing
|
||||
Dim oCaption As String = oRow.Item("COLNAME")
|
||||
Dim oControlType As String = oRow.Item("CTRLTYPE")
|
||||
Dim oControlId As String = oRow.Item("RECORD_ID").ToString
|
||||
|
||||
Select Case oControlType
|
||||
Case CONTROL_TEXTEDIT
|
||||
Dim oTextEdit As New TextEdit() With {.Name = oControlId}
|
||||
oEditor = oTextEdit
|
||||
Case CONTROL_MEMOEDIT
|
||||
Dim oMemoEdit As New MemoEdit() With {.Name = oControlId}
|
||||
oEditor = oMemoEdit
|
||||
Case CONTROL_DATEEDIT
|
||||
Dim oDateEdit As New DateEdit() With {.Name = oControlId}
|
||||
oEditor = oDateEdit
|
||||
Case CONTROL_CHECKEDIT
|
||||
Dim oCheckEdit As New CheckEdit() With {.Name = oControlId}
|
||||
oEditor = oCheckEdit
|
||||
Case CONTROL_COMBOEDIT
|
||||
Dim oComboEdit As New ComboBoxEdit() With {.Name = oControlId}
|
||||
oEditor = oComboEdit
|
||||
Case Else
|
||||
|
||||
End Select
|
||||
Dim oEditor As BaseEdit = GetControl(oControlType, oControlId)
|
||||
|
||||
If oEditor Is Nothing Then
|
||||
Continue For
|
||||
@@ -65,4 +162,8 @@ Public Class frmFormDesigner
|
||||
|
||||
LayoutControlGroupMain.AddItem(New EmptySpaceItem())
|
||||
End Sub
|
||||
|
||||
Private Sub LayoutControlMain_ItemSelectionChanged(sender As Object, e As EventArgs) Handles LayoutControlMain.ItemSelectionChanged
|
||||
' TODO: Load Property Grid for selected item
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user