Custom Annotation (WPF - WindowsFormHost)
Posted: 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:
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.
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.