public FormMain() { InitializeComponent(); SimParameters param = new SimParameters(); param.LoadSavedParams(); for (int i = 0; i < param.paramWeightCurve.Count(); ++i) { this.fuelWeightCurve.Rows.Add(param.paramWeightCurve[i], param.paramWeightLaptime[i]); } for (int i = 0; i < param.paramTireWearCurve.Count(); ++i) { this.TireWearCurve.Rows.Add(param.paramTireWearCurve[i], param.paramTireLapFactor[i]); } for (int i = 0; i < param.pitStrategy1.Count(); ++i) { this.strategy1.Rows.Add(param.pitStrategy1[i]); } for (int i = 0; i < param.pitStrategy2.Count(); ++i) { this.strategy2.Rows.Add(param.pitStrategy2[i]); } for (int i = 0; i < param.pitStrategy3.Count(); ++i) { this.strategy3.Rows.Add(param.pitStrategy3[i]); } }
public void LoadSavedParams() { System.Xml.Serialization.XmlSerializer deserializer = new System.Xml.Serialization.XmlSerializer(typeof(SimParameters)); System.IO.StreamReader lecteur = new System.IO.StreamReader("Params.xml"); if (lecteur == null) { return; } SimParameters p = (SimParameters)deserializer.Deserialize(lecteur); lecteur.Close(); this.totalRaceLaps = p.totalRaceLaps; this.trackLenght_m = p.trackLenght_m; this.paramWeightCurve = p.paramWeightCurve; this.paramWeightLaptime = p.paramWeightLaptime; this.paramTireWearCurve = p.paramTireWearCurve; this.paramTireLapFactor = p.paramTireLapFactor; this.fuelCons = p.fuelCons; this.pitStrategy1 = p.pitStrategy1; this.pitStrategy2 = p.pitStrategy2; this.pitStrategy3 = p.pitStrategy3; }