/// <summary> /// Initializes a new instance of the <see cref="AppSettings"/> class. /// </summary> public AppSettings() { _tomlSettings = TomlSettings.Create(cfg => { cfg.ConfigureType <Color>(type => type.WithConversionFor <TomlString>(convert => convert .ToToml(SerializationConversions.ColorToString) .FromToml(tomlString => SerializationConversions.StringToColor(tomlString.Value)))); cfg.ConfigureType <CustomLabel.TextAlignment>(type => type.WithConversionFor <TomlString>(convert => convert .ToToml(SerializationConversions.EnumToString) .FromToml(str => SerializationConversions.StringToEnum <CustomLabel.TextAlignment>(str.Value)))); cfg.ConfigureType <double>(type => type.WithConversionFor <TomlInt>(c => c .FromToml(tml => tml.Value))); }); if (!Directory.Exists(SettingsDirectory)) { Directory.CreateDirectory(SettingsDirectory); } if (!File.Exists(SettingsFilePath)) { CreateDefaultSettingsFile(); } else { LoadSettingsFromPath(SettingsFilePath); } if (_settings.AudioSourceSettings == null) { _settings.AudioSourceSettings = new List <AudioSourceSettings>(); } SelectProfile(_settings.CurrentProfileName); }
/// <summary> /// Initializes a new instance of the <see cref="AppSettings"/> class. /// </summary> public AppSettings() { _tomlSettings = TomlSettings.Create(cfg => { cfg.ConfigureType <Color>(type => type.WithConversionFor <TomlString>(convert => convert .ToToml(ColorTranslator.ToHtml) .FromToml(tomlString => ColorTranslator.FromHtml(tomlString.Value)))); cfg.ConfigureType <CustomLabel.TextAlignment>(type => type.WithConversionFor <TomlString>(convert => convert .ToToml(SerializationConversions.EnumToString) .FromToml(str => SerializationConversions.StringToEnum <CustomLabel.TextAlignment>(str.Value)))); }); if (!Directory.Exists(SettingsDirectory)) { Directory.CreateDirectory(SettingsDirectory); } if (!File.Exists(SettingsFilePath)) { CreateDefault(); Toml.WriteFile(_settings, SettingsFilePath, _tomlSettings); } else { LoadSettings(); } GetModels(); }