Custom Annotation (WPF - WindowsFormHost)

Discussions about annotation support.
Post Reply
goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

Custom Annotation (WPF - WindowsFormHost)

Post by goldrian » Fri Jun 17, 2022 6:55 pm

Hi!

I'm trying to use custom annotations but I'm quite confused...
Using the code from the example from https://www.gdpicture.com/guides/gdpict ... nt_EV.html

I try to draw a triangle. It kinda works, even if when I finish the interactive drawing the triangle is not in the exact position I was drawing.
If I select it, the bounding box is not correct. I attach an image.
The code I'm using to draw is exactly the one in the example:

Code: Select all

// when starting to draw...
 GdViewer.AddCustomAnnotInteractive(1);

Code: Select all

private void GdViewer1_OnCustomAnnotationPaint(AnnotationCustom annot, Graphics g)
        {
            switch (annot.ModelID)
            {
                case 1: //triangle annotation, previously defined by the AddCustomAnnotInteractive() function.
                    using (System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath())
                    {
                        gp.AddLine(new PointF(annot.Left - annot.Width / 2, annot.Top + annot.Height / 2), new PointF(annot.Left, annot.Top - annot.Height / 2));
                        gp.AddLine(new PointF(annot.Left, annot.Top - annot.Height / 2), new PointF(annot.Left + annot.Width / 2, annot.Top + annot.Height / 2));
                        gp.CloseFigure();
                        g.DrawPath(new Pen(Brushes.Red, (float)(0.1)), gp);
                    }

                    break;
                case 2: //cross annotation, previously defined by the AddCustomAnnotInteractive() function.
                    g.DrawLine(new Pen(Brushes.Red, (float)(0.1)), new PointF(annot.Left - annot.Width / 2, annot.Top - annot.Height / 2), new PointF(annot.Left + annot.Width / 2, annot.Top + annot.Height / 2));
                    g.DrawLine(new Pen(Brushes.Red, (float)(0.1)), new PointF(annot.Left - annot.Width / 2, annot.Top + annot.Height / 2), new PointF(annot.Left + annot.Width / 2, annot.Top - annot.Height / 2));
                    break;
            }
        }

I tried to just draw a line from the top left to the bottom right of the box, but it doesn't collimate even.
What's happening here?
Thanks.
Attachments
wrongBox.PNG

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: Custom Annotation (WPF - WindowsFormHost)

Post by Hugo » Mon Jun 20, 2022 4:55 pm

Goldrian,

I see you have found the CustomAnnotation methods since your previous forum post.
Since you are having difficulties, could you please provide me with a code project isolating the issue so I may reproduce this on my end?

Currently I am unable to notice any issues. Could you also please highlight the issue observed so I may fully understand what you are having issues with?

If you prefer you can contact us here to provide this more easily:
https://orpalis.zendesk.com/hc/en-us/requests/new

Regards,
Hugo Cudd
Technical Support

goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

Re: Custom Annotation (WPF - WindowsFormHost)

Post by goldrian » Wed Jun 22, 2022 3:48 pm

I'm preparing a sample project in which this problem is present.
I forgot to mention that I'm using .Net Core 3.1 dll in a .Net 6 WPF project, using GdViewer in a WindowsFormHost panel (since there's no support for custom annotations in WPF version :( )
I'll send it asap.

Thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest