Poo in C#

Page 164

private void timer1_Tick(object sender, EventArgs e) { double u = 2 * i * Math.PI / 100; v[0].X = cx / 2 + cx / 2 * (float)Math.Cos(u); v[0].Y = 5 * cy / 8 + cy / 16 * (float)Math.Sin(u); v[1] = new PointF(cx / 2, -cy);v[2] = new PointF(cx / 2, 2 * cy); u += Math.PI / 4;v[3].X = cx / 2 + cx / 4 * (float)Math.Cos(u); v[3].Y = cy / 2 + cy / 16 * (float)Math.Sin(u); Pen p = new Pen(Color.FromArgb(r.Next(2), r.Next(200), r.Next(2))); graf.DrawBeziers(p, v); i++; }

Executaţi dublu clic pe butonul START şi completaţi funcţia button1_Click conform modelului de mai jos: private void button1_Click(object sender, EventArgs e) {graf = this.CreateGraphics(); timer1.Start(); }

În fereastra Solution Explorer executaţi dublu clic pe Form1.Designer.cs pentru a declara variabilele globale i,cx,cy

în zona de declaraţii a funcţiei InitializeComponent().

private System.Windows.Forms.Button button1; private System.Windows.Forms.Timer timer1; int i = 0, cx = 300, cy = 300;

În acest moment aplicaţia este gata. Din meniul File alegeţi opţiunea Save All şi rulaţi aplicaţia.

Metoda Dispose()

Exemplul 13: 163


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.