Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Emerson Sepia  
#1 Posted : Wednesday, April 29, 2009 3:08:56 AM(UTC)
Emerson Sepia

Rank: Newbie

Groups: Member
Joined: 4/28/2009(UTC)
Posts: 9

how can I then use a drag and drop in a Multilayer put the figure in place
Exact mouse. I'm having difficulty, anyone know? I'm making the drop this way:
Code:
   Private Sub canvas_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles canvas.DragDrop
        Dim myData As DragDropData = CType(e.Data.GetData(GetType(DragDropData)), DragDropData)
        If Not IsNothing(myData) Then
            Try
'the problem, the location always returns the relative position and not the absolute position of the control also would like to place on the workspace that is visually smaller than the size of the control.

           Dim PosicaoX As Integer = Control.MousePosition.X - (Me.Location.X + Split_01.Location.X + Split_01.SplitterWidth + Split_01.SplitterDistance)
                Dim PosicaoY As Integer = Control.MousePosition.Y - (Me.Location.Y + Split_01.Location.Y)


                Dim ivo As New ImageVObject(New Aurigma.GraphicsMill.Bitmap(myData.Pidl.Path), True, PosicaoX, posicaoY)

                canvas.Layers(0).VObjects.Add(ivo)
             

            Catch ex As Exception
                MessageBox.Show(ex.Message, "Load Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
      
            End Try

     
        End If
    End Sub


tcrosbie  
#2 Posted : Wednesday, April 29, 2009 4:21:06 PM(UTC)
tcrosbie

Rank: Advanced Member

Groups: Member
Joined: 6/22/2008(UTC)
Posts: 27

You'll probably be wanting to use the canvas.ControlToWorkspace to convert your mouse location to the correct point I believe, try the below code, (it might not work, I've just modded your VB code based on what I'd do in C#)

Code:

Private Sub canvas_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles canvas.DragDrop
        Dim myData As DragDropData = CType(e.Data.GetData(GetType(DragDropData)), DragDropData)
        If Not IsNothing(myData) Then
            Try
'the problem, the location always returns the relative position and not the absolute position of the control also would like to place on the workspace that is visually smaller than the size of the control.

Dim pointToConv as new Point(Control.MousePosition.X, Control.MousePosition.Y)
Dim pnt as  new PointF  = canvas.ControlToWorkspace(pointToConv, canvas.Unit)


                Dim ivo As New ImageVObject(New Aurigma.GraphicsMill.Bitmap(myData.Pidl.Path), True, pnt.X, pnt.Y)

                canvas.Layers(0).VObjects.Add(ivo)
             

            Catch ex As Exception
                MessageBox.Show(ex.Message, "Load Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
     
            End Try

     
        End If
    End Sub


Emerson Sepia  
#3 Posted : Wednesday, April 29, 2009 11:30:13 PM(UTC)
Emerson Sepia

Rank: Newbie

Groups: Member
Joined: 4/28/2009(UTC)
Posts: 9

I used part of its implementation, but most of the problem really is finding the point of
control on the form, since it is within a splitcontainer, thanks.


tcrosbie wrote:
You'll probably be wanting to use the canvas.ControlToWorkspace to convert your mouse location to the correct point I believe, try the below code, (it might not work, I've just modded your VB code based on what I'd do in C#)

Code:

Private Sub canvas_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles canvas.DragDrop
        Dim myData As DragDropData = CType(e.Data.GetData(GetType(DragDropData)), DragDropData)
        If Not IsNothing(myData) Then
            Try
'the problem, the location always returns the relative position and not the absolute position of the control also would like to place on the workspace that is visually smaller than the size of the control.

Dim pointToConv as new Point(Control.MousePosition.X, Control.MousePosition.Y)
Dim pnt as  new PointF  = canvas.ControlToWorkspace(pointToConv, canvas.Unit)


                Dim ivo As New ImageVObject(New Aurigma.GraphicsMill.Bitmap(myData.Pidl.Path), True, pnt.X, pnt.Y)

                canvas.Layers(0).VObjects.Add(ivo)
             

            Catch ex As Exception
                MessageBox.Show(ex.Message, "Load Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
     
            End Try

     
        End If
    End Sub


Emerson Sepia  
#4 Posted : Thursday, April 30, 2009 3:00:26 AM(UTC)
Emerson Sepia

Rank: Newbie

Groups: Member
Joined: 4/28/2009(UTC)
Posts: 9

Now, I get the value of that position, but even so the position
occurs in the wrong place, I think the problem in this part: canvas.Layers(0).VObjects.Add(ivo)

Code:
 Private Sub canvas_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles canvas.DragDrop
        Dim myData As DragDropData = CType(e.Data.GetData(GetType(DragDropData)), DragDropData)
        If Not IsNothing(myData) Then
            Try


                
                Dim PosicaoX As Integer = Control.MousePosition.X - (Me.Left + Split_01.Left + Split_02.Width + Split_01.SplitterWidth + Split_03.Left + canvas.Left)
                Dim PosicaoY As Integer = Control.MousePosition.Y - (Me.Top + Split_01.Top + Split_01.SplitterWidth + Split_03.Top + canvas.Top + 15)
                Dim PosicaoNoCanvas As PointF = canvas.ControlToWorkspace(New Point(PosicaoX, PosicaoY), canvas.Unit)
           

                Dim ivo As New ImageVObject(New Aurigma.GraphicsMill.Bitmap(myData.Pidl.Path), False, PosicaoNoCanvas.X, PosicaoNoCanvas.Y)
                canvas.Layers(0).VObjects.Add(ivo)
                'retirar
                MsgBox(PosicaoNoCanvas.X)
                MsgBox(PosicaoNoCanvas.Y)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Load Image Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End If
    End Sub
Tamila  
#5 Posted : Sunday, May 3, 2009 8:19:35 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi Sepia,

The following code demonstrates how to convert coordinates of mouse to points of workspace:
Code:
Dim newPoint As Point = MultiLayerViewer1.PointToClient(New Point(Control.MousePosition.X, Control.MousePosition.Y))
Dim PosicaoNoCanvas As PointF = MultiLayerViewer1.ControlToWorkspace(newPoint, Unit.Point)
Dim ivo As New ImageVObject(New Aurigma.GraphicsMill.Bitmap("c:/me.jpg"), True, PosicaoNoCanvas.X, PosicaoNoCanvas.Y)
MultiLayerViewer1.Layers(0).VObjects.Add(ivo)

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
Emerson Sepia  
#6 Posted : Sunday, May 3, 2009 9:10:31 PM(UTC)
Emerson Sepia

Rank: Newbie

Groups: Member
Joined: 4/28/2009(UTC)
Posts: 9

thank you, I think my mistake was trying to use "MM" instead of "Point"
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.