By NaNo
Seçkin Üye
Form Application ile alarm kurup belirttiğimiz zaman geldiğinde bize sesli uyarı veren bir çalar saat yaptık.
- Ses çalmak için ilk önce System.Media Kütüphanesini eklenemeniz gerekiyor.
Kod:
using System.Media;
Kod:
using System;
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;
using System.Media;//Yeni kütüphane
namespace FormAlarmKur
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToShortTimeString();
//Label'ın texinini şuanki zamanı göstermesi için ayarlıyoruz.
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
//Timerımızı başlatıyoruz.
button2.Enabled = false;
//Başlangıçta Alarm iptal butonunu pasifleştiriyoruz.
}
private void button1_Click(object sender, EventArgs e)
{//Alarm kur butonuna tıklanınca yapılacaklar.
numericUpDown1.Enabled = false;//Saati pasifleştiriyoruz.
numericUpDown2.Enabled = false;//Dakikayı pasifleştiriyoruz.
button1.Enabled = false;//Alarm kur butonunu pasifleştiriyoruz.
if (numericUpDown1.Value == DateTime.Now.Hour && numericUpDown2.Value == DateTime.Now.Minute)
{//Eğer saat ve dakika şuanki zamana eşit ise
timer1.Stop();//Timerı durduruyoruz
SoundPlayer player = new SoundPlayer();//Yeni bir soundplayer oluşturuyoruz
string sarkiYol = Application.StartupPath + "/alarm.wav";
//Çalınacak sesin yolunu belirliyoruz
player.SoundLocation = sarkiYol;
player.Play();//Sesi çalıyoruz.
}//http//www.programlamadersleri.com
button2.Enabled = true;//Alarm iptal butonunu aktifleştiriyoruz.
}
private void button2_Click(object sender, EventArgs e)
{
button1.Enabled = true;//Alarm kur butonunu aktifleştiriyoruz.
button2.Enabled = false;//Alarm iptal butonunu pasifleştiriyoruz.
numericUpDown1.Enabled = true;//Saati aktifleştiriyoruz.
numericUpDown2.Enabled = true;//Dakikayı aktifleştiriyoruz.
}
}
}
Günceldir.............
mustafacan
Üye
Krdş yapacam İnş Olur
- Durum
- Üzgünüz bu konu cevaplar için kapatılmıştır...