2018-01-08 20:04:23 +04:00
|
|
|
//! \file ResourceSettings.cs
|
|
|
|
//! \date 2018 Jan 08
|
|
|
|
//! \brief Persistent resource settings implementation.
|
|
|
|
//
|
|
|
|
|
2018-01-11 18:39:43 +04:00
|
|
|
using System.ComponentModel.Composition;
|
2018-02-18 03:55:00 +04:00
|
|
|
using System.Text;
|
2018-01-12 19:56:25 +04:00
|
|
|
using GameRes.Formats.Strings;
|
2018-01-11 18:39:43 +04:00
|
|
|
|
2018-01-08 20:04:23 +04:00
|
|
|
namespace GameRes.Formats
|
|
|
|
{
|
|
|
|
internal class LocalResourceSetting : ResourceSettingBase
|
|
|
|
{
|
|
|
|
public override object Value {
|
|
|
|
get { return Properties.Settings.Default[Name]; }
|
|
|
|
set { Properties.Settings.Default[Name] = value; }
|
|
|
|
}
|
2018-01-12 19:56:25 +04:00
|
|
|
|
|
|
|
public LocalResourceSetting () { }
|
|
|
|
|
|
|
|
public LocalResourceSetting (string name)
|
|
|
|
{
|
|
|
|
Name = name;
|
2018-01-30 09:20:12 +04:00
|
|
|
Text = arcStrings.ResourceManager.GetString (name, arcStrings.Culture) ?? name;
|
2018-01-12 19:56:25 +04:00
|
|
|
}
|
2018-01-08 20:04:23 +04:00
|
|
|
}
|
2018-01-11 18:39:43 +04:00
|
|
|
|
2018-02-18 03:55:00 +04:00
|
|
|
internal class EncodingSetting : LocalResourceSetting
|
|
|
|
{
|
|
|
|
public override object Value {
|
|
|
|
get { return Encoding.GetEncoding ((int)base.Value); }
|
|
|
|
set { base.Value = ((Encoding)value).CodePage; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public EncodingSetting () { }
|
|
|
|
|
|
|
|
public EncodingSetting (string name) : base (name) { }
|
|
|
|
}
|
|
|
|
|
2018-01-11 18:39:43 +04:00
|
|
|
[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();
|
|
|
|
}
|
|
|
|
}
|
2018-01-08 20:04:23 +04:00
|
|
|
}
|