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 static void AddUserTab()
        {
            if (m_UserTabPage != null)
            {
                m_UserTabPage.DataGrid.MouseDoubleClick -= new MouseEventHandler(UserTabPage_DataGrid_MouseDoubleClick);
                m_tabControlUp.RemovePage(m_UserTabPage);
                m_UserTabPage = null;
            }
            m_UserTabPage = new CDataGridTabPage()
            {
                Title            = "登录用户",
                BTabRectClosable = true,
                DataGrid         = new CExDataGridView()
                {
                    Header = new string[] { "用户名", "口令", "权限" }
                }
            };
            m_UserTabPage.DataGrid.MouseDoubleClick += new MouseEventHandler(UserTabPage_DataGrid_MouseDoubleClick);
            m_UserTabPage.DisabledLeftLabel();
            m_UserTabPage.TabClosed += (s, e) =>
            {
                m_UserTabPage = null;
            };
            m_tabControlUp.AddPage(m_UserTabPage);
            m_tabControlUp.SelectedIndex = m_tabControlUp.TabPages.Count - 1;
            bool islogin = CCurrentLoginUser.Instance.IsLogin;

            if (islogin)
            {
                string name  = CCurrentLoginUser.Instance.Name;
                string admin = CCurrentLoginUser.Instance.IsAdmin ? "管理员" : "普通用户";
                m_UserTabPage.DataGrid.AddRow(new string[]
                {
                    name,
                    "******",
                    admin
                }, CExDataGridView.EDataState.ENormal);
            }
            //  更新UI
            m_UserTabPage.DataGrid.UpdateDataToUI();
        }
        private static void AddProtocolTab()
        {
            if (m_ProtocolTabPage != null)
            {
                m_ProtocolTabPage.DataGrid.CellDoubleClick -= new DataGridViewCellEventHandler(ProtocolTabPage_DataGrid_CellDoubleClick);
                m_tabControlUp.RemovePage(m_ProtocolTabPage);
                m_ProtocolTabPage = null;
            }
            m_ProtocolTabPage = new CDataGridTabPage()
            {
                Title            = "数据协议",
                BTabRectClosable = true,
                DataGrid         = new CExDataGridView()
                {
                    Header = new string[] { "数据协议" }
                }
            };
            m_ProtocolTabPage.DataGrid.CellDoubleClick += new DataGridViewCellEventHandler(ProtocolTabPage_DataGrid_CellDoubleClick);
            m_ProtocolTabPage.DisabledLeftLabel();
            var m_dllCollections = Protocol.Manager.XmlDocManager.Deserialize();

            m_ProtocolTabPage.TabClosed += (s, e) =>
            {
                m_ProtocolTabPage = null;
            };
            m_tabControlUp.AddPage(m_ProtocolTabPage);
            m_tabControlUp.SelectedIndex = m_tabControlUp.TabPages.Count - 1;
            foreach (var item in m_dllCollections.Infos)
            {
                if (item.Type == "data" && item.Enabled)
                {
                    m_ProtocolTabPage.DataGrid.AddRow(new string[] { item.Name }, CExDataGridView.EDataState.ENormal);
                }
            }

            //  更新UI
            m_ProtocolTabPage.DataGrid.UpdateDataToUI();
        }