This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

multilayer vs drag-n-drop

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:
   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


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#)


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


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
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#)


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


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)

 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
Hi Sepia,

The following code demonstrates how to convert coordinates of mouse to points of workspace:
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)

thank you, I think my mistake was trying to use "MM" instead of "Point"