mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(GUI): settings upgrade moved to ApplicationStartup handler.
This commit is contained in:
parent
95e7aa7614
commit
7920af7fe9
@ -48,6 +48,8 @@ namespace GARbro.GUI
|
||||
|
||||
void ApplicationStartup (object sender, StartupEventArgs e)
|
||||
{
|
||||
UpgradeSettings();
|
||||
|
||||
string exe_dir = Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
#if DEBUG
|
||||
Trace.Listeners.Add (new TextWriterTraceListener (Path.Combine (exe_dir, "trace.log")));
|
||||
@ -86,7 +88,7 @@ namespace GARbro.GUI
|
||||
}
|
||||
catch (Exception X)
|
||||
{
|
||||
Trace.WriteLine (X.Message, "scheme deserialization failed");
|
||||
Trace.WriteLine (string.Format ("Scheme deserialization failed: {0}", X.Message), "[GARbro.GUI.App]");
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,6 +97,27 @@ namespace GARbro.GUI
|
||||
Settings.Default.Save();
|
||||
}
|
||||
|
||||
void UpgradeSettings ()
|
||||
{
|
||||
if (Settings.Default.UpgradeRequired)
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.Default.Upgrade();
|
||||
Settings.Default.UpgradeRequired = false;
|
||||
Settings.Default.Save();
|
||||
}
|
||||
catch (System.Exception X)
|
||||
{
|
||||
Trace.WriteLine (string.Format ("Settings upgrade failed: {0}", X.Message), "[GARbro.GUI.App]");
|
||||
}
|
||||
}
|
||||
|
||||
// do not restore in minimized state
|
||||
if (Settings.Default.winState == System.Windows.WindowState.Minimized)
|
||||
Settings.Default.winState = System.Windows.WindowState.Normal;
|
||||
}
|
||||
|
||||
void DeserializeScheme (Stream file)
|
||||
{
|
||||
using (var reader = new BinaryReader (file))
|
||||
|
@ -15,21 +15,7 @@
|
||||
//
|
||||
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||
//
|
||||
this.SettingsLoaded += OnSettingsLoadedHandler;
|
||||
}
|
||||
|
||||
void OnSettingsLoadedHandler (object sender, System.Configuration.SettingsLoadedEventArgs e)
|
||||
{
|
||||
if (Settings.Default.UpgradeRequired)
|
||||
{
|
||||
Settings.Default.Upgrade();
|
||||
Settings.Default.UpgradeRequired = false;
|
||||
Settings.Default.Save();
|
||||
}
|
||||
|
||||
// do not restore in minimized state
|
||||
if (Settings.Default.winState == System.Windows.WindowState.Minimized)
|
||||
Settings.Default.winState = System.Windows.WindowState.Normal;
|
||||
// this.SettingsLoaded += OnSettingsLoadedHandler;
|
||||
}
|
||||
|
||||
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user