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 _FormId As Int64 Private _ControlLoader As ClassControlLoader #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 = _ControlLoader.CreateLayoutControl(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 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 Async Sub frmFormDesigner_Load(sender As Object, e As EventArgs) Handles MyBase.Load _ControlLoader = New ClassControlLoader(My.LogConfig) Dim oTable = Await My.Common.Views.VWICM_FORM_CONTROL(_FormId) _ControlLoader.LoadControls(oTable, LayoutControlGroupMain) End Sub Private Function CreateLayoutControlItem(Id As String) As LayoutControlItem Return New LayoutControlItem() With {.Tag = Id} End Function Private Sub LayoutControlMain_ItemSelectionChanged(sender As Object, e As EventArgs) Handles LayoutControlMain.ItemSelectionChanged ' TODO: Load Property Grid for selected item End Sub End Class