Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Volume s = new Volume();
            //s.SetVolumeNAudio(10);
            float initialVolumeValue = s.GetVolumeNAudio();

            try
            {
                CurrentMinutes = Minutes;
                Console.WriteLine("Go to sleep :) relax...");
                while (CurrentMinutes > 0 || CurrentSeconds > 0)
                {
                    if (CurrentSeconds == 0 && CurrentMinutes > 0)
                    {
                        CurrentSeconds = 60;
                        CurrentMinutes--;
                    }
                    //128
                    CurrentSeconds--;
                    //99
                    Console.Write(string.Format("{0}:{1}", CurrentMinutes.ToString("D2"), CurrentSeconds.ToString("D2")));
                    Thread.Sleep(1000);

                    var scallar       = (float)(CurrentMinutes * 60 + CurrentSeconds) / (Minutes * 60);
                    var volumeScallar = initialVolumeValue * scallar;
                    s.SetVolumeNAudio(volumeScallar);
                    Console.CursorLeft = 0;
                }

                if (AlarmInMinutes > 0)
                {
                    while (true)
                    {
                        if (CurrentMinutes > AlarmInMinutes)
                        {
                            s.SetVolumeNAudio(initialVolumeValue);
                            SoundPlayer player = new SoundPlayer();
                            player.SoundLocation = "Alarm.wav";
                            player.Load();
                            player.Play();
                            Console.WriteLine("Alarm!!!");
                            Thread.Sleep(10000);
                            break;
                        }

                        Thread.Sleep(60000);
                        CurrentMinutes++;
                    }
                }
                else
                {
                    Process.Start("CMD.exe", "/C shutdown /h");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadKey();
            }
        }
 private void CancelTimer()
 {
     cts.Cancel();                                                                                                   //Cancel Timer Function
     TimerButton.Text = "Start";                                                                                     //TimerButton == Start (Has been changed to 'Stop' in StartTimer)
     CurrentMinutes   = Item.RecipeSteps[CurrentPageNumber - 1].TimerMinuteCount;                                    //Resets CurrentMinutes to the Max
     CurrentSeconds   = Item.RecipeSteps[CurrentPageNumber - 1].TimerSecondCount;                                    //Resets CurrentSeconds to the Max
     TimerText.Text   = CurrentMinutes.ToString().PadLeft(2, '0') + ":" + CurrentSeconds.ToString().PadLeft(2, '0'); //Resets Timer to Max Minutes and Seconds
     cts = null;
 }
Ejemplo n.º 3
0
        // %t - minutes
        // %h - hours
        // %d - current day
        // %D - current day name
        // %m - current month index
        // %M - current month name
        // %y - year
        public string GetTimeAsString(string format)
        {
            string ret = format;

            ret = ret.Replace("%t", CurrentMinutes.ToString());
            ret = ret.Replace("%h", CurrentHours.ToString());
            ret = ret.Replace("%d", CurrentDay.ToString());
            ret = ret.Replace("%D", Days[CurrentDayIndex]);
            ret = ret.Replace("%m", CurrentMonthIndex.ToString());
            ret = ret.Replace("%M", Months.ElementAt(CurrentMonthIndex).Key);
            ret = ret.Replace("%y", CurrentYear.ToString());

            return(ret);
        }