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 Timbre_escolar_DTMF_01 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } DateTime hora; byte cnt = 0; SoundPlayer dtmf; private void Form1_Load(object sender, EventArgs e) { hora = DateTime.Now; lblHora.Text = hora.ToString("HH:mm:ss"); } private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { DateTime horaTimbre = dateTimePicker1.Value; } private void btnAgregar_Click(object sender, EventArgs e) { lstActivaciones.Items.Add(dateTimePicker1.Value.ToString("HH:mm:ss")); } private void lstActivaciones_SelectedIndexChanged(object sender, EventArgs e) { if (lstActivaciones.SelectedIndex != -1) btnEliminar.Enabled = true; else btnEliminar.Enabled = false; } private void btnEliminar_Click(object sender, EventArgs e) { lstActivaciones.Items.RemoveAt(lstActivaciones.SelectedIndex); } private void btnActivar_Click(object sender, EventArgs e) { cnt = 1; } private void timer1_Tick(object sender, EventArgs e) { if (cnt > 0 && cnt <= nudTiempo.Value) { lblMonitor.Text = "Timbre: ACTIVADO"; dtmf = new SoundPlayer("DTMF_1.wav"); if (cnt == 1) dtmf.Play(); cnt++; } else { lblMonitor.Text = "Timbre: Desactivado"; dtmf = new SoundPlayer("DTMF_D.wav"); if (cnt == nudTiempo.Value + 1) dtmf.Play(); cnt = 0; } hora = DateTime.Now; lblHora.Text = hora.ToString("HH:mm:ss"); if (lstActivaciones.Items.Count > 0) { int indice = lstActivaciones.FindString(lblHora.Text); if (indice != -1) cnt = 1; } } } }
Descarga del archivo
Descargar archivo