C SHARP – FORM APPLİCATİON ÇALAR SAAT / ALARM UYGULAMASI

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.
1
using System.Media;
NOT:Çalacağınız ses dosyasının uzantısı wav olmak zorunda aksi halde sorun yaşayabilirsiniz.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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)
        {//http//www.programlamadersleri.com
            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)
        {//http//www.programlamadersleri.com
            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.
        }
    }
}

0 Comments


EmoticonEmoticon