Beispiel #1
0
        public bool zedGraph_MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            if (isMousePressed)
            {
                // Координаты, которые переданы в событие
                PointF    eventPoint = new PointF(e.X, e.Y);
                GraphPane pane       = new GraphPane();
                object    nearestObj = new object();
                int       index      = 0;

                using (Graphics g = sender.CreateGraphics())
                {
                    MP.FindNearestPaneObject(eventPoint, g, out pane, out nearestObj, out index);
                }

                // Пересчитать координаты из системы координат, связанной с контролом zedGraph
                // в систему координат, связанную с графиком
                double newX;
                double newY;
                double oldX;
                double oldY;

                pane.ReverseTransform(new PointF(posX, posY), out oldX, out oldY);
                pane.ReverseTransform(new PointF(e.X, e.Y), out newX, out newY);
                MoveImage(oldX, oldY, newX, newY);
            }
            return(false);
        }
Beispiel #2
0
        void ProcessRubberBand(GraphPane selectedPane, Rectangle?rect)
        {
            if (!rect.HasValue &&
                !previousRectangle.IsEmpty &&
                IsMinimumDragDisplacement(previousRectangle.Width, previousRectangle.Height))
            {
                double minX, maxX;
                double minY, maxY;
                selectedPane.ZoomStack.Push(selectedPane, ZoomState.StateType.Zoom);
                selectedPane.ReverseTransform(previousRectangle.Location, out minX, out maxY);
                selectedPane.ReverseTransform(previousRectangle.Location + previousRectangle.Size, out maxX, out minY);
                if (IsEnableHZoom)
                {
                    selectedPane.XAxis.Scale.Min = minX;
                    selectedPane.XAxis.Scale.Max = maxX;
                }

                if (IsEnableVZoom)
                {
                    selectedPane.YAxis.Scale.Min = minY;
                    selectedPane.YAxis.Scale.Max = maxY;
                }

                selectedPane.AxisChange();
            }

            UpdateRubberBand(rect.GetValueOrDefault(), Rectangle.Truncate(selectedPane.Chart.Rect));
        }
Beispiel #3
0
        //----Двигаем точки
        private bool zGraph_MouseDownEvent(ZedGraphControl control, MouseEventArgs e)
        {
            if (Control.ModifierKeys == Keys.Shift)
            {
                PointF mousePt = new PointF(e.X, e.Y);

                if (pane.FindNearestPoint(mousePt, out dragCurve, out dragIndex) &&
                    dragCurve.Points is PointPairList &&
                    dragCurve.YAxisIndex == 0 && dragCurve.Label.Text == "Curve3")
                {
                    startPt   = mousePt;
                    startPair = dragCurve.Points[dragIndex];

                    isDragPoint = true;

                    pane.ReverseTransform(mousePt, out startX, out startY);

                    hLine            = new LineObj(pane.XAxis.Scale.Min, startPair.Y, pane.XAxis.Scale.Max, startPair.Y);
                    hLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                    vLine            = new LineObj(startPair.X, pane.YAxis.Scale.Min, startPair.X, pane.YAxis.Scale.Max);
                    vLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                    pane.GraphObjList.Add(hLine);
                    pane.GraphObjList.Add(vLine);

                    control.Refresh();
                }
            }

            return(false);
        }
        private void zedGraphControl_MouseMove(object sender, MouseEventArgs e)
        {
            // Save the mouse location
            PointF mousePt = new PointF(e.X, e.Y);

            // Find the Chart rect that contains the current mouse location
            GraphPane pane = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt);

            // If pane is non-null, we have a valid location.  Otherwise, the mouse is not
            // within any chart rect.
            if (pane != null)
            {
                double x, y;
                // Convert the mouse location to X, and Y scale values
                pane.ReverseTransform(mousePt, out x, out y);

                // 获取横纵坐标信息
                coordinateX.Text = x.ToString("f2");
                coordinateY.Text = y.ToString("f2");
                //coordinateX.Text = e.X.ToString();
                //coordinateY.Text = e.Y.ToString();
                //ColorRGB.Text = ;

                // 改变鼠标指针
                object nearestCurve;
                int    iNearest;
                bool   isSelected = zedGraphControl.GraphPane.FindNearestObject(mousePt, zedGraphControl.CreateGraphics(), out nearestCurve, out iNearest);
                if (isSelected)
                {
                    zedGraphControl.Cursor = Cursors.Hand;
                }
                else
                {
                    if (isStartDraw || isModify)
                    {
                        zedGraphControl.Cursor = Cursors.Cross;
                    }
                    else
                    {
                        zedGraphControl.Cursor = Cursors.Default;
                    }
                }

                // 拖拽修改折线
                if (isModify)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        if (TargetcurveItem != null)
                        {
                            IPointListEdit newlist = TargetcurveItem.Points as IPointListEdit;
                            newlist[TarfgetIndex].X = double.Parse(x.ToString("f2"));
                            newlist[TarfgetIndex].Y = double.Parse(y.ToString("f2"));
                            zedGraphControl.AxisChange();
                            zedGraphControl.Refresh();
                        }
                    }
                }
            }
        }
Beispiel #5
0
        private bool ZedGraph_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            // Save the mouse location
            PointF mousePt = new PointF(e.X, e.Y);

            // Find the Chart rect that contains the current mouse location
            GraphPane pane = sender.MasterPane.FindChartRect(mousePt);

            // If pane is non-null, we have a valid location.  Otherwise, the mouse is not
            // within any chart rect.
            if (pane != null)
            {
                // Convert the mouse location to X, and Y scale values
                pane.ReverseTransform(mousePt, out double x, out double y);
                // Format the status label text
                toolStripStatusXY.Text = "(" + x.ToString("f2") + ", " + y.ToString("f2") + ")";
            }
            else
            {
                // If there is no valid data, then clear the status label text
                toolStripStatusXY.Text = string.Empty;
            }

            // Return false to indicate we have not processed the MouseMoveEvent
            // ZedGraphControl should still go ahead and handle it
            return(false);
        }
Beispiel #6
0
        private bool zedGraphControl1_MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            if (mouseDown)
            {
                GraphPane pane = zedGraphControl1.GraphPane;
                double    x;
                double    y;
                pane.ReverseTransform(new PointF(e.X, e.Y), out x, out y);
                double x1 = x - x0;
                double y1 = y - y0;
                int    m  = Convert.ToInt32(M_tb.Text);
                double k  = (ymax_limit - ymin_limit) / (ymax_limit0 - ymin_limit0);
                zedGraphControl1.GraphPane.YAxisList[curveIndex].Scale.Min -= y1 * k;
                zedGraphControl1.GraphPane.YAxisList[curveIndex].Scale.Max -= y1 * k;

                /*
                 * for (int i = 0; i < m; ++i)
                 * {
                 *  zedGraphControl1.GraphPane.CurveList[curveIndex].Points[i].X += x1;
                 *  zedGraphControl1.GraphPane.CurveList[curveIndex].Points[i].Y += y1 * k;   // k - множитель для сопоставления осей y
                 * }
                 *
                 * zedGraphControl1.GraphPane.XAxis.Scale.Min = xmin_limit;
                 * zedGraphControl1.GraphPane.XAxis.Scale.Max = xmax_limit;
                 */
                zedGraphControl1.AxisChange();
                zedGraphControl1.Invalidate();
            }
            mouseDown = false;
            return(true);
        }
Beispiel #7
0
        /// <summary>
        /// Обработчик события нажатия на кнопку мыши
        /// </summary>
        /// <returns>Метод возвращает true, если нужно запретить дальнейшую встроенную обработку события (показ контекстного меню, начало выделения и т.п.), и false, если обработка события должна быть продолжена</returns>
        bool zedGraph_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            GraphPane pane = zedGraph.GraphPane;

            // Координаты, которые переданы в событие
            Point eventPoint = new Point(e.X, e.Y);

            eventCoord.Text = string.Format("({0}; {1})", eventPoint.X, eventPoint.Y);

            // Координаты, пересчитанные в систему координат графика
            double graphX, graphY;

            // Пересчитать координаты из системы координат, связанной с контролом zedGraph
            // в систему координат, связанную с графиком
            pane.ReverseTransform(new PointF(e.X, e.Y), out graphX, out graphY);
            graphCoord.Text = string.Format("({0:F3}; {1:F3})", graphX, graphY);

            // Пересчитаем в обратную сторону из системы координат графика
            // в систему координат контрола.
            // Должны получить те же значения, что и в eventPoint
            // (с точностью до погрешности округления)
            // Последний параметр CoordType.AxisXYScale обозначает,
            // в какой системе координат заданы координаты, переданные в первых двух параметрах.
            PointF controlPoint = pane.GeneralTransform(new PointF((float)graphX,
                                                                   (float)graphY),
                                                        CoordType.AxisXYScale);

            controlCoord.Text = string.Format("({0}; {1})", controlPoint.X, controlPoint.Y);

            return(false);
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            double x = (double)new XDate(DateTime.Now);
            double y = Math.Sin(i * Math.PI / 15.0) * 16.0;

            dataGridView1.Rows[0].Cells[2].Value = y * rd.NextDouble();
            dataGridView1.Rows[0].Cells[3].Value = y;

            if (y < Convert.ToDouble(dataGridView1.Rows[0].Cells[4].Value))
            {
                dataGridView1.Rows[0].Cells[4].Value = y;
            }
            if (y > Convert.ToDouble(dataGridView1.Rows[0].Cells[5].Value))
            {
                dataGridView1.Rows[0].Cells[5].Value = y;
            }
            //if (myCurve.Points.Count > 100)
            //{
            //    myCurve.RemovePoint(0);
            //}
            myCurve.AddPoint(x, y);

            //double x1=0, y1=0;
            myPane.ReverseTransform(new PointF((float)myPane.XAxis.Scale.Min, 0f), out x, out y);
            //XDate xd = new XDate(x1);
            zedGraphControl1.AxisChange();
            zedGraphControl1.Refresh();
            //myPane.GetImage(true).Save(); //调用保存接口
            i++;

            //radTrackBar1.Value = 0.5f * i;
            radTrackBar1.Maximum = i;
            //radTrackBar1.Value = i;
            radTrackBar1.Ranges.Maximum     = i;
            this.radTrackBar1.Ranges[0].End = i;
            try
            {
                //radTrackBar1.Ranges.Maximum = 0.5f * i;
                //radTrackBar1.Ranges.Maximum = 0.5f * i;
                if (i > (xMax - xSpace))
                {
                    this.radTrackBar1.Ranges[0].Start = i - xMax + xSpace;
                }
                else
                {
                    this.radTrackBar1.Ranges[0].Start = 0;
                }
            }
            catch
            { }
            if (iPos < xMax - xSpace)
            {
                iPos++;
            }
            else
            {
                myPane.XAxis.Scale.Min++;
                myPane.XAxis.Scale.Max++;
            }
        }
Beispiel #9
0
        private void ContextMenuBuilder(ZedGraphControl sender, ContextMenuStrip menu, Point mousePt,
                                        ZedGraphControl.ContextMenuObjectState objState)
        {
            // Find the Chart rect that contains the current mouse location
            GraphPane pane = sender.MasterPane.FindChartRect(mousePt);

            // If pane is non-null, we have a valid location.  Otherwise, the mouse is not
            // within any chart rect.
            if (pane != null && pane.XAxis.Title.IsVisible)
            {
                double x, y;
                // Convert the mouse location to X, and Y scale values
                pane.ReverseTransform(mousePt, out x, out y);

                string sParameterName = pane.XAxis.Title.Text;
                _CurrentParameter = new NameValuePair(sParameterName, x);

                menu.Items.Insert(0, new ToolStripSeparator());

                oSBWMenu = new ToolStripMenuItem("Send SBML to");
                updateSBWMenu();
                menu.Items.Insert(0, oSBWMenu);

                var oStartSimulation = new ToolStripMenuItem("Perform a Simulation");
                oStartSimulation.Click += StartSimulation;
                menu.Items.Insert(0, oStartSimulation);

                menu.Items.Insert(0, new ToolStripSeparator());
                menu.Items.Insert(0, new ToolStripMenuItem(String.Format("{0} = {1:F5}", sParameterName, x)));
            }
        }
Beispiel #10
0
        private bool ActivateDragPoint(ZedGraphControl control, MouseEventArgs e)
        {
            // mousedown combination
            GraphPane myPane  = control.GraphPane;
            PointF    mousePt = new PointF(e.X, e.Y);

            // find the point that was clicked, and make sure the point list is editable
            // and that it's a primary Y axis (the first Y or Y2 axis)
            if (myPane.FindNearestPoint(mousePt, out graph, out dragIndex) &&
                graph.Points is PointPairList &&
                graph.YAxisIndex == 0)
            {
                // save the starting point information
                startPt   = mousePt;
                startPair = graph.Points[dragIndex];
                // indicate a drag operation is in progress
                isDragPoint = true;
                // get the scale values for the start of the drag
                double startX2, startY2;
                myPane.ReverseTransform(mousePt, out startX, out startX2, out startY, out startY2);
                // if it's a Y2 axis, use that value instead of Y
                if (graph.IsY2Axis)
                {
                    startY = startY2;
                }

                return(true);
            }
            return(false);
        }
Beispiel #11
0
        public LineItem createIntervals(ZedGraphControl zgc, MouseEventArgs e, HRMObjectClass hrmobject)
        {
            GraphPane pane = zgc.GraphPane;

            // x & y variables to store the axis values
            double xVal;
            double yVal;

            pane.ReverseTransform(e.Location, out xVal, out yVal);

            LineItem line = new LineItem(String.Empty, new[] { xVal, xVal },
                                         new[] { 0.0, hrmobject.calcMax() },
                                         Color.Black, SymbolType.None);

            line.Line.Width = 1f;

            // Add Interval Points to List
            intervalManualClickList.Add(xVal, pane.YAxis.Scale.Min);
            intervalManualClickList.Add(xVal, hrmobject.calcMax());

            // Add Curve to Zedgraph
            pane.CurveList.Add(line);

            zgc.Refresh();

            return(line);
        }
Beispiel #12
0
        private bool zedGraphControl1_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            GraphPane myPane = zedGraphControl1.GraphPane;    // X & Y CO-Ordinates

            myPane.ReverseTransform(e.Location, out xVal, out yVal);
            start_dragXval = xVal;
            start_dragYval = yVal;

            if (myPane.CurveList.Count > 1)
            {
                myPane.CurveList[myPane.CurveList.Count - 1].Clear();
            }

            zedGraphControl1.Refresh();

            // Clear the previous values if any
            userClickrList.Clear();

            myPane.Legend.IsVisible = false;


            // Create a list using the above x & y values
            userClickrList.Add(start_dragXval, start_dragYval);


            // Add a curve
            userClickCurve = myPane.AddCurve(" ", userClickrList, Color.Red, SymbolType.Circle);

            zedGraphControl1.Refresh();

            return(true);
        }
Beispiel #13
0
        private bool DragPoint(ZedGraphControl control, MouseEventArgs e)
        {
            GraphPane myPane  = control.GraphPane;
            PointF    mousePt = new PointF(e.X, e.Y);

            // see if a dragging operation is underway
            if (isDragPoint)
            {
                // get the scale values that correspond to the current point
                double curX, curX2, curY, curY2;
                myPane.ReverseTransform(mousePt, out curX, out curX2, out curY, out curY2);
                // if it's a Y2 axis, use that value instead of Y
                if (graph.IsY2Axis)
                {
                    curY = curY2;
                }
                // calculate the new scale values for the point
                PointPair newPt = new PointPair(startPair.X + curX - startX, startPair.Y + curY - startY);
                // save the data back to the point list
                (graph.Points as PointPairList)[dragIndex] = newPt;
                // force a redraw
                control.Refresh();
            }
            return(false);
        }
Beispiel #14
0
        private void Mouseup(object sender, MouseEventArgs e)
        {
            GraphPane myPane = zedGraphControl1.GraphPane;

            if (e.Button == MouseButtons.Left & zoomcase == 1)
            {
                myPane.ReverseTransform(new PointF(e.X, e.Y), out graphX, out graphY, out graphYn);
                x2         = graphX;
                y2         = graphY;
                axisflag   = 0;
                yscalectrl = 0;
                eventflagL = true;
                Cursor     = Cursors.Default;
            }
            if (eventflagL & eventflagR == true)
            {
                if (Math.Abs(x1 - x2) < 0.01)
                {
                    x1 = myPane.XAxis.Max;
                }
                if (Math.Abs(y1 - y2) < 0.01)
                {
                    y1 = myPane.YAxis.Max;
                }


                myPane.XAxis.Max = Math.Max(x2, x1);
                myPane.XAxis.Min = Math.Min(x2, x1);
                myPane.YAxis.Max = Math.Max(y2, y1);
                myPane.YAxis.Min = Math.Min(y2, y1);
                eventflagL       = false;
                eventflagR       = false;
                zedGraphControl1.Refresh();
            }
        }
Beispiel #15
0
        private void GraphControl_MouseMove(
            object sender,
            MouseEventArgs e)
        {
            ZedGraphControl graph = (ZedGraphControl)sender;
            PointF          pt    = new PointF(e.X, e.Y);
            GraphPane       pane  = graph.MasterPane.FindChartRect(pt);

            if (!IsHoverDisabled && pane != null)
            {
                double x, y;
                pane.ReverseTransform(pt, out x, out y);

                TimeSpan time = new TimeSpan(
                    0, 0, 0, 0, (int)Math.Round(x * 1000 * 60));

                toolStripStatus.Text = string.Format(
                    "Time: {0} ({1}) Value: {2}",
                    string.Format("{0:F3} sec", x),
                    string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D2}",
                                  time.Hours, time.Minutes, time.Seconds, time.Milliseconds),
                    string.Format("{0:F2} {1}", y, UnitText));
            }
            else
            {
                toolStripStatus.Text = string.Empty;
            }
        }
        private string zGraph_CursorValueEvent(ZedGraphControl sender, GraphPane pane, Point mousePt)
        {
            double x, y;

            pane.ReverseTransform(mousePt, out x, out y);
            return(string.Format("X={0} Y={1}", ((XDate)x).ToString("mm:ss"), y));
        }
Beispiel #17
0
        private void MouseMove(object sender, MouseEventArgs e)
        {
            GraphPane myPane = zedGraphControl1.GraphPane;

            myPane.ReverseTransform(new PointF(e.X, e.Y), out graphX, out graphY, out graphYn);



            if (graphX > myPane.XAxis.Min & graphY > myPane.YAxis.Min & graphX < myPane.XAxis.Max & graphY < myPane.YAxis.Max)
            {
                richTextBox2.Text = graphX.ToString("N2");
                richTextBox3.Text = graphY.ToString("N2");
            }


            if (eventflagL & zoomcase == 3)
            {
                PointPairList diagline = new PointPairList();
                //diagline.Add(x1, y1);
                //diagline.Add(graphX, graphY);

                double[] cX = new double[1];
                double[] cY = new double[1];
                cX[0] = x1;
                cY[0] = y1;
                LineItem midline = myPane.AddCurve(null, cX, cY, Color.Blue, SymbolType.Star);
                //midline.Line.Style = DashStyle.Dot;
                //diagline.Clear();
            }
        }
Beispiel #18
0
        private double GetLocationValue(GraphPane pane, PointF point)
        {
            double x, y;

            pane.ReverseTransform(point, out x, out y);
            return(y);
        }
        private void zedGraphControl1_MouseMove(object sender, MouseEventArgs e)
        {
            #region [曲线显示值例子]
            PointF    mousePt = new PointF(e.X, e.Y);
            GraphPane mypane  = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt);
            //StockPointList stockPointList = new StockPointList(stockChart.stockList);


            if (point_x != MousePosition.X || point_y != MousePosition.Y)
            {
                if (mypane != null)
                {
                    point_x = MousePosition.X;
                    point_y = MousePosition.Y;
                    double x, y;
                    //StockPt mouseStock;
                    mypane.ReverseTransform(mousePt, out x, out y);
                    //mouseStock = stockPointList.GetAt((int)x - 1);
                    //toolTip1.SetToolTip(zedGraphControl1, "Open=" + mouseStock.Open.ToString("f2") + " \n High=" + mouseStock.High.ToString("f2") + "\n Low=" + mouseStock.Low.ToString("f2") + "\n Close=" + mouseStock.Close.ToString("f2"));
                }
                zedGraphControl1.Refresh();
                currentPoint = new Point(e.X, e.Y);

                DrawCross();
            }


            #endregion

            //// Save the mouse location
            //PointF mousePt = new PointF(e.X, e.Y);
            //dx = e.X;
            //string InfoString = string.Empty;

            //// Find the Chart rect that contains the current mouse location
            //GraphPane pane = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt);

            //// If pane is non-null, we have a valid location.  Otherwise, the mouse is not
            //// within any chart rect.
            //if (pane != null)
            //{
            //    double x, y;
            //    // Convert the mouse location to X, and Y scale values
            //    pane.ReverseTransform(mousePt, out x, out y);
            //    // 获取横纵坐标信息
            //    //x=myPane.XAxis.
            //    //XDate xd = new XDate(x);
            //    //DateTime date = xd.DateTime;
            //    //InfoString = xd.ToString();
            //}
        }
Beispiel #20
0
        public void showToolTip()
        {
            if (!m_bShowTip)
            {
                return;
            }

            double    dTimestamp; //时间戳
            double    dUseless;   //占位
            GraphPane pane = zed1.GraphPane;

            pane.ReverseTransform(location, out dUseless, out dTimestamp);
            txt = GetPointValue(dTimestamp);
            toolTip1.SetToolTip(zed1, txt);
        }
Beispiel #21
0
        /// <summary>
        /// Finds the closest point in the plot to the mouse position and assigns it to closestPoint
        /// </summary>
        /// <param name="mousePosition">The current mouse position</param>
        /// <param name="closestPoint">will either be the closest point or an empty point if one is not found</param>
        /// <returns>True if a point is found, False otherwise</returns>
        public bool FindClosestPoint(PointF mousePosition, out PointPair closestPoint, out GraphPane closestPane)
        {
            double graphX;
            double graphY;

            closestPoint = null;
            closestPane  = null;

            PointPair unmatchedClosest = new PointPair();
            PointPair matchedClosest   = new PointPair();

            closestPane = MasterPane.FindPane(mousePosition);

            if (closestPane == null)
            {  //if we couldn't get the pane then we can't find the point
                return(false);
            }

            // reverseTransform converts the mouse position to the point on a graph
            closestPane.ReverseTransform(mousePosition, out graphX, out graphY);

            PointPair mousePositionPP = new PointPair(graphX, graphY);

            matchedClosest = GetClosestPointInCurve(mousePositionPP, closestPane.CurveList[matchedCurveName]);
            if (!m_options.hideUnmatched)
            {
                unmatchedClosest = GetClosestPointInCurve(mousePositionPP, closestPane.CurveList[unmatchedCurveName]);
            }

            //determine which of the points we found was closer
            if (CalculateDistance(mousePositionPP, matchedClosest) > CalculateDistance(mousePositionPP, unmatchedClosest))
            {
                //unmatched is closest
                closestPoint   = unmatchedClosest;
                m_snapBoxColor = m_options.unmatchedColor;
            }
            else
            {
                //matched is closest
                closestPoint   = matchedClosest;
                m_snapBoxColor = m_options.matchedColor;
            }

            bool foundClosest = (closestPoint.X != 0 || closestPoint.Y != 0);

            return(foundClosest);
        }
Beispiel #22
0
        private void Mousedown(object sender, MouseEventArgs e)
        {
            GraphPane myPane     = zedGraphControl1.GraphPane;
            Point     eventPoint = new Point(e.X, e.Y);


            if (e.Button == MouseButtons.Left & zoomcase == 1)
            {
                myPane.ReverseTransform(new PointF(e.X, e.Y), out graphX, out graphY, out graphYn);
                x1         = graphX;
                y1         = graphY;
                axisflag   = 0;
                yscalectrl = 0;
                eventflagR = true;
                Cursor     = Cursors.Cross;
            }
        }
Beispiel #23
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (ModifierKeys == Keys.Shift)
            {
                var       mousePt = new Point(e.X, e.Y);
                GraphPane pane    = zedGraphControl1.MasterPane.FindChartRect(mousePt);
                if (pane != null && pane.XAxis.Title.IsVisible)
                {
                    try
                    {
                        double x, y;
                        // Convert the mouse location to X, and Y scale values
                        pane.ReverseTransform(mousePt, out x, out y);
                        string sParameterName = pane.XAxis.Title.Text;
                        _oPopup.Label = String.Format("{0} = {1:F5}", sParameterName, x);

                        Simulator.setValue(sParameterName, x);

                        //_oPopup.SetData(Simulator.simulateEx(0.0, 10.0, 100));
                        double startTime = MainForm.Instance.SetupControl.SimulationStartTime;
                        double endTime   = MainForm.Instance.SetupControl.SimulationEndTime;
                        var    numPoints = (int)MainForm.Instance.SetupControl.SimulationNumPoints;
                        _oPopup.SetData(Simulator.simulateEx(startTime, endTime, numPoints));

                        _oPopup.Location = MousePosition;
                        _oPopup.Show();
                    }
                    catch (Exception)
                    {
                        _oPopup.Hide();
                    }
                }
                else
                {
                    _oPopup.Hide();
                }
            }
            else
            {
                _oPopup.Hide();
            }
        }
        private void chartPoint_MouseClick(object sender, MouseEventArgs e)
        {
            GraphPane pane = zedGraphControl1.GraphPane;

            double x;
            double y;

            pane.Legend.IsVisible = false;

            pane.ReverseTransform(e.Location, out x, out y);

            if (x != null && y != null)
            {
                LineItem pointLineItem = null;

                if (_selectedEnum == MenuEnum.Points)
                {
                    Points.Add(new Point()
                    {
                        X = x,
                        Y = y
                    });

                    //Set up points
                    PointPairList pointPairList = new PointPairList();
                    pointPairList.Add(x, y);

                    pointLineItem = new LineItem(null, pointPairList, _baseColor, SymbolType.Default, 3.0f);
                }


                if (pointLineItem != null)
                {
                    pointLineItem.Line.IsVisible   = false;
                    pointLineItem.Symbol.Fill.Type = FillType.Solid;

                    pane.CurveList.Add(pointLineItem);

                    zedGraphControl1.Refresh();
                }
            }
        }
Beispiel #25
0
        private void zed1_MouseMove(object sender, MouseEventArgs e)
        {
            GraphPane pane = zed1.GraphPane;

            if (temp.Y != e.Y)
            {
                zed1.Invalidate();
                pane.Chart.pt.X = e.X;
                pane.Chart.pt.Y = e.Y;
                location        = new Point(e.X, e.Y);
                double timestamp; //时间戳
                double useless;   //占位
                pane.ReverseTransform(location, out useless, out timestamp);
                TIMEStamp = timestamp;
                txt       = GetPointValue(TIMEStamp);
                toolTip1.SetToolTip(zed1, txt);
                m_bShowTip = true;
            }
            temp.X = e.X;
            temp.Y = e.Y;
        }
Beispiel #26
0
        private bool zgc_MouseMoveEvent_1(ZedGraphControl sender, MouseEventArgs e)
        {
            if (mouseDragged == true)
            {
                GraphPane pane = zgc.GraphPane;

                // x & y variables to store the axis values
                double xVal;
                double yVal;

                pane.ReverseTransform(e.Location, out xVal, out yVal);

                // Move line to New X Value
                intervalLine.Points[0].X = xVal;
                intervalLine.Points[1].X = xVal;

                zgc.Invalidate();
            }

            return(default(bool));
        }
        private void zedGraphControl_MouseClick(object sender, MouseEventArgs e)
        {
            if (isStartDraw)
            {
                GraphPane myPane = zedGraphControl.GraphPane;
                // Save the mouse location
                PointF mousePt = new PointF(e.X, e.Y);


                // Find the Chart rect that contains the current mouse location
                GraphPane pane = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt);

                // If pane is non-null, we have a valid location.  Otherwise, the mouse is not
                // within any chart rect.
                if (pane != null)
                {
                    double x, y;
                    // Convert the mouse location to X, and Y scale values
                    pane.ReverseTransform(mousePt, out x, out y);
                    // Determine if the clicked point exists
                    object nearestCurve;
                    int    iNearest;
                    bool   isSelected = zedGraphControl.GraphPane.FindNearestObject(mousePt, zedGraphControl.CreateGraphics(), out nearestCurve, out iNearest);
                    if (isSelected && iNearest == 0)
                    {
                        CurveItem curveItem = (CurveItem)nearestCurve;
                        x = curveItem.Points[iNearest].X;
                        y = curveItem.Points[iNearest].Y;
                    }
                    LineItem       myCurve = (LineItem)pane.CurveList[pane.CurveList.Count - 1];
                    IPointListEdit newlist = myCurve.Points as IPointListEdit;

                    newlist.Add(x, y);
                    zedGraphControl.AxisChange();
                    zedGraphControl.Refresh();
                }
            }
        }
Beispiel #28
0
        private bool zedGraphControl1_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            // Сюда будет сохранена кривая, рядом с которой был произведен клик
            CurveItem curve;


            GraphPane pane = zedGraphControl1.GraphPane;

            // Максимальное расстояние от точки клика до кривой в пикселях,
            // при котором еще считается, что клик попал в окрестность кривой.
            GraphPane.Default.NearestTol = 10;
            Point eventPoint = new Point(e.X, e.Y);
            bool  result     = pane.FindNearestPoint(e.Location, out curve, out pointIndex);

            if (result)
            {
                pane.ReverseTransform(new PointF(e.X, e.Y), out x0, out y0);
                mouseDown = true;
                int n = Convert.ToInt32(N_tb.Text);
                for (int i = 0; i < n; ++i)
                {
                    if (curve == zedGraphControl1.GraphPane.CurveList[i])
                    {
                        curveIndex = i;
                        ymin_limit = zedGraphControl1.GraphPane.YAxisList[i].Scale.Min;
                        ymax_limit = zedGraphControl1.GraphPane.YAxisList[i].Scale.Max;

                        xmin_limit  = zedGraphControl1.GraphPane.XAxis.Scale.Min;
                        xmax_limit  = zedGraphControl1.GraphPane.XAxis.Scale.Max;
                        ymin_limit0 = zedGraphControl1.GraphPane.YAxisList[0].Scale.Min;
                        ymax_limit0 = zedGraphControl1.GraphPane.YAxisList[0].Scale.Max;
                        break;
                    }
                }
            }
            return(true);
        }
        private bool xxxGraph_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            try
            {
                ZedGraphControl zgc = (ZedGraphControl)sender;

                // save the mouse location
                PointF mousePt = new PointF(e.X, e.Y);

                // find the Chart rect that contains the current mouse location
                GraphPane pane = zgc.MasterPane.FindChartRect(mousePt);

                // if pane is non-null, we have a valid location.  Otherwise, the mouse is not
                // within any chart rect.
                if (pane != null)
                {
                    double x, y;

                    // convert the mouse location to X, Y scale values
                    pane.ReverseTransform(mousePt, out x, out y);

                    // update cursor
                    xxxGraph_UpdateCursor(zgc, x, y);
                }
                else
                {
                    // if there is no valid data, then clear the status label text
                    // toolStripStatusXY.Text = string.Empty;
                }
            }
            catch { }

            // return false to indicate we have not processed the MouseMoveEvent
            // ZedGraphControl should still go ahead and handle it

            return(false);
        }
Beispiel #30
0
        private void statusStripUpdate(ZedGraphControl sender, MouseEventArgs e)
        {
            // Save the mouse location
            PointF mousePt = new PointF(e.X, e.Y);
            // Find the Chart rect that contains the current mouse location
            GraphPane pane = sender.MasterPane.FindChartRect(mousePt);

            // If pane is non-null, we have a valid location.  Otherwise, the mouse is not
            // within any chart rect.
            if (pane != null)
            {
                double x, y;
                // Convert the mouse location to X, and Y scale values
                pane.ReverseTransform(mousePt, out x, out y);
                // Format the status label text
                toolStripStatusLabel1.Text = "(" + x.ToString("f2") + ", "
                                             + String.Format("{0:0.###################}", y) + ")";
            }
            else
            {
                // If there is no valid data, then clear the status label text
                toolStripStatusLabel1.Text = string.Empty;
            }
        }
        /// <summary>
        /// Zoom a specified pane in or out according to the specified zoom fraction.
        /// </summary>
        /// <remarks>
        /// The zoom will occur on the <see cref="XAxis" />, <see cref="YAxis" />, and
        /// <see cref="Y2Axis" /> only if the corresponding flag, <see cref="IsEnableHZoom" /> or
        /// <see cref="IsEnableVZoom" />, is true.  Note that if there are multiple Y or Y2 axes, all of
        /// them will be zoomed.
        /// </remarks>
        /// <param name="pane">The <see cref="GraphPane" /> instance to be zoomed.</param>
        /// <param name="zoomFraction">The fraction by which to zoom, less than 1 to zoom in, greater than
        /// 1 to zoom out.  For example, 0.9 will zoom in such that the scale is 90% of what it was
        /// originally.</param>
        /// <param name="centerPt">The screen position about which the zoom will be centered.  This
        /// value is only used if <see paramref="isZoomOnCenter" /> is true.
        /// </param>
        /// <param name="isZoomOnCenter">true to cause the zoom to be centered on the point
        /// <see paramref="centerPt" />, false to center on the <see cref="Chart.Rect" />.
        /// </param>
        /// <param name="isRefresh">true to force a refresh of the control, false to leave it unrefreshed</param>
        protected void ZoomPane(GraphPane pane, double zoomFraction, PointF centerPt,
                                bool isZoomOnCenter, bool isRefresh)
        {
            double x;
            double x2;
            double[] y;
            double[] y2;

            pane.ReverseTransform(centerPt, out x, out x2, out y, out y2);

            if (_isEnableHZoom)
            {
                ZoomScale(pane.XAxis, zoomFraction, x, isZoomOnCenter);
                ZoomScale(pane.X2Axis, zoomFraction, x2, isZoomOnCenter);
            }
            if (_isEnableVZoom)
            {
                for (int i = 0; i < pane.YAxisList.Count; i++)
                    ZoomScale(pane.YAxisList[i], zoomFraction, y[i], isZoomOnCenter);
                for (int i = 0; i < pane.Y2AxisList.Count; i++)
                    ZoomScale(pane.Y2AxisList[i], zoomFraction, y2[i], isZoomOnCenter);
            }

            using (Graphics g = CreateGraphics())
            {
                pane.AxisChange(g);
                //g.Dispose();
            }

            SetScroll(hScrollBar1, pane.XAxis, _xScrollRange.Min, _xScrollRange.Max);
            SetScroll(vScrollBar1, pane.YAxis, _yScrollRangeList[0].Min,
                      _yScrollRangeList[0].Max);

            if (isRefresh)
                Refresh();
        }