0
点赞
收藏
分享

微信扫一扫

Winform中设置ZedGraph鼠标双击获取距离最近曲线上的点的坐标值


场景


在多条曲线中,鼠标双击面板,弹窗显示距离焦点最近的坐标的值。

效果

Winform中设置ZedGraph鼠标双击获取距离最近曲线上的点的坐标值_公众号

 

注:

实现

双击事件绑定

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;
}

 

举报

相关推荐

0 条评论