/// <summary> /// Reads a new setting from a file. /// </summary> /// <param name="filePath">Filepath of the settings file</param> /// <returns></returns> public static Settings Load(string filePath) { var settings = new Settings(); if (File.Exists(filePath)) { var text = File.ReadAllText(filePath); IniData ini = IniData.Deserialize(text); foreach (var section in ini.Content) { var id = section.Key; if (id == General) { if (section.Value.ContainsKey(LanguageKey)) { LanguageManager.Instance.Language = section.Value[LanguageKey]; } if (section.Value.ContainsKey(CloseToTrayKey)) { settings.CloseToTray = section.Value[CloseToTrayKey] == "true"; } if (section.Value.ContainsKey(ShowAllKey)) { settings.ShowAll = section.Value[ShowAllKey] == "true"; } if (section.Value.ContainsKey(HidGuardianEnabledKey)) { settings.HidGuardianEnabled = section.Value[HidGuardianEnabledKey] == "true"; } } else if (id == KeyboardKey) { settings.mappers[id] = KeyboardToXInputMapper.Parse(section.Value); logger.Debug("Mapper loaded for keyboard"); } else { settings.mappers[id] = DirectToXInputMapper.Parse(section.Value); logger.Debug("Mapper loaded for " + id); } } } return(settings); }
private LanguageManager(string filePath) { data = IniData.Deserialize(Properties.Resources.languages).Content; Language = "English"; }