public static void tracker_tick() { totalTimer++; //CALCULATE EPISODETIMER int episodeTimer = (totalTimer - breakingTimeAccumulated); if (currentlyBreaking) episodeTimer -= (totalTimer - currentBreak.totTimeStart); Tuple<string, string, string> timeVisualized = timeVisualiser(totalTimer); //Check if approaching deadline if (projectConfig.deadline) { int timeToDeadline = (projectConfig.deadlineTimer - episodeTimer); //Set blinking status (and color) properly to deadline-timer. if (timeToDeadline < deadline_redBlink) { if (currentDeadlineState != deadlineStates.redblink) { currentDeadlineState = deadlineStates.redblink; mainInstance.la_status_deadline.ForeColor = System.Drawing.Color.Red; } } else if (timeToDeadline < deadline_yellowBlink) { if (currentDeadlineState != deadlineStates.yellowblink) { currentDeadlineState = deadlineStates.yellowblink; mainInstance.la_status_deadline.ForeColor = System.Drawing.Color.Yellow; } } else if (timeToDeadline < deadline_yellow) { if (currentDeadlineState != deadlineStates.yellow) { currentDeadlineState = deadlineStates.yellow; mainInstance.la_status_deadline.ForeColor = System.Drawing.Color.Yellow; } } //end deadline } //Update the visuals. //Totaltimer mainInstance.la_totalTimer.Text = timeVisualized.Item1 + ":" + timeVisualized.Item2 + ":" + timeVisualized.Item3; //Episodetimer //Episodetimer may depend on wether we are breaking right now Tuple<string, string, string> episodeTimerVisualized = timeVisualiser(episodeTimer); mainInstance.la_episodeTimer.Text = episodeTimerVisualized.Item1 + ":" + episodeTimerVisualized.Item2 + ":" + episodeTimerVisualized.Item3; //Breaktimer if (currentlyBreaking) { int breakTimer = (totalTimer - currentBreak.totTimeStart); Tuple<string, string, string> breakTimerVisualized = timeVisualiser(breakTimer); mainInstance.la_breakTimer.Text = breakTimerVisualized.Item1 + ":" + breakTimerVisualized.Item2 + ":" + breakTimerVisualized.Item3; } else { //Breaktimer - is not breaking if (mainInstance.la_breakTimer.Text != "00:00:00") mainInstance.la_breakTimer.Text = "00:00:00"; } }
public static void newProject() { //Reset vars TimeTracking.projectConfig = null; currentTrackingState = timeTrackingStates.inactive; totalTimer = 0; breakingTimeAccumulated = 0; currentlyBreaking = false; currentBreak = null; previousBreaks = new List<timeTrackingBreak>(); marks = new List<timeTrackingMark>(); currentDeadlineState = deadlineStates.normal; mainInstance.dgv_marks.Rows.Clear(); //Reset vars for other classes timeTrackingBreak.index = 0; timeTrackingMark.index = 0; //Reset timers and vars mainInstance.timer_tracker.Enabled = false; mainInstance.la_totalTimer.Text = "00:00:00"; mainInstance.la_episodeTimer.Text = "00:00:00"; mainInstance.la_breakTimer.Text = "00:00:00"; mainInstance.la_deadlineTimer.Text = "00:00:00"; //Set colors to normal. mainInstance.la_status_tracking.ForeColor = System.Drawing.Color.FromArgb(64, 64, 64); mainInstance.la_status_inactive.ForeColor = System.Drawing.Color.FromArgb(255, 255, 255); mainInstance.la_status_break.ForeColor = System.Drawing.Color.FromArgb(64, 64, 64); mainInstance.la_status_deadline.ForeColor = System.Drawing.Color.FromArgb(64, 64, 64); //SHOW Settings form settingsInstance = new frm_settings(); settingsInstance.Show(); settingsShown = true; mainInstance.SendToBack(); settingsInstance.Activate(); }