场景
在多条曲线中,鼠标双击面板,弹窗显示距离焦点最近的坐标的值。
效果
注:
实现
双击事件绑定
zgc.DoubleClickEvent += zgc_DoubleClickEvent;
其中zgc
ZedGraphControl zgc
实现方法
private static bool zgc_DoubleClickEvent(ZedGraphControl sender, MouseEventArgs e)
{
PointF mousePt = new PointF(e.X, e.Y);
CurveItem nearstCurve;
int i ;
Global.zedGraphControl1.GraphPane.FindNearestPoint(mousePt, out nearstCurve,out i);
if (nearstCurve != null && nearstCurve.Points[i]!= null)
{
Double x = nearstCurve.Points[i].X;
Double y = nearstCurve.Points[i].Y;
string title = Global.zedGraphControl1.GraphPane.XAxis.Title.Text;
DevExpress.XtraEditors.XtraMessageBox.Show("索引值:" + i + " X:" + x + " Y:" + y + " Xtitle:" + title);
}
return true;
}