private static void AddPortSettingsTab() { if (m_SerialPortTabPage != null) { m_SerialPortTabPage.DataGrid.MouseDoubleClick -= new MouseEventHandler(SerialPortTabPage_DataGrid_MouseDoubleClick); m_tabControlUp.RemovePage(m_SerialPortTabPage); m_SerialPortTabPage = null; } m_SerialPortTabPage = new CDataGridTabPage() { Title = "串口配置", BTabRectClosable = true, //DataGrid = new CDataGridViewSerialPort() DataGrid = new CExDataGridView() { Header = new string[] { "串口号", "通讯方式", "数据协议", "波特率", "数据位", "停止位", "校验方式", "当前状态" } } }; //(m_SerialPortTabPage.DataGrid as CDataGridViewSerialPort).InitDataSource(CDBDataMgr.GetInstance().GetSerialPortProxy()); //(m_SerialPortTabPage.DataGrid as CDataGridViewSerialPort).LoadData(); m_SerialPortTabPage.DataGrid.MouseDoubleClick += new MouseEventHandler(SerialPortTabPage_DataGrid_MouseDoubleClick); m_SerialPortTabPage.DisabledLeftLabel(); m_SerialPortTabPage.TabClosed += (s, e) => { m_SerialPortTabPage = null; }; m_tabControlUp.AddPage(m_SerialPortTabPage); m_tabControlUp.SelectedIndex = m_tabControlUp.TabPages.Count - 1; var listPorts = CDBDataMgr.Instance.GetAllSerialPort(); // 添加串口数据到表格中 foreach (var item in listPorts) { int com = item.PortNumber; var channelDll = XmlDocManager.Instance.GetChannelDllByComOrPort(com, true); var dataDll = XmlDocManager.Instance.GetDataDllByComOrPort(com, true); if (channelDll == null || dataDll == null) { continue; } m_SerialPortTabPage.DataGrid.AddRow(new string[] { "COM" + item.PortNumber, channelDll.Name, dataDll.Name, item.Baudrate.ToString(), item.DataBit.ToString(), item.StopBit.ToString(), CEnumHelper.PortParityTypeToUIStr(item.ParityType).ToString(), (item.SwitchSatus.Value?"开启":"关闭"), }, CExDataGridView.EDataState.ENormal); } // 更新UI m_SerialPortTabPage.DataGrid.UpdateDataToUI(); }
private void EHMI_Soil_Click(object sender, EventArgs e) { MI_Soil.Checked = !MI_Soil.Checked; if (MI_Soil.Checked) { // 显示 m_tabControlUp.AddPage(m_formSoilRTD); m_tabControlUp.SelectedIndex = m_tabControlUp.TabCount - 1; m_formStationState.Show(); } else { // 隐藏 m_tabControlUp.RemovePage(m_formSoilRTD); m_formStationState.Hide(); } }
private void EHMI_CommPortState_Click(object sender, EventArgs e) { if (null == m_listFormComState) { return; } MI_ComPortState.Checked = !MI_ComPortState.Checked; if (MI_ComPortState.Checked) { // 显示 m_tabControlBottom.AddPage(m_listFormComState); m_tabControlBottom.SelectedIndex = m_tabControlBottom.TabCount - 1; m_listFormComState.Show(); } else { // 隐藏 m_tabControlBottom.RemovePage(m_listFormComState); m_listFormComState.Hide(); } }