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
62
63
64
65
66
67
68
69
70
71
72
|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Alarm
{
public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, System.EventArgs e)
{
//tarih ve saati Text kutularında göster
textBox1.Text = DateTime.Now.ToShortDateString();
textBox2.Text = DateTime.Now.ToLongTimeString();
//Başlangıçta alarm kapalı
timer2.Enabled = false;
timer1.Enabled = false;
//her 100 ms'de bir yanıp sönmeyi sağla
timer2.Interval = 100;
//her 1000 ms'de bir alarmı kontrol etsin
timer1.Interval = 1000;
Text = "Alarm Kapalı";
}
private void timer1_Tick(object sender, System.EventArgs e)
{
//alarm zamanı geldiyse
if (textBox1.Text == DateTime.Now.ToShortDateString() && textBox2.Text == DateTime.Now.ToLongTimeString())
{
//timer2yi aktif yap (yanıp sönmeyi sağlayacak)
timer2.Enabled = true;
//Alarm metnini bildir
MessageBox.Show(textBox3.Text);
}
}
private void timer2_Tick(object sender, System.EventArgs e)
{
//Yazı ve zemin rengini değiştirerek
//Yanıp sönmesini sağla
Color c;
c=textBox3.BackColor;
textBox3.BackColor=textBox3.ForeColor ;
textBox3.ForeColor=c;
}
private void button1_Click(object sender, System.EventArgs e)
{
//Alarmı aktif yap
timer1.Enabled = true;
this.Text = "Alarm Açık";
}
private void button2_Click(object sender, System.EventArgs e)
{
//alarmı kapat
timer2.Enabled = false;
timer1.Enabled = false;
this.Text = "Alarm Kapalı";
}
}
}
|