09-09-2005 09:31 AM
09-09-2005 02:06 PM
1) Is is possible to use an image to represent an annotation? If so, how?
Yes, you can do this by creating an image FillStyle via the FillStyle.FromImage method, then assign this FillStyle to the XYPointAnnotation.ShapeFillStyle property. For example:
XYPointAnnotation annotation = new XYPointAnnotation(xAxis1, yAxis1, 5.0, 5.0); // Make the shape a little larger so that the image can be seen more clearly. annotation.Caption = "Image annotation"; annotation.ShapeStyle = ShapeStyle.Rectangle; annotation.ShapeSize = new Size(50, 50); // Create an image fill style and set annotation shape fill style to this style. Image img = Image.FromFile(@"C:\Windows\FeatherTexture.bmp"); annotation.ShapeFillStyle = FillStyle.FromImage(img, ImageAlignment.Stretch); // Add the annotation to the graph. scatterGraph1.Annotations.Add(annotation);
2) Is there any native support for annotations reacting to mouse events build in to MS.net?
Yes, but only for the caption of the annotation. See the ScatterGraph.InteractionMode and XYPointAnnotation.InteractionMode properties. Interactive captions are enabled by default. Usually if you want to interact with the point you will want to use a cursor instead of an annotation.
- Elton
09-09-2005 03:29 PM
09-09-2005 03:34 PM
It depends - what are you trying to do? In general, you'll probably want to use the graph's PlotAreaMouse* events, then use the graph's GetAnnotationAt method to check to see if the mouse is interacting with an annotation, get a reference to the annotation, then make updates to the annotation.
- Elton