From d8389d2289cd4acb033f5e7ce1fc8a38ba2b984c Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 11 Jan 2018 18:39:43 +0400 Subject: [PATCH] added ISettingsManager implementation. --- ArcFormats/ArcFormats.csproj | 1 + ArcFormats/Properties/Settings.Designer.cs | 12 ++++++++++++ ArcFormats/Properties/Settings.cs | 12 ------------ ArcFormats/Properties/Settings.settings | 3 +++ ArcFormats/ResourceSettings.cs | 21 +++++++++++++++++++++ ArcFormats/app.config | 3 +++ 6 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index 6ee91984..5516d519 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -1008,6 +1008,7 @@ + perl "$(SolutionDir)inc-revision.pl" "$(ProjectPath)" $(ConfigurationName) diff --git a/ArcFormats/Properties/Settings.Designer.cs b/ArcFormats/Properties/Settings.Designer.cs index 8360601c..e4aef5bc 100644 --- a/ArcFormats/Properties/Settings.Designer.cs +++ b/ArcFormats/Properties/Settings.Designer.cs @@ -705,5 +705,17 @@ namespace GameRes.Formats.Properties { this["RCTApplyMask"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool UpgradeRequired { + get { + return ((bool)(this["UpgradeRequired"])); + } + set { + this["UpgradeRequired"] = value; + } + } } } diff --git a/ArcFormats/Properties/Settings.cs b/ArcFormats/Properties/Settings.cs index d3dcb774..7b83795c 100644 --- a/ArcFormats/Properties/Settings.cs +++ b/ArcFormats/Properties/Settings.cs @@ -19,18 +19,6 @@ namespace GameRes.Formats.Properties { // // this.SettingsSaving += this.SettingsSavingEventHandler; // - - if (null != Application.Current) - { - Application.Current.Dispatcher.BeginInvoke (DispatcherPriority.Normal, new Action(() => { - Application.Current.Exit += ApplicationExitHandler; - })); - } - } - - void ApplicationExitHandler (object sender, System.Windows.ExitEventArgs args) - { - Default.Save(); } private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { diff --git a/ArcFormats/Properties/Settings.settings b/ArcFormats/Properties/Settings.settings index 7dc1121d..48c76550 100644 --- a/ArcFormats/Properties/Settings.settings +++ b/ArcFormats/Properties/Settings.settings @@ -173,5 +173,8 @@ True + + True + \ No newline at end of file diff --git a/ArcFormats/ResourceSettings.cs b/ArcFormats/ResourceSettings.cs index 856a5e6e..c1652dff 100644 --- a/ArcFormats/ResourceSettings.cs +++ b/ArcFormats/ResourceSettings.cs @@ -3,6 +3,8 @@ //! \brief Persistent resource settings implementation. // +using System.ComponentModel.Composition; + namespace GameRes.Formats { internal class LocalResourceSetting : ResourceSettingBase @@ -12,4 +14,23 @@ namespace GameRes.Formats set { Properties.Settings.Default[Name] = value; } } } + + [Export(typeof(ISettingsManager))] + internal class SettingsManager : ISettingsManager + { + public void UpgradeSettings () + { + if (Properties.Settings.Default.UpgradeRequired) + { + Properties.Settings.Default.Upgrade(); + Properties.Settings.Default.UpgradeRequired = false; + Properties.Settings.Default.Save(); + } + } + + public void SaveSettings () + { + Properties.Settings.Default.Save(); + } + } } diff --git a/ArcFormats/app.config b/ArcFormats/app.config index 95837a08..a39c7467 100644 --- a/ArcFormats/app.config +++ b/ArcFormats/app.config @@ -175,6 +175,9 @@ True + + True +