Annotation Screen Position

Discussions about annotation support.
Post Reply
ahmad1987
Posts: 11
Joined: Sat Jun 02, 2012 10:41 pm

Annotation Screen Position

Post by ahmad1987 » Tue Jun 05, 2012 1:38 pm

Hi,

Can you please tell me how can i get the top left position of annotation in respect to screen, i tried the following but didn't work correctly:

Code: Select all

Dim imgHorResolution As Int32 = gdPicEdit.HorizontalResolution
            Dim imgVerResolution As Int32 = gdPicEdit.VerticalResolution
            Dim TopLeftXPoint As Decimal = (_SelectedObject.Left - _SelectedObject.Width / 2) * imgHorResolution
            Dim TopLeftYPoint As Decimal = (_SelectedObject.Top - _SelectedObject.Height / 2) * imgVerResolution
            Dim p As New Point(TopLeftXPoint, TopLeftYPoint)
            Return Me.gdPicEdit.PointToScreen(New Point(p.X, p.Y))
where gdPicEdit is a GDViewer and _SelectedObject is the selected annotation

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Annotation Screen Position

Post by Loïc » Tue Jun 05, 2012 1:58 pm

Hello,

You have to use the CoordDocumentToViewer to translate coordinate from document to control.

Kind regards,

Loïc

ahmad1987
Posts: 11
Joined: Sat Jun 02, 2012 10:41 pm

Re: Annotation Screen Position

Post by ahmad1987 » Tue Jun 05, 2012 2:11 pm

Hello,
Can you please explain in it in an example with respect to the code above

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Annotation Screen Position

Post by Loïc » Tue Jun 05, 2012 2:16 pm

You already have a demo code and explanations in the reference guide, this is very basic.

See: https://www.gdpicture.com/guides/gdpicture/v8/html/con ... teger.html

ahmad1987
Posts: 11
Joined: Sat Jun 02, 2012 10:41 pm

Re: Annotation Screen Position

Post by ahmad1987 » Tue Jun 05, 2012 2:20 pm

i have already checked it, and tried the following code, but still didn't get the result i want

Code: Select all

  Dim imgHorResolution As Int32 = gdPicEdit.HorizontalResolution
            Dim imgVerResolution As Int32 = gdPicEdit.VerticalResolution
            Dim TopLeftXPoint As Decimal = (_SelectedObject.Left - _SelectedObject.Width / 2) *imgHorResolution 
            Dim TopLeftYPoint As Decimal = (_SelectedObject.Top - _SelectedObject.Height / 2) *imgVerResolution
            gdPicEdit.CoordDocumentToViewer(0, 0, TopLeftXPoint, TopLeftYPoint)
            Dim p As New Point(TopLeftXPoint, TopLeftYPoint)
            Return Me.gdPicEdit.PointToScreen(p)
what i am trying to do, is to show some kind of a floating control on point p, but the positions returned from the above are incorrect, i tried it also with removing the multiplication with the resolution, with no successful result.

ahmad1987
Posts: 11
Joined: Sat Jun 02, 2012 10:41 pm

Re: Annotation Screen Position

Post by ahmad1987 » Tue Jun 05, 2012 2:24 pm

never mind sir, i found my mistake,
i changed it to the following
Dim vwLeft As Int32
Dim vwTop As Int32
gdPicEdit.CoordDocumentToViewer(TopLeftXPoint, TopLeftYPoint, vwLeft, vwTop)

thank you for your help

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Annotation Screen Position

Post by Loïc » Tue Jun 05, 2012 2:31 pm

ok perfect, thank you for the update.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest