public void Balance_UnderTargetTime() { // current time: 15:30 IClock workedTooShort = new StaticClock(new DateTime(2011, 06, 10, 15, 30, 0)); var workTime = new WorkTime(workedTooShort, "8:00"); var minusTime = new TimeSpan(-1, -15, 0); Assert.AreEqual(minusTime, workTime.Balance); }
public void Balance_UnderMinTimeStart() { // current time: 10:00 IClock workedTooShort = new StaticClock(new DateTime(2011, 06, 10, 10, 0, 0)); var workTime = new WorkTime(workedTooShort, "8:00"); var minusTime = new TimeSpan(-6, 0, 0); Assert.AreEqual(minusTime, workTime.Balance); }
public void Balance_AboveMaxTime() { // current time: 19:30 IClock workedTooShort = new StaticClock(new DateTime(2011, 06, 10, 19, 30, 0)); var workTime = new WorkTime(workedTooShort, "8:00"); var minusTime = new TimeSpan(2, 0, 0); Assert.AreEqual(minusTime, workTime.Balance); }
public void Balance_UnderMinTimeStart_JustStarted() { // current time: 8:15 IClock workedTooShort = new StaticClock(new DateTime(2011, 06, 10, 8, 15, 0)); var workTime = new WorkTime(workedTooShort, "8:00"); var minusTime = new TimeSpan(-7, -45, 0); Assert.AreEqual(minusTime, workTime.Balance); }
public void UpdateTextBoxes(WorkTime workTime) { tbTimeTarget.Text = workTime.TargetTime.ToShortTimeString(); tbTimeTargetRemaining.Text = workTime.RemainingTillTarget.ToDisplayString(); tbMinTime.Text = workTime.MinTimeStart.ToShortTimeString(); tbMinTimeRemaining.Text = workTime.RemainingTillMinTime.ToDisplayString(); tbMaxTime.Text = workTime.MaxTime.ToShortTimeString(); tbMaxTimeRemaining.Text = workTime.RemainingTillMaxTime.ToDisplayString(); tbBalance.Text = workTime.Balance.ToDisplayString(); }
public void Init(WorkTime workTime, Config config) { if (workTime == null || config == null) { throw new ArgumentException("bla"); } _startTime = workTime.StartTime; _config = config; InitStartTime(workTime); InitTargetTime(workTime, RadiusTargetTime); InitMinTime(workTime, RadiusMinTime); InitMaxTime(workTime, RadiusMaxTime); }
public void Update(WorkTime workTime, bool isChecked) { _timeSpentArc = new Arc(timeSpentPath, timeSpentStartOnCircle, timeSpentArc, _zeroPos, _config.TimeSpentColor); _timeSpentArc.Update(workTime.StartTime, DateTime.Now, RadiusTimeSpent, workTime.TimeSpent > _config.MinTimeSpan); _timeSpentArc.Visibility = isChecked; lbClockTop.Content = "time spent: " + workTime.TimeSpent.ToDisplayString(); lbClockBottom.Content = "remaining: " + workTime.RemainingTillTarget.ToDisplayString(); if (workTime.StartTime != _startTime) { Init(workTime, _config); } }
public void UpdateWarnings(WorkTime workTime) { if (workTime.WarningTimeReached()) { gbTimes.Background = new SolidColorBrush(_config.WarnBackgroundColor); tbMaxTimeRemaining.Background = new SolidColorBrush(_config.WarnBackgroundColor); } else { gbTimes.Background = _defaultBackground; tbMaxTimeRemaining.Background = new SolidColorBrush(_config.OkBackgroundColor); } tbTimeTargetRemaining.Background = workTime.IsLessThanTargetTime() ? new SolidColorBrush(_config.WarnBackgroundColor) : new SolidColorBrush(_config.OkBackgroundColor); tbMinTimeRemaining.Background = workTime.IsLessThanMinTime() ? new SolidColorBrush(_config.WarnBackgroundColor) : new SolidColorBrush(_config.OkBackgroundColor); }
public void TargetTime_With_StartTime_TwoDaysAgo() { IClock currentTime = new StaticClock(new DateTime(2011, 06, 10, 11, 0, 0)); var startDate = new DateTime(2011, 06, 9); var workTime = new WorkTime(currentTime, "8:00", startDate); var expectedTargetTime = startDate.Add(new TimeSpan(16, 45, 0)); Assert.AreEqual(expectedTargetTime, workTime.TargetTime); }
public void StartTime_InputValid() { const string validInput = "8:00"; _workTime = new WorkTime(_clock, validInput); var startTime = _workTime.StartTime; Assert.IsNotNull(startTime); }
public void TargetTime_NextDay() { // current time: 00:05 // start time: 23:00 (previous day) IClock currentTime = new StaticClock(new DateTime(2011, 06, 10, 0, 5, 0)); var startDate = new DateTime(2011, 06, 9); var workTime = new WorkTime(currentTime, "23:00", startDate); var minusTime = new TimeSpan(-6, -55, 0); Assert.AreEqual(minusTime, workTime.Balance); }
public void StartTime_InputTimeInvalid_TooSmall() { const string inValidInput = "-8:00"; _workTime = new WorkTime(_clock, inValidInput); }
public void StartTime_InputTimeInvalid_WrongFormat_Point() { const string inValidInput = "8.00"; _workTime = new WorkTime(_clock, inValidInput); }
private void UpdateTitle(WorkTime workTime) { Title = string.Format("{0} ({1})", _config.TitleString, workTime.TimeSpent.ToDisplayString()); }
public void StartTime_InputTimeInvalid_TooLarge() { const string inValidInput = "25:00"; _workTime = new WorkTime(_clock, inValidInput); }
private void InitTargetTime(WorkTime workTime, double radius) { var rect = new Rect(TargetTimeRotation, rectangleTargetTime); rect.Update(workTime.TargetTime); rect.Visibility = false; _targetTimeArc = InitArc(targetTimePath, targetTimeStartOnCircle, targetTimeArc, workTime.StartTime, workTime.TargetTime, radius, true, _config.TargetTimeColor); }
public void StartTime_InputTimeInvalid_Empty() { var inValidInput = string.Empty; _workTime = new WorkTime(_clock, inValidInput); }
private void UpdateClock(WorkTime workTime) { ucClock.Update(workTime, ucTimeCheckboxes.cbTimeSpent.IsChecked.GetValueOrDefault()); UpdateClockDisplayTimes(); }
private void Update() { if (!IsValidStartTime()) { return; } try { var workTime = new WorkTime(ucTimeAsText.StartTime); UpdateTextBoxes(workTime); UpdateProgressGui(workTime); UpdateTitle(workTime); UpdateClock(workTime); UpdateTrayIcon(workTime); UpdateWarnings(workTime); } catch (Exception exception) { ShowErrorDlg(exception.Message); } }
private void UpdateProgressGui(WorkTime workTime) { ucProgress.UpdateCurrentPos(workTime.TimeSpent); ucProgress.ToggleMinTimeDisplay(ucTimeCheckboxes.cbMinTime.IsChecked.GetValueOrDefault()); ucProgress.ToggleMaxTimeDisplay(ucTimeCheckboxes.cbMaxTime.IsChecked.GetValueOrDefault()); ucProgress.ToggleTargetTimeDisplay(ucTimeCheckboxes.cbTargetTime.IsChecked.GetValueOrDefault()); ucProgress.ToggleTimeSpentDisplay(ucTimeCheckboxes.cbTimeSpent.IsChecked.GetValueOrDefault()); }
private void UpdateWarnings(WorkTime workTime) { ucTimeAsText.UpdateWarnings(workTime); // TODO SOMETHING REALLY FLASHY HERE var showFlashyWarning = workTime.TargetTimePassed() && workTime.WarningTimeReached() && !_warningCancelled && LastWarningIntervalExpired(); if (showFlashyWarning) { ShowWarningMsgBox(workTime); } }
private void UpdateTrayIcon(WorkTime workTime) { _trayIcon.Icon.Text = workTime.TimeSpent.ToDisplayString(); }
private void ShowWarningMsgBox(WorkTime workTime) { var msgBoxText = string.Format("Achtung: Ende in {0} Minuten!", workTime.RemainingTillMaxTime.ToDisplayString()); var caption = "Achtung!"; var buttons = MessageBoxButton.OKCancel; var icon = MessageBoxImage.Warning; var result = MessageBox.Show(msgBoxText, caption, buttons, icon); switch (result) { case MessageBoxResult.OK: _lastWarning = DateTime.Now; break; case MessageBoxResult.Cancel: _lastWarning = DateTime.Now; _warningCancelled = true; break; default: break; } }
public void StartTime_InputTimeInvalid_String() { const string inValidInput = "invalid"; _workTime = new WorkTime(_clock, inValidInput); }
public void TimeTillMaxTime_WorkedTooLong() { IClock workedTooLong = new StaticClock(new DateTime(2011, 06, 10, 19, 0, 0)); var workTime = new WorkTime(workedTooLong, "8:00"); var expected = workTime.MaxTime.Subtract(workedTooLong.Now); Assert.AreEqual(expected, workTime.RemainingTillMaxTime); }
private void UpdateTextBoxes(WorkTime workTime) { ucTimeAsText.UpdateTextBoxes(workTime); }
public void RemainingTimeTarget_With_StartTime_TwoDaysAgo() { IClock currentTime = new StaticClock(new DateTime(2011, 06, 10, 11, 0, 0)); var startDate = new DateTime(2011, 06, 9); var workTime = new WorkTime(currentTime, "8:00", startDate); var expectedRemainingTargetTime = new TimeSpan(-18, -15, 0); Assert.AreEqual(expectedRemainingTargetTime, workTime.RemainingTillTarget); }
public void Setup() { _clock = new StaticClock(); _w = new WorkTime(_clock, "8:00"); }
public void CurrentTimeSpent_With_StartTime_TwoDaysAgo() { IClock currentTime = new StaticClock(new DateTime(2011, 06, 10, 11, 0, 0)); var startDate = new DateTime(2011, 06, 9); var workTime = new WorkTime(currentTime, "8:00", startDate); const double expectedCurrentTimeSpent = 27d; Assert.AreEqual(expectedCurrentTimeSpent, workTime.TimeSpent.TotalHours); }
private void InitStartTime(WorkTime workTime) { var rect = new Rect(StartTimeRotation, rectangleStartTime); rect.Update(workTime.StartTime); rect.Visibility = false; }