C # winform small alarm clock

Source: Internet
Author: User

 Recently, I was very busy. The teacher forgot some things and turned to the computer all day. So I wanted to remind myself to be a C # winform.ProgramTrainer!

The alarm function I implemented is relatively simple. I mainly used the timer Timer control and referenced the system during the alarm. media namespace, playing wav files, tried to play only this type of files. I don't know if I can play MP3. Currently I won't, mainlyCodeAs follows:

Using system; using system. windows. forms; using system. media; namespace alarmclock {public partial class form1: FORM {public form1 () {initializecomponent ();} soundplayer player = new soundplayer (); Private void form1_load (Object sender, eventargs E) {timer1.start (); // bind to ComboBox for (INT I = 0; I <= 23; I ++) {cmbhour. items. add (I) ;}for (Int J = 0; j <60; j ++) {cmbminute. items. add (j);} // bind the ringtone Cmbring. items. add ("step by step music .wav"); cmbring. items. add ("background music .wav");} private void timer1_tick (Object sender, eventargs e) {timer1.interval = 1000; lblnow. TEXT = datetime. now. tostring ();} private void btnpreview_click (Object sender, eventargs e) {If (string. isnullorempty (cmbring. text) {MessageBox. show ("select the playing ringtone !! "); Return;} playsound () ;}/// <summary> // play the wav sound file /// </Summary> private void playsound () {// use the new instance point soundlocation to specify the name of the music player to be played. soundlocation = cmbring. text; // (put the playing music in the application DEBUG directory) player. load (); // player for music playback. play ();} private void btnopen_click (Object sender, eventargs e) {If (cmbhour. TEXT = "" & cmbminute. TEXT = "") {MessageBox. show ("no alert time set"); Return ;}timer2.start () ;}private void timer2_tick (Object sender, eventargs e) {timer2.interval = 1000; string H = cmbhour. text; string M = cmbminute. text; string nowh = datetime. now. hour. tostring (); string nowm = datetime. now. minute. tostring (); If (H = nowh & M = nowm) {playsound (); // After enabling timer2.stop ();}} private void btnstop_click (Object sender, eventargs e) {timer2.stop (); player. stop ();}}}

 Download all source code of this program!

      Download the attachment:

    • Alarmclcok.rar (3.5 MB)

Existing0People comment, slam->Here<-Participate in the discussion

Iteye recommendation

    • -Software talents free of language and low guarantee paid study in the United States! -

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.