worktimehero

git clone https://git.clttr.info/worktimehero.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 12feb8bf816b695c48cfd7f5eb77821e762b1ec6
parent 1e7f4cee619dbe6be6855e27416f809b2c7560ce
Author: René Wagner <rwagner@rw-net.de>
Date:   Wed, 20 May 2020 19:54:37 +0200

implements ~rwa/misc#22: safe starttime of current day

Diffstat:
MWorkTimeHero/App.config | 17++++++++++-------
MWorkTimeHero/MainForm.cs | 15++++++++++++++-
MWorkTimeHero/Properties/Settings.Designer.cs | 111+++++++++++++++++++++++++++++++++++++++++++------------------------------------
MWorkTimeHero/Properties/Settings.settings | 25++++++++++++++-----------
AWorkTimeHero/Settings.cs | 28++++++++++++++++++++++++++++
MWorkTimeHero/WorkTimeHero.csproj | 1+
6 files changed, 128 insertions(+), 69 deletions(-)

diff --git a/WorkTimeHero/App.config b/WorkTimeHero/App.config @@ -9,13 +9,16 @@ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <userSettings> - <WorkTimeHero.Properties.Settings> - <setting name="StartTimePreamp" serializeAs="String"> - <value>-10</value> - </setting> - <setting name="TargetTime" serializeAs="String"> - <value>01/01/2016 08:00:00</value> - </setting> + <WorkTimeHero.Properties.Settings> + <setting name="StartTimePreamp" serializeAs="String"> + <value>-10</value> + </setting> + <setting name="TargetTime" serializeAs="String"> + <value>05/20/2020 08:00:00</value> + </setting> + <setting name="StartTimestamp" serializeAs="String"> + <value /> + </setting> </WorkTimeHero.Properties.Settings> </userSettings> </configuration> \ No newline at end of file diff --git a/WorkTimeHero/MainForm.cs b/WorkTimeHero/MainForm.cs @@ -28,7 +28,19 @@ namespace WorkTimeHero private void MainForm_Load(object sender, EventArgs e) { - dtpStartTime.Value = DateTime.Now.AddMinutes((int)Settings.Default.StartTimePreamp); + //ttings.Default.Upgrade(); + + if (Settings.Default.StartTimestamp.Date.Equals(DateTime.Now.Date)) + { + dtpStartTime.Value = Settings.Default.StartTimestamp; + } + else + { + dtpStartTime.Value = DateTime.Now.AddMinutes((int)Settings.Default.StartTimePreamp); + + Settings.Default.StartTimestamp = dtpStartTime.Value; + Settings.Default.Save(); + } if (File.Exists(startUpFolderPathLink)) { @@ -185,6 +197,7 @@ namespace WorkTimeHero private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { + Settings.Default.StartTimestamp = dtpStartTime.Value; Settings.Default.Save(); } diff --git a/WorkTimeHero/Properties/Settings.Designer.cs b/WorkTimeHero/Properties/Settings.Designer.cs @@ -1,50 +1,61 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace WorkTimeHero.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("-10")] - public decimal StartTimePreamp { - get { - return ((decimal)(this["StartTimePreamp"])); - } - set { - this["StartTimePreamp"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("01/01/2016 08:00:00")] - public global::System.DateTime TargetTime { - get { - return ((global::System.DateTime)(this["TargetTime"])); - } - set { - this["TargetTime"] = value; - } - } - } -} +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace WorkTimeHero.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("-10")] + public decimal StartTimePreamp { + get { + return ((decimal)(this["StartTimePreamp"])); + } + set { + this["StartTimePreamp"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("05/20/2020 08:00:00")] + public global::System.DateTime TargetTime { + get { + return ((global::System.DateTime)(this["TargetTime"])); + } + set { + this["TargetTime"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.DateTime StartTimestamp { + get { + return ((global::System.DateTime)(this["StartTimestamp"])); + } + set { + this["StartTimestamp"] = value; + } + } + } +} diff --git a/WorkTimeHero/Properties/Settings.settings b/WorkTimeHero/Properties/Settings.settings @@ -1,12 +1,15 @@ -<?xml version='1.0' encoding='utf-8'?> -<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="WorkTimeHero.Properties" GeneratedClassName="Settings"> - <Profiles /> - <Settings> - <Setting Name="StartTimePreamp" Type="System.Decimal" Scope="User"> - <Value Profile="(Default)">-10</Value> - </Setting> - <Setting Name="TargetTime" Type="System.DateTime" Scope="User"> - <Value Profile="(Default)">01/01/2016 08:00:00</Value> - </Setting> - </Settings> +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="WorkTimeHero.Properties" GeneratedClassName="Settings"> + <Profiles /> + <Settings> + <Setting Name="StartTimePreamp" Type="System.Decimal" Scope="User"> + <Value Profile="(Default)">-10</Value> + </Setting> + <Setting Name="TargetTime" Type="System.DateTime" Scope="User"> + <Value Profile="(Default)">05/20/2020 08:00:00</Value> + </Setting> + <Setting Name="StartTimestamp" Type="System.DateTime" Scope="User"> + <Value Profile="(Default)" /> + </Setting> + </Settings> </SettingsFile> \ No newline at end of file diff --git a/WorkTimeHero/Settings.cs b/WorkTimeHero/Settings.cs @@ -0,0 +1,28 @@ +namespace WorkTimeHero.Properties { + + + // This class allows you to handle specific events on the settings class: + // The SettingChanging event is raised before a setting's value is changed. + // The PropertyChanged event is raised after a setting's value is changed. + // The SettingsLoaded event is raised after the setting values are loaded. + // The SettingsSaving event is raised before the setting values are saved. + internal sealed partial class Settings { + + public Settings() { + // // To add event handlers for saving and changing settings, uncomment the lines below: + // + // this.SettingChanging += this.SettingChangingEventHandler; + // + // this.SettingsSaving += this.SettingsSavingEventHandler; + // + } + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + // Add code to handle the SettingChangingEvent event here. + } + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + // Add code to handle the SettingsSaving event here. + } + } +} diff --git a/WorkTimeHero/WorkTimeHero.csproj b/WorkTimeHero/WorkTimeHero.csproj @@ -65,6 +65,7 @@ </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Settings.cs" /> <Compile Include="WorkTimeCalculator.cs" /> <EmbeddedResource Include="MainForm.resx"> <DependentUpon>MainForm.cs</DependentUpon>