コード例 #1
0
        private static void handleRunning(TimeHandler timeHandler = null, ExeHandler exeHandler = null)
        {
            if (timeHandler == null)
            {
                timeHandler = new TimeHandler();
            }
            if (exeHandler == null)
            {
                exeHandler = new ExeHandler();
            }

            if (exeHandler.ExesRunning().Length > 0)
            {
                if (!timeHandler.CheckTime())
                {
                    NotificationHandler.NotifyWindows("You've played enough for today. Shutting down.", () => {
                        Thread.Sleep(5000);
                        exeHandler.CloseExes();
                        exeHandler.DisableAll();
                        timeHandler.StopTimer();
                        Environment.Exit(0);
                    });
                }
            }
            else
            {
                NotificationHandler.NotifyWindows("Stopping timer.", () => {
                    exeHandler.DisableAll();
                    timeHandler.StopTimer();
                    Environment.Exit(0);
                });
            }
        }
コード例 #2
0
        private static void handleRun(string exeName)
        {
            TimeHandler timeHandler = new TimeHandler();
            bool        time        = timeHandler.CheckTime();

            if (time)
            {
                ExeHandler exeHandler = new ExeHandler();
                exeHandler.AddExecutables();
                exeHandler.EnableAll();
                exeHandler.StartExe(exeName);
                exeHandler.DisableAll();
                timeHandler.StartTimer();
                NotificationHandler.NotifyWindows("Starting timer.");
                DateTime start = DateTime.Now;
                while (true)
                {
                    DateTime now = DateTime.Now;
                    handleRunning(timeHandler, exeHandler);
                    Thread.Sleep(60000);
                }
            }
        }
コード例 #3
0
 private static void handleRun(string exeName)
 {
     TimeHandler timeHandler = new TimeHandler();
     bool time = timeHandler.CheckTime();
     if(time) {
         ExeHandler exeHandler = new ExeHandler();
         exeHandler.AddExecutables();
         exeHandler.EnableAll();
         exeHandler.StartExe(exeName);
         exeHandler.DisableAll();
         timeHandler.StartTimer();
         NotificationHandler.NotifyWindows("Starting timer.");
         DateTime start = DateTime.Now;
         while(true) {
             DateTime now = DateTime.Now;
             handleRunning(timeHandler, exeHandler);
             Thread.Sleep(60000);
         }
     }
 }
コード例 #4
0
        private static void handleRunning(TimeHandler timeHandler=null, ExeHandler exeHandler=null)
        {
            if(timeHandler == null)
                timeHandler = new TimeHandler();
            if(exeHandler == null)
                exeHandler = new ExeHandler();

            if(exeHandler.ExesRunning().Length > 0) {
                if(!timeHandler.CheckTime()) {
                    NotificationHandler.NotifyWindows("You've played enough for today. Shutting down.", () => {
                        Thread.Sleep(5000);
                        exeHandler.CloseExes();
                        exeHandler.DisableAll();
                        timeHandler.StopTimer();
                        Environment.Exit(0);
                    });
                }
            } else {
                NotificationHandler.NotifyWindows("Stopping timer.", () => {
                    exeHandler.DisableAll();
                    timeHandler.StopTimer();
                    Environment.Exit(0);
                });
            }
        }