private void ButtonInputGraph_Click(object sender, EventArgs e) { buttonSubmit.Enabled = true; int taskIndex = -1; for (int i = 0; i < taskControls.Count; i++) { if (taskControls[i].GetButtonInputGraph().Equals(sender as Button)) { taskIndex = i; } } // Case of proceeding to EditAdjacencyMatrix if ((sender as Button).Text == "Adjacency Matrix") { formEditAdjacencyMatrix = new FormEditAdjacencyMatrix(accountMenu.accountID, accountMenu.username, accountMenu.labelAccountName.Text, accountMenu.accountType) { Text = "Task " + (taskIndex + 1).ToString() }; if (taskControls[taskIndex].GetInputMatrix() != null) { for (int col = 1; col <= taskControls[taskIndex].GetInputMatrix().GetSize(); col++) { for (int row = 0; row < taskControls[taskIndex].GetInputMatrix().GetSize(); row++) { if (taskControls[taskIndex].GetInputMatrix().ContainsEdge(col - 1, row)) { formEditAdjacencyMatrix.dataGridViewAdjacencyMatrix[col, row].Value = taskControls[taskIndex].GetInputMatrix().GetEdge(col - 1, row); } } } } formEditAdjacencyMatrix.labelInstructions.Text += "\nIf you want to go back to look at the graph of the question, you can save and close this and come back later. Your working progress will be saved."; formEditAdjacencyMatrix.buttonSubmit.Text = "Save"; formEditAdjacencyMatrix.buttonSubmit.Click += new System.EventHandler(this.GraphEditingForms_buttonSubmit_Click); formEditAdjacencyMatrix.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.GraphEditingForms_FormClosed); formEditAdjacencyMatrix.Show(); this.Enabled = false; this.Hide(); } // Case of proceeding to EditAdjacencyList else if ((sender as Button).Text == "Adjacency List") { formEditAdjacencyList = new FormEditAdjacencyList(accountMenu.accountID, accountMenu.username, accountMenu.labelAccountName.Text, accountMenu.accountType) { Text = "Task " + (taskIndex + 1).ToString() }; if (taskControls[taskIndex].GetInputMatrix() != null) { for (int vStart = 0; vStart < taskControls[taskIndex].GetInputMatrix().GetSize(); vStart++) { for (int vFinish = 0; vFinish < taskControls[taskIndex].GetInputMatrix().GetSize(); vFinish++) { if (taskControls[taskIndex].GetInputMatrix().ContainsEdge(vStart, vFinish)) { if (formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value == null) { formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value = Convert.ToChar('A' + vFinish).ToString() + "," + taskControls[taskIndex].GetInputMatrix().GetEdge(vStart, vFinish); } else { formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value = formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value.ToString() + "," + Convert.ToChar('A' + vFinish).ToString() + "," + taskControls[taskIndex].GetInputMatrix().GetEdge(vStart, vFinish); } } } } } formEditAdjacencyList.labelInstructions.Text += "\nIf you want to go back to look at the graph of the question, you can save and close this and come back later. Your working progress will be saved."; formEditAdjacencyList.buttonSubmit.Text = "Save"; formEditAdjacencyList.buttonSubmit.Click += new System.EventHandler(this.GraphEditingForms_buttonSubmit_Click); formEditAdjacencyList.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.GraphEditingForms_FormClosed); formEditAdjacencyList.Show(); this.Enabled = false; this.Hide(); } // Case of proceeding to SketchBoard else // if ((sender as Button).Text == "Sketch Board") { formSketchBoard = new FormSketchBoard(accountMenu.accountID, accountMenu.username, accountMenu.labelAccountName.Text, accountMenu.accountType) { Text = "Task " + (taskIndex + 1).ToString() }; formSketchBoard.buttonViewTask.Visible = true; formSketchBoard.buttonViewTask.Click += new System.EventHandler(this.FormSketchBoard_ButtonViewTask_Click); formSketchBoard.buttonSubmit.Click += new System.EventHandler(this.GraphEditingForms_buttonSubmit_Click); formSketchBoard.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormSketchBoard_FormClosed_CloseFormViewTask); formSketchBoard.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.GraphEditingForms_FormClosed); formSketchBoard.Show(); this.Enabled = false; this.Hide(); } }
private void ButtonShowAnswer_Click(object sender, EventArgs e) { int taskIndex = -1; for (int i = 0; i < taskControls.Count; i++) { if (taskControls[i].GetButtonShowAnswer().Equals(sender as Button)) { taskIndex = i; } } // Show/hide numeric answer if (taskControls[taskIndex].GetTextBoxInputAnswer().Visible) { if ((sender as Button).Text == "Answer") { taskControls[taskIndex].GetLabelAnswer().Visible = true; (sender as Button).Text = "Hide"; } else // if (buttonShowAnswer.Text == "Answer") { taskControls[taskIndex].GetLabelAnswer().Visible = false; (sender as Button).Text = "Answer"; } } // Show/hide graphical answer else { // Adjacency matrix representation if (taskControls[taskIndex].GetButtonInputGraph().Text == "Adjacency Matrix") { formEditAdjacencyMatrix = new FormEditAdjacencyMatrix(accountMenu.accountID, accountMenu.username, accountMenu.labelAccountName.Text, accountMenu.accountType) { Text = "Task " + (taskIndex + 1).ToString() }; for (int col = 1; col <= taskControls[taskIndex].GetAnswerMatrix().GetSize(); col++) { for (int row = 0; row < taskControls[taskIndex].GetAnswerMatrix().GetSize(); row++) { if (taskControls[taskIndex].GetAnswerMatrix().ContainsEdge(col - 1, row)) { formEditAdjacencyMatrix.dataGridViewAdjacencyMatrix[col, row].Value = taskControls[taskIndex].GetAnswerMatrix().GetEdge(col - 1, row); } } } formEditAdjacencyMatrix.labelInstructions.Text = "This is the answer adjacecy matrix.\n" + "Close this window to return to the question."; formEditAdjacencyMatrix.dataGridViewAdjacencyMatrix.ReadOnly = true; formEditAdjacencyMatrix.buttonSubmit.Enabled = false; formEditAdjacencyMatrix.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.GraphicAnswerForms_FormClosed); formEditAdjacencyMatrix.Show(); this.Enabled = false; this.Hide(); } // Adjacency list representation else if (taskControls[taskIndex].GetButtonInputGraph().Text == "Adjacency List") { formEditAdjacencyList = new FormEditAdjacencyList(accountMenu.accountID, accountMenu.username, accountMenu.labelAccountName.Text, accountMenu.accountType) { Text = "Task " + (taskIndex + 1).ToString() }; for (int vStart = 0; vStart < taskControls[taskIndex].GetAnswerMatrix().GetSize(); vStart++) { for (int vFinish = 0; vFinish < taskControls[taskIndex].GetAnswerMatrix().GetSize(); vFinish++) { if (taskControls[taskIndex].GetAnswerMatrix().ContainsEdge(vStart, vFinish)) { if (formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value == null) { formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value = Convert.ToChar('A' + vFinish).ToString() + "," + taskControls[taskIndex].GetAnswerMatrix().GetEdge(vStart, vFinish); } else { formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value = formEditAdjacencyList.dataGridViewAdjacencyList[1, vStart].Value.ToString() + "," + Convert.ToChar('A' + vFinish).ToString() + "," + taskControls[taskIndex].GetAnswerMatrix().GetEdge(vStart, vFinish); } } } } formEditAdjacencyList.labelInstructions.Text = "This is the answer adjacency list.\n" + "Close this window to return to the question."; formEditAdjacencyList.dataGridViewAdjacencyList.ReadOnly = true; formEditAdjacencyList.buttonSubmit.Enabled = false; formEditAdjacencyList.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.GraphicAnswerForms_FormClosed); formEditAdjacencyList.Show(); this.Enabled = false; this.Hide(); } } }