Skip to content

Commit

Permalink
On master: Preserve main window size and position; Closes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Jan 22, 2021
1 parent 90d402a commit fd73d63
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
39 changes: 39 additions & 0 deletions src/KKManager.Core/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/KKManager.Core/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@
<Setting Name="Language" Provider="PortableSettingsProvider.PortableSettingsProvider" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="WindowSize" Provider="PortableSettingsProvider.PortableSettingsProvider" Type="System.Drawing.Size" Scope="User">
<Value Profile="(Default)">0, 0</Value>
</Setting>
<Setting Name="WindowLocation" Provider="PortableSettingsProvider.PortableSettingsProvider" Type="System.Drawing.Point" Scope="User">
<Value Profile="(Default)">-1, -1</Value>
</Setting>
<Setting Name="WindowMaximized" Provider="PortableSettingsProvider.PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
30 changes: 30 additions & 0 deletions src/KKManager.Core/app.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="KKManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
Expand Down Expand Up @@ -40,4 +45,29 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<KKManager.Properties.Settings>
<setting name="GamePath" serializeAs="String">
<value />
</setting>
<setting name="DockState" serializeAs="String">
<value />
</setting>
<setting name="AutoUpdateSearch" serializeAs="String">
<value>False</value>
</setting>
<setting name="Language" serializeAs="String">
<value />
</setting>
<setting name="WindowSize" serializeAs="String">
<value>0, 0</value>
</setting>
<setting name="WindowLocation" serializeAs="String">
<value>-1, -1</value>
</setting>
<setting name="WindowMaximized" serializeAs="String">
<value>False</value>
</setting>
</KKManager.Properties.Settings>
</userSettings>
</configuration>
15 changes: 14 additions & 1 deletion src/KKManager/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public MainWindow()

Settings.Default.Binder.BindControl(checkForUpdatesOnStartupToolStripMenuItem, settings => settings.AutoUpdateSearch, this);
Settings.Default.Binder.SendUpdates(this);

if (Settings.Default.WindowLocation != new Point(-1, -1))
{
StartPosition = FormStartPosition.Manual;
Location = Settings.Default.WindowLocation;
}
if (!Settings.Default.WindowSize.IsEmpty) Size = Settings.Default.WindowSize;
if (Settings.Default.WindowMaximized) WindowState = FormWindowState.Maximized;
}

private static DirectoryInfo GetGameDirectory()
Expand Down Expand Up @@ -145,7 +153,7 @@ private static string ShowInstallDirectoryDialog(string currentPath)
Title = "Select the install directory of your game"
})
{
retryFolderSelect:
retryFolderSelect:
if (fb.ShowDialog() == CommonFileDialogResult.Ok)
{
var path = fb.FileName;
Expand Down Expand Up @@ -329,6 +337,11 @@ private void MainWindow_FormClosed(object sender, FormClosedEventArgs e)
dockPanel.SaveAsXml(s, Encoding.Unicode);
Settings.Default.DockState = Encoding.Unicode.GetString(s.ToArray());
}

Settings.Default.WindowLocation = Location;
var maximized = WindowState == FormWindowState.Maximized;
Settings.Default.WindowMaximized = maximized;
if (!maximized) Settings.Default.WindowSize = Size;
}

private void openFemaleCardFolderToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down

0 comments on commit fd73d63

Please sign in to comment.