public void SaveMap(string path, Dictionary <string, object[]> saveMap) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, false)) { file.WriteLine("[START][MAPGROUP1][MAPGROUP]"); file.WriteLine(String.Format("Map Name:-[{0}]", MapName)); file.WriteLine(String.Format("Map Comments:-[{0}]", MapComments)); file.WriteLine("Fuel Map"); WriteTable(file, TableHelper.GetTable("MapFuel", saveMap), "0"); file.WriteLine(); file.WriteLine("Timing Map"); WriteTable(file, TableHelper.GetTable("MapTiming", saveMap), "-100"); file.WriteLine(); file.WriteLine("Boost Map"); WriteTable(file, TableHelper.GetTable("MapBoost", saveMap), "0"); file.WriteLine(String.Format("[END][MAPGROUP][{0}][EOF]", CalcCheckSum(saveMap))); } }
public Dictionary <string, object[]> LoadMap(String path) { Dictionary <string, object[]> mapTables = new Dictionary <string, object[]>(); foreach (Table table in TableHelper.MapTableNames) { mapTables.Add(table.TableName, new object[] { TableHelper.CreateTable(_rows, _columns), table.TableOperation }); } StreamReader sr; string s; sr = File.OpenText(path); s = sr.ReadLine(); string tableName = string.Empty; Int32 row = 0; while (s != null) { s = sr.ReadLine(); if (!string.IsNullOrEmpty(s)) { switch (s) { case "Fuel Map": tableName = "MapFuel"; TableHelper.ClearTable(TableHelper.GetTable(tableName, mapTables)); row = 1; break; case "Timing Map": tableName = "MapTiming"; TableHelper.ClearTable(TableHelper.GetTable(tableName, mapTables)); row = 1; break; case "Boost Map": tableName = "MapBoost"; TableHelper.ClearTable(TableHelper.GetTable(tableName, mapTables)); row = 1; break; default: if (s != null) { if (s.Substring(0, 10) == "Map Name:-") { MapName = s.Substring(10, s.Length - 10).Trim("[]".ToCharArray()); } else if (s.Substring(0, 14) == "Map Comments:-") { MapComments = s.Substring(14, s.Length - 14).Trim("[]".ToCharArray()); } if (!string.IsNullOrEmpty(tableName)) { if (row >= 3 && row <= 37) { PlotUtecMap(s, row - 3, TableHelper.GetTable(tableName, mapTables)); } row++; } } break; } } } sr.Close(); return(mapTables); }