Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Alarm dock Lab Objectives: . Learn how to use SAPI .Learn how to use the timer .

ID: 3740337 • Letter: A

Question

Alarm dock Lab Objectives: . Learn how to use SAPI .Learn how to use the timer . Learn how to use dialog forms . Learn how to playsounds Create an Alarm Clock Add a menu that allows userto o exit (underfile menu) o Setalarm and turn on o Add5 seconds to alarm and turn on o Change alarm type from following choices Annoying Beeping Message from text to speech . o Show about us page . Set alarm using dialog form . Show current time in digital clock and keepit current . Show time alarm will go off if turned on Ability to turn on and off alarm from checkbox Play sounds when alarm fires

Explanation / Answer

Presentation

When I deal with the PC, I regularly get so retained that I look up a moment later to locate that three hours have gone without my notwithstanding seeing it. So I've pulled together some C# abilities I've learnt from a portion of the articles here at Code Project, to make a straightforward little application that uses a Timer question check during the time towards a period set by a client, and afterward plays a circling wave sound record until the point when the clock is reset.

I've attempted to keep it straightforward, yet I've included some additional usefulness for an advise symbol to show up in the status bar. I mostly included this usefulness since I despise the possibility of a straightforward application like this consuming up room in the taskbar.

Rudiments of the Timer Object

The principal thing you require, is to get to the essential namespaces to utilize a Timer protest.

utilizing System.Threading;

utilizing System.Timers;

Presently I'll give you the essentials for making the Timer and setting an occasion designate for the Timer protest's open Elapsed occasion.

The production of the Timer protest starts things out, I called my clock timerClock. Next I set the Elapsed occasion assign, by determining a delegate to be called when the occasion fires. I called my delegate OnTimer().

Next I set the Interval property, to the time in milliseconds that I wish the Elapsed occasion to be let go, which implies that my delegate OnTimer()will be called each 1000 milliseconds, or each 1 second, on the off chance that I set the Interval property to 1000 milliseconds.

At last, I set the Enabled property to genuine with the goal that the clock is dynamic. At that point it's only a basic matter of making a delegate to be called when the Elapsed occasion is terminated by the

Clock

question. On the off chance that you haven't utilized delegates previously, at that point don't stress, they are anything but difficult to utilize. Simply make a strategy that gets the proper factors for the occasion you are catching.

On account of the Elapsed occasion, my delegate needs to get a plain Object, and an ElapsedEventArgs question.

private System.Timers.Timer timerClock = new System.Timers.Timer();

timerClock.Elapsed += new ElapsedEventHandler(OnTimer);

timerClock.Interval = 1000;

timerClock.Enabled = genuine;

Utilizing the Timer in an Alarm Application

Affirm, with the nuts and bolts off the beaten path I can demonstrate to you the code for the genuine application. Note that I have excluded the code to play wave sounds or the code for showing a tell symbol, in light of a legitimate concern for keeping this basic. The full code is accessible in the demo venture where you will see that, I have basically quite recently reordered the wave player works straight from the article by jow Blow on "Low level sound players".

In the code underneath you will see that I have isolated the instantiation of the Timer question into it's own particular instatement strategy named InitializeTimer() which is called from the class' constructor. I've additionally made two techniques named inputToSeconds() and secondsToTime() which simply process the time an incentive from a

string

to a number, and the other way around. These techniques are simply used to help show the time in the application's TextBox control and aren't in reality vital in the enormous plan of things. Whatever is left of the code you will perceive as the standard Visual Studio.NET Boilerplate code for a Win Form.

Here is the code for the Alarm Clock

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote