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(); } }
// 初始化自定义控件 private void InitCustomerControls() { this.SuspendLayout(); //m_dataGridLatestData = new CDataGridTabPage() { Title = "实时数据", BTabRectClosable = false }; //m_dataGridLatestData.DataGrid = new CDataGridViewRTD(); m_formRTD = new CRTDForm() { Title = "实时水情数据", BTabRectClosable = false, MdiParent = this }; m_formRTD.Dock = DockStyle.Fill; //m_formSoilRTD = new CRTDSoilForm() { Title = "实时墒情数据", BTabRectClosable = false, MdiParent = this }; //m_formSoilRTD.Dock = DockStyle.Fill; m_listFormSystemInfo = new CListFormTabPage() { Title = "运行日志", BTabRectClosable = false, BCloseButton = false, MdiParent = this, Text = "实时信息" }; m_listFormSystemInfo.Dock = DockStyle.Fill; m_listFormSystemInfo.ListView.AutoUpdateLists = true; m_listFormComState = new CListFormTabPage() { Title = "串口状态", BTabRectClosable = false, MdiParent = this, Text = "通讯口状态" }; m_listFormComState.Dock = DockStyle.Fill; m_listFormComState.ListView = new CListViewSerialPortState(); m_listFormComState.ListView.AutoUpdateLists = true; //m_listFormComState.SetMsgViewMode(true); m_listFormWarningInfo = new CListFormTabPage() { Title = "告警信息", BTabRectClosable = false, MdiParent = this, Text = "告警信息2" }; m_listFormWarningInfo.Dock = DockStyle.Fill; m_listFormWarningInfo.ListView.AutoUpdateLists = true; m_formStationState = new CStationStateForm() { Title = "站点状态", BTabRectClosable = true, MdiParent = this }; m_formStationState.Dock = DockStyle.Fill; m_formRTD.MouseEnter += MainForm_MouseEnter; //m_formSoilRTD.MouseEnter += MainForm_MouseEnter; m_listFormSystemInfo.MouseEnter += MainForm_MouseEnter; m_listFormComState.MouseEnter += MainForm_MouseEnter; m_listFormWarningInfo.MouseEnter += MainForm_MouseEnter; m_formStationState.MouseEnter += MainForm_MouseEnter; #region TABCONTROL m_tabControlUp = new CExTabControl(); m_tabControlUp.SuspendLayout(); m_tabControlUp.AddPage(m_formRTD); //m_tabControlUp.AddPage(m_formSoilRTD); //m_tabControlUp.AddPage(m_formStationState); //m_tabControlUp.AddPage(m_formSoilRTD); splitContainer2.Panel1.Controls.Add(m_tabControlUp); m_tabControlUp.ResumeLayout(false); //this.m_tabControlUp.MouseDown += (s, e) => { this.m_timer.Stop(); this.m_timer.Start(); MessageBox.Show("up enter"); }; m_tabControlBottom = new CExTabControl(); m_tabControlBottom.SuspendLayout(); m_tabControlBottom.Alignment = TabAlignment.Bottom; //选项卡位于底部 m_tabControlBottom.AddPage(m_listFormSystemInfo); //m_tabControlBottom.AddPage(m_listFormComState); //m_tabControlBottom.AddPage(m_listFormWarningInfo); //告警信息 splitContainer2.Panel2.Controls.Add(m_tabControlBottom); m_tabControlBottom.ResumeLayout(false); //m_tabControlBottom.MouseDown += (s, e) => { this.m_timer.Stop(); this.m_timer.Start(); MessageBox.Show("bottom enter"); }; #endregion m_tabControl // 初始化表头 //m_dataGridLatestData.DataGrid.Header = new string[] { "站名", "站点编号", "站点类型", "采集时间", "延迟", "水量", "雨量", "电压", "端口", "报文类型" }; //m_dataGridView2.Header = new string[] { "站名", "站点编号", "站点类型", "采集时间", "延迟", "水量", "雨量", "电压", "端口", "报文类型" }; m_listFormSystemInfo.Show(); m_listFormComState.Show(); m_formRTD.Show(); m_formStationState.Show(); //if (IsLoadSoilRTD()) //{ // this.MI_Soil.Enabled = false; // this.MI_Soil.Checked = true; // this.MI_Soil.Enabled = true; //m_formSoilRTD.Show(); //} m_listFormWarningInfo.Show(); // 加载 CTreeView CMainFormAndCTreeViewBridage.LoadTreeView(this, this.m_tabControlUp); this.ResumeLayout(false); }