VB.net xyPanel

Moderator: Moderator Group

VB.net xyPanel

Postby alverman » Tue Sep 09, 2014 9:47 pm

I'm trying to create a xypanel in vb.net :D
Could you tell me, if I may ask, what kind of control in the planning stage did you use?
I used a panel that sends the x and y position to the manager, and works great.
In my project I have 3 panel then, one who sends it to the manager the x and y position (X Pos and Y Pos) and this works fine.

Then I have 2 other panel to the position of one X and one Y.
In widget can individually set the position of X and Y in the respective XYPanel.
But in vb.net how can I set the x and y position of the relevant panel by moving the panel that handles the x and y?

I have been clear enough? ehhhhhh

Thank you, Alberto

My code:
Code: Select all

Private Sub Panel1_MouseMove(sender As Object, e As MouseEventArgs) Handles Panel1.MouseMove

        Dim deltaX As Double, deltaY As Double
        Dim larghezza As Double = CDbl(XMin.Text) * 2
        Dim altezza As Double = CDbl(YMin.Text) * 2

        deltaX = (larghezza / CDbl(Panel1.Width))
        deltaY = (altezza / CDbl(Panel1.Height))
        Dim point As Point = Panel1.PointToClient(Cursor.Position)

        If CheckInfo.Checked = True Then
            lblPanelData.Visible = True
        Else
            lblPanelData.Visible = False
        End If

        If chkMouseOver.Checked = True Then
            AutoSetParamDouble(numDev1.Value, numDev2.Value, "X Pos", Math.Round((point.X * deltaX), 3) - CDbl(XMin.Text))
            AutoSetParamDouble(numDev1.Value, numDev2.Value, "Y Pos", -Math.Round((point.Y * deltaY), 3) + CDbl(YMin.Text))
        Else
            If e.Button = Windows.Forms.MouseButtons.Left Then
                AutoSetParamDouble(numDev1.Value, numDev2.Value, "X Pos", Math.Round((point.X * deltaX), 3) - CDbl(XMin.Text))
                AutoSetParamDouble(numDev1.Value, numDev2.Value, "Y Pos", -Math.Round((point.Y * deltaY), 3) + CDbl(YMin.Text))
            End If
        End If
        lblPanelData.Text = "Mousepoint: " & point.X & "," & point.Y & vbCrLf &
                            "Mousepointdelta: " & Math.Round((point.X * deltaX), 0) & "," & Math.Round((point.Y * deltaY), 0) & vbCrLf &
                            "XPos: " & Math.Round((point.X * deltaX), 3) - CDbl(XMin.Text) & vbCrLf &
                            "YPos: " & -Math.Round((point.Y * deltaY), 3) + CDbl(YMin.Text) & vbCrLf &
                            "Panel: " & Panel1.Width & "," & Panel1.Height
    End Sub
PROService -IT
Intel i7 2600K LGA1155
MB P8H67-MLE 16GB
2xSSD 250GB
GTX470
Win 8.1 PRO
Manager STD V6.1
Player PRO V6.1
WDPro V5 2500
** La famiglia ti nutre, ti veste .... finchè non sei pronto per girare il mondo alla ricerca di qualcosa di tuo. **
User avatar
alverman
 
Posts: 562
Joined: Sat Jun 12, 2010 6:37 pm

Re: VB.net xyPanel

Postby Dennis Kuypers » Thu Sep 11, 2014 10:35 pm

Hey,

I don't quite get what the other panels are doing. Can you please elaborate on this?

Regards
Dennis


Also, to keep your code DRY you can change the following code:
Code: Select all
        If chkMouseOver.Checked = True Then
            AutoSetParamDouble(numDev1.Value, numDev2.Value, "X Pos", Math.Round((point.X * deltaX), 3) - CDbl(XMin.Text))
            AutoSetParamDouble(numDev1.Value, numDev2.Value, "Y Pos", -Math.Round((point.Y * deltaY), 3) + CDbl(YMin.Text))
        Else
            If e.Button = Windows.Forms.MouseButtons.Left Then
                AutoSetParamDouble(numDev1.Value, numDev2.Value, "X Pos", Math.Round((point.X * deltaX), 3) - CDbl(XMin.Text))
                AutoSetParamDouble(numDev1.Value, numDev2.Value, "Y Pos", -Math.Round((point.Y * deltaY), 3) + CDbl(YMin.Text))
            End If
        End If
Use the "Or" to chain the conditions.
Code: Select all
        If chkMouseOver.Checked = True Or e.Button = Windows.Forms.MouseButtons.Left Then
            AutoSetParamDouble(numDev1.Value, numDev2.Value, "X Pos", Math.Round((point.X * deltaX), 3) - CDbl(XMin.Text))
            AutoSetParamDouble(numDev1.Value, numDev2.Value, "Y Pos", -Math.Round((point.Y * deltaY), 3) + CDbl(YMin.Text))
        End If
Dennis Kuypers
(former Product Developer, Software)
Dennis Kuypers
coolux Germany
 
Posts: 771
Joined: Thu Jul 05, 2012 12:18 pm


Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 21 guests

cron