void SaveConfig() { WreckfestConfig save = new WreckfestConfig(); save.selectedVehicle = (string)vehicleSelector.SelectedItem; string output = JsonConvert.SerializeObject(save, Formatting.Indented); File.WriteAllText(saveFilename, output); }
void LoadConfig() { if (File.Exists(saveFilename)) { string text = File.ReadAllText(saveFilename); WreckfestConfig config = JsonConvert.DeserializeObject <WreckfestConfig>(text); for (int i = 0; i < vehicleSelector.Items.Count; ++i) { if (((string)vehicleSelector.Items[i]).CompareTo(config.selectedVehicle) == 0) { vehicleSelector.SelectedIndex = i; break; } } } }