// Alarm Projesi | www.yazilimcik.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
// Alarm Projesi | www.yazilimcik.com
namespace Alarm_Project__Yazilimcik_Com
{
public partial class Form1 : Form
{
internal System.Windows.Forms.Button btnAlarmKapa;
internal System.Windows.Forms.Button btnAlarmAc;
internal System.Windows.Forms.Label Label3;
internal System.Windows.Forms.TextBox txtMetin;
internal System.Windows.Forms.TextBox txtSaat;
internal System.Windows.Forms.Timer timer2;
internal System.Windows.Forms.Label Label2;
internal System.Windows.Forms.TextBox txtTarih;
internal System.Windows.Forms.Timer timer1;
internal System.Windows.Forms.Label Label1;
private Label label4;
private System.ComponentModel.IContainer components;
public Form1()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.btnAlarmKapa = new System.Windows.Forms.Button();
this.btnAlarmAc = new System.Windows.Forms.Button();
this.Label3 = new System.Windows.Forms.Label();
this.txtMetin = new System.Windows.Forms.TextBox();
this.txtSaat = new System.Windows.Forms.TextBox();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.Label2 = new System.Windows.Forms.Label();
this.txtTarih = new System.Windows.Forms.TextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.Label1 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btnAlarmKapa
//
this.btnAlarmKapa.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.btnAlarmKapa.ForeColor = System.Drawing.Color.Red;
this.btnAlarmKapa.Image = ((System.Drawing.Image)(resources.GetObject("btnAlarmKapa.Image")));
this.btnAlarmKapa.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.btnAlarmKapa.Location = new System.Drawing.Point(383, 16);
this.btnAlarmKapa.Name = "btnAlarmKapa";
this.btnAlarmKapa.Size = new System.Drawing.Size(110, 55);
this.btnAlarmKapa.TabIndex = 26;
this.btnAlarmKapa.Text = "Alarmi Kapat";
this.btnAlarmKapa.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.btnAlarmKapa.Click += new System.EventHandler(this.btnAlarmKapa_Click);
//
// btnAlarmAc
//
this.btnAlarmAc.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.btnAlarmAc.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
this.btnAlarmAc.Image = ((System.Drawing.Image)(resources.GetObject("btnAlarmAc.Image")));
this.btnAlarmAc.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.btnAlarmAc.Location = new System.Drawing.Point(267, 16);
this.btnAlarmAc.Name = "btnAlarmAc";
this.btnAlarmAc.Size = new System.Drawing.Size(110, 55);
this.btnAlarmAc.TabIndex = 25;
this.btnAlarmAc.Text = "Alarmi Aç";
this.btnAlarmAc.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.btnAlarmAc.Click += new System.EventHandler(this.btnAlarmAc_Click);
//
// Label3
//
this.Label3.Location = new System.Drawing.Point(33, 64);
this.Label3.Name = "Label3";
this.Label3.Size = new System.Drawing.Size(72, 23);
this.Label3.TabIndex = 23;
this.Label3.Text = "Alarm Metni:";
//
// txtMetin
//
this.txtMetin.Location = new System.Drawing.Point(111, 61);
this.txtMetin.Name = "txtMetin";
this.txtMetin.Size = new System.Drawing.Size(150, 20);
this.txtMetin.TabIndex = 24;
this.txtMetin.Text = "txtMetin";
//
// txtSaat
//
this.txtSaat.Location = new System.Drawing.Point(111, 37);
this.txtSaat.Name = "txtSaat";
this.txtSaat.Size = new System.Drawing.Size(150, 20);
this.txtSaat.TabIndex = 22;
this.txtSaat.Text = "txtSaat";
//
// timer2
//
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// Label2
//
this.Label2.Location = new System.Drawing.Point(33, 40);
this.Label2.Name = "Label2";
this.Label2.Size = new System.Drawing.Size(72, 23);
this.Label2.TabIndex = 21;
this.Label2.Text = "Alarm Saati:";
//
// txtTarih
//
this.txtTarih.Location = new System.Drawing.Point(111, 13);
this.txtTarih.Name = "txtTarih";
this.txtTarih.Size = new System.Drawing.Size(150, 20);
this.txtTarih.TabIndex = 20;
this.txtTarih.Text = "txtTarih";
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Label1
//
this.Label1.Location = new System.Drawing.Point(33, 16);
this.Label1.Name = "Label1";
this.Label1.Size = new System.Drawing.Size(72, 16);
this.Label1.TabIndex = 19;
this.Label1.Text = "Alarm Tarihi:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(392, 86);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(101, 13);
this.label4.TabIndex = 27;
this.label4.Text = "www.yazilimcik.com";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(527, 103);
this.Controls.Add(this.label4);
this.Controls.Add(this.Label3);
this.Controls.Add(this.txtMetin);
this.Controls.Add(this.txtSaat);
this.Controls.Add(this.Label2);
this.Controls.Add(this.txtTarih);
this.Controls.Add(this.Label1);
this.Controls.Add(this.btnAlarmKapa);
this.Controls.Add(this.btnAlarmAc);
this.Name = "Form1";
this.Text = "Alarm Projesi | www.yazilimcik.com";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
SoundPlayer sp = new SoundPlayer(Alarm_Project__Yazilimcik_Com.Properties.Resources.zil);
private void Form1_Load(object sender, EventArgs e)
{
txtTarih.Text = DateTime.Now.ToShortDateString();
txtSaat.Text = DateTime.Now.ToLongTimeString();
timer2.Enabled = false;
timer1.Enabled = false;
timer2.Interval = 100;
timer1.Interval = 1000;
Text = "Alarm Kapali";
}
private void timer1_Tick(object sender, EventArgs e)
{
if (txtTarih.Text == DateTime.Now.ToShortDateString() && txtSaat.Text == DateTime.Now.ToLongTimeString())
{
timer2.Enabled = true;
sp.Play();
MessageBox.Show(txtMetin.Text, "Alarm");
}
}
private void timer2_Tick(object sender, EventArgs e)
{
Color renk;
renk = txtMetin.BackColor;
txtMetin.BackColor = txtMetin.ForeColor;
txtMetin.ForeColor = renk;
}
private void btnAlarmAc_Click(object sender, EventArgs e)
{
DateTime now = DateTime.Parse(DateTime.Now.ToString());
DateTime baslangicTarihi = DateTime.Parse(txtTarih.Text);
TimeSpan t = now.Subtract(baslangicTarihi);
int toplamgecenGun = int.Parse(t.Days.ToString());
if (toplamgecenGun
{
timer1.Enabled = true;
this.Text = "Alarm Açik";
}
else
{
MessageBox.Show("Lütfen ’Alarm Tarihi’ Olarak Bugünden Önceki Bir Tarih Girmeyin..!\n\nwww.yazilimcik.com", "Uyari");
txtTarih.Focus();
}
}
private void btnAlarmKapa_Click(object sender, EventArgs e)
{
timer2.Enabled = false;
timer1.Enabled = false;
this.Text = "Alarm Kapali";
sp.Stop();
txtTarih.Focus();
}
}
}
// Alarm Projesi | www.yazilimcik.com