How to create and display a Sicky Note in the PDFViewWPF

Im new to PDFNet, im trying the trial version...
Im displaying a PDF on the PDFViewWPF and it renders ok.
Now i wanted to create a sticky annotation on it and open the pop up with the annotation text when i click on it.

Right now i can create the annotation and i can see the icon of it but i dont know how to do to open the pop up when i click on it?

Example code:

// Create a Sticky Note
pdftron.PDF.Annots.Text txt = pdftron.PDF.Annots.Text.Create(doc, new pdftron.PDF.Rect(130, 388, 180, 406), "Hello World");

// Create a 'pop-up' annotation associated with the sticky note.
pdftron.PDF.Annots.Popup pop = pdftron.PDF.Annots.Popup.Create(doc, new pdftron.PDF.Rect(272, 300, 450, 450));
pop.SetParent(txt);
txt.SetPopup(pop);

txt.RefreshAppearance();

var first_page = doc.GetPage(1);

// Add annotations to the page.
first_page.AnnotPushBack(txt);
PdfViewWpf.Update(txt, 1);

I should be able to get the annotation when i click on it and then open the pop up right?

I can atach to the MouseLeftButtonUp event on the PdfViewWpf but then i dont know how to continue:

void Current_View_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var mouseClick = e.GetPosition(Current_View);
            var annot = Current_View.GetAnnotationAt(mouseClick.X, mouseClick.Y);
            if (annot != null)
            {
                var annotationSelected = new Annot(annot);
                //TODO Continue
            }
        }

Any help will be helpfull, thanks.

Hello Diego,

Did you look at the PDFViewWPFTools? The PDFViewWPFTest used the PDFViewWPFTools in order to handle things like popup creation.
The PDFViewWPFTools has a StickyNoteCreate which creates the Sticky Note with a Popup. The popup is displayed in the NoteHost and the NoteManager handles which notes are open and should be displayed and so on.
The Pan tool (Pan.cs) handles double clicks on Sticky Notes. See the MouseLeftButtonUpHandler for how that is done. The AnnotEdit tool will display the popup for any (markup) annotation that is double clicked. See the MouseLeftButtonUpHandler in AnnotEdit.cs.

The code in your TODO should look something like this:

TextBox tb = new TextBox();
tb.AcceptsReturn = true;
tb.TextWrapping = TextWrapping.Wrap;
tb.VerticalAlignment = VerticalAlignment.Stretch;

// create a new popup if necessary
mPopup = mMarkup.GetPopup();
if (mPopup == null || !mPopup.IsValid())
{
mPopup = pdftron.PDF.Annots.Popup.Create(mNoteManager.PDFView.GetDoc().GetSDFDoc(), mMarkup.GetRect());
mMarkup.SetPopup(mPopup);
mPopup.SetParent(mMarkup);
}

tb.Text = mPopup.GetContents();

It’s up to you to decide where to place the Popup. You could respect the mPopup.GetRect() for this, or just place it conveniently on the screen somewhere, like the PDFViewWPFTools do.

I hope this helps you get going.
If you have any other questions, or need more clarifications, pleas don’t hesitate to ask.

Best Regards,
Tomas Hofmann