ZedGraph 显示鼠标信息

Posted Thomas会写字

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZedGraph 显示鼠标信息相关的知识,希望对你有一定的参考价值。

zedGra.IsShowCursorValues = true;
zedGra.CursorValueEvent += ZedGra_CursorValueEvent;
 string ZedGra_CursorValueEvent(ZedGraphControl sender, Graphpane pane, Point mousePt)
        
            ZedGraphControl zedGra = sender as ZedGraphControl;

            if (zedGra == null) return "";

            //声明曲线对象
            CurveItem nearstCurve;
            int i;
            Double y = 0.0;
            string z = String.Empty;
            string xTitle = String.Empty;
            string yTtile = String.Empty;
            String sTic = "MouseInfo -- ";

            try
            
                zedGra.GraphPane.FindNearestPoint(mousePt, out nearstCurve, out i);
                if (nearstCurve != null && nearstCurve.Points.Count > i && nearstCurve.Points.Count > i)
                

                    double dX = nearstCurve.Points[i].X;
                    double dY = nearstCurve.Points[i].Y;
                    double pointX = dX;
                    if (nSelX == 4)
                    
                        pointX = pointX / 500;
                        int h = (int)(pointX / 3600);
                        pointX -= h * 3600;
                        int m = (int)(pointX / 60);
                        pointX -= m * 60;
                        int s = (int)pointX;
                        pointX -= s;
                        int ms = (int)(pointX * 1000);
                        sTic += "Time = " + h.ToString("D2") + ":" + m.ToString("D2") + ":" + m.ToString("D2") + "::" + ms.ToString("D3") + "   ";

                        sTic += "X = ";
                        if (dX > 10000 * 10000)
                        
                            int n = (int)(dX / 10000 / 10000);
                            dX -= n * 10000 * 10000;
                            sTic += n.ToString() + ",";
                        
                        if (dX > 10000)
                        
                            int n = (int)(dX / 10000);
                            dX -= n * 10000;
                            sTic += n.ToString() + ",";
                        
                        if (dX > 0)
                        
                            int n = (int)(dX);
                            dX -= n;
                            sTic += n.ToString() + ",";
                        
                        sTic += "   ";
                    
                    else
                        sTic += "X = " + dX.ToString("F2") + "   ";
                    sTic += "Y = " + dY.ToString("F2");
                
            
            catch (Exception ex)
            

            
            return sTic;
        

以上是关于ZedGraph 显示鼠标信息的主要内容,如果未能解决你的问题,请参考以下文章

zedgraph 鼠标单击节点事件

Winform中设置ZedGraph鼠标悬浮显示线上的点的坐标并自定义显示的内容

Winform中设置ZedGraph鼠标悬浮显示线上的点的坐标并自定义显示的内容

设置zedgraph鼠标拖拽和局部放大属性 转

ZedGraph 鼠标右键菜单栏编辑

ZedGraph 鼠标右键菜单栏编辑