, Visual C#



30.1. .

// :

float x = 0;

float y0 = 49;

float y1 = 0;

float k = 10;

float b = -5;

// dx ::

private const float dx = 2;

// y=f(x):

private float f()

{

// NextDouble

// double, x:

Random myRandom = new Random();

x = Convert.ToSingle(myRandom.NextDouble());

// y=f(x):

y1 = y0 + k * x + b;

// y=f(x):

if (y1 > 98.9) y1 = 98.9f;

if (y1 < 0.999) y1 = 0.999f;

return y1;

}

30.2. Form1_Load.

private void Form1_Load(object sender, EventArgs e)

{

// myGraphics,

// PictureBox1 :

Bitmap myBitmap = new Bitmap(pictureBox1.Width,

pictureBox1.Height);

Graphics myGraphics = Graphics.FromImage(myBitmap);

myGraphics.ScaleTransform(1, -100.0f /

pictureBox1.Height);

myGraphics.TranslateTransform(0, -100);

// :

Pen myPen = new Pen(Color.Blue, 1);

int i;

for (i = 10; i <= 100; i+=10)

myGraphics.DrawLine(myPen,

0, i, pictureBox1.Width, i);

//

// PictureBox1:

pictureBox1.Image = myBitmap;

// , myGraphics:

myGraphics.Dispose();

}

Timer ( ). Form1.cs , .

30.3. Timer1_Tick.

private void timer1_Tick(object sender, EventArgs e)