|
Hi Guys , I have posted this article to explain about a simple alarm application
Place a label to display today's datetime , 3 text boxes for hh mm ss , 2 radio buttons for Alarm on or off
and a button. Done in C#.net
Code is . . .
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;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Boolean alarm = false;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = DateTime.Today.ToString("yyyy:mm:dd hh:mm:ss");
}
private void button1_Click(object sender, EventArgs e)
{
label1.Show();
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
DateTime dat = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text));
String AlarmTime = dat.ToString();
if(DateTime.Now > dat && alarm)
{
PlayAlarm()-----> any media player control or u can give as My.computer.audio.play(filename)
}
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
alarm = true;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
alarm = false;
}
}
}
|