Esempio n. 1
0
 public static void Pause()
 {
     MoveTimer.Stop();
     GenCarTimer.Stop();
     WorkTimer.Stop();
     LightsTimer.Stop();
 }
Esempio n. 2
0
 public void StartCountdown(Action OnCountdown, Action OnWork, Action OnRest)
 {
     MinutesToGo      = Duration;
     OnSecondElapsed += (obj, args) =>
     {
         SecondsToGo = SecondsToGo <= 0 ? 59 : SecondsToGo - 1;
         MinutesToGo = MinutesToGo - (SecondsToGo == 59 ? 1 : 0);
         OnCountdown();
         if (Elapsed)
         {
             WorkTimer.Stop();
             if (Mode == PomodoroMode.Work)
             {
                 OnRest();
                 Mode        = PomodoroMode.Rest;
                 MinutesToGo = Intermission;
                 WorkTimer.Start();
             }
             else
             {
                 OnWork();
                 PomodoroUnit.AnythingRunning = false;
             }
         }
     };
     WorkTimer.Elapsed += OnSecondElapsed;
     WorkTimer.Start();
 }
Esempio n. 3
0
 public void StopCountdown()
 {
     WorkTimer.Stop();
     MinutesToGo        = Duration;
     SecondsToGo        = 0;
     Mode               = PomodoroMode.Work;
     WorkTimer.Elapsed -= OnSecondElapsed;
 }
Esempio n. 4
0
        private void SecondTimer_Tick(object sender, EventArgs e)
        {
            int minutes = int.Parse(WorkTimeLabel.Text.Substring(0, minChar));
            int seconds = int.Parse(WorkTimeLabel.Text.Substring(minChar + 1));

            if (minutes != 0 || seconds != 0)
            {
                if (seconds != 0)
                {
                    seconds -= 1;
                    if (seconds < 10)
                    {
                        WorkTimeLabel.Text = $"{minutes}:0{seconds}";
                    }
                    else
                    {
                        WorkTimeLabel.Text = $"{minutes}:{seconds}";
                    }
                }
                else
                {
                    seconds            = 59;
                    minutes           -= 1;
                    WorkTimeLabel.Text = $"{minutes}:{seconds}";
                }
            }
            else
            {
                MessageBox.Show("You have completed your work session! For your hard work, have a little break.", "Timeout", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                WorkTimer.Stop();
                SecondTimer.Stop();

                int breakmins = (int)BreakNumericUpDown.Value;
                if (breakmins < 10)
                {
                    breakChar          = 1;
                    WorkTimeLabel.Text = $"{breakmins}:00";
                    breakTimer.Start();
                    //  gameForm.Show();
                }
                else if (breakmins > 10 && breakmins < 99)
                {
                    breakChar          = 2;
                    WorkTimeLabel.Text = $"{breakmins}:00";
                    breakTimer.Start();
                    //gameForm.Show();
                }
                else
                {
                    MessageBox.Show("Stop being lazy! Dont take such a long break.");
                }
            }
        }
Esempio n. 5
0
 public void StopWorkTimer()
 {
     WorkTimer.Stop();
     SecondsLeft            = 0;
     labelTimer.Text        = "Process stopped";
     labelTimer.ForeColor   = System.Drawing.Color.Red;
     labelHourOrMinute.Text = string.Empty;
     progressBar.Value      = 0;
     buttonPause.Enabled    = false;
     buttonStart.Enabled    = true;
     ResetButtonsToDefault();
 }
Esempio n. 6
0
 private void StopTimer()
 {
     if (WorkTimer != null)
     {
         WorkTimer.Stop();
         WorkTimer.TimerUpdated -= Timer_Update;
         WorkTimer.TimerStarted -= Timer_Start;
         WorkTimer.TimerStopped -= Timer_Stop;
         WorkTimer.TimerPaused  -= Timer_Pause;
         WorkTimer.Dispose();
         WorkTimer = null;
     }
 }
Esempio n. 7
0
 public static void Stop()
 {
     Car.Clear();
     Deleter.Clear();
     MoveTimer.Stop();
     LightsTimer.Stop();
     GenCarTimer.Stop();
     WorkTimer.Stop();
     CarCount.Text          = "0";
     CurrentlyCarCount.Text = "0";
     WorkTime.Text          = "0 c";
     Cpm.Text = "0";
     WorkTm   = 0;
     UserPanel.ResetBackColor();
     UserPanel.Invalidate();
 }
Esempio n. 8
0
 private void ResetButtonsToDefault()
 {
     WorkTimer.Stop();
     SecondsLeft           = MyDateTimeHandler.GetSecondsToWork(numericUpDownHours.Value.ToString(), numericUpDownMinutes.Value.ToString(), numericUpDownSeconds.Value.ToString());
     buttonStart.Enabled   = true;
     progressBar.Value     = 0;
     currentWeek           = MyTimeTable.GetWeekOfYear(DateTime.Now);
     labelPredictTime.Text = "Expected end of Work: ";
     labelStartTime.Text   = "Started work ";
     labelTime.Text        = MyDateTimeHandler.TimeString + " Uhr " + MyDateTimeHandler.GetAM();
     labelDate.Text        = "It's " + DateTimeHandler.DateString;
     if (firstStart)
     {
         buttonStart.Enabled = false;
         WorkTimer.Interval  = 1000;
         WorkTimer.Enabled   = true;
     }
 }
Esempio n. 9
0
        private void startButton_Click(object sender, EventArgs e) //Starts the app.
        {
            if (ProcessesListBox.SelectedItem != null)
            {
                int minutes = (int)WorkNumericUpDown.Value;

                if (minutes < 10)
                {
                    minChar = 1;
                }
                else if (minutes > 10 && minutes < 99)
                {
                    minChar = 2;
                }
                else if (minutes > 99)
                {
                    minChar = 3;
                }

                if (startButton.Text.Contains("Start"))
                {
                    WorkTimer.Start();
                    SecondTimer.Start();
                    startButton.Text      = "Stop Working";
                    refreshButton.Enabled = false;
                }
                else
                {
                    WorkTimer.Stop();
                    SecondTimer.Stop();
                    breakTimer.Stop();
                    startButton.Text      = "Start Working";
                    refreshButton.Enabled = true;
                }

                WorkTimeLabel.Text = $"{minutes}:00";
            }
            else
            {
                MessageBox.Show("You must select the window you will be working on.");
            }
        }
Esempio n. 10
0
        protected override void Handle(StopTaskCommand request)
        {
            ActiveTaskValidator validator = new ActiveTaskValidator(TaskRecorder.HasActiveTask);

            validator.CheckIfAnyTaskIsRunning();

            if (TaskService.AskBeforeStopActiveTaskResult() == DialogResult.No)
            {
                return;
            }

            BaseTask activeTask = TaskRecorder.ActiveTask;
            DateTime endTime    = Database.GetCurrentTime();

            TaskRepository.Finish(activeTask, endTime);

            TaskRecorder.StopActiveTask(endTime);

            WorkTimer.Stop();
        }