public OptionsModel LoadOptions() { OptionsModel optionsModel = new OptionsModel(); if (File.Exists(OPTIONS_OUTSIDE_FILENAME)) { using (StreamReader file = new StreamReader(OPTIONS_OUTSIDE_FILENAME)) { string line; while ((line = file.ReadLine()) != null) { line = line.Trim(); if (line.Length == 0) { continue; } var split = splitOptionLine(line); if (split == null) { throw new IOException("Can't split string: " + line); } switch (split[0]) { case OPTION_ADAPTER: optionsModel.Adapter = split[1].Replace("\"", ""); break; case OPTION_FONTSIZE: optionsModel.ChatFontSizeType = Int32.Parse(split[1]); break; case OPTION_COLOR: optionsModel.Color = Int32.Parse(split[1]); break; case OPTION_FULLSCREEN: optionsModel.FullScreen = split[1].Equals("true", StringComparison.InvariantCultureIgnoreCase); break; case OPTION_RESOLUTIONX: optionsModel.ResolutionX = Int32.Parse(split[1]); break; case OPTION_RESOLUTIONY: optionsModel.ResolutionY = Int32.Parse(split[1]); break; // No strict parsing /*default: * throw new IOException("Unknown option: " + line);*/ } } } } if (File.Exists(OPTIONS_NEW_FILENAME)) { using (StreamReader file = new StreamReader(OPTIONS_NEW_FILENAME)) { string line = file.ReadLine(); if (line != null) { line = line.Trim(); optionsModel.JapLocale = line.Equals(OPTION_LOCALE_JAP, StringComparison.InvariantCultureIgnoreCase); } } } if (File.Exists(OPTIONS_UPDATER_FILENAME)) { using (StreamReader file = new StreamReader(OPTIONS_UPDATER_FILENAME)) { string line; while ((line = file.ReadLine()) != null) { line = line.Trim(); if (line.Length == 0) { continue; } // TODO: handle categories if needed if (line.StartsWith("[")) { continue; } var split = splitUpdaterOptionLine(line); if (split == null) { throw new IOException("Can't split string: " + line); } switch (split[0]) { case OPTION_BASE_URL1: optionsModel.baseUrl1 = split[1]; break; case OPTION_INFORMATION: optionsModel.information = split[1]; break; case OPTION_DISABLE_BLACKLISTS: optionsModel.disableBlacklists = split[1].Equals("true", StringComparison.InvariantCultureIgnoreCase); break; } } } } return(optionsModel); }
private void UpdateFullscreen(OptionsModel model) { cmbWindowMode.Items.Add("Windowed"); cmbWindowMode.Items.Add("Fullscreen"); cmbWindowMode.SelectedIndex = model.FullScreen ? 1 : 0; }