/// <summary> /// A method that reads the cities from the current file /// </summary> private void ReadFile() { CitySeries.Points.Clear(); Cities.Clear(); // Makes sure the file is valid if (CurrentFile != null && !CurrentFile.Exists) { MessageBox.Show("There is no valid file selected", "No Valid File", MessageBoxButton.OK, MessageBoxImage.Error); return; } StreamReader reader = new StreamReader(CurrentFile.FullName); // Skip the first four lines for (int x = 0; x < 4; x++) { reader.ReadLine(); } // Get the number of destinations var temp = reader.ReadLine().Split(' '); int cityCount = int.Parse(temp[1]); // Skip two more lines for (int y = 0; y < 2; y++) { reader.ReadLine(); } // Read the data for each city for (int z = 0; z < cityCount; z++) { temp = reader.ReadLine().Split(' '); var city = new City(int.Parse(temp[0]), double.Parse(temp[1]), double.Parse(temp[2])); // Add the city to the list Cities.Add(city); // Add the city to the graph CitySeries.Points.Add(new ScatterPoint(city.XPosition, city.YPosition)); } CESolver.OrderData(Cities); }
/// <summary> /// A method called by the UI to add a the closest city to an edge /// </summary> public void AddCity() { CESolver.AddClosestCity(); }