Skip to content

Commit

Permalink
fixed a bug where settings were not saved
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Aagren committed May 25, 2020
1 parent ce87c9f commit a646208
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 20 deletions.
43 changes: 28 additions & 15 deletions SteamAccountSwitcher2/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private void askUserForSteamLocation()
}
else
{
Properties.Settings.Default.steamInstallDir = installDir;
SasManager.InitiateInstanceWithDir(installDir);
}
}
Expand All @@ -111,27 +112,39 @@ private void settingsButton_Click(object sender, RoutedEventArgs e)

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
SasManager.Instance.SaveAccounts();
try
{
SasManager.Instance.SaveAccounts();

if (WindowState == WindowState.Maximized)
if (this.WindowState == WindowState.Maximized)
{
// Use the RestoreBounds as the current values will be 0, 0 and the size of the screen
Properties.Settings.Default.Top = RestoreBounds.Top;
Properties.Settings.Default.Left = RestoreBounds.Left;
Properties.Settings.Default.Height = RestoreBounds.Height;
Properties.Settings.Default.Width = RestoreBounds.Width;
Properties.Settings.Default.Maximized = true;
}
else
{
Properties.Settings.Default.Top = this.Top;
Properties.Settings.Default.Left = this.Left;
Properties.Settings.Default.Height = this.Height;
Properties.Settings.Default.Width = this.Width;
Properties.Settings.Default.Maximized = false;
}

}
catch (Exception ex)
{
// Use the RestoreBounds as the current values will be 0, 0 and the size of the screen
Properties.Settings.Default.Top = RestoreBounds.Top;
Properties.Settings.Default.Left = RestoreBounds.Left;
Properties.Settings.Default.Height = RestoreBounds.Height;
Properties.Settings.Default.Width = RestoreBounds.Width;
Properties.Settings.Default.Maximized = true;
Log.Logger.Error(ex, "Error while saving accounts");
}
else
finally
{
Properties.Settings.Default.Top = this.Top;
Properties.Settings.Default.Left = this.Left;
Properties.Settings.Default.Height = this.Height;
Properties.Settings.Default.Width = this.Width;
Properties.Settings.Default.Maximized = false;
Properties.Settings.Default.Save();
}

Properties.Settings.Default.Save();

}

private void buttonAdd_Click(object sender, RoutedEventArgs e)
Expand Down
8 changes: 4 additions & 4 deletions SteamAccountSwitcher2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SteamAccountSwitcher2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("Steam Account Switcher 2")]
[assembly: AssemblyDescription("Modified by Ogglord")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SteamAccountSwitcher2")]
[assembly: AssemblyProduct("Steam Account Switcher 2")]
[assembly: AssemblyCopyright("Copyright © 2016 Christoph Wedenig")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand Down Expand Up @@ -50,7 +50,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("")]

2 changes: 1 addition & 1 deletion SteamAccountSwitcher2/SasManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public UserSettings GlobalSettings

public void SetSteamInstallDir(string pathToSteamExe)
{
if (string.IsNullOrEmpty(pathToSteamExe) || !pathToSteamExe.EndsWith("steam.exe"))
if (string.IsNullOrEmpty(pathToSteamExe) || !pathToSteamExe.ToLower().EndsWith("steam.exe"))
throw new ArgumentException("Invalid Steam Path: " + pathToSteamExe);

if (pathToSteamExe != null)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit a646208

Please sign in to comment.