Using System; Abdualimov Akbar using System. Collections. Generic
Download 56.16 Kb.
|
algo2mod
using System; Abdualimov Akbar using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace _27fevral { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void traffic_light(int rang) { Graphics g = this.CreateGraphics(); g.Clear(Color.White); SolidBrush kok = new SolidBrush(Color.LightBlue); SolidBrush qizil = new SolidBrush(Color.Red); SolidBrush sariq = new SolidBrush(Color.Yellow); SolidBrush yashil = new SolidBrush(Color.Green); SolidBrush oq = new SolidBrush(Color.White); Pen qora = new Pen(Color.Black, 4); g.FillPolygon(kok, new Point[] { new Point(350,155),new Point(500,155),new Point(500,480),new Point(350,480) });
new Point(350,155),new Point(500,155),new Point(500,480),new Point(350,480) }); Rectangle rec = new Rectangle(381, 173, 90, 90); g.DrawEllipse(qora, rec); Rectangle rec1 = new Rectangle(381, 270, 90, 90); g.DrawEllipse(qora, rec1); Rectangle rec2 = new Rectangle(381, 374, 90, 90); g.DrawEllipse(qora, rec2); //rang =1 qizil =2sariq =3yashil if(rang==1) { g.FillEllipse(qizil, rec); g.FillEllipse(oq, rec1); g.FillEllipse(oq, rec2); } else if(rang==2) { g.FillEllipse(oq, rec); g.FillEllipse(sariq, rec1); g.FillEllipse(oq, rec2); } else if(rang==3) { g.FillEllipse(oq, rec); g.FillEllipse(oq, rec1); g.FillEllipse(yashil, rec2); } } int i = 0; private void button2_Click(object sender, EventArgs e) { timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { i++; if(i==20) { traffic_light(1); } if(i==40) { traffic_light(2); } if(i==60) { traffic_light(3); i = 0; } } private void button1_Click(object sender, EventArgs e) { timer1.Stop(); i = 0; } } } Download 56.16 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling