// logic for OK_button click, method verifies if bounds are selected. If not, none are printed. // error checking in case upper is entered without lower and vice versa is included private void OK_Click(object sender, EventArgs e) { if (this.UpperBound_txt.Text != "" && this.LowerBound_txt.Text != "") { MainKeyboard a = (MainKeyboard)help1.getOpenForm(this, "MainKeyboard"); a.setUp(this.UpperBound_txt.Text); // mutator method found in MainKeyboard class a.setLow(this.LowerBound_txt.Text); // mutator method found in MainKeyboard class this.Dispose(); } else if (this.UpperBound_txt.Text != "" && this.LowerBound_txt.Text == "") { var result = MessageBox.Show("Please Enter a Lower Bound", "Bounds Error", MessageBoxButtons.OK); } else if (this.UpperBound_txt.Text == "" && this.LowerBound_txt.Text != "") { var result = MessageBox.Show("Please Enter an Upper Bound", "Bounds Error", MessageBoxButtons.OK); } else { this.Dispose(); } }
// this method was created so that test classes could have access to an "Open" mainKeyboard object public void setTempForm() { foreach (Form tempMainKeyBoard in Application.OpenForms) { if (tempMainKeyBoard.Name == "MainKeyboard") { tempForm = (MainKeyboard)tempMainKeyBoard; } } }
public void openFormForTest() // used for testing purposes { tempForm = new MainKeyboard(); tempForm.Show(); this.Show(); }