From 82376122c8f07bc14ad110b8b0d9dbcea680196b Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 22 Jan 2019 17:00:02 +0100 Subject: [PATCH] jj: add initial propertygrid functions --- EDMI_ClientSuite/EDMI_ClientSuite.vbproj | 2 + .../EntityDesigner/ClassControlBuilder.vb | 14 +++-- .../EntityDesigner/ClassControlUtils.vb | 1 + .../ControlProperties/ClassBaseProperties.vb | 10 +++ .../ControlProperties/ClassLabelProperties.vb | 7 +++ .../frmEntityDesigner.Designer.vb | 62 +++++++++---------- .../EntityDesigner/frmEntityDesigner.vb | 43 ++++++++++--- 7 files changed, 93 insertions(+), 46 deletions(-) create mode 100644 EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassBaseProperties.vb create mode 100644 EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassLabelProperties.vb diff --git a/EDMI_ClientSuite/EDMI_ClientSuite.vbproj b/EDMI_ClientSuite/EDMI_ClientSuite.vbproj index c7a752d2..830ac6ac 100644 --- a/EDMI_ClientSuite/EDMI_ClientSuite.vbproj +++ b/EDMI_ClientSuite/EDMI_ClientSuite.vbproj @@ -180,6 +180,8 @@ + + frmEntityDesigner.vb diff --git a/EDMI_ClientSuite/EntityDesigner/ClassControlBuilder.vb b/EDMI_ClientSuite/EntityDesigner/ClassControlBuilder.vb index ea8587df..3bee6344 100644 --- a/EDMI_ClientSuite/EntityDesigner/ClassControlBuilder.vb +++ b/EDMI_ClientSuite/EntityDesigner/ClassControlBuilder.vb @@ -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 { diff --git a/EDMI_ClientSuite/EntityDesigner/ClassControlUtils.vb b/EDMI_ClientSuite/EntityDesigner/ClassControlUtils.vb index 667696a1..252ea377 100644 --- a/EDMI_ClientSuite/EntityDesigner/ClassControlUtils.vb +++ b/EDMI_ClientSuite/EntityDesigner/ClassControlUtils.vb @@ -6,5 +6,6 @@ Public Class ControlMetadata Public Id As Integer + Public Type As ControlType End Class End Class diff --git a/EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassBaseProperties.vb b/EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassBaseProperties.vb new file mode 100644 index 00000000..66f10403 --- /dev/null +++ b/EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassBaseProperties.vb @@ -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 + diff --git a/EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassLabelProperties.vb b/EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassLabelProperties.vb new file mode 100644 index 00000000..0c6e4d16 --- /dev/null +++ b/EDMI_ClientSuite/EntityDesigner/ControlProperties/ClassLabelProperties.vb @@ -0,0 +1,7 @@ +Namespace ControlProperties + Public Class ClassLabelProperties + Inherits ClassBaseProperties + End Class + +End Namespace + diff --git a/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.Designer.vb b/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.Designer.vb index 7fe2dde0..d43b2c31 100644 --- a/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.Designer.vb +++ b/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.Designer.vb @@ -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 diff --git a/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.vb b/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.vb index 79573c7f..d939906f 100644 --- a/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.vb +++ b/EDMI_ClientSuite/EntityDesigner/frmEntityDesigner.vb @@ -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}")