diff --git a/OnTopReplica/MainForm.cs b/OnTopReplica/MainForm.cs index 477cd49..811abdb 100644 --- a/OnTopReplica/MainForm.cs +++ b/OnTopReplica/MainForm.cs @@ -83,18 +83,6 @@ namespace OnTopReplica { } protected override void OnClosing(CancelEventArgs e) { - //Store last thumbnail, if any - if (_thumbnailPanel.IsShowingThumbnail && CurrentThumbnailWindowHandle != null) { - Settings.Default.RestoreLastWindowTitle = CurrentThumbnailWindowHandle.Title; - Settings.Default.RestoreLastWindowHwnd = CurrentThumbnailWindowHandle.Handle.ToInt64(); - Settings.Default.RestoreLastWindowClass = CurrentThumbnailWindowHandle.Class; - } - else { - Settings.Default.RestoreLastWindowTitle = string.Empty; - Settings.Default.RestoreLastWindowHwnd = 0; - Settings.Default.RestoreLastWindowClass = string.Empty; - } - _msgPumpManager.Dispose(); Program.Platform.CloseForm(this); diff --git a/OnTopReplica/Program.cs b/OnTopReplica/Program.cs index b03599a..ad90306 100644 --- a/OnTopReplica/Program.cs +++ b/OnTopReplica/Program.cs @@ -71,7 +71,8 @@ namespace OnTopReplica { //Enter GUI loop Application.Run(_mainForm); - //HACK: re-enable chrome to fix position persistence (ideally, chrome status should be stored and restored - but this is not always possible) + //Re-enable chrome to store correct position (position is stored always WITH chrome: when restoring fails, the position stays ok) + Settings.Default.RestoreLastShowChrome = _mainForm.IsChromeVisible; if (!_mainForm.IsChromeVisible) _mainForm.IsChromeVisible = true; @@ -80,6 +81,18 @@ namespace OnTopReplica { Settings.Default.RestoreLastPosition = _mainForm.Location; Settings.Default.RestoreLastSize = _mainForm.ClientSize; Settings.Default.Save(); + + //Store last thumbnail, if any + if (_mainForm.ThumbnailPanel.IsShowingThumbnail && _mainForm.CurrentThumbnailWindowHandle != null) { + Settings.Default.RestoreLastWindowTitle = _mainForm.CurrentThumbnailWindowHandle.Title; + Settings.Default.RestoreLastWindowHwnd = _mainForm.CurrentThumbnailWindowHandle.Handle.ToInt64(); + Settings.Default.RestoreLastWindowClass = _mainForm.CurrentThumbnailWindowHandle.Class; + } + else { + Settings.Default.RestoreLastWindowTitle = string.Empty; + Settings.Default.RestoreLastWindowHwnd = 0; + Settings.Default.RestoreLastWindowClass = string.Empty; + } } } diff --git a/OnTopReplica/Properties/Settings.Designer.cs b/OnTopReplica/Properties/Settings.Designer.cs index b5038b9..2f2bedd 100644 --- a/OnTopReplica/Properties/Settings.Designer.cs +++ b/OnTopReplica/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18051 +// Runtime Version:4.0.30319.34003 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -237,5 +237,17 @@ namespace OnTopReplica.Properties { this["FullscreenMode"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool RestoreLastShowChrome { + get { + return ((bool)(this["RestoreLastShowChrome"])); + } + set { + this["RestoreLastShowChrome"] = value; + } + } } } diff --git a/OnTopReplica/Properties/Settings.settings b/OnTopReplica/Properties/Settings.settings index 5535ca5..70d1706 100644 --- a/OnTopReplica/Properties/Settings.settings +++ b/OnTopReplica/Properties/Settings.settings @@ -56,5 +56,8 @@ Standard + + True + \ No newline at end of file diff --git a/OnTopReplica/StartupOptions/Factory.cs b/OnTopReplica/StartupOptions/Factory.cs index 4647546..2016035 100644 --- a/OnTopReplica/StartupOptions/Factory.cs +++ b/OnTopReplica/StartupOptions/Factory.cs @@ -33,8 +33,10 @@ namespace OnTopReplica.StartupOptions { if (Settings.Default.RestoreSizeAndPosition) { options.StartLocation = Settings.Default.RestoreLastPosition; options.StartSize = Settings.Default.RestoreLastSize; + options.DisableChrome = !Settings.Default.RestoreLastShowChrome; - Log.Write("Restoring window at {0} size {1}", Settings.Default.RestoreLastPosition, Settings.Default.RestoreLastSize); + Log.Write("Restoring window at {0} size {1} {2}", Settings.Default.RestoreLastPosition, Settings.Default.RestoreLastSize, + (Settings.Default.RestoreLastShowChrome) ? "with chrome" : "without chrome"); } if (Settings.Default.RestoreLastWindow) { diff --git a/OnTopReplica/app.config b/OnTopReplica/app.config index 06326b9..9494b26 100644 --- a/OnTopReplica/app.config +++ b/OnTopReplica/app.config @@ -58,6 +58,9 @@ Standard + + True +