Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        private void StopTimer()
        {
            taskStarted        = false;
            textTimerTime.Text = $"00:00:00";

            switch (modeOfWork)
            {
            case ModesOfWork.Pomodoro:
                if (timerStage == TimerStage.Work)
                {
                    // Get the difference between the specified time and the past time
                    TimeSpan time = new TimeSpan(0, GlobalSettings.dataSettings.TimeOfWork, 0).Subtract(timerTime);
                    currentTask.DataTask.TotalTime = currentTask.DataTask.TotalTime.Add(time);
                    UpdateTotalTime();
                    // Adding exp to profile
                    Profile.data.AddExperience((int)time.TotalMinutes);
                }

                TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.None;

                progressBar.Close();
                progressBar = null;
                break;

            case ModesOfWork.Timer:
                currentTask.DataTask.TotalTime = currentTask.DataTask.TotalTime.Add(timerTime);
                UpdateTotalTime();

                // Adding exp to profile
                Profile.data.AddExperience((int)timerTime.TotalMinutes);
                break;
            }

            UpdateTimerInfo();
            UpdateButtonsTimer();

            dispatcherTimer.Stop();
            dataChanged = true;
        }