Ejemplo n.º 1
0
 private void chart_exp_Paint(object sender, PaintEventArgs e)
 {
     if (pos_left_x >= 0)
     {
         double    x = axisX.Transform(pos_left_x);
         double    y = axisY.Transform(pos_left_y);
         Rectangle r = new Rectangle((int)x - 5, (int)y - 5, 10, 10);
         e.Graphics.DrawEllipse(Pens.Red, r);
     }
     if (pos_right_x >= 0)
     {
         double    x = axisX.Transform(pos_right_x);
         double    y = axisY.Transform(pos_right_y);
         Rectangle r = new Rectangle((int)x - 5, (int)y - 5, 10, 10);
         e.Graphics.DrawEllipse(Pens.Red, r);
     }
     //直線引きます
     if (pos_left_x >= 0 && pos_right_x >= 0)
     {
         if (pos_left_x > pos_right_x)
         {
             Swap(ref pos_left_x, ref pos_right_x);
             Swap(ref pos_left_y, ref pos_right_y);
         }
         double a  = (pos_right_y - pos_left_y) / (pos_right_x - pos_left_x);
         double b  = pos_left_y - a * pos_left_x;
         double x1 = axisX.ActualMinimum;
         //double x1 = 8800;
         //double y1 = axisX.Minimum * a + b;
         double y1 = x1 * a + b;
         //double y1 = 8800 * a + b;
         double x2 = axisX.ActualMaximum;
         //double x2 = 13000;
         //double y2 = axisX.Maximum * a + b;
         //double y2 = 13000 * a + b;
         double y2 = x2 * a + b;
         //e.Graphics.DrawLine(Pens.Green,new Point((int)axisX.Transform(9000), (int)axisY.Transform(0)),new Point((int)axisX.Transform(10000),(int)axisY.Transform(-2)));
         axisY.Minimum = y2;
         myModel.InvalidatePlot(true);
         e.Graphics.DrawLine(Pens.Blue
                             , new Point((int)axisX.Transform(x1), (int)axisY.Transform(y1))
                             , new Point((int)axisX.Transform(x2), (int)axisY.Transform(y2)));
     }
 }
Ejemplo n.º 2
0
        private void AddNewData(object sender, ElapsedEventArgs args)
        {
            _series1.Points.Add(new DataPoint(_currentX, euler_angles[0]));
            _series2.Points.Add(new DataPoint(_currentX, euler_angles[1]));
            _series3.Points.Add(new DataPoint(_currentX, euler_angles[2]));

            xAxis.Pan(xAxis.Transform(-0.05 + xAxis.Offset));

            _currentX += 0.05;

            uiMainPlot.InvalidatePlot(true);

            //if (_currentX == 20)
            //    _dataTimer.Stop();
        }