private void btnHotOpenDevice_Click(object sender, EventArgs e) { string port = this.txtHotPort.Text.Trim(); if (port.StartsWith("lpt")) { if (helper.Open(this.txtHotPort.Text.Trim())) { this.btnHotOpenDevice.Enabled = false; this.btnHotCloseDevice.Enabled = true; this.btnHotGetState.Enabled = true; this.btnBeginPrint.Enabled = true; this.btnEndPrint.Enabled = false; this.btnPrintCommandOnce.Enabled = true; this.lbOperationHint.Text = "打开并口成功!"; helper.Read(new HandleReturnStringDelegate(SetReadHint)); } else { this.lbOperationHint.Text = "打开并口失败!"; } } else { try { if (helper2.Open(port, Convert.ToInt32(this.txtBaudRate.Text.Trim()), (System.IO.Ports.Parity)Convert.ToInt32(this.txtParity.Text.Trim()) , Convert.ToInt32(this.txtDataBits.Text.Trim()), (System.IO.Ports.StopBits)Convert.ToInt32(this.txtStopBit.Text.Trim()) )) { this.btnHotOpenDevice.Enabled = false; this.btnHotCloseDevice.Enabled = true; this.btnHotGetState.Enabled = true; this.btnBeginPrint.Enabled = true; this.btnEndPrint.Enabled = false; this.btnPrintCommandOnce.Enabled = true; this.lbOperationHint.Text = "打开串口成功!"; helper2.Read(new HandleReturnStringDelegate(SetReadHint)); } else { this.lbOperationHint.Text = "打开串口失败!"; } } catch (Exception ex) { MessageBoxHelper.Show(ex.ToString()); } } }