Пример #1
0
        public static string ToCapsString(this TimerStage stage)
        {
            switch (stage)
            {
            case TimerStage.Work: return("WORK");

            case TimerStage.Break: return("BREAK");

            default: return(string.Empty);
            }
        }
Пример #2
0
        void RunTest(long delay, long period)
        {
            TimerMonitor monitor  = new TimerMonitor();
            int          expected = 10;

            TestEventHandler handler = new TestEventHandler(monitor, expected);
            IStage           stage   = new TimerStage(handler, delay, period);

            monitor.Mwait();
            Assert.Equal(expected, handler.GetCount());
        }
Пример #3
0
        /// <summary>
        /// Launch the timer
        /// </summary>
        private void BtnPlayTimer(object sender, RoutedEventArgs e)
        {
            switch (modeOfWork)
            {
            case ModesOfWork.Pomodoro:
                timerStage = TimerStage.Work;

                // Set time from settings to 'wholeTimer' and 'timerTime'
                wholeTimer = new TimeSpan(0, GlobalSettings.dataSettings.TimeOfWork, 0);
                timerTime  = wholeTimer;

                TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal;
                TaskbarItemInfo.ProgressValue = 0;

                progressBar = new WindowProgressBar();
                progressBar.Show();

                receivedTomato = 0;
                break;

            case ModesOfWork.Timer:

                if (GlobalSettings.dataSettings.MaximumTaskTime > 0 &&
                    currentTask.DataTask.TotalTime.TotalMinutes >= GlobalSettings.dataSettings.MaximumTaskTime)
                {
                    ShowNotifyMessage("Max time of whole task is up", 10);
                    return;
                }

                timerTime  = new TimeSpan();
                wholeTimer = new TimeSpan();
                break;
            }
            taskStarted = true;

            UpdateTimerInfo();
            UpdateButtonsTimer();

            dispatcherTimer.Start();
        }
Пример #4
0
        /// <summary>
        /// It's only for the Pomodoro mode
        /// </summary>
        private void ChangeTimerStage()
        {
            switch (timerStage)
            {
            case TimerStage.Work:
                receivedTomato++;
                currentTask.DataTask.Tomatoes++;
                // Adding exp to profile
                Profile.data.AddExperience((int)wholeTimer.TotalMinutes);

                UpdateTotalTime();
                dataChanged = true;

                bool isLongBreak = false;

                // If hasn't passed 4 tomatoes then do a simple break, else do a long break
                if (receivedTomato % 4 != 0)
                {
                    wholeTimer = new TimeSpan(0, GlobalSettings.dataSettings.TimeOfBreak, 0);
                }
                else
                {
                    wholeTimer  = new TimeSpan(0, GlobalSettings.dataSettings.TimeOfLongBreak, 0);
                    isLongBreak = true;
                }

                timerStage = TimerStage.Break;

                currentTask.DataTask.TotalTime =
                    currentTask.DataTask.TotalTime.Add
                        (new TimeSpan(0, GlobalSettings.dataSettings.TimeOfWork, 0));

                UpdateTotalTime();
                TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Paused;

                Save();

                // If the window of rest is enable than open it
                if (GlobalSettings.dataSettings.EnableWindowBreak)
                {
                    windowRest           = new WindowRest();
                    windowRest.PathImage = !isLongBreak ? GlobalSettings.dataSettings.PathImgBreakTime :
                                           GlobalSettings.dataSettings.PathImgLongBreakTime;

                    windowRest.Show();

                    if (progressBar != null)
                    {
                        progressBar.Activate();
                    }
                }
                break;

            case TimerStage.Break:
                wholeTimer = new TimeSpan(0, GlobalSettings.dataSettings.TimeOfWork, 0);
                timerStage = TimerStage.Work;
                TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal;

                if (windowRest != null)
                {
                    windowRest.Close(); windowRest = null;
                }
                break;
            }
            timerTime = wholeTimer;
            ShowNotifyMessage(timerStage.ToCapsString(), 10);
            UpdateTimerInfo();
        }