private void okBtn_Click(object sender, EventArgs e) { if (0 == this.PortName.Length) { MessageBox.Show( this, "A port name must be entered.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } try { PortManager.AddPrintJackPort(this.PortName); } catch (PortAlreadyExistsException) { MessageBox.Show( this, "A port with this name already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } this.DialogResult = DialogResult.OK; this.Close(); }