private void CalcArgVisualRange(XYDiagram diagram, out object argMin, out object argMax)
        {
            int minX = Math.Min(FirstPoint.Value.X, SecondPoint.Value.X);
            int maxX = Math.Max(FirstPoint.Value.X, SecondPoint.Value.X);

            argMin = diagram.PointToDiagram(new Point(minX, SecondPoint.Value.Y)).NumericalArgument;
            argMax = diagram.PointToDiagram(new Point(maxX, SecondPoint.Value.Y)).NumericalArgument;
        }
        private void chartControl2_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                XYDiagram xYDiagram = (XYDiagram)chartControl2.Diagram;

                double LastMouseCentreX = xYDiagram.PointToDiagram(e.Location).NumericalArgument;
                double LastMouseCentreY = xYDiagram.PointToDiagram(e.Location).NumericalValue;

                AddPointToChart(chartControl2, LastMouseCentreX, LastMouseCentreY, 0);
                LineSeriesView line = new LineSeriesView();

                seriesPointsInChart2 = chartControl2.Series[0].Points;
                SteeringExist        = true;
            }
        }
        void chartControl1_MouseWheel(object sender, MouseEventArgs e)
        {
            XYDiagram          diagram         = ((ChartControl)sender).Diagram as XYDiagram;
            double             minValueX       = diagram.AxisX.VisualRange.MinValueInternal;
            double             maxValueX       = diagram.AxisX.VisualRange.MaxValueInternal;
            double             minValueY       = diagram.AxisY.VisualRange.MinValueInternal;
            double             maxValueY       = diagram.AxisY.VisualRange.MaxValueInternal;
            double             scrollMinValueX = diagram.AxisX.WholeRange.MinValueInternal;
            double             scrollMaxValueX = diagram.AxisX.WholeRange.MaxValueInternal;
            double             scrollMinValueY = diagram.AxisY.WholeRange.MinValueInternal;
            double             scrollMaxValueY = diagram.AxisY.WholeRange.MaxValueInternal;
            DiagramCoordinates coord           = diagram.PointToDiagram(e.Location);
            double             x = coord.NumericalArgument;
            double             y = coord.NumericalValue;

            if (e.Delta > 0 && maxValueY - minValueY > 0.1 && maxValueX - minValueX > 0.1)
            {
                diagram.AxisX.VisualRange.SetMinMaxValues(0.2 * x + 0.8 * minValueX, 0.2 * x + 0.8 * maxValueX);
                diagram.AxisY.VisualRange.SetMinMaxValues(0.2 * y + 0.8 * minValueY, 0.2 * y + 0.8 * maxValueY);
            }
            if (e.Delta < 0 && (minValueX > scrollMinValueX || maxValueX < scrollMinValueX || minValueY > scrollMinValueY || maxValueY < scrollMaxValueY))
            {
                double minValueInternalX = (1.2 * minValueX - 0.2 * x >= scrollMinValueX) ? 1.2 * minValueX - 0.2 * x : scrollMinValueX;
                double maxValueInternalX = (1.2 * maxValueX - 0.2 * x <= scrollMaxValueX) ? 1.2 * maxValueX - 0.2 * x : scrollMaxValueX;
                double minValueInternalY = (1.2 * minValueY - 0.2 * y >= scrollMinValueY) ? 1.2 * minValueY - 0.2 * y : scrollMinValueY;
                double maxValueInternalY = (1.2 * maxValueY - 0.2 * y <= scrollMaxValueY) ? 1.2 * maxValueY - 0.2 * y : scrollMaxValueY;
                diagram.AxisX.VisualRange.SetMinMaxValues(minValueInternalX, maxValueInternalX);
                diagram.AxisY.VisualRange.SetMinMaxValues(minValueInternalY, maxValueInternalY);
            }
        }
Example #4
0
 private void chartControl1_MouseMove(object sender, MouseEventArgs e)
 {
     if (mouseDown)
     {
         if (curruentConstantLine != null)
         {
             //this.Cursor = System.Windows.Forms.Cursors.VSplit;
             XYDiagram          diagram     = (XYDiagram)chartControl1.Diagram;
             DiagramCoordinates coordinates = diagram.PointToDiagram(e.Location);
             if (coordinates.NumericalArgument >= minValue)
             {
                 curruentConstantLine.AxisValue = coordinates.NumericalArgument;
                 curruentConstantLine.Name      = string.Format("{0:############0.#######}", coordinates.NumericalArgument);
                 foreach (var tL in textAndLine)
                 {
                     tL.textEdit.Text = tL.constantLine.Name;
                 }
             }
         }
     }
     else
     {
         ChartHitInfo hitinfo = chartControl1.CalcHitInfo(e.X, e.Y);
         if (hitinfo.ConstantLine != null)
         {
             this.Cursor = System.Windows.Forms.Cursors.VSplit;
         }
     }
 }
        /// <summary>
        /// Event raised during the MouseClick event inside the chart
        /// ----Chart is disabled during Output Plotting and hence this won't fired---
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chartControl1_MouseClick(object sender, MouseEventArgs e)
        {
            if (!IsOutputChart)
            {
                if (e.Button == MouseButtons.Right)
                {
                    XYDiagram xYDiagram = (XYDiagram)chartControl1.Diagram;

                    double LastMouseCentreX = xYDiagram.PointToDiagram(e.Location).NumericalArgument;
                    double LastMouseCentreY = xYDiagram.PointToDiagram(e.Location).NumericalValue;

                    AddPointToChart(chartControl1, LastMouseCentreX, LastMouseCentreY, 0, false);
                    LineSeriesView line = new LineSeriesView();

                    seriesPointsInChart = chartControl1.Series[0].Points;
                }
            }
        }
        private void chartControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            SecondPoint = e.Location;
            if (ShouldScroll())
            {
                XYDiagram diagram = (XYDiagram)chartControl.Diagram;

                double argMin = diagram.PointToDiagram(new Point(FirstPoint.Value.X, SecondPoint.Value.Y)).NumericalArgument;
                double argMax = diagram.PointToDiagram(new Point(SecondPoint.Value.X, SecondPoint.Value.Y)).NumericalArgument;
                double diff   = -(argMax - argMin);
                double newMin = (double)diagram.AxisX.VisualRange.MinValue + diff;
                double newMax = (double)diagram.AxisX.VisualRange.MaxValue + diff;
                if ((newMin >= (double)diagram.AxisX.WholeRange.MinValue) && newMax <= (double)diagram.AxisX.WholeRange.MaxValue)
                {
                    diagram.AxisX.VisualRange.SetMinMaxValues(newMin, newMax);
                }
                FirstPoint = SecondPoint;
            }
        }
Example #7
0
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (diagram == null)
            {
                return;
            }

            // Get the information about the clicked point.
            DiagramCoordinates coords = diagram.PointToDiagram(e.Location);

            // If the point is within the diagram and in the constant line ...
            if (!coords.IsEmpty && line.AxisValue is DateTime &&
                coords.DateTimeArgument.Equals((DateTime)line.AxisValue))
            {
                // Allow dragging, catch the mouse and change the cursor.
                dragging      = true;
                chart.Capture = true;
                SetCursor();
            }
        }