//------------------------ // コンソール操作系 //------------------------ // "セパレート" private void button4_Click(object sender, EventArgs e) { Consolewindow = new ConsoleWindow(2); Consolewindow.Width = 450; Consolewindow.textBox1.Text = this.textBox5.Text; Consolewindow.textBox1.Select(0, 0); Consolewindow.Show(); }
// "隣接行列を表示” private void 隣接行列を表示ToolStripMenuItem_Click(object sender, EventArgs e) { List <int> temp = new List <int>(); ConsoleWindow cw = new ConsoleWindow(1); cw.Text = "AdjacencyMatrix"; cw.Show(); cw.textBox1.AppendText("Now Printing...\r\n"); String buffer = System.String.Empty; Task.Run(() => { // 並列処理させる. // 隣接リストを読み取り,隣接行列へ変換する for (int i = 0; i < maze.AMatrix.GetLength(0); i++) { for (int j = 0; j < 4; j++) { if (maze.AMatrix[i, j] != -1) { temp.Add(maze.AMatrix[i, j]); } } for (int k = 0; k < maze.AMatrix.GetLength(0); k++) { if (temp.Exists(x => x == k)) { buffer += "1"; } else { buffer += "0"; } } buffer += string.Format("\r\n"); temp.Clear(); } cw.textBox1.Text = buffer; }); }
//-------------------------------- // "表示"メニュー //-------------------------------- // "隣接リストを表示” private void ShowMatrixMenu_Click(object sender, EventArgs e) { ConsoleWindow cw = new ConsoleWindow(0); cw.Text = "AdjacencyList"; cw.textBox1.AppendText("Now Printing...\r\n"); cw.Show(); // ウィンドウに隣接リストを表示させる String buffer = System.String.Empty; Task.Run(() => { // 並列処理させる. for (int i = 0; i < maze.AMatrix.GetLength(0); i++) { buffer += string.Format("\r\n{0,5}:\t[", i); for (int j = 0; j < 3; j++) { if (maze.AMatrix[i, j] != -1) { buffer += (string.Format("{0}\t,", maze.AMatrix[i, j])); } else { buffer += (string.Format("{0}\t,", "")); } } if (maze.AMatrix[i, 3] != -1) { buffer += (string.Format("{0}\t", maze.AMatrix[i, 3])); } else { buffer += (string.Format("{0}\t", "")); } buffer += "]"; } cw.textBox1.Text = buffer; }); }