private void laserOpenCloseSpbtn_Click(object sender, EventArgs e) { if (laserOpenCloseSpbtn.Text == "Open") { if (serialPortCom != null && !serialPortCom.SerialPort.IsOpen) { serialPortCom.SerialPortOpen(laserComListCbx.Text, laserBaudRateCbx.Text, laserDataBitsCbx.Text, laserStopBitsCbx.Text, laserParityCbx.Text, laserHandshakingcbx.Text); } } else { if (serialPortCom != null && serialPortCom.SerialPort.IsOpen) { serialPortCom.Close(); } } }