Exemple #1
0
        public void checkActivity()
        {
            bool running = true;

            while (running)
            {
                if (IdleTimeFinder.GetIdleTime() < 3000)
                {
                    mute();
                    enableThread(2);
                    running = false;
                }
            }
        }
Exemple #2
0
        private void runProgram()
        {
            bool running = true;

            while (running)
            {
                TimeSpan start = new TimeSpan(0, 0, 0);
                TimeSpan end   = new TimeSpan(8, 0, 0);

                int minute      = 60000; // Minute in milliseconds
                int idle_stage1 = minute * 30;
                int idle_stage2 = minute * 59;
                int idle_stage3 = minute * 60;

                if (IsBetween(DateTime.Now, start, end))
                {
                    //Reset
                    if (IdleTimeFinder.GetIdleTime() < 3000)
                    {
                        setTextBox_Text("Initializing...");

                        setForm_Color(Color.ForestGreen);
                    }

                    else if (IdleTimeFinder.GetIdleTime() >= 3000 && IdleTimeFinder.GetIdleTime() < idle_stage1)
                    {
                        setTextBox_Text("Started, idle time is " + Math.Ceiling(TimeSpan.FromMilliseconds(IdleTimeFinder.GetIdleTime()).TotalMinutes) + " minutes.");
                    }
                    //Warn them after 30 minutes
                    else if (IdleTimeFinder.GetIdleTime() >= idle_stage1 && IdleTimeFinder.GetIdleTime() < idle_stage2)
                    {
                        setTextBox_Text("Turning sound off in 30 minutes.");
                    }
                    //Tell them they're going to turn off in 1 minute.
                    else if (IdleTimeFinder.GetIdleTime() >= idle_stage2 && IdleTimeFinder.GetIdleTime() < idle_stage3)
                    {
                        setTextBox_Text("Turning sound off in 1 minute.");
                        setForm_Color(Color.Red);
                        System.Media.SystemSounds.Hand.Play();
                        Thread.Sleep(5000);
                    }
                    // Turn off sound.
                    else if (IdleTimeFinder.GetIdleTime() >= idle_stage3)
                    {
                        setTextBox_Text("Sound is disabled.");
                        mute();
                        running = false;
                        enableThread(1);
                    }
                    else
                    {
                        setTextBox_Text("ERROR");
                    }
                }
                else
                {
                    setTextBox_Text("Time will start at 12am and end at 8am.");
                    setForm_Color(Color.Orange);
                }
                Thread.Sleep(1000);
            }
        }