I had an idea to build an alarm clock in c# with the following features
- Show a to-do list for the day
- Play a song from a list of songs chosen
Completed features I've already done
- Show list of to-do's
- Play a song
Show form between a certain time
private void Form1_Load(object sender, EventArgs e) { Timer MyTimer = new Timer(); MyTimer.Interval = (1 * 60 * 1000); // 1 mins MyTimer.Tick += new EventHandler(MyTimer_Tick); MyTimer.Start(); } private void MyTimer_Tick(object sender, EventArgs e) { WakeUpProcess(); } private void WakeUpProcess() { StreamReader CurrentAgenda = new StreamReader("C:/Users/Max/documents/visual studio 2015/Projects/Advanced_AlarmClock/Advanced_AlarmClock/File Resources/Todays Agenda.txt"); TimeSpan start = new TimeSpan(06, 50, 0); //10 o'clock TimeSpan end = new TimeSpan(07, 00, 0); //12 o'clock TimeSpan now = DateTime.Now.TimeOfDay; System.IO.StreamReader CurrentAgendaRaw = new System.IO.StreamReader("C:/Users/Max/documents/visual studio 2015/Projects/Advanced_AlarmClock/Advanced_AlarmClock/File Resources/Todays Agenda.txt"); string CurrentAgendaTxt = CurrentAgendaRaw.ReadToEnd(); if ((now > start) && (now < end)) { this.WindowState = FormWindowState.Normal; Output.Text = ("Good Morning Max" + Environment.NewLine + CurrentAgendaTxt); Process.Start("C:/Users/Max/Downloads/Juice Newton - Angel Of The Morning.mp3"); } }
However, I need some solutions to problems I'm facing. - Every time the time requirement is met (Between 6:50 and 7:00) a new instance is opened of the song. I only want one instance open. - Also could someone helep me with how I'd get the program to wake up the computer if possible.
Thank you, Maximus