, Visual C#


- 3


// Graphics

// ,

// .

// Black ,

// :

myGraphics = Graphics.FromImage(myBitmap);

myGraphics.Clear(BackColor);

myGraphics.FillEllipse(Brushes.Black, new

Rectangle(move_of_ball_x,

move_of_ball_y, 2 * radius_of_ball_x, 2 *

radius_of_ball_y));

// , myGraphics:

myGraphics.Dispose();

// :

position_of_ball_x =

Convert.ToInt32(width_of_rectangle / 2);

position_of_ball_y =

Convert.ToInt32(height_of_rectangle / 2);

}

, Timer ( ). Form1.cs , .

59.3. Timer.

private void timer1_Tick(object sender, EventArgs e)

{

// myGraphics Graphics:

Graphics myGraphics = CreateGraphics();

// ,

// :

myGraphics.DrawLine(new Pen(Color.Red, 3),

boundary_of_rectangle_x, boundary_of_rectangle_,

width_of_rectangle, boundary_of_rectangle_);

 

myGraphics.DrawLine(new Pen(Color.Red, 3),

boundary_of_rectangle_x, boundary_of_rectangle_,

boundary_of_rectangle_x, height_of_rectangle);

 

myGraphics.DrawLine(new Pen(Color.Red, 3),

boundary_of_rectangle_x, height_of_rectangle,

width_of_rectangle, height_of_rectangle);

 

myGraphics.DrawLine(new Pen(Color.Red, 3),

width_of_rectangle, boundary_of_rectangle_,

width_of_rectangle, height_of_rectangle);