PDFViewWPF Add New Pop up window position


Please give a brief summary of your issue:
New added window coordinate issue

Please describe your issue and provide steps to reproduce it:

I am using the WPFViewWPF sample code and mainly working on the “PDFViewWPFTestCS2019” .

In “PDFViewWPFToolsCS2019”, I add a Menu class (extend from Window). In the public class “AnnotEdit”, in the over ride method “MouseLeftButtonDownHandler” I added “menuclass.Show()” to open it.
My purpose is when user click on one exist annotation, this menu will pop up and the location is close to this annotation.
I am trying to use

double x1 = mSelectedAnnotation.BoundingBoxRect.x1;
            double y1 = mSelectedAnnotation.BoundingBoxRect.y1;
mPDFView.ConvPagePtToScreenPt(ref x1, ref y1, mSelectedAnnotationPageNumber);

But the pop up menu location seems like so far away from the annotation.

I also try to use

double x1 = e.GetPosition(mPDFView).X;
            double y1 = e.GetPosition(mPDFView).Y;

to set the coordinates, but still doesn’t looks right.

What is the proper way to do this? thank you

According to SelectionHelper.cs (In PDFViewWPFTools project) the BoundingBoxRect is rectangle in the viewer's canvas space and not in PagePt as you are calling.

I’m not sure what coordinate system your menuClass is in, but you might be able to use the coordinates as is, or you can use one of the PDFViewWPF.ConvCanvasPtToXXXX calls.

thank you for reply.

I create my Menu Class under “PDFViewWPFToolsCS2019” - “Utilities” , and is a public partial class inherited Window. I am new to WPF and not sure which coordinate system this menu is in.
So now I am using

double x1 = mSelectedAnnotation.BoundingBoxRect.x1;
            double y1 = mSelectedAnnotation.BoundingBoxRect.y1;
            mPDFView.ConvCanvasPtToScreenPt(ref x1, ref y1);
           MenuClass.Top = y1;
            MenuClass.Left = x1;

In this case, the Y position is right but the X position is still far away from the annotation.
And if I zoom in the PDF file, the MenuClass will not show(the Y position is wrong ).

what function can I use to fix this? thank you

Actually I found a similar question and the answer solve my problem.
Here is the questionhttps://community.pdftron.com/t/placement-of-widgets-to-move-with-pdfviewctrl/2112/2

so I end up using :

Canvas canvas = mPDFView.GetCanvas();  
 Canvas.SetLeft(MenuClass, mSelectedAnnotation.BoundingBoxRect.x1);
            Canvas.SetTop(MenuClass, mSelectedAnnotation.BoundingBoxRect.y2);