Skip to content

Commit 4b58487

Browse files
committed
Only use settings if they look valid
Top/Left values of 0 probably means uninitialized. We would rather the first run cause the window to pop up in the center of the existing VS window with an appropriate default width and height.
1 parent 66497dd commit 4b58487

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

ListFiles.xaml.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,24 +288,27 @@ private void LoadWindowSettings()
288288
{
289289
try
290290
{
291-
var bottomBound = System.Windows.Forms.Screen.AllScreens.Max(s => s.Bounds.Bottom);
292-
var rightBound = System.Windows.Forms.Screen.AllScreens.Max(s => s.Bounds.Right);
293-
294-
// only apply left setting if it is visible on current screen(s)
295-
if (Properties.Settings.Default.Left < rightBound)
291+
if (Properties.Settings.Default.Left > 0 && Properties.Settings.Default.Top > 0)
296292
{
297-
this.Left = Properties.Settings.Default.Left;
298-
}
293+
var bottomBound = System.Windows.Forms.Screen.AllScreens.Max(s => s.Bounds.Bottom);
294+
var rightBound = System.Windows.Forms.Screen.AllScreens.Max(s => s.Bounds.Right);
299295

300-
// only apply top setting if it is visible on current screen(s)
301-
if (Properties.Settings.Default.Top < bottomBound)
302-
{
303-
this.Top = Properties.Settings.Default.Top;
304-
}
296+
// only apply left setting if it is visible on current screen(s)
297+
if (Properties.Settings.Default.Left < rightBound)
298+
{
299+
this.Left = Properties.Settings.Default.Left;
300+
}
305301

306-
this.Width = Properties.Settings.Default.Width;
307-
this.Height = Properties.Settings.Default.Height;
308-
this.WindowState = (WindowState)Properties.Settings.Default.WindowState;
302+
// only apply top setting if it is visible on current screen(s)
303+
if (Properties.Settings.Default.Top < bottomBound)
304+
{
305+
this.Top = Properties.Settings.Default.Top;
306+
}
307+
308+
this.Width = Properties.Settings.Default.Width;
309+
this.Height = Properties.Settings.Default.Height;
310+
this.WindowState = (WindowState)Properties.Settings.Default.WindowState;
311+
}
309312
}
310313
catch (System.Exception)
311314
{

0 commit comments

Comments
 (0)