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 70b52d5a87a28c0208c4f904380565ce7a19afd4
parent 504df951ef57ddb7c42b402195915818bbed9d18
Author: René Wagner <rwagner@rw-net.de>
Date:   Mon,  6 Jul 2020 19:54:15 +0200

WIP: ~rwa/misc#21: add break button

Diffstat:
MWorkTimeHero/App.config | 3+++
MWorkTimeHero/MainForm.Designer.cs | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
MWorkTimeHero/MainForm.cs | 59+++++++++++++++++++++++++++++++++++++++++++++++++----------
MWorkTimeHero/Properties/Settings.Designer.cs | 12++++++++++++
MWorkTimeHero/Properties/Settings.settings | 3+++
5 files changed, 120 insertions(+), 36 deletions(-)

diff --git a/WorkTimeHero/App.config b/WorkTimeHero/App.config @@ -22,6 +22,9 @@ <setting name="IndividualBreakTime" serializeAs="String"> <value>1970-01-01</value> </setting> + <setting name="CurrentBreakStartTime" serializeAs="String"> + <value>00:00:00</value> + </setting> </WorkTimeHero.Properties.Settings> </userSettings> </configuration> \ No newline at end of file diff --git a/WorkTimeHero/MainForm.Designer.cs b/WorkTimeHero/MainForm.Designer.cs @@ -32,7 +32,7 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.lblStartTime = new System.Windows.Forms.Label(); this.dtpStartTime = new System.Windows.Forms.DateTimePicker(); - this.dtpBreak = new System.Windows.Forms.DateTimePicker(); + this.dtpIndividualBreak = new System.Windows.Forms.DateTimePicker(); this.prgPercentage = new System.Windows.Forms.ProgressBar(); this.lblCompleted = new System.Windows.Forms.Label(); this.refreshTimer = new System.Windows.Forms.Timer(this.components); @@ -48,9 +48,11 @@ this.lblBuchungVorlauf = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.cboAutostart = new System.Windows.Forms.CheckBox(); - this.dtpTargetTime = new System.Windows.Forms.DateTimePicker(); this.lblSollzeit = new System.Windows.Forms.Label(); + this.lblCurrentBreak = new System.Windows.Forms.Label(); + this.dtpTargetTime = new System.Windows.Forms.DateTimePicker(); this.nudPreamp = new System.Windows.Forms.NumericUpDown(); + this.cboBreak = new System.Windows.Forms.CheckBox(); this.cmsNotifyIcon.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudPreamp)).BeginInit(); @@ -78,19 +80,19 @@ this.dtpStartTime.TabIndex = 6; this.dtpStartTime.ValueChanged += new System.EventHandler(this.dtpStartTime_ValueChanged); // - // dtpBreak + // dtpIndividualBreak // - this.dtpBreak.CustomFormat = "HH:mm"; - this.dtpBreak.Enabled = false; - this.dtpBreak.Font = new System.Drawing.Font("Consolas", 9.75F); - this.dtpBreak.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.dtpBreak.Location = new System.Drawing.Point(226, 106); - this.dtpBreak.Name = "dtpBreak"; - this.dtpBreak.ShowUpDown = true; - this.dtpBreak.Size = new System.Drawing.Size(67, 23); - this.dtpBreak.TabIndex = 8; - this.dtpBreak.Value = new System.DateTime(2016, 1, 1, 0, 45, 0, 0); - this.dtpBreak.ValueChanged += new System.EventHandler(this.dtpBreak_ValueChanged); + this.dtpIndividualBreak.CustomFormat = "HH:mm"; + this.dtpIndividualBreak.Enabled = false; + this.dtpIndividualBreak.Font = new System.Drawing.Font("Consolas", 9.75F); + this.dtpIndividualBreak.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dtpIndividualBreak.Location = new System.Drawing.Point(226, 106); + this.dtpIndividualBreak.Name = "dtpIndividualBreak"; + this.dtpIndividualBreak.ShowUpDown = true; + this.dtpIndividualBreak.Size = new System.Drawing.Size(67, 23); + this.dtpIndividualBreak.TabIndex = 8; + this.dtpIndividualBreak.Value = new System.DateTime(2016, 1, 1, 0, 45, 0, 0); + this.dtpIndividualBreak.ValueChanged += new System.EventHandler(this.dtpIndividualBreak_ValueChanged); // // prgPercentage // @@ -233,6 +235,25 @@ this.cboAutostart.UseVisualStyleBackColor = true; this.cboAutostart.CheckedChanged += new System.EventHandler(this.cboAutostart_CheckedChanged); // + // lblSollzeit + // + this.lblSollzeit.AutoSize = true; + this.lblSollzeit.Font = new System.Drawing.Font("Consolas", 9.75F); + this.lblSollzeit.Location = new System.Drawing.Point(6, 57); + this.lblSollzeit.Name = "lblSollzeit"; + this.lblSollzeit.Size = new System.Drawing.Size(63, 15); + this.lblSollzeit.TabIndex = 2; + this.lblSollzeit.Text = "Sollzeit"; + // + // lblCurrentBreak + // + this.lblCurrentBreak.Font = new System.Drawing.Font("Consolas", 9.75F); + this.lblCurrentBreak.Location = new System.Drawing.Point(299, 108); + this.lblCurrentBreak.Name = "lblCurrentBreak"; + this.lblCurrentBreak.Size = new System.Drawing.Size(153, 18); + this.lblCurrentBreak.TabIndex = 10; + this.lblCurrentBreak.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // dtpTargetTime // this.dtpTargetTime.CustomFormat = "HH:mm"; @@ -247,16 +268,6 @@ this.dtpTargetTime.Value = global::WorkTimeHero.Properties.Settings.Default.TargetTime; this.dtpTargetTime.ValueChanged += new System.EventHandler(this.dtpTargetTime_ValueChanged); // - // lblSollzeit - // - this.lblSollzeit.AutoSize = true; - this.lblSollzeit.Font = new System.Drawing.Font("Consolas", 9.75F); - this.lblSollzeit.Location = new System.Drawing.Point(6, 57); - this.lblSollzeit.Name = "lblSollzeit"; - this.lblSollzeit.Size = new System.Drawing.Size(63, 15); - this.lblSollzeit.TabIndex = 2; - this.lblSollzeit.Text = "Sollzeit"; - // // nudPreamp // this.nudPreamp.DataBindings.Add(new System.Windows.Forms.Binding("Value", global::WorkTimeHero.Properties.Settings.Default, "StartTimePreamp", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); @@ -277,12 +288,26 @@ this.nudPreamp.TabIndex = 1; this.nudPreamp.Value = global::WorkTimeHero.Properties.Settings.Default.StartTimePreamp; // + // cboBreak + // + this.cboBreak.Appearance = System.Windows.Forms.Appearance.Button; + this.cboBreak.Location = new System.Drawing.Point(335, 79); + this.cboBreak.Name = "cboBreak"; + this.cboBreak.Size = new System.Drawing.Size(80, 23); + this.cboBreak.TabIndex = 12; + this.cboBreak.Text = "Pause"; + this.cboBreak.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.cboBreak.UseVisualStyleBackColor = true; + this.cboBreak.CheckedChanged += new System.EventHandler(this.cboBreak_CheckedChanged); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(464, 257); this.ControlBox = false; + this.Controls.Add(this.cboBreak); + this.Controls.Add(this.lblCurrentBreak); this.Controls.Add(this.groupBox1); this.Controls.Add(this.cboIndividualBreak); this.Controls.Add(this.lblTimeDue); @@ -290,7 +315,7 @@ this.Controls.Add(this.lblRemaining); this.Controls.Add(this.lblCompleted); this.Controls.Add(this.prgPercentage); - this.Controls.Add(this.dtpBreak); + this.Controls.Add(this.dtpIndividualBreak); this.Controls.Add(this.dtpStartTime); this.Controls.Add(this.lblStartTime); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; @@ -315,7 +340,7 @@ private System.Windows.Forms.Label lblStartTime; private System.Windows.Forms.DateTimePicker dtpStartTime; - private System.Windows.Forms.DateTimePicker dtpBreak; + private System.Windows.Forms.DateTimePicker dtpIndividualBreak; private System.Windows.Forms.ProgressBar prgPercentage; private System.Windows.Forms.Label lblCompleted; private System.Windows.Forms.Timer refreshTimer; @@ -334,6 +359,8 @@ private System.Windows.Forms.DateTimePicker dtpTargetTime; private System.Windows.Forms.Label lblSollzeit; private System.Windows.Forms.CheckBox cboAutostart; + private System.Windows.Forms.Label lblCurrentBreak; + private System.Windows.Forms.CheckBox cboBreak; } } diff --git a/WorkTimeHero/MainForm.cs b/WorkTimeHero/MainForm.cs @@ -35,21 +35,26 @@ namespace WorkTimeHero else { dtpStartTime.Value = DateTime.Now.AddMinutes((int)Settings.Default.StartTimePreamp); - Settings.Default.StartTimestamp = dtpStartTime.Value; - Settings.Default.Save(); } if (Settings.Default.IndividualBreakTime.Date.Equals(DateTime.Now.Date)) { cboIndividualBreak.Checked = true; - dtpBreak.Value = Settings.Default.IndividualBreakTime; + dtpIndividualBreak.Value = Settings.Default.IndividualBreakTime; + } + + if (Settings.Default.CurrentBreakStartTime != TimeSpan.Zero) + { + cboBreak.Checked = true; } if (File.Exists(startUpFolderPathLink)) { cboAutostart.Checked = true; } + + Settings.Default.Save(); } private void RefreshDisplay() @@ -128,27 +133,26 @@ namespace WorkTimeHero { TargetTime = dtpTargetTime.Value.TimeOfDay }; - if (!dtpBreak.Enabled) + if (!dtpIndividualBreak.Enabled) { wtc.IndividualBreakTime = null; } else { - wtc.IndividualBreakTime = dtpBreak.Value.TimeOfDay; + wtc.IndividualBreakTime = dtpIndividualBreak.Value.TimeOfDay; } RefreshDisplay(); } - private void dtpBreak_ValueChanged(object sender, EventArgs e) + private void dtpIndividualBreak_ValueChanged(object sender, EventArgs e) { RefreshWtc(); } private void cboIndividualBreak_CheckedChanged(object sender, EventArgs e) { - dtpBreak.Enabled = cboIndividualBreak.Checked; - if (!dtpBreak.Value.Date.Equals(DateTime.Now.Date)) { dtpBreak.Value = DateTime.Now.Date.AddMinutes(45); } - RefreshWtc(); + dtpIndividualBreak.Enabled = cboIndividualBreak.Checked; + if (!dtpIndividualBreak.Value.Date.Equals(DateTime.Now.Date)) { dtpIndividualBreak.Value = DateTime.Now.Date.AddMinutes(45); } } private void ntiWorkTimeHero_MouseDoubleClick(object sender, MouseEventArgs e) @@ -203,7 +207,7 @@ namespace WorkTimeHero private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { Settings.Default.StartTimestamp = dtpStartTime.Value; - if (cboIndividualBreak.Checked) { Settings.Default.IndividualBreakTime = dtpBreak.Value; } + if (cboIndividualBreak.Checked) { Settings.Default.IndividualBreakTime = dtpIndividualBreak.Value; } Settings.Default.Save(); } @@ -211,5 +215,40 @@ namespace WorkTimeHero { RefreshWtc(); } + + private void cboBreak_CheckedChanged(object sender, EventArgs e) + { + if (cboBreak.Checked) + { + if (Settings.Default.CurrentBreakStartTime == TimeSpan.Zero) + { + Settings.Default.CurrentBreakStartTime = DateTime.Now.TimeOfDay; + } + + cboBreak.BackColor = Color.Yellow; + lblCurrentBreak.Text = "Pause seit " + Settings.Default.CurrentBreakStartTime.ToString(@"hh\:mm"); + } + else + { + cboBreak.BackColor = SystemColors.Control; + lblCurrentBreak.Text = string.Empty; + double breakTimeInMinutes = DateTime.Now.TimeOfDay.TotalMinutes - Settings.Default.CurrentBreakStartTime.TotalMinutes; + + if ( cboIndividualBreak.Checked ) + { + dtpIndividualBreak.Value = dtpIndividualBreak.Value.AddMinutes(breakTimeInMinutes); + } + else + { + cboIndividualBreak.Checked = true; + dtpIndividualBreak.Value = DateTime.Now.Date.AddMinutes(breakTimeInMinutes); + } + + Settings.Default.IndividualBreakTime = dtpIndividualBreak.Value; + Settings.Default.CurrentBreakStartTime = TimeSpan.Zero; + } + + Settings.Default.Save(); + } } } \ No newline at end of file diff --git a/WorkTimeHero/Properties/Settings.Designer.cs b/WorkTimeHero/Properties/Settings.Designer.cs @@ -70,5 +70,17 @@ namespace WorkTimeHero.Properties { this["IndividualBreakTime"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("00:00:00")] + public global::System.TimeSpan CurrentBreakStartTime { + get { + return ((global::System.TimeSpan)(this["CurrentBreakStartTime"])); + } + set { + this["CurrentBreakStartTime"] = value; + } + } } } diff --git a/WorkTimeHero/Properties/Settings.settings b/WorkTimeHero/Properties/Settings.settings @@ -14,5 +14,8 @@ <Setting Name="IndividualBreakTime" Type="System.DateTime" Scope="User"> <Value Profile="(Default)">1970-01-01</Value> </Setting> + <Setting Name="CurrentBreakStartTime" Type="System.TimeSpan" Scope="User"> + <Value Profile="(Default)">00:00:00</Value> + </Setting> </Settings> </SettingsFile> \ No newline at end of file