jj: add initial propertygrid functions

This commit is contained in:
Jonathan Jenne 2019-01-22 17:00:02 +01:00
parent 1e0bccdb48
commit 82376122c8
7 changed files with 93 additions and 46 deletions

View File

@ -180,6 +180,8 @@
</Compile>
<Compile Include="EntityDesigner\ClassControlBuilder.vb" />
<Compile Include="EntityDesigner\ClassControlUtils.vb" />
<Compile Include="EntityDesigner\ControlProperties\ClassBaseProperties.vb" />
<Compile Include="EntityDesigner\ControlProperties\ClassLabelProperties.vb" />
<Compile Include="EntityDesigner\frmEntityDesigner.Designer.vb">
<DependentUpon>frmEntityDesigner.vb</DependentUpon>
</Compile>

View File

@ -1,4 +1,6 @@
Public Class ClassControlBuilder
Imports EDMI_ClientSuite.ClassControlUtils
Public Class ClassControlBuilder
#Region "State"
Private _DesignMode As Boolean
#End Region
@ -18,8 +20,9 @@
End Function
Public Function CreateLabel() As Label
Dim Metadata As New ClassControlUtils.ControlMetadata() With {
.Id = 4711
Dim Metadata As New ControlMetadata() With {
.Id = 4711,
.Type = ControlType.Label
}
Dim oLabel As New Label() With {
@ -34,8 +37,9 @@
End Function
Public Function CreateTextbox() As TextBox
Dim Metadata As New ClassControlUtils.ControlMetadata() With {
.Id = 4711
Dim Metadata As New ControlMetadata() With {
.Id = 4711,
.Type = ControlType.TextBox
}
Dim oTextbox As New TextBox() With {

View File

@ -6,5 +6,6 @@
Public Class ControlMetadata
Public Id As Integer
Public Type As ControlType
End Class
End Class

View File

@ -0,0 +1,10 @@
Namespace ControlProperties
Public MustInherit Class ClassBaseProperties
Public Property Id As Integer
Public Property Type As String
Public Property Name As String
End Class
End Namespace

View File

@ -0,0 +1,7 @@
Namespace ControlProperties
Public Class ClassLabelProperties
Inherits ClassBaseProperties
End Class
End Namespace

View File

@ -24,18 +24,18 @@ Partial Class frmEntityDesigner
Private Sub InitializeComponent()
Me.SplitContainerMain = New DevExpress.XtraEditors.SplitContainerControl()
Me.PanelMain = New EDMI_ClientSuite.SnapPanel()
Me.TabControlDetail = New DevExpress.XtraTab.XtraTabControl()
Me.TabControlMain = New DevExpress.XtraTab.XtraTabControl()
Me.TabPageProperties = New DevExpress.XtraTab.XtraTabPage()
Me.PropertyGridControl1 = New DevExpress.XtraVerticalGrid.PropertyGridControl()
Me.PropertyGridMain = New DevExpress.XtraVerticalGrid.PropertyGridControl()
Me.TabPageControls = New DevExpress.XtraTab.XtraTabPage()
Me.btnTextbox = New System.Windows.Forms.Button()
Me.btnLabel = New System.Windows.Forms.Button()
CType(Me.SplitContainerMain, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerMain.SuspendLayout()
CType(Me.TabControlDetail, System.ComponentModel.ISupportInitialize).BeginInit()
Me.TabControlDetail.SuspendLayout()
CType(Me.TabControlMain, System.ComponentModel.ISupportInitialize).BeginInit()
Me.TabControlMain.SuspendLayout()
Me.TabPageProperties.SuspendLayout()
CType(Me.PropertyGridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PropertyGridMain, System.ComponentModel.ISupportInitialize).BeginInit()
Me.TabPageControls.SuspendLayout()
Me.SuspendLayout()
'
@ -46,10 +46,10 @@ Partial Class frmEntityDesigner
Me.SplitContainerMain.Name = "SplitContainerMain"
Me.SplitContainerMain.Panel1.Controls.Add(Me.PanelMain)
Me.SplitContainerMain.Panel1.Text = "Panel1"
Me.SplitContainerMain.Panel2.Controls.Add(Me.TabControlDetail)
Me.SplitContainerMain.Panel2.Controls.Add(Me.TabControlMain)
Me.SplitContainerMain.Panel2.Text = "Panel2"
Me.SplitContainerMain.Size = New System.Drawing.Size(800, 450)
Me.SplitContainerMain.SplitterPosition = 583
Me.SplitContainerMain.SplitterPosition = 571
Me.SplitContainerMain.TabIndex = 0
Me.SplitContainerMain.Text = "SplitContainerControl1"
'
@ -61,41 +61,41 @@ Partial Class frmEntityDesigner
Me.PanelMain.Location = New System.Drawing.Point(0, 0)
Me.PanelMain.Name = "PanelMain"
Me.PanelMain.ShowGrid = True
Me.PanelMain.Size = New System.Drawing.Size(583, 450)
Me.PanelMain.Size = New System.Drawing.Size(571, 450)
Me.PanelMain.TabIndex = 0
'
'TabControlDetail
'TabControlMain
'
Me.TabControlDetail.Dock = System.Windows.Forms.DockStyle.Fill
Me.TabControlDetail.Location = New System.Drawing.Point(0, 0)
Me.TabControlDetail.Name = "TabControlDetail"
Me.TabControlDetail.SelectedTabPage = Me.TabPageProperties
Me.TabControlDetail.Size = New System.Drawing.Size(205, 450)
Me.TabControlDetail.TabIndex = 1
Me.TabControlDetail.TabPages.AddRange(New DevExpress.XtraTab.XtraTabPage() {Me.TabPageControls, Me.TabPageProperties})
Me.TabControlMain.Dock = System.Windows.Forms.DockStyle.Fill
Me.TabControlMain.Location = New System.Drawing.Point(0, 0)
Me.TabControlMain.Name = "TabControlMain"
Me.TabControlMain.SelectedTabPage = Me.TabPageControls
Me.TabControlMain.Size = New System.Drawing.Size(217, 450)
Me.TabControlMain.TabIndex = 0
Me.TabControlMain.TabPages.AddRange(New DevExpress.XtraTab.XtraTabPage() {Me.TabPageControls, Me.TabPageProperties})
'
'TabPageProperties
'
Me.TabPageProperties.Controls.Add(Me.PropertyGridControl1)
Me.TabPageProperties.Controls.Add(Me.PropertyGridMain)
Me.TabPageProperties.Name = "TabPageProperties"
Me.TabPageProperties.Size = New System.Drawing.Size(203, 425)
Me.TabPageProperties.Size = New System.Drawing.Size(215, 425)
Me.TabPageProperties.Text = "Properties"
'
'PropertyGridControl1
'PropertyGridMain
'
Me.PropertyGridControl1.Cursor = System.Windows.Forms.Cursors.Hand
Me.PropertyGridControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.PropertyGridControl1.Location = New System.Drawing.Point(0, 0)
Me.PropertyGridControl1.Name = "PropertyGridControl1"
Me.PropertyGridControl1.Size = New System.Drawing.Size(203, 425)
Me.PropertyGridControl1.TabIndex = 0
Me.PropertyGridMain.Cursor = System.Windows.Forms.Cursors.Hand
Me.PropertyGridMain.Dock = System.Windows.Forms.DockStyle.Fill
Me.PropertyGridMain.Location = New System.Drawing.Point(0, 0)
Me.PropertyGridMain.Name = "PropertyGridMain"
Me.PropertyGridMain.Size = New System.Drawing.Size(215, 425)
Me.PropertyGridMain.TabIndex = 0
'
'TabPageControls
'
Me.TabPageControls.Controls.Add(Me.btnTextbox)
Me.TabPageControls.Controls.Add(Me.btnLabel)
Me.TabPageControls.Name = "TabPageControls"
Me.TabPageControls.Size = New System.Drawing.Size(262, 425)
Me.TabPageControls.Size = New System.Drawing.Size(215, 425)
Me.TabPageControls.Text = "Controls"
'
'btnTextbox
@ -126,19 +126,19 @@ Partial Class frmEntityDesigner
Me.Text = "Entitäten Designer"
CType(Me.SplitContainerMain, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainerMain.ResumeLayout(False)
CType(Me.TabControlDetail, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabControlDetail.ResumeLayout(False)
CType(Me.TabControlMain, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabControlMain.ResumeLayout(False)
Me.TabPageProperties.ResumeLayout(False)
CType(Me.PropertyGridControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PropertyGridMain, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabPageControls.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
Friend WithEvents SplitContainerMain As DevExpress.XtraEditors.SplitContainerControl
Friend WithEvents TabControlDetail As DevExpress.XtraTab.XtraTabControl
Friend WithEvents TabControlMain As DevExpress.XtraTab.XtraTabControl
Friend WithEvents TabPageProperties As DevExpress.XtraTab.XtraTabPage
Friend WithEvents PropertyGridControl1 As DevExpress.XtraVerticalGrid.PropertyGridControl
Friend WithEvents PropertyGridMain As DevExpress.XtraVerticalGrid.PropertyGridControl
Friend WithEvents TabPageControls As DevExpress.XtraTab.XtraTabPage
Friend WithEvents PanelMain As SnapPanel
Friend WithEvents btnTextbox As Button

View File

@ -1,4 +1,5 @@

Imports EDMI_ClientSuite.ClassControlUtils
Imports EDMI_ClientSuite.ControlProperties
Public Class frmEntityDesigner
Private _IsMouseDown As Boolean = False
@ -13,14 +14,13 @@ Public Class frmEntityDesigner
Private Sub frmEntityDesigner_Load(sender As Object, e As EventArgs) Handles Me.Load
' Assign Control Types to DragDrop Buttons
btnLabel.Tag = ClassControlUtils.ControlType.Label
btnTextbox.Tag = ClassControlUtils.ControlType.TextBox
btnLabel.Tag = ControlType.Label
btnTextbox.Tag = ControlType.TextBox
_ControlBuilder = New ClassControlBuilder(DesignMode:=True)
End Sub
#Region "Control Buttons Events"
Private Sub btnControl_MouseDown(sender As Object, e As MouseEventArgs) Handles btnLabel.MouseDown, btnTextbox.MouseDown
_IsMouseDown = True
@ -63,14 +63,13 @@ Public Class frmEntityDesigner
End If
End Sub
Private Sub Control_MouseMove(sender As Control, e As MouseEventArgs)
Private Sub Control_MouseMove(sender As Object, e As MouseEventArgs)
If _CurrentControl Is Nothing Or Not _IsMouseMoving Then
Exit Sub
End If
Cursor = Cursors.Hand
Dim oControl = sender
Dim oCursorPosition As Point = PanelMain.PointToClient(Cursor.Position)
Dim oNewPosition As New Point(oCursorPosition.X - _BeginPosition.X, oCursorPosition.Y - _BeginPosition.Y)
@ -79,7 +78,7 @@ Public Class frmEntityDesigner
Exit Sub
End If
oControl.Location = oNewPosition
_CurrentControl.Location = oNewPosition
End Sub
Private Sub Control_MouseUp(sender As Object, e As MouseEventArgs)
@ -93,21 +92,45 @@ Public Class frmEntityDesigner
Cursor = Cursors.Default
End Sub
Private Sub Control_MouseClick(sender As Control, e As MouseEventArgs)
TabControlMain.SelectedTabPage = TabPageControls
HandleLoadProperties(sender)
End Sub
Private Sub SetEventHandlers(Control As Control)
AddHandler Control.MouseDown, AddressOf Control_MouseDown
AddHandler Control.MouseMove, AddressOf Control_MouseMove
AddHandler Control.MouseUp, AddressOf Control_MouseUp
AddHandler Control.MouseClick, AddressOf Control_MouseClick
End Sub
#End Region
Private Sub HandleDragDrop(type As ClassControlUtils.ControlType)
Private Sub HandleLoadProperties(Control As Control)
Dim oMetadata As ControlMetadata = Control.Tag
Dim oType = oMetadata.Type
Dim oProps As ClassBaseProperties = Nothing
Select Case oType
Case ControlType.Label
oProps = New ClassLabelProperties()
oProps.Id = oMetadata.Id
oProps.Name = Control.Name
oProps.Type = oType
Case Else
Exit Sub
End Select
PropertyGridMain.SelectedObject = oProps
End Sub
Private Sub HandleDragDrop(type As ControlType)
Dim oCursorPosition As Point = PanelMain.PointToClient(Cursor.Position)
Dim oControl As Control = Nothing
Select Case type
Case ClassControlUtils.ControlType.Label
Case ControlType.Label
oControl = _ControlBuilder.CreateLabel()
Case ClassControlUtils.ControlType.TextBox
Case ControlType.TextBox
oControl = _ControlBuilder.CreateTextbox()
Case Else
MsgBox($"Unknown Control Type {type.ToString}")