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 c707dd94cd1c1a66f81b141b1dee496151cc0ef0
parent a4638aeba92f4cf8904cccf33dfbcf0937030a77
Author: René Wagner <rwagner@rw-net.de>
Date:   Mon, 13 Jul 2020 16:32:56 +0200

fix form initalizing

Diffstat:
MWorkTimeHero/MainForm.Designer.cs | 22+++++++++++-----------
MWorkTimeHero/MainForm.cs | 20+++++++++++++++++++-
2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/WorkTimeHero/MainForm.Designer.cs b/WorkTimeHero/MainForm.Designer.cs @@ -47,13 +47,13 @@ this.tsmiBeenden = new System.Windows.Forms.ToolStripMenuItem(); this.lblBuchungVorlauf = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.btnInfo = new System.Windows.Forms.Button(); this.cboAutostart = new System.Windows.Forms.CheckBox(); this.dtpTargetTime = new System.Windows.Forms.DateTimePicker(); this.lblSollzeit = new System.Windows.Forms.Label(); this.nudPreamp = new System.Windows.Forms.NumericUpDown(); this.lblCurrentBreak = new System.Windows.Forms.Label(); this.btnSwitchBreak = new System.Windows.Forms.Button(); - this.btnInfo = new System.Windows.Forms.Button(); this.cmsNotifyIcon.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudPreamp)).BeginInit(); @@ -225,6 +225,16 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "Einstellungen"; // + // btnInfo + // + this.btnInfo.Location = new System.Drawing.Point(373, 82); + this.btnInfo.Name = "btnInfo"; + this.btnInfo.Size = new System.Drawing.Size(51, 23); + this.btnInfo.TabIndex = 5; + this.btnInfo.Text = "Info"; + this.btnInfo.UseVisualStyleBackColor = true; + this.btnInfo.Click += new System.EventHandler(this.btnInfo_Click); + // // cboAutostart // this.cboAutostart.AutoSize = true; @@ -299,16 +309,6 @@ this.btnSwitchBreak.UseVisualStyleBackColor = true; this.btnSwitchBreak.Click += new System.EventHandler(this.btnSwitchBreak_Click); // - // btnInfo - // - this.btnInfo.Location = new System.Drawing.Point(373, 82); - this.btnInfo.Name = "btnInfo"; - this.btnInfo.Size = new System.Drawing.Size(51, 23); - this.btnInfo.TabIndex = 5; - this.btnInfo.Text = "Info"; - this.btnInfo.UseVisualStyleBackColor = true; - this.btnInfo.Click += new System.EventHandler(this.btnInfo_Click); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/WorkTimeHero/MainForm.cs b/WorkTimeHero/MainForm.cs @@ -19,6 +19,8 @@ namespace WorkTimeHero private readonly string startUpFolderPathLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), Application.ProductName + ".lnk"); + private Boolean initialize = true; + private WorkTimeCalculator wtc; public MainForm() @@ -28,18 +30,26 @@ namespace WorkTimeHero private void MainForm_Load(object sender, EventArgs e) { - DateTime individualBreakTime = Settings.Default.IndividualBreakTime.Date == DateTime.Now.Date ? DateTime.MinValue : Settings.Default.IndividualBreakTime; + DateTime individualBreakTime = DateTime.MinValue; + if (Settings.Default.IndividualBreakTime.Date == DateTime.Now.Date) + { + individualBreakTime = Settings.Default.IndividualBreakTime; + cboIndividualBreak.Checked = true; + } DateTime startTime = Settings.Default.StartTime.Date == DateTime.Now.Date ? Settings.Default.StartTime : DateTime.Now; wtc = new WorkTimeCalculator(startTime , Settings.Default.TargetTime, individualBreakTime, Settings.Default.CurrentBreakStartTime); dtpIndividualBreak.Value = DateTime.Now.Date.Add(wtc.PlannedBreakTime); dtpTargetTime.Value = DateTime.Now.Date.Add(Settings.Default.TargetTime); dtpStartTime.Value = DateTime.Now.Date.Add(Settings.Default.StartTime.TimeOfDay); + RefreshDisplay(); if (File.Exists(startUpFolderPathLink)) { cboAutostart.Checked = true; } + + initialize = false; } private void RefreshDisplay() @@ -135,17 +145,22 @@ namespace WorkTimeHero private void dtpStartTime_ValueChanged(object sender, EventArgs e) { + if ( initialize ) { return; } RefreshWtc(); } private void dtpIndividualBreak_ValueChanged(object sender, EventArgs e) { + if (initialize) { return; } if ( cboIndividualBreak.Checked ) { RefreshWtc(); } } private void cboIndividualBreak_CheckedChanged(object sender, EventArgs e) { dtpIndividualBreak.Enabled = cboIndividualBreak.Checked; + + if (initialize) { return; } + RefreshWtc(); } @@ -168,6 +183,7 @@ namespace WorkTimeHero private void cboAutostart_CheckedChanged(object sender, EventArgs e) { + if (initialize) { return; } if (cboAutostart.Checked) { WshShell wshShell = new WshShell(); @@ -208,11 +224,13 @@ namespace WorkTimeHero private void dtpTargetTime_ValueChanged(object sender, EventArgs e) { + if (initialize) { return; } RefreshWtc(); } private void btnSwitchBreak_Click(object sender, EventArgs e) { + if (initialize) { return; } if (!wtc.IsInBreak) { wtc.StartBreak();