1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 11 namespace Circle 12 { 13 public partial class Form1 : Form 14 { 15 public Form1() 16 { 17 InitializeComponent(); 18 } 19 20 Random random = new Random(); 21 22 Color getRandomColor() 23 { 24 return Color.FromArgb( 25 random.Next(256), 26 random.Next(256), 27 random.Next(256)); 28 } 29 30 protected override void OnPaint(PaintEventArgs e) 31 { 32 Graphics g = this.CreateGraphics(); 33 int x0 = this.Width / 2; 34 int y0 = this.Height / 2; 35 36 for (int r = 0; r < this.Height / 2; r++) 37 { 38 g.DrawEllipse( 39 new Pen(getRandomColor(), 1), 40 x0 - r, 41 y0 - r/2, 42 r * 2, 43 r * 2 44 ); 45 } 46 g.Dispose(); 47 } 48 } 49 }