protected override void Handle(StartProjectTaskCommand request) { if (TaskRecorder.HasActiveTask) { DuplicateTaskValidator taskValidator = new DuplicateProjectTaskValidator(TaskRecorder.ActiveTask, request.ProjectDto.ID, request.ProjectStageDto.ID, request.WorksetDto.ID, request.IsAddCost, request.IsMistake); taskValidator.ValidateDuplicate(); } if (TaskService.AskBeforeStartNewTaskResult() == DialogResult.No) { return; } DateTime currentTime = Database.GetCurrentTime(); if (TaskRecorder.HasActiveTask) { TaskRepository.Finish(TaskRecorder.ActiveTask, currentTime); TaskRecorder.StopActiveTask(currentTime); } Project project = ProjectRepository.Load(request.ProjectDto.ID); ProjectStage projectStage = ProjectStageRepository.Load(request.ProjectStageDto.ID); Workset workset = WorksetRepository.Load(request.WorksetDto.ID); ProjectTask newProjectTask = TaskFactory.CreateProjectTask(TaskRepository.NextIdentity(), project, projectStage, workset, request.IsAddCost, request.IsMistake); TaskRepository.Save(newProjectTask, currentTime); TaskRecorder.StartNewTask(newProjectTask, currentTime); WorkTimer.Start(); }
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(); }
public static void Start() { MoveTimer.Start(); GenCarTimer.Start(); WorkTimer.Start(); LightsTimer.Start(); CurrentRoad = new Road(1, 1, 1, 1); CurrentRoadTransit = new RoadTransit(false, false, false, false, 1, 1, 1, 1); TrafficLight.CreateLight(); IsReady = true; }
public static void Start() { MoveTimer.Start(); PMoveTimer.Start(); GenCarTimer.Start(); WorkTimer.Start(); GenPeopleTimer.Start(); LightsTimer.Start(); TrafficLight.CreateLight(); IsReady = true; }
private void StartWorkTimer() { if (firstStart) { SecondsLeft = MyDateTimeHandler.GetSecondsToWork(numericUpDownHours.Value.ToString(), numericUpDownMinutes.Value.ToString(), numericUpDownSeconds.Value.ToString()); WorkTimer.Tick += new EventHandler(WorkTimer_Tick); StartTime = DateTime.Now; EndTime = DateTime.Now.AddSeconds(SecondsLeft); progressBar.Maximum = Convert.ToInt32(SecondsLeft); } labelPredictTime.Text = "Expected end of Work: " + EndTime.ToShortTimeString() + " " + MyDateTimeHandler.GetAM(EndTime); buttonStart.Enabled = false; buttonPause.Enabled = true; labelTimer.ForeColor = System.Drawing.Color.Black; WorkTimer.Interval = 1000; WorkTimer.Start(); }
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."); } }
private void breakTimer_Tick(object sender, EventArgs e) { int minutes = int.Parse(WorkTimeLabel.Text.Substring(0, breakChar)); int seconds = int.Parse(WorkTimeLabel.Text.Substring(breakChar + 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 { // gameForm.Close(); MessageBox.Show("Break time is over. Get back to work!", "Timeout", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); breakTimer.Stop(); WorkTimeLabel.Text = $"{(int)WorkNumericUpDown.Value}:00"; WorkTimer.Start(); SecondTimer.Start(); } }