MSChartControl 选择时的奇怪行为
我在我的应用程序中使用 MSChartControl。在图表控件中,我显示一个图像,我想使用图表控件的选择机制来使用 ChartArea 中的 CursorX 选择图像范围。
在 SelectionRangeChanged 事件中,我想在用户完成选择时收到通知,然后我想对尚未选择的区域进行着色并隐藏原始选择。
由于没有ClearSelection(至少我还没有找到这样的方法),我将选择设置为未完成选择时光标最初具有的值:
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();
}
在paint方法中我自己进行绘画。
除非我调整窗口和图表控件的大小,否则这似乎有效。
1)我启动窗口,然后选择一些内容 2)我调整图表控件的大小(更大/更小并不重要) 3)我做了另一个选择
->结果是,显然该控件已在内部缓冲了一些图形,并向我显示了调整控件大小之前的图表大小。
如果我注释掉该行,
chartTopoAP.ChartAreas[0].CursorX.SetSelectionPosition(double.NaN, double.NaN);
它就可以工作。但我该如何清除选择呢?
谢谢 马丁
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 ChartArea.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎与scaleview缩放设置有关。如果在重置选择后添加
,症状就会消失。
It seems to be related to scaleview zoom settings. if you add
after reseting the selection, the symptom goes away.