public static void AddOrUpdateStation(csvData data, int idx, GameData outputData) { int foundSystem = -1, foundStation = -1; // See if we already have the StarSystem foundSystem = Routines.IndexOfSystem(outputData, data.stations[idx].SystemName); if (foundSystem == -1) { // Not found, add StarSystem. outputData.StarSystems.Add(new StarSystem()); foundSystem = outputData.StarSystems.Count - 1; outputData.StarSystems[foundSystem].Name = data.stations[idx].SystemName; outputData.StarSystems[foundSystem].Stations.Add(new Station(data.stations[idx])); } else { // Found StarSystem, check if we already have the Station foundStation = Routines.IndexOfStation(outputData.StarSystems[foundSystem], data.stations[idx].Name); if (foundStation == -1) { // Not found, add Station outputData.StarSystems[foundSystem].Stations.Add(new Station(data.stations[idx])); foundStation = outputData.StarSystems[foundSystem].Stations.Count - 1; } else { // Found, update Commodities Routines.UpdateCommodities(outputData.StarSystems[foundSystem].Stations[foundStation], data.stations[idx].Commodities); } } }
private void browseCSV_Click(object sender, EventArgs e) { OpenFileDialog fdlg = new OpenFileDialog(); fdlg.Title = "CSV File"; //fdlg.InitialDirectory = @"c:\"; fdlg.Filter = "Comma Seperated Variable (*.csv)|*.csv"; fdlg.FilterIndex = 2; fdlg.RestoreDirectory = true; if (fdlg.ShowDialog() == DialogResult.OK) { csvFilename.Text = fdlg.FileName; data = new csvData(csvFilename.Text); } }
private void csvFilename_TextChanged(object sender, EventArgs e) { data = new csvData(csvFilename.Text); }