public MainForm() { InitializeComponent(); dockPanel.ClosingPanel += DockPanel_ClosingPanel; //打开串口 textEdit_串口号.Text = Function_Module.GetConfig("串口号"); SerialPort = new SerialPort_Module(richTextBox1); SerialPortControl(true); _DataModule = new DataModule(); //开始测试模块 ucStartTest2 ucstart = CreateModule("延迟线收发组件_十六通道.Modules.ucStartTest2", _DataModule) as ucStartTest2; }
/// <summary> /// 开关串口视图控制 /// </summary> /// <param name="Open"></param> private void SerialPortControl(bool Open) { try { if (Open) { SerialPort.SerialPort_Set(textEdit_串口号.Text, Convert.ToInt32(Function_Module.GetConfig("波特率"))); SerialPort.SerialPort_Open(); windowsUIButtonPanel1.Buttons.FindFirst(m => m.Properties.Caption == "打开串口(Q)").Properties.Image = global::延迟线收发组件_十六通道.Properties.Resources.squeeze_32x32; windowsUIButtonPanel1.Buttons.FindFirst(m => m.Properties.Caption == "打开串口(Q)").Properties.Caption = "关闭串口(Q)"; } else { SerialPort.SerialPort_Close(); windowsUIButtonPanel1.Buttons.FindFirst(m => m.Properties.Caption == "关闭串口(Q)").Properties.Image = global::延迟线收发组件_十六通道.Properties.Resources.stretch_32x32; windowsUIButtonPanel1.Buttons.FindFirst(m => m.Properties.Caption == "关闭串口(Q)").Properties.Caption = "打开串口(Q)"; } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }