/// <summary>
        /// 修改串口通信设置
        /// </summary>
        public void ModifyModem()
        {
            bool isopen = modem.IsOpen;

            if (isopen)
            {
                modem.Close();
            }
            modem.PortName  = this.comboBoxPortName.Text;
            modem.BaudRate  = (int)this.comboBoxBaudRate.SelectedItem;
            modem.DataBits  = (int)this.comboBoxDataBits.SelectedItem;
            modem.Parity    = (Parity)this.comboBoxParity.SelectedItem;
            modem.StopBits  = (StopBits)this.comboBoxStopBits.SelectedItem;
            modem.Handshake = (Handshake)this.comboBoxHandshake.SelectedItem;
            if (isopen)
            {
                modem.Open();
            }
        }
示例#2
0
 /// <summary>
 /// 关闭按钮单击处理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonClose_Click(object sender, EventArgs e)
 {
     modem.Close();
 }