Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
markdhem
Posts: 6
Joined: Thu Jul 05, 2018 9:30 am

Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by markdhem »

Hi Alex

I want to draw on a AnnotationViewer a

RulerAnnotation from PointF(0,0) to PointF(500,0) programmatically.

Best Regards
Mark
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by Alex »

Hi Mark,
I want to draw on a AnnotationViewer a
RulerAnnotation from PointF(0,0) to PointF(500,0) programmatically.
You can set the start point of ruler annotation (line-based annotation) using the LineAnnotationData.StartPoint property:
https://www.vintasoft.com/docs/vsimagin ... Point.html

You can set the end point of ruler annotation (line-based annotation) using the LineAnnotationData.EndPoint property:
https://www.vintasoft.com/docs/vsimagin ... Point.html

Please read about the annotation's coordinate system and units of measure here:
https://www.vintasoft.com/docs/vsimagin ... _Data.html

Best regards, Alexander
markdhem
Posts: 6
Joined: Thu Jul 05, 2018 9:30 am

Re: Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by markdhem »

Hi Alex,

I read the documentation but still I don't get it, can you show me an example or a hint about this?



Best regards

Mark
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by Alex »

Here is code snippet that shows how to add the ruler annotation with coordinates (0;0)-(0;500) to the image in annotation viewer:

Code: Select all

// create an image
Vintasoft.Imaging.VintasoftImage image = new Vintasoft.Imaging.VintasoftImage(1000, 1000);
// add the image to the annotation viewer
annotationViewer1.Images.Add(image);


// create the ruler annotation
Vintasoft.Imaging.Annotation.RulerAnnotationData rulerAnnotationData = new Vintasoft.Imaging.Annotation.RulerAnnotationData();

// coordinate in pixels
float coordinateInPixels = 500;
// coordinate in DIP (device independent pixels)
float coordinateInDips = coordinateInPixels * 96 / image.Resolution.Horizontal;
// set the ruler coordinates
rulerAnnotationData.StartPoint = new System.Drawing.PointF(0, 0);
rulerAnnotationData.EndPoint = new System.Drawing.PointF(0, coordinateInDips);

// add the ruler annotation to the image in annotation viewer
int imageIndex = 0;
annotationViewer1.AnnotationDataController[imageIndex].Add(rulerAnnotationData);
Best regards, Alexander
markdhem
Posts: 6
Joined: Thu Jul 05, 2018 9:30 am

Re: Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by markdhem »

Hi Alex,

This works perfectly. Thanks a lot, but I still have a problem, when I have a multiple pages and when I go to the
second page and click the button it will draw at page 1.

Regards

Mark
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by Alex »

You need to set the correct image index when you selecting the annotation collection:

Code: Select all

...
// add the ruler annotation to the image in annotation viewer
int imageIndex = 0;
annotationViewer1.AnnotationDataController[imageIndex].Add(rulerAnnotationData);
Best regards, Alexander
markdhem
Posts: 6
Joined: Thu Jul 05, 2018 9:30 am

Re: Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by markdhem »

Hi Alex,

I still don't know how to select the Current Page.
Please give me an example. Thank you

Mark
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Draw RulerAnnotation from PointF(0,0) to PointF(500, 0)

Post by Alex »

Hello Mark,

The focused image in image viewer can be changed using the ImageViewer.FocusedIndex property:
https://www.vintasoft.com/docs/vsimagin ... Index.html

More info about image viewer please read here:
https://www.vintasoft.com/docs/vsimagin ... Forms.html

Best regards, Alexander
Post Reply