Rectangle annotation click

Mar 19, 2014 at 6:02 PM
I have multiple rectangle annotations on the plot, and I want to perform a hittest with the mouse position to check what annotation was clicked, how do I do this? I cannot find anything useful in the documentation.

Thanks
Coordinator
Mar 19, 2014 at 10:54 PM
I added the following example to the 'example browser':
            var annotation = new RectangleAnnotation() { MinimumX = 10, MaximumX = 60, MinimumY = 10, MaximumY = 20 };
            plotModel.Annotations.Add(annotation);

            int i = 0;
            annotation.MouseDown += (s, e) =>
            {
                annotation.Text = "Clicked " + (++i) + " times.";
                plotModel.InvalidatePlot(false);
            };
It has not yet been decided whether the mouse events should go...
https://oxyplot.codeplex.com/workitem/10132
Mar 20, 2014 at 10:39 AM
Thanks, that set me off down a different route:
var rect1 = new RectangleAnnotation();
rect1.Fill = GlassMainColor.ToOxyColor();
rect1.StrokeThickness = 1;
rect1.MinimumX = g1;
rect1.MaximumX = g2;
rect1.MinimumY = 0;
rect1.MaximumY = 100;

rect1.MouseDown += (s, e) =>
{
    SelectedPane = pane;
};
Where "SelectedPane" is a public property. On the setter of the property, the plot is re-drawn and if the CurrentPane == SelectedPane then the annotation renders in a different colour, and the SelectedPane object is exposed publicly.