Exemplo n.º 1
0
        /// <summary>
        /// private method for handling MouseMove events to display tooltips over
        /// individual datapoints.
        /// </summary>
        /// <param name="sender">
        /// A reference to the control that has the MouseMove event.
        /// </param>
        /// <param name="e">
        /// A MouseEventArgs object.
        /// </param>
        private void ZedGraphControl_MouseMove(object sender,
                                               System.Windows.Forms.MouseEventArgs e)
        {
            if (isShowPointValues)
            {
                CurveItem curve;
                int       iPt;

                if (graphPane.FindNearestPoint(new PointF(e.X, e.Y),
                                               out curve, out iPt))
                {
                    if (curve.Points[iPt].Tag is string)
                    {
                        this.pointToolTip.SetToolTip(this,
                                                     (string)curve.Points[iPt].Tag);
                    }
                    else
                    {
                        this.pointToolTip.SetToolTip(this,
                                                     curve.Points[iPt].ToString(this.pointValueFormat));
                    }
                    this.pointToolTip.Active = true;
                }
                else
                {
                    this.pointToolTip.Active = false;
                }
            }
        }
Exemplo n.º 2
0
        public static object GetObject(this ZedGraphControl zgc, MouseEventArgs e)
        {
            for (int i = 0; i < zgc.MasterPane.PaneList.Count; i++)
            {
                GraphPane myPane = zgc.MasterPane.PaneList[i];
                CurveItem item;
                int       iNearest;
                myPane.FindNearestPoint(new PointF(e.X, e.Y), out item, out iNearest);
                if (null != item)
                {
                    return(item.Points[iNearest].Tag);
                }
            }

            return(null);
        }