diff --git a/Source/IdleMaster/Properties/Settings.Designer.cs b/Source/IdleMaster/Properties/Settings.Designer.cs index e36dc9ab..842ddeff 100644 --- a/Source/IdleMaster/Properties/Settings.Designer.cs +++ b/Source/IdleMaster/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace IdleMaster.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -228,5 +228,41 @@ public bool OneThenMany { this["OneThenMany"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int mainWindowLeft { + get { + return ((int)(this["mainWindowLeft"])); + } + set { + this["mainWindowLeft"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int mainWindowTop { + get { + return ((int)(this["mainWindowTop"])); + } + set { + this["mainWindowTop"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool useMainWindowPos { + get { + return ((bool)(this["useMainWindowPos"])); + } + set { + this["useMainWindowPos"] = value; + } + } } } diff --git a/Source/IdleMaster/Properties/Settings.settings b/Source/IdleMaster/Properties/Settings.settings index c1c21994..989d00a8 100644 --- a/Source/IdleMaster/Properties/Settings.settings +++ b/Source/IdleMaster/Properties/Settings.settings @@ -56,5 +56,14 @@ True + + 0 + + + 0 + + + False + \ No newline at end of file diff --git a/Source/IdleMaster/app.config b/Source/IdleMaster/app.config index b8ec6744..eba1cae7 100644 --- a/Source/IdleMaster/app.config +++ b/Source/IdleMaster/app.config @@ -63,6 +63,15 @@ True + + 0 + + + 0 + + + False + diff --git a/Source/IdleMaster/frmMain.Designer.cs b/Source/IdleMaster/frmMain.Designer.cs index 94fcba68..b11cca06 100644 --- a/Source/IdleMaster/frmMain.Designer.cs +++ b/Source/IdleMaster/frmMain.Designer.cs @@ -573,6 +573,7 @@ private void InitializeComponent() this.MaximizeBox = false; this.Name = "frmMain"; this.Text = "Idle Master"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmMain_FormClose); this.Load += new System.EventHandler(this.frmMain_Load); this.Resize += new System.EventHandler(this.frmMain_Resize); diff --git a/Source/IdleMaster/frmMain.cs b/Source/IdleMaster/frmMain.cs index f11ab8d5..88eb1f6c 100644 --- a/Source/IdleMaster/frmMain.cs +++ b/Source/IdleMaster/frmMain.cs @@ -712,6 +712,14 @@ private void frmMain_Load(object sender, EventArgs e) var scale = graphics.DpiY * 1.625; Height = Convert.ToInt32(scale); + // Don't use saved position first time so Windows can supply a default position + if (Settings.Default.useMainWindowPos) + { + // Set the form position + Left = Settings.Default.mainWindowLeft; + Top = Settings.Default.mainWindowTop; + } + // Set the location of certain elements so that they scale correctly for different DPI settings var point = new Point(Convert.ToInt32(graphics.DpiX * 1.14), Convert.ToInt32(lblGameName.Location.Y)); lblGameName.Location = point; @@ -770,6 +778,9 @@ private void ResetClientStatus() Settings.Default.steamLogin = string.Empty; Settings.Default.myProfileURL = string.Empty; Settings.Default.steamparental = string.Empty; + Settings.Default.mainWindowLeft = 0; + Settings.Default.mainWindowTop = 0; + Settings.Default.useMainWindowPos = false; Settings.Default.Save(); // Stop the steam-idle process @@ -1050,5 +1061,17 @@ private void tmrStatistics_Tick(object sender, EventArgs e) statistics.increaseMinutesIdled(); statistics.checkCardRemaining((uint)CardsRemaining); } + + private void frmMain_FormClosing(object sender, FormClosingEventArgs e) + { + // Save form position + Settings.Default.mainWindowLeft = Left; + Settings.Default.mainWindowTop = Top; + // Use saved position next launch + Settings.Default.useMainWindowPos = true; + + // Save settings + Settings.Default.Save(); + } } } \ No newline at end of file