added ISettingsManager implementation.

This commit is contained in:
morkt 2018-01-11 18:39:43 +04:00
parent 21f2529e97
commit d8389d2289
6 changed files with 40 additions and 12 deletions

View File

@ -1008,6 +1008,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Strings\arcStrings.ru-RU.resx" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>perl "$(SolutionDir)inc-revision.pl" "$(ProjectPath)" $(ConfigurationName)

View File

@ -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;
}
}
}
}

View File

@ -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) {

View File

@ -173,5 +173,8 @@
<Setting Name="RCTApplyMask" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="UpgradeRequired" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -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();
}
}
}

View File

@ -175,6 +175,9 @@
<setting name="RCTApplyMask" serializeAs="String">
<value>True</value>
</setting>
<setting name="UpgradeRequired" serializeAs="String">
<value>True</value>
</setting>
</GameRes.Formats.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>