Only save window size if not maximized or minimized, and save and restore window maximized state

This should help with the tiny window in issue #5
Branch_2.1.x
Nathan Crawford 2016-01-11 19:50:02 -05:00
rodzic cb65256d5b
commit b1d1fd0c89
2 zmienionych plików z 40 dodań i 5 usunięć

Wyświetl plik

@ -50,7 +50,8 @@ namespace embroideryReader
private const String SETTING_LAST_OPEN_FILE_FOLDER = "last open file folder";
private const String SETTING_LAST_SAVE_IMAGE_LOCATION = "last save image location";
private const String SETTING_WINDOW_MAXIMIZED = "window maximized";
private const String SETTING_WINDOW_WIDTH = "window width";
private const String SETTING_WINDOW_HEIGHT = "window height";
private const String SETTING_AUTOSCALE_DESIGN = "auto scale design";
@ -283,6 +284,18 @@ namespace embroideryReader
}
}
public bool windowMaximized
{
get
{
return settings.getValue(SETTING_WINDOW_MAXIMIZED, false);
}
set
{
settings.setValue(SETTING_WINDOW_MAXIMIZED, value);
}
}
public int windowWidth
{
get

Wyświetl plik

@ -71,8 +71,17 @@ namespace embroideryReader
{
panel2.BackColor = Color.FromKnownColor(KnownColor.Control);
}
this.Width = settings.windowWidth;
this.Height = settings.windowHeight;
if (settings.windowMaximized)
{
// Check maximized first
this.WindowState = FormWindowState.Maximized;
}
else
{
// Not maximized, restore last saved window size
this.Width = settings.windowWidth;
this.Height = settings.windowHeight;
}
setDesignScaleSetting(1.0f, settings.AutoScaleDesign, false);
}
@ -407,8 +416,21 @@ namespace embroideryReader
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
settings.windowWidth = this.Width;
settings.windowHeight = this.Height;
if (this.WindowState == FormWindowState.Maximized)
{
settings.windowMaximized = true;
}
else
{
settings.windowMaximized = false;
if (this.WindowState == FormWindowState.Normal)
{
// If window is not minimized or maximized, save current size
settings.windowWidth = this.Width;
settings.windowHeight = this.Height;
}
}
settings.save();
}