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

Notification

Icon
Error

Options
Go to last post Go to first unread
Dustin  
#1 Posted : Friday, August 24, 2007 4:07:49 AM(UTC)
Dustin

Rank: Member

Groups: Member
Joined: 8/21/2007(UTC)
Posts: 4

I've been struggling with this for some time, I know it's probably simple, but I need some help. I have a Form in VB.NET where I need to enable a user to create an Ellipse on a canvas by drag and drop. I have a PictureBox on the Form that a user can drag and drop onto a layer of of the MultiLayerViewer, but on the DragDrop event, I can never seem to create an Elliple at the location the user dropped.

Any help or pointing in the right direction would greatly be appreciated.

My code is as follows:

Code:
    Private Sub _multiLayerViewer_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles _multiLayerViewer.DragDrop

        Dim a As Aurigma.GraphicsMill.WinControls.VObject
        Dim Pt As Point

        Pt = Me.PointToClient(New Point(e.X, e.Y))
        Pt.Offset(-DragPoint.X, -DragPoint.Y)  ' DragPoint is being set when user begins drag

        a = New Aurigma.GraphicsMill.WinControls.EllipseVObject(Pt.X, Pt.Y, 10, 10)
        _multiLayerViewer.CurrentLayer.VObjects.Add(a)


    End Sub

Edited by user Monday, December 17, 2007 1:19:45 PM(UTC)  | Reason: Not specified

bcardi  
#2 Posted : Saturday, August 25, 2007 1:23:55 AM(UTC)
bcardi

Rank: Member

Groups: Member
Joined: 8/25/2007(UTC)
Posts: 7

I first used the PointToClient method to convert the cursor position to a point within the MultiLayerViewer control and then used the ControlToWorkspace method to convert it to a point within the workspace.

Example (documentPage is of type MultiLayerViewer)

Code:
        private void documentPage_DragDrop(object sender, DragEventArgs e)
        {
            thumbNail1.Visible = false;

            //convert cursor location to point within control
            Point controlLocation = documentPage.PointToClient(new Point(e.X, e.Y));

            //convert control location to point within workspace
            PointF workspaceLocation = documentPage.ControlToWorkspace(controlLocation, Aurigma.GraphicsMill.Unit.Point);

            //create new image object at workspace location
            Aurigma.GraphicsMill.WinControls.ImageVObject newImageVObject = new
                Aurigma.GraphicsMill.WinControls.ImageVObject(getBitMap(lastFilename), false, workspaceLocation.X, workspaceLocation.Y);

            //Add the image to layer
            documentPage.Layers[0].VObjects.Add(newImageVObject);
        }

Edited by user Monday, December 17, 2007 1:20:21 PM(UTC)  | Reason: Not specified

Alex Kon  
#3 Posted : Sunday, August 26, 2007 5:32:00 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello bcardi,

Thank you for your answer! :)
Dustin  
#4 Posted : Monday, August 27, 2007 8:02:58 AM(UTC)
Dustin

Rank: Member

Groups: Member
Joined: 8/21/2007(UTC)
Posts: 4

Hello bcardi,

Thanks for your post... for some reason (maybe it was the level I was Zoomed in at on my Control) the code wouldn't place an object at that location, but your post got me going in the right direction. Thanks!

hopefully this might help others out, but here is what works for me in my DragDrop event:

Code:
Dim Pt As Point
Pt = Me.MultiLayerViewer1.PointToClient(New Point(e.X, e.Y))

Dim aPoint As PointF
aPoint = Me.MultiLayerViewer1.ControlToWorkspace(New Point(Pt.X, Pt.Y), Aurigma.GraphicsMill.Unit.Point)
' I can now place an object at aPoint like such:
Dim a As Aurigma.GraphicsMill.WinControls.VObject
a = New Aurigma.GraphicsMill.WinControls.EllipseVObject(aPoint.X - 5, aPoint.Y - 5, 10, 10)


Thanks again!
Dustin

Edited by user Monday, December 17, 2007 1:20:40 PM(UTC)  | Reason: Not specified

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.