Digital Clock with Alarm ( runs .wav extension songs)


This clock appears on the top right side of our computer screen. We can set alarm tone of our choice in it but it should have .wav extension only. Learn Digital Clock with Alarm ( runs .wav extension songs) It will play the song at the set time but the program should be on running mode or the setup of the program should be installed in your PC.

About Digital Clock with Alarm ( runs .wav extension songs)


This clock appears on the top right side of our computer screen. We can set alarm tone of our choice in it but it should have .wav extension only.
It will play the song at the set time but the program should be on running mode or the setup of the program should be installed in your PC.


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;
using System.Drawing.Drawing2D;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
int x = Screen.GetWorkingArea(this).Width;
int y = Screen.GetWorkingArea(this).Height;
this.Location = new Point(x - this.Size.Width);
label2.Text = Convert.ToString(DateTime.Now.TimeOfDay).Substring(0, 8);
label3.Text =Convert.ToString( DateTime.Today.DayOfWeek);
label1.Text =Convert.ToString (DateTime.Today.ToShortDateString());
timer1.Enabled = true;
}

int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
//GraphicsPath gp = new GraphicsPath();
//string dateTime = DateTime.Now.TimeOfDay.ToString().Substring(0, 8);
//gp.AddString(dateTime, Font.FontFamily, 0, 50, new Point(0, 0), new StringFormat());
//this.Region = new Region(gp);
i++;
if (i == 1)
{
label2.Text = DateTime.Now.ToLongTimeString();
i = 0;
}
}

int j = 0;
SoundPlayer sp;
private void timer2_Tick(object sender, EventArgs e)
{
if (s == Convert.ToString(DateTime.Now.ToShortTimeString()))
{
j++;
if (j == 1)
{
timer2.Enabled = false;
//System.Diagnostics.Process.Start(textBox3.Text);
sp = new SoundPlayer(textBox3.Text);
sp.Play();
j = 0;
}
}
}

private void button2_Click(object sender, EventArgs e)
{
sp.Stop();
}

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsLetter(e.KeyChar) == true)
{
e.Handled = true;
}
}

private void button1_Click_1(object sender, EventArgs e)
{
comboBox2.Visible = true;
comboBox3.Visible = true;
comboBox1.Visible = true;
button4.Visible = true;
}

private void button3_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox3.Text = openFileDialog1.FileName;
}
}

string s = "";
private void button4_Click(object sender, EventArgs e)
{
if ((comboBox2.Text == "") || (comboBox3.Text == "") || (comboBox1.Text == ""))
{

MessageBox.Show("Enter Alarm Time");
}
else
{
s = comboBox2.Text + ":" + comboBox3.Text + " " + comboBox1.Text;
label4.Text = "Alarm Set on " + s.ToString();
timer2.Enabled = true;
button2.Visible = true;
button3.Visible = true;
textBox3.Visible = true;
}
}

private void button5_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("Do you want to close application ?", "Alarm Clock", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
this.Close();
}
else
{
}
}
}
}


Attachments

  • Digital Clock with Alarm ( runs .wav extension songs) (43256-42226-WindowsFormsApplication1.sln)
  • Comments

    No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: