Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Annotation with self-defined image

There are several shapes that can be chosen when I add an annotation, but can I add a self-defined image from a file or resources?

 

(I'm using C#)

0 Kudos
Message 1 of 5
(4,158 Views)
You can create your own shapes by implementing 'NationalInstruments.UI.ShapeStyle' abstract class. You can make the annotation to use this custom shape by using the property 'ShapeStyle' of the annotation. Refer to the CustomAnnotations example present at Examples\UI\WindowsForms\Graph\CustomAnnotations.
Thanks,
Mohammed Haseeb|Measurement Studio|National Instruments
0 Kudos
Message 2 of 5
(4,139 Views)

Thank you for your answer, I would like to use an image as the annotation. As far as I can see, the  shapestyle must return   PointF[] from  GetPoints(PointF shapePoint, Size shapeSize).

 

Is there any way I can convert my Image to be returned and used as the annotation?

 

 

 

-Per Helge

0 Kudos
Message 3 of 5
(4,137 Views)

There is no direct way of converting an image to an annotation. But it is possible to display an image as an annotation. 

 

Using ShapeStyle, you can only customize the shape of a XYPointAnnotation. To display an image you can use ShapeFillStyle property on Annotation to fill from Image.

 

 xyPointAnnotation1.ShapeFillStyle = FillStyle.FromImage(image, ImageAlignment.Stretch);

 

As a simple alternative, you can use a XYRangeAnnotation which is rectangular in shape and use the RangeFillStyle property of it to display an image.

 

xyRangeAnnotation1.RangeFillStyle = FillStyle.FromImage(image, ImageAlignment.Stretch); 

  

Let me know if this works for you. 

Thanks,
Mohammed Haseeb|Measurement Studio|National Instruments
0 Kudos
Message 4 of 5
(4,133 Views)

Thank you, I used the XYPointAnnotation shaped as a square. It worked great.

 

-per helge

0 Kudos
Message 5 of 5
(4,129 Views)