private void timeSortRadioButton_CheckedChanged(object sender, EventArgs e) { if (timeSortRadioButton.Checked == true) { FlightList.quickSort(0, FlightList.Count - 1, 2); } loadFlights(FlightList); }
public FlightsForm(FlightList flightList, PassengerList passengerList, Graph graph) { InitializeComponent(); PassengerList = passengerList; FlightList = flightList; FlightsGraph = graph; flightsListView.FullRowSelect = true; flightsListView.MultiSelect = false; FlightList.quickSort(0, FlightList.Count - 1, 3); loadFlights(FlightList); }
static void Main() { FlightList flightList = new FlightList(); PassengerList passengerList = new PassengerList(); Graph graph = new Graph(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string flightsFile = "Flights.data"; string passengersFile = "Passengers.data"; string graphFile = "Graph.data"; if (File.Exists(passengersFile)) { using (Stream stream = File.Open(passengersFile, FileMode.Open)) { var bformater = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); passengerList = (PassengerList)bformater.Deserialize(stream); } } if (File.Exists(flightsFile)) { using (Stream stream = File.Open(flightsFile, FileMode.Open)) { var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); flightList = (FlightList)bformatter.Deserialize(stream); } } else { Flight f1 = new Flight("a", "b", 600, 50); Flight f2 = new Flight("a", "f", 1050, 90); Flight f3 = new Flight("a", "g", 1150, 80); Flight f4 = new Flight("b", "a", 600, 50); Flight f5 = new Flight("b", "c", 750, 40); Flight f6 = new Flight("b", "d", 650, 60); Flight f7 = new Flight("b", "e", 1850, 70); Flight f8 = new Flight("c", "b", 800, 35); Flight f9 = new Flight("c", "e", 850, 50); Flight f10 = new Flight("e", "c", 750, 45); Flight f11 = new Flight("e", "g", 1150, 80); Flight f12 = new Flight("e", "l", 1650, 60); Flight f13 = new Flight("e", "d", 700, 35); Flight f14 = new Flight("d", "e", 900, 45); Flight f15 = new Flight("d", "b", 700, 55); Flight f16 = new Flight("f", "b", 800, 65); Flight f17 = new Flight("f", "l", 2850, 140); Flight f18 = new Flight("g", "a", 1250, 95); Flight f19 = new Flight("g", "e", 1175, 75); Flight f20 = new Flight("g", "l", 2675, 135); Flight f21 = new Flight("g", "u", 1400, 60); Flight f22 = new Flight("g", "h", 450, 25); Flight f23 = new Flight("h", "g", 350, 30); Flight f24 = new Flight("h", "i", 400, 35); Flight f25 = new Flight("i", "h", 400, 35); Flight f26 = new Flight("i", "k", 400, 35); Flight f27 = new Flight("k", "i", 400, 35); Flight f28 = new Flight("k", "j", 300, 25); Flight f29 = new Flight("j", "l", 750, 40); Flight f30 = new Flight("j", "m", 1450, 70); Flight f31 = new Flight("l", "m", 650, 40); Flight f32 = new Flight("l", "k", 700, 70); Flight f33 = new Flight("l", "e", 1550, 60); Flight f34 = new Flight("m", "l", 700, 40); flightList.Add(f1); flightList.Add(f2); flightList.Add(f3); flightList.Add(f4); flightList.Add(f5); flightList.Add(f6); flightList.Add(f7); flightList.Add(f8); flightList.Add(f9); flightList.Add(f10); flightList.Add(f11); flightList.Add(f12); flightList.Add(f13); flightList.Add(f14); flightList.Add(f15); flightList.Add(f16); flightList.Add(f17); flightList.Add(f18); flightList.Add(f19); flightList.Add(f20); flightList.Add(f21); flightList.Add(f22); flightList.Add(f23); flightList.Add(f24); flightList.Add(f25); flightList.Add(f26); flightList.Add(f27); flightList.Add(f28); flightList.Add(f29); flightList.Add(f30); flightList.Add(f31); flightList.Add(f32); flightList.Add(f33); flightList.Add(f34); } if (File.Exists(graphFile)) { using (Stream stream = File.Open(graphFile, FileMode.Open)) { var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); graph = (Graph)bformatter.Deserialize(stream); } } else { graph.createGraph(flightList); } foreach (Node node in graph.NodeList) { bool drawed = true; do { if (node.X == null) { GraphForm graphForm = new GraphForm(node, graph); graphForm.ShowDialog(); drawed = graphForm.Drawed; } } while (!drawed); } flightList.quickSort(0, flightList.Count - 1, 3); passengerList.quickSort(0, passengerList.Count - 1, 1); MainForm mainWindow = new MainForm(flightList, passengerList, graph); mainWindow.ShowDialog(); File.Delete(graphFile); File.Delete(passengersFile); File.Delete(flightsFile); using (Stream graphStream = File.Open(graphFile, FileMode.Create)) { var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); bformatter.Serialize(graphStream, graph); graphStream.Close(); } using (Stream passengerStream = File.Open(passengersFile, FileMode.Create)) { var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); bformatter.Serialize(passengerStream, passengerList); passengerStream.Close(); } using (Stream flightStream = File.Open(flightsFile, FileMode.Create)) { var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); bformatter.Serialize(flightStream, flightList); flightStream.Close(); } }