'We assume that the GdViewer1 control has been properly integrated.
Friend WithEvents GdViewer1 As GdPicture14.GdViewer
'Add the event.
AddHandler GdViewer1.OnCustomAnnotationPaint, AddressOf GdViewer1_OnCustomAnnotationPaint
'Define the event.
Sub GdViewer1_OnCustomAnnotationPaint(ByVal Annot As GdPicture14.Annotations.AnnotationCustom, ByVal g As System.Drawing.Graphics) Handles GdViewer1.OnCustomAnnotationPaint
Select Case Annot.ModelID
Case 1 'triangle annotation
Using gp As New 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, 0.1), gp)
End Using
Case 2 'cross annotation
g.DrawLine(New Pen(Brushes.Red, 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, 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))
End Select
End Sub
//We assume that the GdViewer1 control has been properly integrated.
//Add the event.
GdViewer1.OnCustomAnnotationPaint += GdViewer1_OnCustomAnnotationPaint;
//Define the event.
void GdViewer1_OnCustomAnnotationPaint(GdPicture14.Annotations.AnnotationCustom Annot, System.Drawing.Graphics g)
{
switch (Annot.ModelID)
{
case 1:
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(System.Drawing.Brushes.Red, 0.1f), gp);
}
break;
case 2:
g.DrawLine(new Pen(System.Drawing.Brushes.Red, 0.1f), 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(System.Drawing.Brushes.Red, 0.1f), 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;
default: break;
}
}