/*public static double[] percMaxTabu_T = { 0.1, 0.5, 1, 5, 10 }; * public static int[] cadenceMod_T = { 1, 10, 25, 50, 100 }; * public static int[] aspirationPlus_T = { 10, 50, 100, 500, 2000 }; * public static int[] aspirationPlusPlus_T = { 3, 5, 10, 15, 25 };*/ public MainWindow() { InitializeComponent(); windowInited = true; DrawX.SendData(mainGrid, clientsCount); DrawX.DrawMainStation(main_station); string exePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); try { new StreamReader(System.IO.Path.Combine(exePath, "plik1.txt")); } catch (FileNotFoundException e) { load_Button.IsEnabled = false; } }
private void Load_Button2_Click(object sender, RoutedEventArgs e) { start_Button.IsEnabled = true; save_Button.IsEnabled = true; OpenFileDialog okienko = new OpenFileDialog(); okienko.ShowDialog(); okienko.Filter = "|*.txt"; string bufor = okienko.FileName; if (!bufor.Equals("")) { using (StreamReader inputFile = new StreamReader(@bufor)) // capacity->(linia_i=4,druga liczba), main baza - linia 9. koordynaty - druga i trzecia liczba { int i = 0; clientsCount = 0; List <Point> clientsBuf = new List <Point>(); List <int> clientsOrdersBuf = new List <int>(); while (!inputFile.EndOfStream) { var lineA = inputFile.ReadLine(); var liniaTab = lineA.Split(' '); if (i == 4) { int ii = 0; for (int j = 0; j < liniaTab.Length; j++) { if (Int32.TryParse(liniaTab[j], out capacity)) { ii++; if (ii == 2) { cap_textBox.Dispatcher.Invoke(() => { cap_textBox.Text = capacity.ToString(); }); break; } } } } else if (i == 9) { int ii = 0, xbuf = -1, ybuf = -1; for (int j = 0; j < liniaTab.Length; j++) { if (Int32.TryParse(liniaTab[j], out ybuf)) { ii++; if (ii == 2) { xbuf = ybuf; } else if (ii == 3) { main_station = new Point(10 * xbuf, 10 * ybuf); DrawX.DrawMainStation(main_station); break; } } } } else if (i > 9) { int ii = 0, xbuf = -1, ybuf = -1; for (int j = 0; j < liniaTab.Length; j++) { if (Int32.TryParse(liniaTab[j], out ybuf)) { ii++; if (ii == 2) { xbuf = ybuf; } else if (ii == 3) { clientsBuf.Add(new Point(10 * xbuf, 10 * ybuf, i - 10)); } else if (ii == 4) { clientsOrdersBuf.Add(ybuf); break; } } } } i++; } if (debug) { Console.WriteLine(capacity + ", " + main_station.x + ", " + main_station.y); } if (debug) { Console.WriteLine(i); } clientsCount = clientsBuf.Count; DrawX.SendData(mainGrid, clientsCount); clients = new Point[clientsCount]; clientsOrders = new int[clientsCount]; for (int j = 0; j < clientsCount; j++) { if (debug) { Console.WriteLine(clientsBuf[j].x + ", " + clientsBuf[j].y + ", " + clientsOrdersBuf[j]); } clients[j] = clientsBuf[j]; clientsOrders[j] = clientsOrdersBuf[j]; } clientCount_textBox.Dispatcher.Invoke(() => { clientCount_textBox.Text = clientsCount.ToString(); }); DrawX.RemoveClients(); DrawX.DrawClients(clients); start_Button.IsEnabled = true; } } }