Page 1 of 1

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

Posted: Fri Jul 06, 2018 4:58 am
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

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

Posted: Fri Jul 06, 2018 9:30 am
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

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

Posted: Fri Jul 06, 2018 10:11 am
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

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

Posted: Fri Jul 06, 2018 10:40 am
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

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

Posted: Fri Jul 06, 2018 11:55 am
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

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

Posted: Fri Jul 06, 2018 2:05 pm
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

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

Posted: Sat Jul 07, 2018 9:50 am
by markdhem
Hi Alex,

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

Mark

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

Posted: Sat Jul 07, 2018 10:59 am
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