Question
This is the design of the alarm clock. The (sample) text in the time label and in the alarm time textbox are just to see
This is the design of the alarm clock. The (sample) text in the time label and in the alarm time textbox are just to see what theyll look like when the clock is running when created it must always show the current time to the second.
Double-click the form to create a Form Load method. Load the current time into the time label hour, minute second, AM/PM. Also, consider saving here the forms background colour into a private variable (i.e. of type System.Drawing.Color). Why? So that you can reset it after the timer is stopped (see below).
From the Component category in the toolbox, add 2 timers: 1 for a clock timer and another for an alarm timer. Have each issue a Tick event once a second. The clock timer is always active. When it issues a tick event, update the clock display and, if Alarm Activate is checked, check the alarm time.
The alarm timer is initially inactive. The user enters the alarm time in H:MM format with AM/PM, e.g. 3:11 PM. When the displayed time equals (to the second) the alarm time and Is alarm active? is checked, activate the alarm timer. That is, play a sound and every time it fires a tick event you may wish to alternate the clock face from red to green & back on each tick.
When Use 24 hour clock? is checked, display the clock in 24 hour format (0-23, e.g. 1PM=13) - the AM/PM must not be shown in this mode.
When Stop Alarm is clicked or the Alarm Active checkbox is unchecked, deactivate the alarm timer and reset the background colour (if you were changing that too).
To play a sound:
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = @"c:\windows\media\Alarm01.wav"; // Or 1 - 10, another wave file
player.Play(); // Or: player.PlayLooping();
Marking:
1 current time is displayed & stays current
2 alarm sounds if alarm time equals clock time and Alarm Active is checked.
3 alarm stops sounding when Stop Alarm is clicked
Note: the alternating red to green background colour is nice to have and not required to get 3/3.
please do this using C#...
Alam time: Is alam active? Place holder for error message
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started