first pass of new layout loading and editing
This commit is contained in:
@@ -1,26 +1,137 @@
|
||||
Public Class frmDesignerLayout
|
||||
Dim DT_Foms As DataTable
|
||||
Imports System.IO
|
||||
Imports System.Text.Encoding
|
||||
Imports DevExpress.XtraBars
|
||||
Imports DevExpress.XtraLayout
|
||||
Imports DevExpress.XtraLayout.Customization
|
||||
Imports DevExpress.XtraLayout.Dragging
|
||||
Imports DevExpress.XtraLayout.HitInfo
|
||||
Imports DevExpress.XtraToolbox
|
||||
|
||||
Public Class frmDesignerLayout
|
||||
Private SelectedLayoutId As Integer = 0
|
||||
Private FormsDatatable As DataTable
|
||||
Private _ControlLoader As ControlLoader
|
||||
|
||||
#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 & Guid.NewGuid().ToString().GetHashCode().ToString("x")
|
||||
Dim oControl As Control = _ControlLoader.CreateLayoutControl(oLayoutControl.Tag, oControlName, 0)
|
||||
|
||||
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
|
||||
|
||||
Private Function CreateLayoutControlItem(Id As String) As LayoutControlItem
|
||||
Return New LayoutControlItem() With {.Tag = Id}
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
Private Sub frmDesignerLayout_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
Try
|
||||
_ControlLoader = New ControlLoader(LOGCONFIG, LayoutControlGroupMain)
|
||||
|
||||
Dim oSQL = "Select * from TBIDB_LAYOUT_CONFIG"
|
||||
DT_Foms = ClassDatabase.Return_Datatable_ConStr(oSQL, CONNECTION_STRING_IDB)
|
||||
If Not IsNothing(DT_Foms) Then
|
||||
For Each oRow As DataRow In DT_Foms.Rows
|
||||
BarListItem1.Strings.Add(oRow.Item("TITLE"))
|
||||
FormsDatatable = ClassDatabase.Return_Datatable_ConStr(oSQL, CONNECTION_STRING_IDB)
|
||||
If Not IsNothing(FormsDatatable) Then
|
||||
For Each oRow As DataRow In FormsDatatable.Rows
|
||||
Dim oItem As New BarButtonItem(RibbonControl1.Manager, oRow.Item("TITLE"))
|
||||
oItem.Tag = oRow.Item("GUID")
|
||||
AddHandler oItem.ItemClick, AddressOf Item_Click
|
||||
|
||||
BarListItem1.ItemLinks.Add(oItem)
|
||||
Next
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in FormLoad:" & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub BarListItem1_ListItemClick(sender As Object, e As DevExpress.XtraBars.ListItemClickEventArgs) Handles BarListItem1.ListItemClick
|
||||
Dim barlistItem = e.Item
|
||||
' Dim oSelectedText = e.Item.str
|
||||
Private Sub Item_Click(sender As Object, e As ItemClickEventArgs)
|
||||
SelectedLayoutId = e.Item.Tag
|
||||
Dim oRow As DataRow = FormsDatatable.Select($"GUID = {SelectedLayoutId}").First()
|
||||
'Dim oXml = oRow.Item("XML_CONTENT")
|
||||
Dim b As Byte() = System.Convert.FromBase64String(oRow.Item("XML_CONTENT"))
|
||||
|
||||
Using oStream As New MemoryStream(b, False)
|
||||
LayoutControlMain.RestoreLayoutFromStream(oStream)
|
||||
End Using
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||
LayoutControl1.sa
|
||||
Private Sub BarButtonItem2_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
||||
Using oStream As New MemoryStream()
|
||||
LayoutControlMain.SaveLayoutToStream(oStream)
|
||||
Dim oBase64 = System.Convert.ToBase64String(oStream.ToArray())
|
||||
'Dim oXml As String = UTF8.GetString(oStream.ToArray())
|
||||
Dim oSql As String = $"UPDATE TBIDB_LAYOUT_CONFIG SET XML_CONTENT = '{oBase64}' WHERE GUID = {SelectedLayoutId}"
|
||||
|
||||
ClassDatabase.Execute_non_Query_ConStr(oSql, CONNECTION_STRING_IDB)
|
||||
End Using
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user