Beispiel #1
0
 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);
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 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);
 }
Beispiel #5
0
 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();
 }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
 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);
 }
Beispiel #10
0
 public void StartTime_InputValid()
 {
     const string validInput = "8:00";
     _workTime = new WorkTime(_clock, validInput);
     var startTime = _workTime.StartTime;
     Assert.IsNotNull(startTime);
 }
Beispiel #11
0
 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);
 }
Beispiel #12
0
 public void StartTime_InputTimeInvalid_TooSmall()
 {
     const string inValidInput = "-8:00";
     _workTime = new WorkTime(_clock, inValidInput);
 }
Beispiel #13
0
 public void StartTime_InputTimeInvalid_WrongFormat_Point()
 {
     const string inValidInput = "8.00";
     _workTime = new WorkTime(_clock, inValidInput);
 }
Beispiel #14
0
 private void UpdateTitle(WorkTime workTime)
 {
     Title = string.Format("{0} ({1})", _config.TitleString, workTime.TimeSpent.ToDisplayString());
 }
Beispiel #15
0
 public void StartTime_InputTimeInvalid_TooLarge()
 {
     const string inValidInput = "25:00";
     _workTime = new WorkTime(_clock, inValidInput);
 }
Beispiel #16
0
        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);
        }
Beispiel #17
0
 public void StartTime_InputTimeInvalid_Empty()
 {
     var inValidInput = string.Empty;
     _workTime = new WorkTime(_clock, inValidInput);
 }
Beispiel #18
0
 private void UpdateClock(WorkTime workTime)
 {
     ucClock.Update(workTime, ucTimeCheckboxes.cbTimeSpent.IsChecked.GetValueOrDefault());
     UpdateClockDisplayTimes();
 }
Beispiel #19
0
        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);
            }
        }
Beispiel #20
0
 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());
 }
Beispiel #21
0
        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);
            }
        }
Beispiel #22
0
 private void UpdateTrayIcon(WorkTime workTime)
 {
     _trayIcon.Icon.Text = workTime.TimeSpent.ToDisplayString();
 }
Beispiel #23
0
 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;
     }
 }
Beispiel #24
0
 public void StartTime_InputTimeInvalid_String()
 {
     const string inValidInput = "invalid";
     _workTime = new WorkTime(_clock, inValidInput);
 }
Beispiel #25
0
 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);
 }
Beispiel #26
0
 private void UpdateTextBoxes(WorkTime workTime)
 {
     ucTimeAsText.UpdateTextBoxes(workTime);
 }
Beispiel #27
0
 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);
 }
Beispiel #28
0
 public void Setup()
 {
     _clock = new StaticClock();
     _w = new WorkTime(_clock, "8:00");
 }
Beispiel #29
0
 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);
 }
Beispiel #30
0
 private void InitStartTime(WorkTime workTime)
 {
     var rect = new Rect(StartTimeRotation, rectangleStartTime);
     rect.Update(workTime.StartTime);
     rect.Visibility = false;
 }