worktimehero

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.clttr.info/worktimehero.git
Log | Files | Refs | README | LICENSE

commit 5d2e87e6a781af7107a5e5f940633470310cff13
parent c707dd94cd1c1a66f81b141b1dee496151cc0ef0
Author: René Wagner <rwagner@rw-net.de>
Date:   Thu, 16 Jul 2020 19:59:03 +0200

honor current break time on calculation

do not count worktime while in a break

Diffstat:
MWorkTimeHero/MainForm.Designer.cs | 1+
MWorkTimeHero/MainForm.cs | 11++++++++++-
MWorkTimeHero/WorkTimeCalculator.cs | 36+++++++++++++++++++++++++++++-------
3 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/WorkTimeHero/MainForm.Designer.cs b/WorkTimeHero/MainForm.Designer.cs @@ -141,6 +141,7 @@ // lblTimeDue // this.lblTimeDue.AutoSize = true; + this.lblTimeDue.BackColor = System.Drawing.Color.Yellow; this.lblTimeDue.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblTimeDue.Location = new System.Drawing.Point(223, 31); this.lblTimeDue.Name = "lblTimeDue"; diff --git a/WorkTimeHero/MainForm.cs b/WorkTimeHero/MainForm.cs @@ -57,7 +57,7 @@ namespace WorkTimeHero prgPercentage.Value = wtc.WorkTimePercentage; lblCompleted.Text = string.Format("{1,-20}{0}", wtc.DoneWorkTime.ToString(TimeFormatter), "Arbeitszeit:"); lblOvertime.Text = string.Format("{1,-20}{0}", wtc.AdditionalWorkTime.ToString(TimeFormatter), "√úberstunden:"); - lblRemaining.Text = string.Format("{1,-20}{0}", wtc.RemainingWorkTime.ToString(TimeFormatter), "Verbleibend:"); + lblRemaining.Text = string.Format("{1,-20}{0}", wtc.RemainingWorkTime.ToString(TimeFormatter), "Arbeitsende:"); lblTimeDue.Text = string.Format("{1,-20}{0}", wtc.TimeDue.ToString(TimeFormatter), "Uhrzeit:"); if (wtc.IndividualBreakTime.Date == DateTime.Now.Date) @@ -77,6 +77,15 @@ namespace WorkTimeHero lblCurrentBreak.Text = string.Empty; } + if ( wtc.AdditionalWorkTime.TotalMinutes > 0) + { + lblTimeDue.BackColor = Color.LightGreen; + } + else + { + lblTimeDue.BackColor = Color.Yellow; + } + RefreshTooltip(); RefreshIcons(); } diff --git a/WorkTimeHero/WorkTimeCalculator.cs b/WorkTimeHero/WorkTimeCalculator.cs @@ -52,7 +52,7 @@ namespace WorkTimeHero { get { - return StartTime.TimeOfDay + TargetTime + PlannedBreakTime; + return StartTime.TimeOfDay + TargetTime + EffectiveBreakTime; } } @@ -63,8 +63,8 @@ namespace WorkTimeHero { get { - TimeSpan nettoTime = BruttoTime - CurrentBreakTime; - if (nettoTime.TotalMinutes < 0) { return new TimeSpan(); } + TimeSpan nettoTime = BruttoTime - EffectiveBreakTime; + if (nettoTime.TotalMinutes < 0) { return TimeSpan.Zero; } return nettoTime; } } @@ -86,18 +86,18 @@ namespace WorkTimeHero } /// <summary> - /// aktueller Pausenabzug + /// aktueller, effektiver Pausenabzug /// </summary> - public TimeSpan CurrentBreakTime + public TimeSpan EffectiveBreakTime { get { if (IndividualBreakTime.Date == DateTime.Now.Date) { - return IndividualBreakTime.TimeOfDay; + return IndividualBreakTime.TimeOfDay + CurrentBreakTime; } - return BruttoTime.CalculateBreak(); + return BruttoTime.CalculateBreak() + CurrentBreakTime; } } @@ -133,18 +133,40 @@ namespace WorkTimeHero } } + /// <summary> + /// individuelle Pausenzeit + /// <summary> public DateTime IndividualBreakTime { get; set; } + /// <summary> + /// Startzeit der aktuellen Pause + /// <summary> public TimeSpan CurrentBreakStartTime { get; set; } + /// <summary> + /// Dauer der aktuellen Pause + /// <summary> + private TimeSpan CurrentBreakTime + { + get + { + if (IsInBreak) + { + return DateTime.Now.TimeOfDay - CurrentBreakStartTime; + } + + return TimeSpan.Zero; + } + } + public bool IsInBreak { get