Revise window auto-centering, add maximize persistence
This commit is contained in:
parent
cb130c318d
commit
e356d99df6
3 changed files with 17 additions and 12 deletions
|
|
@ -300,7 +300,7 @@ namespace MatterHackers.MatterControl
|
|||
UiThread.RunOnIdle(CheckOnPrinter);
|
||||
|
||||
string desktopPosition = ApplicationSettings.Instance.get(ApplicationSettingsKey.DesktopPosition);
|
||||
if (desktopPosition != null && desktopPosition != "")
|
||||
if (!string.IsNullOrEmpty(desktopPosition))
|
||||
{
|
||||
string[] sizes = desktopPosition.Split(',');
|
||||
|
||||
|
|
@ -310,6 +310,12 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
DesktopPosition = new Point2D(xpos, ypos);
|
||||
}
|
||||
else
|
||||
{
|
||||
DesktopPosition = new Point2D(-1, -1);
|
||||
}
|
||||
|
||||
this.Maximized = ApplicationSettings.Instance.get(ApplicationSettingsKey.MainWindowMaximized) == "true";
|
||||
}
|
||||
|
||||
public void TakePhoto(string imageFileName)
|
||||
|
|
@ -436,6 +442,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
// try and open our window matching the last size that we had for it.
|
||||
string[] sizes = windowSize.Split(',');
|
||||
|
||||
width = Math.Max(int.Parse(sizes[0]), (int)minSize.x + 1);
|
||||
height = Math.Max(int.Parse(sizes[1]), (int)minSize.y + 1);
|
||||
}
|
||||
|
|
@ -471,14 +478,6 @@ namespace MatterHackers.MatterControl
|
|||
using (new PerformanceTimer("Startup", "Total"))
|
||||
{
|
||||
instance = new MatterControlApplication(width, height);
|
||||
|
||||
if (instance.DesktopPosition == new Point2D())
|
||||
{
|
||||
Point2D desktopSize = OsInformation.DesktopSize;
|
||||
|
||||
// Now try and center the window. If this is saved it will got overridden
|
||||
instance.DesktopPosition = new Point2D((desktopSize.x - instance.Width) / 2, (desktopSize.y - instance.Height) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
|
@ -599,8 +598,13 @@ namespace MatterHackers.MatterControl
|
|||
public override void OnClosing(out bool CancelClose)
|
||||
{
|
||||
// save the last size of the window so we can restore it next time.
|
||||
ApplicationSettings.Instance.set(ApplicationSettingsKey.WindowSize, string.Format("{0},{1}", Width, Height));
|
||||
ApplicationSettings.Instance.set(ApplicationSettingsKey.DesktopPosition, string.Format("{0},{1}", DesktopPosition.x, DesktopPosition.y));
|
||||
ApplicationSettings.Instance.set(ApplicationSettingsKey.MainWindowMaximized, this.Maximized.ToString().ToLower());
|
||||
|
||||
if (!this.Maximized)
|
||||
{
|
||||
ApplicationSettings.Instance.set(ApplicationSettingsKey.WindowSize, string.Format("{0},{1}", Width, Height));
|
||||
ApplicationSettings.Instance.set(ApplicationSettingsKey.DesktopPosition, string.Format("{0},{1}", DesktopPosition.x, DesktopPosition.y));
|
||||
}
|
||||
|
||||
//Save a snapshot of the prints in queue
|
||||
QueueData.Instance.SaveDefaultQueue();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace MatterHackers.MatterControl
|
|||
public const string HideGCodeWarning = nameof(HideGCodeWarning);
|
||||
public const string DesktopPosition = nameof(DesktopPosition);
|
||||
public const string WindowSize = nameof(WindowSize);
|
||||
public const string MainWindowMaximized = nameof(MainWindowMaximized);
|
||||
}
|
||||
|
||||
public class ApplicationSettings
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 87b30048af006ae4c3028d790594daac31cb9c6e
|
||||
Subproject commit 69f57cb2dc4aec2bf7ec51d75a1cb5633fe2a49f
|
||||
Loading…
Add table
Add a link
Reference in a new issue