, Visual C#



62.1. Form1_Load .

// :

myClass[] Circles = new myClass[100];

// Point myPoint:

Point myPoint;

// :

Random myRandow;

int c, j;

private void myMethod()

{

Circles[c] = new myClass(myPoint);

c = c + 1;

if (c >= Circles.Length) c = 0;

}

private void Form1_Load(object sender, EventArgs e)

{

// :

this.SetStyle(ControlStyles.OptimizedDoubleBuffer |

ControlStyles.AllPaintingInWmPaint, true);

myRandow = new Random();

myMethod();

}

Properties PictureBox Events Paint .

62.2. pictureBox1_Paint .

private void pictureBox1_Paint(object sender,

PaintEventArgs e)

{

Color myColor = Color.Black;

float f;

e.Graphics.SmoothingMode =

System.Drawing.Drawing2D.SmoothingMode.HighQuality;

int k;

for (k = 0; k <= c - 1; k++)

{

f = 0.05f * Circles[k].value;

e.Graphics.DrawEllipse(new Pen(myColor, f),

Circles[k].pos.X - Circles[k].value,

Convert.ToInt32(Circles[k].pos.Y - Circles[k].value / 4),

Circles[k].value * 2,

Convert.ToInt32(Circles[k].value / 2));

Circles[k].value = Circles[k].value + 10;

if (Circles[k].value > 100) Circles[k].Reset();

}

}

, timer1 ( ). Form1.cs , .

62.3. Timer1.

private void timer1_Tick(object sender, EventArgs e)

{

myMethod();

Refresh();

j = j + 1;

if (j > myRandow.Next(30))

{

j = 0;

myPoint.X = myRandow.Next(pictureBox1.Width);

myPoint.Y = myRandow.Next(pictureBox1.Height);

c = 0;

}

}

62.4. .

class myClass

{

public Point pos = Point.Empty;

public int value = 0;

public myClass(Point pos)

{

Reset();

this.pos = pos;

}

public void Reset()

{

pos = Point.Empty;

value = 0;

}

}





- -  - -  - -