Example #1
0
        void SaveConfig()
        {
            Dirt5Config save = new Dirt5Config();

            save.selectedVehicle = (string)vehicleSelector.SelectedItem;

            string output = JsonConvert.SerializeObject(save, Formatting.Indented);

            File.WriteAllText(saveFilename, output);
        }
Example #2
0
        void LoadConfig()
        {
            string[] vehicles = System.IO.File.ReadAllLines("Dirt5\\Dirt5Vehicles.txt");

            vehicleSelector.Items.AddRange(vehicles);


            if (File.Exists(saveFilename))
            {
                string text = File.ReadAllText(saveFilename);

                Dirt5Config config = JsonConvert.DeserializeObject <Dirt5Config>(text);

                for (int i = 0; i < vehicles.Length; ++i)
                {
                    if (vehicles[i] == config.selectedVehicle)
                    {
                        vehicleSelector.SelectedIndex = i;
                        break;
                    }
                }
            }
        }