(散分)庆祝自己写了第一个WCE的application-AlarmClock
RT.
第一次写WCE APPLICATION,给自己留恋一下。也贴个代码,大家别砸转头:
/* project name : Alarm clock
* author : Atsoftworld
* date : 2009/01/04
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DeviceApplication1
{
public partial class frmClock : Form
{
// 声音文件定义
string strSoundFile = "";
public frmClock()
{
InitializeComponent();
}
private void tmrCompare_Tick(object sender, EventArgs e)
{
DateTime dtNow = DateTime.Now;
// 只判断时间的hhmm,不判断yyyymmdd和ss;
if (this.dtpClock.Value.ToString("hhmm") == dtNow.ToString("hhmm"))
{
if (this.strSoundFile != "")
{
System.Diagnostics.Process.Start(this.strSoundFile, "");
}
else
{
this.Close();
}
}
}
private void btnFunction_Click(object sender, EventArgs e)
{
if (tmrCompare.Enabled)
{
btnFunction.Text = "Start";
tmrCompare.Enabled = false;
}
else
{
btnFunction.Text = "Pause";
tmrCompare.Enabled = true;
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnChooseSound_Click(object sender, EventArgs e)
{
this.ofgChooseSound.ShowDialog();
// using all type of file.暂时不区分文件,做DEMO而已。
if (ofgChooseSound.FileName != "")
{
this.strSoundFile = this.ofgChooseSound.FileName;
}
}
private void btnAbout_Click(object sender, EventArgs e)
{
MessageBox.Show("It's an alarm clock. It was Created by joyfish.");
}
}
}