Example #1
0
        private void zedGraphControl_MouseClick(object sender, MouseEventArgs e)
        {
            CurveItem curve;
            int       index;
            GraphPane pane  = zedGraphControl.GraphPane;
            int       count = pane.CurveList.Count;

            if (count != 0)
            {
                CurveItem item = pane.CurveList[0];
                pane.CurveList.Clear();
                pane.CurveList.Add(item);
            }
            GraphPane.Default.NearestTol = 10;
            bool result = pane.FindNearestPoint(e.Location, out curve, out index);

            if (result)
            {
                PointPairList point = new PointPairList();
                point.Add(curve[index]);
                LineItem curvePount = pane.AddCurve("", new double[] { curve[index].X }, new double[] { curve[index].Y }, Color.Red, SymbolType.Circle);
                curvePount.Line.IsVisible    = false;
                curvePount.Symbol.Fill.Color = Color.Red;
                curvePount.Symbol.Fill.Type  = FillType.Solid;
                curvePount.Symbol.Size       = 7;
                zedGraphControl.Invalidate();
                double   x     = Math.Round(curve[index].X, 5);
                object[] param = new object[] { x };
                double   y     = (double)obj.GetType().InvokeMember("GetPoint", BindingFlags.InvokeMethod, null, obj, param);
                label.BackColor = pane.Fill.Color;
                label.Text      = string.Format("x = {0}, y = {1}", x, y);
            }
        }
Example #2
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);
        }
Example #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);
        }
Example #4
0
        /// <summary>
        /// Обработка события MouseClick - клик по графику
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void zedGraph_MouseClick(object sender, MouseEventArgs e)
        {
            // Сюда будет сохранена кривая, рядом с которой был произведен клик
            CurveItem curve;

            // Сюда будет сохранен номер точки кривой, ближайшей к точке клика
            int index;

            GraphPane pane = zedGraph.GraphPane;

            // Максимальное расстояние от точки клика до кривой в пикселях,
            // при котором еще считается, что клик попал в окрестность кривой.
            GraphPane.Default.NearestTol = 10;

            bool result = pane.FindNearestPoint(e.Location, out curve, out index);

            if (result)
            {
                // Максимально расстояние от точки клика до кривой не превысило NearestTol

                // Добавим точку на график, вблизи которой произошел клик
                PointPairList point = new PointPairList();

                point.Add(curve[index]);

                // Кривая, состоящая из одной точки. Точка будет отмечена синим кругом
                LineItem curvePount = pane.AddCurve("",
                                                    new double[] { curve[index].X },
                                                    new double[] { curve[index].Y },
                                                    Color.Blue,
                                                    SymbolType.Circle);

                //
                curvePount.Line.IsVisible = false;

                // Цвет заполнения круга - колубой
                curvePount.Symbol.Fill.Color = Color.Blue;

                // Тип заполнения - сплошная заливка
                curvePount.Symbol.Fill.Type = FillType.Solid;

                // Размер круга
                curvePount.Symbol.Size = 7;
            }
        }
Example #5
0
        private void zedGraph_MouseClick(object sender, MouseEventArgs e)
        {
            if (/*zedGraph.Cursor == Cursors.Hand*/ inBar)
            {
                CurveItem tmpCurve;
                int       tmpNearest;
                tmpCurve   = null;
                tmpNearest = -1;

                myPane.FindNearestPoint(new PointF(e.X, e.Y), out tmpCurve, out tmpNearest);
                if (tmpCurve != null && tmpNearest != -1)
                {
                    Form_Calendar calendar = new Form_Calendar(new DateTime(dateTimePicker_year.Value.Year, (int)tmpCurve[tmpNearest].X, 1));
                    calendar.ShowDialog();
                    Reload();
                }
            }
        }
Example #6
0
        bool zgc_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            GraphPane myPane = sender.GraphPane;
            CurveItem c;
            int       index;

            if (myPane.FindNearestPoint(new PointF(e.X, e.Y), out c, out index))
            {
                BIO.Framework.Core.Evaluation.Results.Result r = c[index].Tag as BIO.Framework.Core.Evaluation.Results.Result;
                if (r != null)
                {
                    /*
                     * TBS.Database.Forms.RecordMatchDetailForm form = new TBS.Database.Forms.RecordMatchDetailForm(r.TemplateRecord, r.CurrentRecord);
                     * form.Size = new Size(1100, 670);
                     * //TBS.Database.Forms.RecordDetailForm form = new TBS.Database.Forms.RecordDetailForm(r.CurrentRecord);
                     * form.ShowDialog();*/
                    return(true);
                }
            }
            return(false);
        }
        void zedGraphControl1_MouseClick(object sender, MouseEventArgs e)
        {
            // Сюда будет сохранена кривая, рядом с которой был произведен клик
            CurveItem curve;
            // Номер точки кривой, ближайшей к точке клика
            int       index;
            GraphPane pane = zedGraphControl1.GraphPane;

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

            //if (result)
            //накладываем дополнительное условие, чтобы отмечать точки только на заданной функции
            if (result && pane.CurveList.IndexOf(curve) == 0)
            {
                // Максимально расстояние от точки клика до кривой не превысило NearestTol
                // Добавим точку на график, вблизи которой произошел клик
                PointPairList point = new PointPairList();
                point.Add(curve[index]);
                line.Add(new point(curve[index].X, curve[index].Y));
                // Кривая, состоящая из одной точки. Точка будет отмечена синим кругом
                LineItem curvePount = pane.AddCurve("",
                                                    new double[] { curve[index].X },
                                                    new double[] { curve[index].Y },
                                                    Color.Blue,
                                                    SymbolType.Circle);
                curvePount.Line.IsVisible    = false;
                curvePount.Symbol.Fill.Color = Color.Red;
                curvePount.Symbol.Fill.Type  = FillType.Solid;
                curvePount.Symbol.Size       = 7;

                indexOfPoint.Add(curvePount);
            }

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
        }
Example #8
0
        private bool zGraph_MouseMoveEvent(ZedGraphControl control, MouseEventArgs e)
        {
            GraphPane myPane  = control.GraphPane;
            PointF    mousePt = new PointF(e.X, e.Y);

            if (isDragPoint)
            {
                double curX, curY;
                pane.ReverseTransform(mousePt, out curX, out curY);

                PointPair newPt = new PointPair(startPair.X + curX - startX, startPair.Y + curY - startY);
                (dragCurve.Points as PointPairList)[dragIndex] = newPt;

                hLine.Location.Y  = startPair.Y + curY - startY;
                hLine.Location.Y1 = startPair.Y + curY - startY;
                vLine.Location.X  = startPair.X + curX - startX;
                vLine.Location.X1 = startPair.X + curX - startX;


                control.Refresh();

                return(true);
            }
            else
            {
                if (myPane.FindNearestPoint(mousePt, out dragCurve, out dragIndex) &&
                    dragCurve.Points is PointPairList &&
                    dragCurve.YAxisIndex == 0 && dragCurve.Label.Text == "Curve3")
                {
                    zGraph.Cursor = Cursors.SizeAll;
                }
                else
                {
                    zGraph.Cursor = Cursors.Default;
                }
            }
            return(false);
        }
Example #9
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);
        }
Example #10
0
        private void zedGraphControl_MouseClick(object sender, MouseEventArgs e)
        {
            CurveItem curve;
            int       index;
            GraphPane pane = zedGraphControl.GraphPane;

            GraphPane.Default.NearestTol = 10;
            bool result = pane.FindNearestPoint(e.Location, out curve, out index);

            if (result)
            {
                PointPairList point = new PointPairList();
                point.Add(curve[index]);
                LineItem curvePount = pane.AddCurve("", new double[] { curve[index].X }, new double[] { curve[index].Y }, Color.Red, SymbolType.Circle);
                curvePount.Line.IsVisible    = false;
                curvePount.Symbol.Fill.Color = Color.Red;
                curvePount.Symbol.Fill.Type  = FillType.Solid;
                curvePount.Symbol.Size       = 7;
                zedGraphControl.Invalidate();
                double y = obj.GetPoint(Math.Round(curve[index].X, 5));
                label.BackColor = pane.Fill.Color;
                label.Text      = string.Format("x = {0}, y = {1}", Math.Round(curve[index].X, 5), y);
            }
        }
Example #11
0
        /// <summary>
        /// acts as a controller for point manipulation on the BW plot
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void zgc_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ZedGraphControl zg   = (ZedGraphControl)sender;
            GraphPane       pane = zg.MasterPane.FindPane(e.Location);

            if (pane == null)
            {
                return;
            }

            if (pane.Tag.ToString() != "BWPlot" && pane.Tag.ToString() != "TSPlot" && pane.Tag.ToString() != "XYPlot")
            {
                return;
            }
            strActiveplot = pane.Tag.ToString();

            //set the pane, curve and point for use by eventhandlers
            _gp = pane;

            CurveItem curve;
            int       pointndx;

            if (!pane.FindNearestPoint(e.Location, out curve, out pointndx))
            {
                return;
            }

            _curve   = curve;
            intPtndx = pointndx;

            PointPair pt = curve.Points[pointndx];

            //boxwhisker plot points do not all have tags - go away if you find one
            if (string.IsNullOrWhiteSpace((string)pt.Tag))
            {
                return;
            }
            string tag = pt.Tag.ToString();

            //build and show context menu items to enable/disable rows in the data sheet
            ContextMenu menuForPlot = new ContextMenu();
            MenuItem    disable     = new MenuItem("Disable Row containing " + tag, new EventHandler(disableRow));
            MenuItem    enable      = new MenuItem("Enable Row containing " + tag, new EventHandler(enableRow));

            menuForPlot.MenuItems.Add(disable);
            menuForPlot.MenuItems.Add(enable);

            //enable/disable the menu items appropriately (if disabled point, enable enable menu item... and conversely)
            CurveList cl1 = zgc.MasterPane.PaneList[2].CurveList;
            CurveList cl2 = zgc.MasterPane.PaneList[1].CurveList;

            if (cl1.Contains(zgc.MasterPane.PaneList[2].CurveList[tag]) || cl2.Contains(zgc.MasterPane.PaneList[2].CurveList[tag]))
            {
                enable.Enabled  = true;
                disable.Enabled = false;
            }
            else
            {
                enable.Enabled  = false;
                disable.Enabled = true;
            }

            //show the enable/disable contextmenu items
            menuForPlot.Show(zgc, new Point(e.X, e.Y));
        }