From 55c7a7210bfcffb63f51fc456bcb72fa060e68e1 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 1 Mar 2018 15:47:25 +0100 Subject: [PATCH] BAUSTELLE: jj / formDesigner --- app/DD_PM_WINDREAM/ClassControl.vb | 40 ++ app/DD_PM_WINDREAM/ClassControls.vb | 52 ++ app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj | 4 + app/DD_PM_WINDREAM/ModuleControlProperties.vb | 113 +++ app/DD_PM_WINDREAM/UnusedCode.ruleset | 13 + .../frmFormDesigner.Designer.vb | 27 + app/DD_PM_WINDREAM/frmFormDesigner.vb | 643 ++++++++++-------- 7 files changed, 603 insertions(+), 289 deletions(-) create mode 100644 app/DD_PM_WINDREAM/ClassControl.vb create mode 100644 app/DD_PM_WINDREAM/ClassControls.vb create mode 100644 app/DD_PM_WINDREAM/ModuleControlProperties.vb create mode 100644 app/DD_PM_WINDREAM/UnusedCode.ruleset diff --git a/app/DD_PM_WINDREAM/ClassControl.vb b/app/DD_PM_WINDREAM/ClassControl.vb new file mode 100644 index 0000000..a2c3b2c --- /dev/null +++ b/app/DD_PM_WINDREAM/ClassControl.vb @@ -0,0 +1,40 @@ +Public Class ClassControl + Private props As BaseProperties + Private ctrl As Control + + Public Sub New(control As Control) + ctrl = control + + If TypeOf control Is Label Then + props = CreateBasePropertyObject(New LabelProperties()) + ElseIf TypeOf control Is TextBox Then + props = CreateBasePropertyObject(New TextboxProperties()) + End If + End Sub + + Public ReadOnly Property Control As Control + Get + Return ctrl + End Get + End Property + + Public Property Properties As BaseProperties + Get + Return props + End Get + Set(value As BaseProperties) + props = value + End Set + End Property + + Private Function CreateBasePropertyObject(obj As BaseProperties) As BaseProperties + obj.ID = ctrl.Tag + obj.Name = ctrl.Name + obj.Location = ctrl.Location + obj.Width = ctrl.Width + obj.Height = ctrl.Height + + Return obj + End Function + +End Class diff --git a/app/DD_PM_WINDREAM/ClassControls.vb b/app/DD_PM_WINDREAM/ClassControls.vb new file mode 100644 index 0000000..393b6a3 --- /dev/null +++ b/app/DD_PM_WINDREAM/ClassControls.vb @@ -0,0 +1,52 @@ +Public Class ClassControls + Private controls As List(Of ClassControl) + + Public Sub New() + controls = New List(Of ClassControl) + End Sub + + Public Sub Load(datatable As DataTable) + + For Each row As DataRow In datatable.Rows + Dim type As String = row.Item("CTRL_TYPE") + Dim guid As Integer = row.Item("GUID") + Dim name As String = row.Item("NAME") + Dim location As New Point(row.Item("X_LOC"), row.Item("Y_LOC")) + Dim width As Integer = row.Item("WIDTH") + Dim height As Integer = row.Item("HEIGHT") + Dim text As String = row.Item("CTRL_TEXT") + + Dim control As ClassControl + + Select Case type + Case "TXT" + Dim textbox = AddTextbox(guid, name, height, width, location) + control = New ClassControl(textbox) + End Select + + + + + + Next + + End Sub + + Public Function GetAll() As List(Of ClassControl) + Return controls + End Function + + Public Function GetById() As ClassControl + + End Function + + Private Function AddTextbox(id As Integer, name As String, height As Integer, width As Integer, location As Point) + Dim textbox As New TextBox() + + textbox.Tag = id + textbox.Name = name + textbox.Height = height + textbox.Width = width + textbox.Location = location + End Function +End Class diff --git a/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj b/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj index 6479038..dde1daa 100644 --- a/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj +++ b/app/DD_PM_WINDREAM/DD_PM_WINDREAM.vbproj @@ -27,6 +27,7 @@ DD_PM_WINDREAM.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 false + UnusedCode.ruleset x86 @@ -149,6 +150,8 @@ + + @@ -269,6 +272,7 @@ Form + diff --git a/app/DD_PM_WINDREAM/ModuleControlProperties.vb b/app/DD_PM_WINDREAM/ModuleControlProperties.vb new file mode 100644 index 0000000..b806516 --- /dev/null +++ b/app/DD_PM_WINDREAM/ModuleControlProperties.vb @@ -0,0 +1,113 @@ +Imports System.ComponentModel + +Public Module ModuleControlProperties + Private _id As Integer + Private _name As String + Private _location As Point + Private _width As Integer + Private _height As Integer + + Public Class BaseProperties + + Public Property ID() As Integer + Get + Return _id + End Get + Set(value As Integer) + _id = value + End Set + End Property + + Public Property Name() As String + Get + Return _name + End Get + Set(value As String) + _name = value + End Set + End Property + + Public Property Location() As Point + Get + Return _location + End Get + Set(value As Point) + _location = value + End Set + End Property + + Public Property Width() As Integer + Get + Return _width + End Get + Set(value As Integer) + _width = value + End Set + End Property + + Public Property Height() As Integer + Get + Return _height + End Get + Set(value As Integer) + _height = value + End Set + End Property + End Class + + Public Class TextboxProperties + Inherits BaseProperties + + Private _required As Boolean + Private _read_only As Boolean + + Public Property Required() As String + Get + Return _required + End Get + Set(ByVal value As String) + _required = value + End Set + End Property + + Public Property [ReadOnly]() As String + Get + Return _read_only + End Get + Set(ByVal value As String) + _read_only = value + End Set + End Property + End Class + + Public Class LabelProperties + Inherits BaseProperties + + Private _text As String + + Public Property Text() As String + Get + Return _text + End Get + Set(value As String) + _text = value + End Set + End Property + End Class + + Public Class CheckboxProperties + Inherits BaseProperties + + Private _text As String + + Public Property Text() As String + Get + Return _text + End Get + Set(value As String) + _text = value + End Set + End Property + End Class + +End Module diff --git a/app/DD_PM_WINDREAM/UnusedCode.ruleset b/app/DD_PM_WINDREAM/UnusedCode.ruleset new file mode 100644 index 0000000..12af0f7 --- /dev/null +++ b/app/DD_PM_WINDREAM/UnusedCode.ruleset @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/DD_PM_WINDREAM/frmFormDesigner.Designer.vb b/app/DD_PM_WINDREAM/frmFormDesigner.Designer.vb index 3b85c5f..072b919 100644 --- a/app/DD_PM_WINDREAM/frmFormDesigner.Designer.vb +++ b/app/DD_PM_WINDREAM/frmFormDesigner.Designer.vb @@ -81,6 +81,8 @@ Partial Class frmFormDesigner Me.Label4 = New System.Windows.Forms.Label() Me.cmbConnection = New System.Windows.Forms.ComboBox() Me.TBPM_CONNECTIONBindingSource = New System.Windows.Forms.BindingSource(Me.components) + Me.TabPage4 = New System.Windows.Forms.TabPage() + Me.pgControls = New System.Windows.Forms.PropertyGrid() Me.btndelete = New System.Windows.Forms.Button() Me.btnsave = New System.Windows.Forms.Button() Me.X_LOCTextBox = New System.Windows.Forms.TextBox() @@ -120,6 +122,7 @@ Partial Class frmFormDesigner Me.TabPage3.SuspendLayout() Me.pnlAuswahlliste.SuspendLayout() CType(Me.TBPM_CONNECTIONBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() + Me.TabPage4.SuspendLayout() Me.StatusStrip1.SuspendLayout() CType(Me.TBWH_CHECK_PROFILE_CONTROLSBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TBPM_CONTROL_TABLEBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() @@ -384,6 +387,7 @@ Partial Class frmFormDesigner Me.TabControlEigenschaften.Controls.Add(Me.TabPage1) Me.TabControlEigenschaften.Controls.Add(Me.TabPage2) Me.TabControlEigenschaften.Controls.Add(Me.TabPage3) + Me.TabControlEigenschaften.Controls.Add(Me.TabPage4) Me.TabControlEigenschaften.Location = New System.Drawing.Point(12, 22) Me.TabControlEigenschaften.Name = "TabControlEigenschaften" Me.TabControlEigenschaften.SelectedIndex = 0 @@ -791,6 +795,26 @@ Partial Class frmFormDesigner Me.TBPM_CONNECTIONBindingSource.DataMember = "TBPM_CONNECTION" Me.TBPM_CONNECTIONBindingSource.DataSource = Me.DD_DMSLiteDataSet ' + 'TabPage4 + ' + Me.TabPage4.Controls.Add(Me.pgControls) + Me.TabPage4.Location = New System.Drawing.Point(4, 25) + Me.TabPage4.Name = "TabPage4" + Me.TabPage4.Padding = New System.Windows.Forms.Padding(3) + Me.TabPage4.Size = New System.Drawing.Size(447, 234) + Me.TabPage4.TabIndex = 3 + Me.TabPage4.Text = "TabPage4" + Me.TabPage4.UseVisualStyleBackColor = True + ' + 'pgControls + ' + Me.pgControls.Dock = System.Windows.Forms.DockStyle.Fill + Me.pgControls.HelpVisible = False + Me.pgControls.Location = New System.Drawing.Point(3, 3) + Me.pgControls.Name = "pgControls" + Me.pgControls.Size = New System.Drawing.Size(441, 228) + Me.pgControls.TabIndex = 0 + ' 'btndelete ' Me.btndelete.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) @@ -1005,6 +1029,7 @@ Partial Class frmFormDesigner Me.pnlAuswahlliste.ResumeLayout(False) Me.pnlAuswahlliste.PerformLayout() CType(Me.TBPM_CONNECTIONBindingSource, System.ComponentModel.ISupportInitialize).EndInit() + Me.TabPage4.ResumeLayout(False) Me.StatusStrip1.ResumeLayout(False) Me.StatusStrip1.PerformLayout() CType(Me.TBWH_CHECK_PROFILE_CONTROLSBindingSource, System.ComponentModel.ISupportInitialize).EndInit() @@ -1083,4 +1108,6 @@ Partial Class frmFormDesigner Friend WithEvents btnShowConnections As System.Windows.Forms.Button Friend WithEvents btnEditor As Button Friend WithEvents GUIDTextBox As TextBox + Friend WithEvents TabPage4 As TabPage + Friend WithEvents pgControls As PropertyGrid End Class diff --git a/app/DD_PM_WINDREAM/frmFormDesigner.vb b/app/DD_PM_WINDREAM/frmFormDesigner.vb index f0abd60..46ac6cb 100644 --- a/app/DD_PM_WINDREAM/frmFormDesigner.vb +++ b/app/DD_PM_WINDREAM/frmFormDesigner.vb @@ -1,15 +1,7 @@ Public Class frmFormDesigner Private _windreamPM As ClassPMWindream - Dim CursorPosition As Point Private COLUMN_GUID Private MouseIsDown As Boolean = False - ' Used by the MoveMove event handler to show that the - ' setup to move the control has completed - Private m_Moving As Boolean - ''Saves the position - 'Private beginX, beginY As Integer - Private begin_location As System.Drawing.Point - Private end_location As System.Drawing.Point Private idxlbl As Integer = 0 Private idxtxt As Integer = 0 Private idxcmb As Integer = 0 @@ -20,6 +12,10 @@ Dim frmTableColumn As New frmControl_Detail Private CURRENT_CONTROL As Control + ' Movement Variables + Private MouseMoving As Boolean + Private BeginLocation As Point + Private EndLocation As Point Private Sub frmFormDesigner_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing ' @@ -53,7 +49,6 @@ Private Sub frmFormDesigner_Load(sender As Object, e As System.EventArgs) Handles Me.Load - Try Me.lblDesign.Text = "FormDesigner für Profil: " & CURRENT_ProfilName @@ -71,8 +66,8 @@ TBPM_PROFILE_CONTROLSTableAdapter.Connection.ConnectionString = MyConnectionString TBPM_CONNECTIONTableAdapter.Connection.ConnectionString = MyConnectionString TBWH_CHECK_PROFILE_CONTROLSTableAdapter.Connection.ConnectionString = MyConnectionString - Me.TBPM_CONTROL_TABLETableAdapter.Connection.ConnectionString = MyConnectionString - Me.TBPM_CONNECTIONTableAdapter.Fill(Me.DD_DMSLiteDataSet.TBPM_CONNECTION) + TBPM_CONTROL_TABLETableAdapter.Connection.ConnectionString = MyConnectionString + TBPM_CONNECTIONTableAdapter.Fill(DD_DMSLiteDataSet.TBPM_CONNECTION) Catch ex As Exception MsgBox("Fehler bei Laden der Connection-Strings und Grunddaten: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Achtung:") End Try @@ -84,15 +79,15 @@ End Try End Sub Sub Load_indexe() - Me.cmbIndex.Items.Clear() + cmbIndex.Items.Clear() Dim indexe = _windreamPM.GetIndicesByObjecttype(CURRENT_OBJECTTYPE) If indexe IsNot Nothing Then - Me.cmbIndex.Items.Add("") + cmbIndex.Items.Add("") For Each index As String In indexe - Me.cmbIndex.Items.Add(index) + cmbIndex.Items.Add(index) Next - Me.cmbIndex.Items.Add("DD PM-ONLY FOR DISPLAY") - Me.cmbIndex.SelectedIndex = -1 + cmbIndex.Items.Add("DD PM-ONLY FOR DISPLAY") + cmbIndex.SelectedIndex = -1 End If End Sub Sub Load_Indexe_Vektor() @@ -192,8 +187,8 @@ End Sub Sub Controls_laden() Try - Me.TBPM_PROFILE_CONTROLSTableAdapter.FillByProfil(Me.DD_DMSLiteDataSet.TBPM_PROFILE_CONTROLS, CURRENT_ProfilGUID) - 'löscht alle Controls + TBPM_PROFILE_CONTROLSTableAdapter.FillByProfil(DD_DMSLiteDataSet.TBPM_PROFILE_CONTROLS, CURRENT_ProfilGUID) + ' löscht alle Controls pnldesigner.Controls.Clear() Dim dt As DataTable = DD_DMSLiteDataSet.TBPM_PROFILE_CONTROLS @@ -256,7 +251,7 @@ Select Case e.Data.GetData(DataFormats.Text) Case "lbl" 'idxlbl += 1 - add_newlabel("lbl" & random.ToString) + AddNewLabel("lbl" & random.ToString) Case "txt" 'idxtxt += 1 add_newtextbox("txt" & random) @@ -296,7 +291,7 @@ Return 0 End Try End Function - Function add_newlabel(lblname As String) + Function AddNewLabel(lblname As String) Try Dim lbl As New Label lbl.Name = lblname @@ -309,10 +304,12 @@ pnldesigner.Controls.Add(lbl) CURRENT_CONTROL = lbl - AddHandler lbl.Click, AddressOf OnlblClick - AddHandler lbl.MouseDown, AddressOf MovableLabel_MouseDown - AddHandler lbl.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler lbl.MouseMove, AddressOf Control_MouseMove 'MovableLabel_MouseMove + 'AddHandler lbl.Click, AddressOf OnlblClick + 'AddHandler lbl.MouseDown, AddressOf MovableLabel_MouseDown + 'AddHandler lbl.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler lbl.MouseMove, AddressOf Control_MouseMove 'MovableLabel_MouseMove + SetMovementHandlers(lbl) + TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(CURRENT_ProfilGUID, lbl.Name, "LBL", lblname, lbl.Location.X, lbl.Location.Y, Environment.UserName, 16, 200) CURRENT_CONTROL.Tag = GetLastID() 'Load_Control() @@ -331,12 +328,19 @@ lbl.Location = New Point(x, y) pnldesigner.Controls.Add(lbl) - AddHandler lbl.Click, AddressOf OnlblClick - AddHandler lbl.MouseDown, AddressOf MovableLabel_MouseDown - AddHandler lbl.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler lbl.MouseMove, AddressOf Control_MouseMove 'MovableLabel_MouseMove + 'AddHandler lbl.Click, AddressOf OnlblClick + 'AddHandler lbl.MouseDown, AddressOf MovableLabel_MouseDown + 'AddHandler lbl.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler lbl.MouseMove, AddressOf Control_MouseMove 'MovableLabel_MouseMove + + SetMovementHandlers(lbl) + End Function + + + + Private Function GetLastID() Dim sql = String.Format("SELECT MAX(GUID) FROM TBPM_PROFILE_CONTROLS WHERE PROFIL_ID = {0}", CURRENT_ProfilGUID) Return ClassDatabase.Execute_Scalar(sql, MyConnectionString, True) @@ -354,10 +358,12 @@ pnldesigner.Controls.Add(txt) CURRENT_CONTROL = txt - AddHandler txt.Click, AddressOf OntxtClick - AddHandler txt.MouseDown, AddressOf MovableText_MouseDown - AddHandler txt.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler txt.MouseMove, AddressOf Control_MouseMove 'MovableText_MouseMove + 'AddHandler txt.Click, AddressOf OntxtClick + 'AddHandler txt.MouseDown, AddressOf MovableText_MouseDown + 'AddHandler txt.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler txt.MouseMove, AddressOf Control_MouseMove 'MovableText_MouseMove + SetMovementHandlers(txt) + TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(CURRENT_ProfilGUID, txt.Name, "TXT", txtname, txt.Location.X, txt.Location.Y, Environment.UserName, 27, 200) CURRENT_CONTROL.Tag = GetLastID() 'GetControlGUID(txt.Name) @@ -383,10 +389,15 @@ txt.Location = New Point(x, y) txt.BackColor = Color.White pnldesigner.Controls.Add(txt) - AddHandler txt.Click, AddressOf OntxtClick - AddHandler txt.MouseDown, AddressOf MovableText_MouseDown - AddHandler txt.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler txt.MouseMove, AddressOf Control_MouseMove 'MovableText_MouseMove + + + ''AddHandler txt.Click, AddressOf OntxtClick + 'AddHandler txt.MouseDown, AddressOf MovableText_MouseDown + 'AddHandler txt.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler txt.MouseMove, AddressOf Control_MouseMove 'MovableText_MouseMove + SetMovementHandlers(txt) + + btnsave.Visible = True End Function @@ -404,10 +415,12 @@ pnldesigner.Controls.Add(chk) CURRENT_CONTROL = chk - AddHandler chk.Click, AddressOf OnchkboxClick - AddHandler chk.MouseDown, AddressOf MovableChk_MouseDown - AddHandler chk.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler chk.MouseMove, AddressOf Control_MouseMove 'MovableChk_MouseMove + 'AddHandler chk.Click, AddressOf OnchkboxClick + 'AddHandler chk.MouseDown, AddressOf MovableChk_MouseDown + 'AddHandler chk.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler chk.MouseMove, AddressOf Control_MouseMove 'MovableChk_MouseMove + SetMovementHandlers(chk) + TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(CURRENT_ProfilGUID, chk.Name, "CHK", chkname, chk.Location.X, chk.Location.Y, Environment.UserName, 27, 200) CURRENT_CONTROL.Tag = GetLastID() Load_Control() @@ -426,10 +439,12 @@ chk.Cursor = Cursors.Hand chk.Location = New Point(x, y) pnldesigner.Controls.Add(chk) - AddHandler chk.Click, AddressOf OnchkboxClick - AddHandler chk.MouseDown, AddressOf MovableChk_MouseDown - AddHandler chk.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler chk.MouseMove, AddressOf Control_MouseMove 'MovableChk_MouseMove + 'AddHandler chk.Click, AddressOf OnchkboxClick + 'AddHandler chk.MouseDown, AddressOf MovableChk_MouseDown + 'AddHandler chk.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler chk.MouseMove, AddressOf Control_MouseMove 'MovableChk_MouseMove + SetMovementHandlers(chk) + btnsave.Visible = True End Function Function add_newCombobox(cmbname As String) @@ -443,10 +458,12 @@ pnldesigner.Controls.Add(cmb) CURRENT_CONTROL = cmb - AddHandler cmb.Click, AddressOf OncmbClick - AddHandler cmb.MouseDown, AddressOf Movablecmb_MouseDown - AddHandler cmb.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler cmb.MouseMove, AddressOf Control_MouseMove 'Movablecmb_MouseMove + 'AddHandler cmb.Click, AddressOf OncmbClick + 'AddHandler cmb.MouseDown, AddressOf Movablecmb_MouseDown + 'AddHandler cmb.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler cmb.MouseMove, AddressOf Control_MouseMove 'Movablecmb_MouseMove + SetMovementHandlers(cmb) + TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(CURRENT_ProfilGUID, cmb.Name, "CMB", cmbname, cmb.Location.X, cmb.Location.Y, Environment.UserName, 24, 180) CURRENT_CONTROL.Tag = GetLastID() Load_Control() @@ -463,10 +480,11 @@ cmb.Cursor = Cursors.Hand cmb.Location = New Point(x, y) pnldesigner.Controls.Add(cmb) - AddHandler cmb.Click, AddressOf OncmbClick - AddHandler cmb.MouseDown, AddressOf Movablecmb_MouseDown - AddHandler cmb.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler cmb.MouseMove, AddressOf Control_MouseMove 'Movablecmb_MouseMove + 'AddHandler cmb.Click, AddressOf OncmbClick + 'AddHandler cmb.MouseDown, AddressOf Movablecmb_MouseDown + 'AddHandler cmb.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler cmb.MouseMove, AddressOf Control_MouseMove 'Movablecmb_MouseMove + SetMovementHandlers(cmb) btnsave.Visible = True End Function Function add_exisiting_DTP(ID As Integer, dtpname As String, x As Integer, y As Integer, vwidth As Integer, vheight As Integer) @@ -479,10 +497,11 @@ dtp.Format = DateTimePickerFormat.Short pnldesigner.Controls.Add(dtp) - AddHandler dtp.Click, AddressOf OndtpClick - AddHandler dtp.MouseDown, AddressOf Movabledtp_MouseDown - AddHandler dtp.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler dtp.MouseMove, AddressOf Control_MouseMove 'Movabledtp_MouseMove + 'AddHandler dtp.Click, AddressOf OndtpClick + 'AddHandler dtp.MouseDown, AddressOf Movabledtp_MouseDown + 'AddHandler dtp.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler dtp.MouseMove, AddressOf Control_MouseMove 'Movabledtp_MouseMove + SetMovementHandlers(dtp) btnsave.Visible = True End Function Function add_newDTP(dtpname As String) @@ -496,10 +515,12 @@ dtp.Location = New Point(clientPosition) pnldesigner.Controls.Add(dtp) CURRENT_CONTROL = dtp - AddHandler dtp.Click, AddressOf OndtpClick - AddHandler dtp.MouseDown, AddressOf Movabledtp_MouseDown - AddHandler dtp.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler dtp.MouseMove, AddressOf Control_MouseMove 'Movabledtp_MouseMove + 'AddHandler dtp.Click, AddressOf OndtpClick + 'AddHandler dtp.MouseDown, AddressOf Movabledtp_MouseDown + 'AddHandler dtp.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler dtp.MouseMove, AddressOf Control_MouseMove 'Movabledtp_MouseMove + SetMovementHandlers(dtp) + TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(CURRENT_ProfilGUID, dtp.Name, "DTP", dtpname, dtp.Location.X, dtp.Location.Y, Environment.UserName, 24, 180) CURRENT_CONTROL.Tag = GetLastID() Load_Control() @@ -528,10 +549,11 @@ pnldesigner.Controls.Add(dgv) - AddHandler dgv.Click, AddressOf OndgvClick - AddHandler dgv.MouseDown, AddressOf MovableDGV_MouseDown - AddHandler dgv.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler dgv.MouseMove, AddressOf dgv_MouseMove + 'AddHandler dgv.Click, AddressOf OndgvClick + 'AddHandler dgv.MouseDown, AddressOf MovableDGV_MouseDown + 'AddHandler dgv.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler dgv.MouseMove, AddressOf dgv_MouseMove + SetMovementHandlers(dgv) btnsave.Visible = True End Function @@ -555,10 +577,12 @@ pnldesigner.Controls.Add(dgv) CURRENT_CONTROL = dgv - AddHandler dgv.Click, AddressOf OndgvClick - AddHandler dgv.MouseDown, AddressOf MovableDGV_MouseDown - AddHandler dgv.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler dgv.MouseMove, AddressOf dgv_MouseMove + 'AddHandler dgv.Click, AddressOf OndgvClick + 'AddHandler dgv.MouseDown, AddressOf MovableDGV_MouseDown + 'AddHandler dgv.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler dgv.MouseMove, AddressOf dgv_MouseMove + SetMovementHandlers(dgv) + TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(CURRENT_ProfilGUID, dgv.Name, "DGV", dgvName, dgv.Location.X, dgv.Location.Y, Environment.UserName, 130, 150) CURRENT_CONTROL.Tag = GetLastID() Load_Control() @@ -590,10 +614,12 @@ pnldesigner.Controls.Add(table) CURRENT_CONTROL = table - AddHandler table.Click, AddressOf OndgvClick - AddHandler table.MouseDown, AddressOf MovableDGV_MouseDown - AddHandler table.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler table.MouseMove, AddressOf dgv_MouseMove + 'AddHandler table.Click, AddressOf OndgvClick + 'AddHandler table.MouseDown, AddressOf MovableDGV_MouseDown + 'AddHandler table.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler table.MouseMove, AddressOf dgv_MouseMove + SetMovementHandlers(table) + AddHandler table.ColumnHeaderMouseClick, AddressOf table_ColumnHeaderMouseClick TBPM_PROFILE_CONTROLSTableAdapter.cmdInsertAnlage(CURRENT_ProfilGUID, table.Name, "TABLE", tableName, table.Location.X, table.Location.Y, Environment.UserName, 130, 150) CURRENT_CONTROL.Tag = GetLastID() @@ -633,10 +659,12 @@ pnldesigner.Controls.Add(table) - AddHandler table.Click, AddressOf OndgvClick - AddHandler table.MouseDown, AddressOf MovableDGV_MouseDown - AddHandler table.MouseUp, AddressOf MovableCtrl_MouseUp - AddHandler table.MouseMove, AddressOf dgv_MouseMove + 'AddHandler table.Click, AddressOf OndgvClick + 'AddHandler table.MouseDown, AddressOf MovableDGV_MouseDown + 'AddHandler table.MouseUp, AddressOf MovableCtrl_MouseUp + 'AddHandler table.MouseMove, AddressOf dgv_MouseMove + SetMovementHandlers(table) + AddHandler table.ColumnHeaderMouseClick, AddressOf table_ColumnHeaderMouseClick btnsave.Visible = True @@ -906,11 +934,11 @@ Dim lbl As Label = DirectCast(sender, Label) CURRENT_CONTROL = sender - begin_location = e.Location + BeginLocation = e.Location lbl.BringToFront() ' Set the mode flag to signal the MouseMove event handler that it ' needs to now calculate new positions for our control - m_Moving = True + MouseMoving = True End If End Sub Private Sub MovableText_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown @@ -920,11 +948,11 @@ Dim txt As TextBox = DirectCast(sender, TextBox) CURRENT_CONTROL = sender - begin_location = e.Location + BeginLocation = e.Location txt.BringToFront() ' Set the mode flag to signal the MouseMove event handler that it ' needs to now calculate new positions for our control - m_Moving = True + MouseMoving = True End If End Sub Private Sub MovableChk_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown @@ -933,11 +961,11 @@ Clear_control_Details() Dim txt As CheckBox = DirectCast(sender, CheckBox) CURRENT_CONTROL = sender - begin_location = e.Location + BeginLocation = e.Location txt.BringToFront() ' Set the mode flag to signal the MouseMove event handler that it ' needs to now calculate new positions for our control - m_Moving = True + MouseMoving = True End If End Sub Private Sub Movablecmb_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown @@ -946,12 +974,12 @@ Clear_control_Details() Dim cmb As ComboBox = DirectCast(sender, ComboBox) CURRENT_CONTROL = sender - begin_location = e.Location + BeginLocation = e.Location cmb.BringToFront() ' Set the mode flag to signal the MouseMove event handler that it ' needs to now calculate new positions for our control - m_Moving = True + MouseMoving = True End If End Sub Private Sub Movabledtp_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown @@ -962,13 +990,13 @@ CURRENT_CONTROL = sender 'Console.WriteLine("X: " & cursor.X & ";Y=" & cursor.Y) - begin_location = e.Location + BeginLocation = e.Location 'begin_location = New Point(cursor.X - Parent.Location.X, ' cursor.Y - Parent.Location.Y) dtp.BringToFront() ' Set the mode flag to signal the MouseMove event handler that it ' needs to now calculate new positions for our control - m_Moving = True + MouseMoving = True 'Jetzt Controleigenschaften laden Load_Control() @@ -989,12 +1017,12 @@ CURRENT_CONTROL = sender - begin_location = e.Location + BeginLocation = e.Location CURRENT_CONTROL.Tag = New clsDragInfo(Form.MousePosition, sender.Location) dgv.BringToFront() ' Set the mode flag to signal the MouseMove event handler that it ' needs to now calculate new positions for our control - m_Moving = True + MouseMoving = True CURRENT_CONTROL = sender @@ -1008,9 +1036,9 @@ Private Sub MovableCtrl_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp CURRENT_CONTROL.Tag = Nothing ' The button was released, so we're going back to Static mode. - If m_Moving = True Then - m_Moving = False - end_location = e.Location + If MouseMoving = True Then + MouseMoving = False + EndLocation = e.Location If X_LOCTextBox.Text <> String.Empty Then If CURRENT_CONTROL.Location.X <> X_LOCTextBox.Text Or CURRENT_CONTROL.Location.Y <> Y_LOCTextBox.Text Then X_LOCTextBox.Text = CURRENT_CONTROL.Location.X @@ -1026,242 +1054,174 @@ ' button was pressed MyBase.Cursor = Cursors.Default End Sub - Private Sub Control_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove - Try - If CURRENT_CONTROL Is Nothing Then - Exit Sub - End If - 'Check which mode we're in. If we're supposed to be moving - 'our control - If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" Then - Me.Cursor = Cursors.Hand - Me.Refresh() - - Dim NowCursor As Point = GetCursorPosition() - ' get the screen position of the mouse pointer and map it - ' to the position relative to the top-left corner of our - If Point.op_Inequality(NowCursor, begin_location) Then - CURRENT_CONTROL.Location = New System.Drawing.Point(NowCursor.X - begin_location.X, - NowCursor.Y - begin_location.Y) - End If - End If - Catch ex As Exception - ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableLabel_MouseMove") - m_Moving = False - End Try + 'Private Sub Control_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove + ' Try + ' If CURRENT_CONTROL Is Nothing Then + ' Exit Sub + ' End If + ' 'Check which mode we're in. If we're supposed to be moving + ' 'our control + ' If MouseMoving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" Then + ' Me.Cursor = Cursors.Hand + ' Me.Refresh() - End Sub - Private Sub MovableLabel_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove - Try - If CURRENT_CONTROL Is Nothing Then - Exit Sub - End If - 'Check which mode we're in. If we're supposed to be moving - 'our control - If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.Label" Then - Me.Cursor = Cursors.Hand - Me.Refresh() - - Dim lbl As Label = DirectCast(sender, Label) - - Dim NowCursor As Point = GetCursorPosition() - ' get the screen position of the mouse pointer and map it - ' to the position relative to the top-left corner of our - If Point.op_Inequality(NowCursor, begin_location) Then - lbl.Location = New System.Drawing.Point(NowCursor.X - begin_location.X, - NowCursor.Y - begin_location.Y) - End If - End If - Catch ex As Exception - ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableLabel_MouseMove") - m_Moving = False - End Try + ' Dim NowCursor As Point = GetCursorPosition() + ' ' get the screen position of the mouse pointer and map it + ' ' to the position relative to the top-left corner of our + ' If Point.op_Inequality(NowCursor, BeginLocation) Then + ' CURRENT_CONTROL.Location = New System.Drawing.Point(NowCursor.X - BeginLocation.X, + ' NowCursor.Y - BeginLocation.Y) + ' End If + ' End If + ' Catch ex As Exception + ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableLabel_MouseMove") + ' MouseMoving = False + ' End Try - End Sub - Private Sub MovableText_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove - 'Check which mode we're in. If we're supposed to be moving - 'our control - If CURRENT_CONTROL Is Nothing Then - Exit Sub - End If - Try - If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.TextBox" Then - Me.Cursor = Cursors.Hand - Me.Refresh() - - Dim txt As TextBox = DirectCast(sender, TextBox) - - Dim NowCursor As Point = GetCursorPosition() - ' get the screen position of the mouse pointer and map it - ' to the position relative to the top-left corner of our - ' parent container - If Point.op_Inequality(NowCursor, begin_location) Then - txt.Location = New System.Drawing.Point(NowCursor.X - begin_location.X, - NowCursor.Y - begin_location.Y) - End If + 'End Sub + 'Private Sub MovableLabel_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove + ' Try + ' If CURRENT_CONTROL Is Nothing Then + ' Exit Sub + ' End If + ' 'Check which mode we're in. If we're supposed to be moving + ' 'our control + ' If MouseMoving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.Label" Then + ' Me.Cursor = Cursors.Hand + ' Me.Refresh() - End If - Catch ex As Exception - ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableText_MouseMove") - m_Moving = False - End Try + ' Dim lbl As Label = DirectCast(sender, Label) + ' Dim NowCursor As Point = GetCursorPosition() + ' ' get the screen position of the mouse pointer and map it + ' ' to the position relative to the top-left corner of our + ' If Point.op_Inequality(NowCursor, BeginLocation) Then + ' lbl.Location = New System.Drawing.Point(NowCursor.X - BeginLocation.X, + ' NowCursor.Y - BeginLocation.Y) + ' End If + ' End If + ' Catch ex As Exception + ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableLabel_MouseMove") + ' MouseMoving = False + ' End Try - End Sub - Private Sub MovableChk_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove - 'Check which mode we're in. If we're supposed to be moving - 'our control - If CURRENT_CONTROL Is Nothing Then - Exit Sub - End If - Try - If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.CheckBox" Then - Me.Cursor = Cursors.Hand - Me.Refresh() - - Dim chk As CheckBox = DirectCast(sender, CheckBox) - Dim NowCursor As Point = GetCursorPosition() - ' get the screen position of the mouse pointer and map it - ' to the position relative to the top-left corner of our - If Point.op_Inequality(NowCursor, begin_location) Then - chk.Location = New System.Drawing.Point(NowCursor.X - begin_location.X, - NowCursor.Y - begin_location.Y) - End If - End If - Catch ex As Exception - ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableChk_MouseMove") - m_Moving = False - End Try + 'End Sub + 'Private Sub MovableText_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove + ' 'Check which mode we're in. If we're supposed to be moving + ' 'our control + ' If CURRENT_CONTROL Is Nothing Then + ' Exit Sub + ' End If + ' Try + ' If MouseMoving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.TextBox" Then + ' Me.Cursor = Cursors.Hand + ' Me.Refresh() - End Sub - Private Sub Movablecmb_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove - 'Check which mode we're in. If we're supposed to be moving - 'our control - If CURRENT_CONTROL Is Nothing Then - Exit Sub - End If - Try - If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.ComboBox" Then - Me.Cursor = Cursors.Hand - Me.Refresh() - - Dim cmb As ComboBox = DirectCast(sender, ComboBox) - Static LastCursor As Point - Dim NowCursor As Point = GetCursorPosition() - ' get the screen position of the mouse pointer and map it - ' to the position relative to the top-left corner of our - If Point.op_Inequality(NowCursor, begin_location) Then - cmb.Location = New System.Drawing.Point(NowCursor.X - begin_location.X, - NowCursor.Y - begin_location.Y) - End If - End If - Catch ex As Exception - ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Movablecmb_MouseMove") - m_Moving = False - End Try + ' Dim txt As TextBox = DirectCast(sender, TextBox) + ' Dim NowCursor As Point = GetCursorPosition() + ' ' get the screen position of the mouse pointer and map it + ' ' to the position relative to the top-left corner of our + ' ' parent container + ' If Point.op_Inequality(NowCursor, BeginLocation) Then + ' txt.Location = New System.Drawing.Point(NowCursor.X - BeginLocation.X, + ' NowCursor.Y - BeginLocation.Y) + ' End If - End Sub - 'Private Sub Movabledtp_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove + ' End If + ' Catch ex As Exception + ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableText_MouseMove") + ' MouseMoving = False + ' End Try + + + 'End Sub + 'Private Sub MovableChk_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove + ' 'Check which mode we're in. If we're supposed to be moving + ' 'our control + ' If CURRENT_CONTROL Is Nothing Then + ' Exit Sub + ' End If + ' Try + ' If MouseMoving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.CheckBox" Then + ' Me.Cursor = Cursors.Hand + ' Me.Refresh() + + ' Dim chk As CheckBox = DirectCast(sender, CheckBox) + ' Dim NowCursor As Point = GetCursorPosition() + ' ' get the screen position of the mouse pointer and map it + ' ' to the position relative to the top-left corner of our + ' If Point.op_Inequality(NowCursor, BeginLocation) Then + ' chk.Location = New System.Drawing.Point(NowCursor.X - BeginLocation.X, + ' NowCursor.Y - BeginLocation.Y) + ' End If + ' End If + ' Catch ex As Exception + ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "MovableChk_MouseMove") + ' MouseMoving = False + ' End Try + + 'End Sub + 'Private Sub Movablecmb_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove ' 'Check which mode we're in. If we're supposed to be moving ' 'our control ' If CURRENT_CONTROL Is Nothing Then ' Exit Sub ' End If ' Try - ' If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.DateTimePicker" Then + ' If MouseMoving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.ComboBox" Then ' Me.Cursor = Cursors.Hand ' Me.Refresh() - ' Dim dtp As DateTimePicker = DirectCast(sender, DateTimePicker) + ' Dim cmb As ComboBox = DirectCast(sender, ComboBox) ' Static LastCursor As Point - ' Dim NowCursor = GetCursorPosition() ' New Point(Cursor.Position.X, Cursor.Position.Y) - ' ' Console.WriteLine("NOW X: " & NowCursor.X & ";Y=" & NowCursor.Y) + ' Dim NowCursor As Point = GetCursorPosition() ' ' get the screen position of the mouse pointer and map it ' ' to the position relative to the top-left corner of our - ' ' parent container - ' If Point.op_Inequality(NowCursor, begin_location) Then - ' 'dtp.Location = New System.Drawing.Point(NowCursor.X - pnldesigner.Location.X, NowCursor.Y - pnldesigner.Location.Y) - ' ' Alle normalen Controls - ' dtp.Location = New Point(NowCursor.X - begin_location.X, - ' NowCursor.Y - begin_location.Y) - ' 'dtp.Location = New System.Drawing.Point(clientPosition.X - begin_location.X, clientPosition.Y - begin_location.Y) + ' If Point.op_Inequality(NowCursor, BeginLocation) Then + ' cmb.Location = New System.Drawing.Point(NowCursor.X - BeginLocation.X, + ' NowCursor.Y - BeginLocation.Y) ' End If ' End If ' Catch ex As Exception - ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Movablecmb_MouseMove") - ' m_Moving = False + ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Movablecmb_MouseMove") + ' MouseMoving = False ' End Try 'End Sub - Private Sub dgv_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove - 'Check which mode we're in. If we're supposed to be moving - 'our control - If CURRENT_CONTROL Is Nothing Then - Exit Sub - End If - Try - If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.DataGridView" Then - Me.Cursor = Cursors.Hand - Me.Refresh() - - Dim dgv As DataGridView = DirectCast(sender, DataGridView) - Static LastCursor As Point - Dim NowCursor As Point = New Point(Cursor.Position.X, Cursor.Position.Y) - ' get the screen position of the mouse pointer and map it - ' to the position relative to the top-left corner of our - ' parent container - Dim clientPosition As Point = Me.pnldesigner.PointToClient(System.Windows.Forms.Cursor.Position) - If Point.op_Inequality(NowCursor, LastCursor) Then - dgv.Location = New System.Drawing.Point(clientPosition.X - begin_location.X, clientPosition.Y - begin_location.Y) - End If - End If - Catch ex As Exception - ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Movablecmb_MouseMove") - m_Moving = False - End Try - - End Sub + ''End Sub 'Private Sub dgv_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove - ' 'Check which mode we're in. If we're supposed to be movingmybase + ' 'Check which mode we're in. If we're supposed to be moving ' 'our control + ' If CURRENT_CONTROL Is Nothing Then + ' Exit Sub + ' End If ' Try + ' If MouseMoving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.DataGridView" Then + ' Me.Cursor = Cursors.Hand + ' Me.Refresh() - ' If CURRENT_CONTROL.Tag IsNot Nothing Then - ' Dim info As clsDragInfo = CType(Panel1.Tag, clsDragInfo) - ' Dim newLoc As Point = info.NewLocation(Form.MousePosition) - ' If Me.ClientRectangle.Contains(New Rectangle(newLoc, CURRENT_CONTROL.Size)) Then CURRENT_CONTROL.Location = newLoc + ' Dim dgv As DataGridView = DirectCast(sender, DataGridView) + ' Static LastCursor As Point + ' Dim NowCursor As Point = New Point(Cursor.Position.X, Cursor.Position.Y) + ' ' get the screen position of the mouse pointer and map it + ' ' to the position relative to the top-left corner of our + ' ' parent container + ' Dim clientPosition As Point = Me.pnldesigner.PointToClient(System.Windows.Forms.Cursor.Position) + ' If Point.op_Inequality(NowCursor, LastCursor) Then + ' dgv.Location = New System.Drawing.Point(clientPosition.X - BeginLocation.X, clientPosition.Y - BeginLocation.Y) + ' End If ' End If - - ' 'If m_Moving = True Then - ' ' ListBox1.Items.Add(sender.ToString & "-" & CURRENT_CONTROL.GetType.ToString) - ' 'End If - - - ' 'If m_Moving = True And sender.ToString <> "DD_PM_WINDREAM.frmFormDesigner, Text: Validation-Designer" And CURRENT_CONTROL.GetType.ToString = "System.Windows.Forms.DateTimePicker" Then - ' ' Me.Cursor = Cursors.Hand - ' ' Me.Refresh() - - ' ' Dim dgv As DataGridView = DirectCast(sender, DataGridView) - ' ' Static LastCursor As Point - ' ' Dim NowCursor As Point = New Point(Cursor.Position.X, Cursor.Position.Y) - ' ' ' get the screen position of the mouse pointer and map it - ' ' ' to the position relative to the top-left corner of our - ' ' ' parent container - ' ' Dim clientPosition As Point = Me.pnldesigner.PointToClient(System.Windows.Forms.Cursor.Position) - ' ' If Point.op_Inequality(NowCursor, LastCursor) Then - ' ' dgv.Location = New System.Drawing.Point(clientPosition.X - begin_location.X, clientPosition.Y - begin_location.Y) - ' ' End If - ' 'End If ' Catch ex As Exception - ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Movabledgv_MouseMove") - ' 'm_Moving = False + ' ' MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Movablecmb_MouseMove") + ' MouseMoving = False ' End Try 'End Sub + Private Sub btnsave_Click(sender As System.Object, e As System.EventArgs) Handles btnsave.Click Save_Control() End Sub @@ -1534,4 +1494,109 @@ End If End Sub + +#Region "Rewrite" + ''' + ''' Setzt die Eventhandler für ein Control, die für die Bewegung via Drag & Drop und das Laden der Eigentschaften verantwortlich sind + ''' + ''' Das Control, für das die Eventhandler gesetzt werden sollen + Private Sub SetMovementHandlers(control As Control) + AddHandler control.Click, AddressOf OnControl_Click + AddHandler control.MouseDown, AddressOf OnControl_MouseDown + AddHandler control.MouseUp, AddressOf OnControl_MouseUp + AddHandler control.MouseMove, AddressOf OnControl_MouseMove + End Sub + + ''' + ''' Weist die grundlegenden Eigenschaften zu einem Properties Objekt zu + ''' Die Properties werden an das Property Grid weitergegeben + ''' + ''' Das grundlegende Properties Objekt + ''' Die DataRow, die die Eigenschaften des Controls enthält + ''' Das gefüllt Properties Objekt + Private Function CreatePropsObject(obj As BaseProperties, row As DataRow) + obj.ID = row.Item("GUID") + obj.Location = New Point(row.Item("X_LOC"), row.Item("Y_LOC")) + obj.Name = row.Item("NAME") + obj.Width = row.Item("WIDTH") + obj.Height = row.Item("HEIGHT") + Return obj + End Function + + Private Sub OnControl_MouseDown(sender As Control, e As MouseEventArgs) + If e.Button = MouseButtons.Left Then + CURRENT_CONTROL = sender + BeginLocation = e.Location + sender.BringToFront() + MouseMoving = True + End If + End Sub + + Private Sub OnControl_MouseUp(sender As Control, e As MouseEventArgs) + If MouseMoving Then + MouseMoving = False + EndLocation = e.Location + + If CURRENT_CONTROL.Location.X <> X_LOCTextBox.Text Or CURRENT_CONTROL.Location.Y <> Y_LOCTextBox.Text Then + X_LOCTextBox.Text = CURRENT_CONTROL.Location.X + Y_LOCTextBox.Text = CURRENT_CONTROL.Location.Y + Save_Control() + End If + End If + + MyBase.Cursor = Cursors.Default + End Sub + + Private Sub OnControl_MouseMove(sender As Control, e As MouseEventArgs) + If CURRENT_CONTROL Is Nothing Then + Exit Sub + End If + + If MouseMoving Then + Cursor = Cursors.Hand + Refresh() + + Dim CurrentPosition As Point = GetCursorPosition() + + If Point.op_Inequality(CurrentPosition, BeginLocation) Then + CURRENT_CONTROL.Location = New Point(CurrentPosition.X - BeginLocation.X, CurrentPosition.Y - BeginLocation.Y) + End If + End If + End Sub + + Private Sub OnControl_Click(sender As Control, e As MouseEventArgs) + Dim props + Dim dt As DataTable = DD_DMSLiteDataSet.TBPM_PROFILE_CONTROLS + Dim row = dt.AsEnumerable().Where(Function(r As DataRow) + Return r.Item("GUID") = sender.Tag + End Function).Single() + + CURRENT_CONTROL = sender + gbxControl.Visible = True + + If TypeOf sender Is Label Then + Dim label As Label = sender + Dim labelProps As LabelProperties = CreatePropsObject(New LabelProperties, row) + labelProps.Text = label.Text + + props = labelProps + ElseIf TypeOf sender Is CheckBox Then + Dim check As CheckBox = sender + Dim checkProps As CheckboxProperties = CreatePropsObject(New CheckboxProperties, row) + checkProps.Text = check.Text + + props = checkProps + ElseIf TypeOf sender Is TextBox Then + Dim txt As TextBox = sender + Dim txtProps As TextboxProperties = CreatePropsObject(New TextboxProperties, row) + + txtProps.ReadOnly = row.Item("READ_ONLY") + txtProps.Required = row.Item("VALIDATION") + + props = txtProps + End If + + pgControls.SelectedObject = props + End Sub +#End Region End Class \ No newline at end of file