Esempio n. 1
0
        static void Main(string[] args)
        {
            quotaTracker = new Classes.QuotaTracker();
            timeTracker  = new Classes.Timetracker(quotaTracker);
            clock        = new Classes.AsciiKello(timeTracker);

            handler = new ConsoleEventDelegate(ConsoleEventCallback);
            SetConsoleCtrlHandler(handler, true);

            PrintInstructions();

            while (true)
            {
                string line = Console.ReadLine();

                if (line == "s" || line == "e")
                {
                    if (!timeTracker.IsRunning())
                    {
                        timeTracker.Start();
                        clock.Start();
                    }
                    else
                    {
                        timeTracker.Stop();
                        clock.Stop();
                    }
                }
                else if (line == "c")
                {
                    Console.Clear();
                    clock.Redraw();
                    if (timeTracker.m_isRunning)
                    {
                        timeTracker.PrintStart();
                    }
                    else
                    {
                        PrintInstructions();
                    }
                }
                else if (line == "x")
                {
                    break;
                }
                else if (line.StartsWith("u"))
                {
                    Classes.UpworkTimePrinter.PrintTimes(line);
                }
                else
                {
                    Console.WriteLine("Unknown command: " + line);
                }

                Console.WriteLine();
            }
        }
Esempio n. 2
0
 static bool ConsoleEventCallback(int eventType)
 {
     if (eventType == 2)
     {
         if (timeTracker != null)
         {
             if (timeTracker.IsRunning())
             {
                 timeTracker.Stop();
             }
         }
     }
     return(false);
 }