//打开端口按钮 private void Opencom_button_Click(object sender, EventArgs e) { Button btn = (Button)sender; bool a, b; a = CTSerialPort.SetSP(com_list.Text, bode_list.Text, data_box.Text, stop_box.Text); b = CTSerialPort.OpenSP(); if (a && b) { MessageBox.Show("打开成功"); //保存串口参数 controlconfig.AddOrModifyItem("portnum", com_list.Text); controlconfig.AddOrModifyItem("bodenum", bode_list.Text); controlconfig.AddOrModifyItem("datanum", data_box.Text); controlconfig.AddOrModifyItem("stopnum", stop_box.Text); if (btn.FindForm().IsMdiChild) { return; } this.Close(); Form_SP_Test form_sp_test = new Form_SP_Test(); form_sp_test.ShowDialog(); return; } return; }
//测试连接按钮 点击 private void SP_Ttest_Click(object sender, EventArgs e) { if (!IsSignIn()) { return; } Form_SP_Test form_sp_test = new Form_SP_Test(); form_sp_test.ShowDialog(); }
//通信设置按钮 点击 private void ButtonSeriportSet_MyButtonClickEvent(object sender, EventArgs e) { if (!IsSignIn()) { return; } CloseAllMdiForms(); Form_SP_Test fspt = new Form_SP_Test(); fspt.MdiParent = this; fspt.WindowState = FormWindowState.Normal; fspt.Show(); Form_SP_Set fsps = new Form_SP_Set(); fsps.MdiParent = this; fsps.WindowState = FormWindowState.Normal; fsps.Show(); this.LayoutMdi(MdiLayout.TileVertical); }