atm959

Timer.cs

Oct 3rd, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7. using System.Runtime;
  8.  
  9. namespace Timer
  10. {
  11.     class Timer
  12.     {
  13.         public static void Main (string[] args)
  14.         {
  15.             Console.Title = "C# Timer";
  16.  
  17.             ConsoleColor defaultBackgroundColor = ConsoleColor.Black;
  18.             ConsoleColor defaultForegroundColor = ConsoleColor.White;
  19.  
  20.             Console.BackgroundColor = ConsoleColor.White;
  21.             Console.ForegroundColor = ConsoleColor.Black;
  22.  
  23.             Console.WriteLine ("=================================");
  24.             Console.WriteLine ("=                               =");
  25.             Console.WriteLine ("= ***** ***** ** ** ***** ****  =");
  26.             Console.WriteLine ("=   *     *   * * * *     *   * =");
  27.             Console.WriteLine ("=   *     *   *   * *     *   * =");
  28.             Console.WriteLine ("=   *     *   *   * ***   ****  =");
  29.             Console.WriteLine ("=   *     *   *   * *     **    =");
  30.             Console.WriteLine ("=   *     *   *   * *     * *   =");
  31.             Console.WriteLine ("=   *   ***** *   * ***** *  ** =");
  32.             Console.WriteLine ("=                               =");
  33.             Console.WriteLine ("=================================");
  34.  
  35.             Console.BackgroundColor = defaultBackgroundColor;
  36.             Console.ForegroundColor = defaultForegroundColor;
  37.  
  38.             Console.WriteLine ();
  39.             Console.WriteLine ("Enter the number of seconds below.");
  40.             Console.Write ("SECONDS>> ");
  41.             String secondsString = Console.ReadLine ();
  42.  
  43.             if (secondsString == "/help") {
  44.                 Console.WriteLine ("Here is a way to get the number of seconds you need: s = m * 60, where s is sec-onds and m is minutes.");
  45.             } else if (secondsString != "/help") {
  46.                 int numberInt = Convert.ToInt32 (secondsString);
  47.  
  48.                 Console.ForegroundColor = ConsoleColor.Green;
  49.  
  50.                 System.Media.SoundPlayer subtractSound = new System.Media.SoundPlayer();
  51.                 subtractSound.SoundLocation = "C:/Users/Aaron/Desktop/More Stuff/Timer/Timer/res/S2HDSFX - Tally Switch.wav";
  52.                 subtractSound.Load();
  53.  
  54.                 //subtractSound.PlayLooping ();
  55.  
  56.  
  57.                 System.Media.SoundPlayer endSound = new System.Media.SoundPlayer();
  58.                 endSound.SoundLocation = "C:/Users/Aaron/Desktop/More Stuff/Timer/Timer/res/S2HDSFX - Tally End.wav";
  59.                 endSound.Load();
  60.  
  61.  
  62.                 for (int i = numberInt; i >= 0; i--) {
  63.                     if (i > 1) {
  64.                         Thread.Sleep(1000);
  65.                         Console.WriteLine (i + " SECONDS LEFT");
  66.                         subtractSound.Play ();
  67.                     } else if (i == 1) {
  68.                         Thread.Sleep(1000);
  69.                         Console.WriteLine (i + " SECOND LEFT");
  70.                         subtractSound.Play ();
  71.                     } else if (i == 0) {
  72.                         Thread.Sleep(1000);
  73.                         Console.Write("DONE!");
  74.  
  75.                         //subtractSound.Stop ();
  76.                         endSound.Play ();
  77.  
  78.                         Console.ForegroundColor = defaultForegroundColor;
  79.                         Console.BackgroundColor = defaultBackgroundColor;
  80.                     }
  81.                 }
  82.             }
  83.  
  84.             Thread.Sleep (System.Threading.Timeout.Infinite);
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment