I'm using the MSChartControl in my application. In the chart control I display an image where I want to use the selection mechanism of the chart control to select a range of the image using the CursorX from the ChartAr开发者_运维技巧ea.
In the SelectionRangeChanged event I want to get informed when a selection has been done by the user and then I want to colorize the areas that haven't been selected and hide the original selection.
Since there is no ClearSelection (at least I haven't found such a method), I set the selection to a value that the Cursor initially had when no selection was done:
private void chartTopoAP_SelectionRangeChanged(object sender, CursorEventArgs e)
{
int Start = (int)e.NewSelectionStart;
int End = (int)e.NewSelectionEnd;
MathUtil.SwapIf(Start > End, ref Start, ref End);
mySelectedRange = new Tuple<int, int>(Start, End);
chartTopoAP.ChartAreas[0].CursorX.SetSelectionPosition(double.NaN, double.NaN);
chartTopoAP.Invalidate();
chartTopoAP.Update();
}
In the paint method I do my own painting.
This is seems to work unless I resize the window and the chartcontrol.
1) I start the window, and select something 2) I resize the chartcontrol (larger/smaller doesn't matter) 3) I do another selection
-> The result is, that obviously the control has buffered some graphics internally and shows me the chart with a size that I had before resizing the control.
If I comment out the line
chartTopoAP.ChartAreas[0].CursorX.SetSelectionPosition(double.NaN, double.NaN);
it works. But how would I clear a selection then?
Thanks Martin
It seems to be related to scaleview zoom settings. if you add
chartTopoAP.ChartAreas[0].AxisX.ScaleView.ZoomReset();
after reseting the selection, the symptom goes away.
精彩评论