private void btnAddField_Click(object sender, EventArgs e) { bool checkNullTextBoxes = string.IsNullOrWhiteSpace(txtTopLeftX.Text) || string.IsNullOrWhiteSpace(txtTopLeftY.Text) || string.IsNullOrWhiteSpace(txtSizeX.Text) || string.IsNullOrWhiteSpace(txtSizeY.Text) || string.IsNullOrWhiteSpace(txtNumOfRows.Text) || string.IsNullOrWhiteSpace(txtNumOfCols.Text) || string.IsNullOrWhiteSpace(txtIdent.Text); if (checkNullTextBoxes) { MessageBox.Show("Please fill in all textboxes. All fields are mandatory.", "Add field", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (detectionTemplate.Fields.FindIndex(x => x.Ident == txtIdent.Text) == -1) { DetectionField df = new DetectionField(); df.TopLeft = new Point(int.Parse(txtTopLeftX.Text), int.Parse(txtTopLeftY.Text)); df.Size = new Size(int.Parse(txtSizeX.Text), int.Parse(txtSizeY.Text)); df.NumOfRows = int.Parse(txtNumOfRows.Text); df.NumOfCols = int.Parse(txtNumOfCols.Text); df.FieldType = cbxFieldType.SelectedItem.ToString(); df.ResultType = cbxResponseType.SelectedItem.ToString(); df.Ident = txtIdent.Text; detectionTemplate.addField(df); // Refocus on the first textbox to enter the second field txtTopLeftX.Clear(); txtTopLeftY.Clear(); txtSizeX.Clear(); txtSizeY.Clear(); txtNumOfRows.Clear(); txtNumOfCols.Clear(); txtIdent.Clear(); txtTopLeftX.Focus(); templateBinding.ResetBindings(false); } else { MessageBox.Show("The indentification has already existed in the template. Please choose a different identification.", "Duplicate field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public void RemoveFromList(DetectionField firstDifferences, DetectionField secondDifferences) { Differences.Remove(firstDifferences); Differences.Remove(secondDifferences); }