ArmandoCircuitos
Inicio
Electronica
Programacion
Resultado
Codigo
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Media; namespace Semaforo_DTMF_01 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } byte cnt = 1; SoundPlayer dtmf; SolidBrush Brush1, Brush2, Brush3; private void panel1_Paint(object sender, PaintEventArgs e) { if (cnt == 1) { dtmf = new SoundPlayer("DTMF_4.wav"); dtmf.Play(); } if (cnt == 8) { dtmf = new SoundPlayer("DTMF_2.wav"); dtmf.Play(); } if (cnt == 10) { dtmf = new SoundPlayer("DTMF_1.wav"); dtmf.Play(); } if (cnt >= 1 && cnt <= 7) Brush3 = new SolidBrush(Color.Green); else Brush3 = new SolidBrush(Color.Gray); if (cnt >= 8 && cnt <= 9) Brush2 = new SolidBrush(Color.Gold); else Brush2 = new SolidBrush(Color.Gray); if (cnt >= 10) Brush1 = new SolidBrush(Color.Red); else Brush1 = new SolidBrush(Color.Gray); Graphics miGraphics = e.Graphics; miGraphics.FillEllipse(Brush1 , 20, 20, 60, 60); miGraphics.FillEllipse(Brush2, 20, 100, 60, 60); miGraphics.FillEllipse(Brush3, 20, 180, 60, 60); } private void timer1_Tick(object sender, EventArgs e) { cnt++; panel1.Invalidate(); if(cnt >= 14) cnt = 1; } } }
Descarga del archivo
Descargar archivo