Example #1
0
 public CWebGsmConfigForm()
 {
     InitializeComponent();
     Init();
     FormHelper.InitUserModeEvent(this);
 }
Example #2
0
        public CProtocolConfigForm(bool bIsInChannelType = true)
        {
            InitializeComponent();
            m_bIsInChannelType = bIsInChannelType;
            this.txt_ChannelProtocolName.Enabled  = false;
            this.txt_ChannelProtocolName.ReadOnly = true;
            this.txt_DataProtocolName.ReadOnly    = true;
            this.txt_DataProtocolName.Enabled     = false;
            m_openFileDialog.Filter           = "库文件(*.dll)|*.dll|所有文件(*.*)|*.*";
            m_openFileDialog.RestoreDirectory = true;
            if (m_bIsInChannelType)
            {
                m_openFileDialog.Title      = "选择通讯方式";
                this.lbl_ClassNames.Visible = false;
                this.lbl_Interfaces.Visible = false;
                this.cmb_ClassNames.Visible = false;
                this.cmb_Interfaces.Visible = false;

                this.txt_ChannelClassName.Visible = false;
                this.lbl_ChannelClassName.Visible = false;
                this.lbl_ToolTip1.Visible         = false;
                this.Text = "通讯方式配置";
            }
            else
            {
                m_openFileDialog.Title      = "选择数据协议";
                this.lbl_ClassNames.Visible = false;
                this.lbl_Interfaces.Visible = false;
                this.cmb_ClassNames.Visible = false;
                this.cmb_Interfaces.Visible = false;


                this.lbl_ToolTip2.Visible  = false;
                this.lbl_DataFlash.Visible = false;
                this.lbl_DataUDisk.Visible = false;
                this.lbl_DataUp.Visible    = false;
                this.lbl_DataDown.Visible  = false;

                this.txt_DataUDisk.Visible = false;
                this.txt_DataUp.Visible    = false;
                this.txt_DataFlash.Visible = false;
                this.txt_DataDown.Visible  = false;

                this.Text = "数据协议配置";
            }

            //m_openFileDialog.InitialDirectory = @"E:\陈乐宁相关\水文监测\HelloWorld.1228\MDITest\bin\Debug";

            m_mapChannelInfo    = new Dictionary <string, XmlDllInfo>();
            m_mapClassInterface = new Dictionary <string, string>();

            panel4DataAdd.Visible    = false;
            panel4ChannelAdd.Visible = false;

            this.cmb_ChannelInterfaceNames.Items.Add(GetInterfaceNameWithoutNamespace(CS_DEFINE.I_CHANNEL_GSM));
            this.cmb_ChannelInterfaceNames.Items.Add(GetInterfaceNameWithoutNamespace(CS_DEFINE.I_CHANNEL_GPRS));
            this.cmb_ChannelInterfaceNames.Items.Add(GetInterfaceNameWithoutNamespace(CS_DEFINE.I_CHANNEL_HDGPRS));
            this.cmb_ChannelInterfaceNames.Items.Add(GetInterfaceNameWithoutNamespace(CS_DEFINE.I_CHANNEL_BEIDOU_NORMAL));
            this.cmb_ChannelInterfaceNames.Items.Add(GetInterfaceNameWithoutNamespace(CS_DEFINE.I_CHANNEL_BEIDOU_500));
            this.cmb_ChannelInterfaceNames.Items.Add(GetInterfaceNameWithoutNamespace(CS_DEFINE.I_CHANNEL_CABLE));

            this.cmb_ChannelInterfaceNames.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cmb_ChannelInterfaceNames.SelectedIndex = 0;
            m_iPreProtocolSelectedIndex = -1;

            LoadData();

            FormHelper.InitUserModeEvent(this);
        }
        // 初始化自定义界面
        private void InitUI()
        {
            // 初始化测站
            // 初始化查询信息类型
            this.SuspendLayout();
            cmbQueryInfo.Items.AddRange(new string[] { CS_CMB_Rain, CS_CMB_Water, CS_CMB_Voltage });

            cmb_RainShape.Items.AddRange(new string[] { CS_CMB_RainShape_Periodrain, CS_CMB_RainShape_Differencerain, CS_CMB_ViewStyle_Dayrain });

            cmb_TimeSelect.Items.AddRange(new string[] { CS_CMB_TimeData, CS_CMB_AllData });
            // 设置日期
            this.dtpTimeStart.Format  = DateTimePickerFormat.Custom;
            this.dptTimeEnd.Format    = DateTimePickerFormat.Custom;
            dtpTimeStart.CustomFormat = "yyyy-MM-dd HH:mm:ss";
            dptTimeEnd.CustomFormat   = "yyyy-MM-dd HH:mm:ss";

            TimeSpan span = new TimeSpan(1, 0, 0, 0);
            DateTime now  = DateTime.Now;

            dptTimeEnd.Value   = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0);
            dtpTimeStart.Value = dptTimeEnd.Value.Subtract(span);// 减少一天


            //
            // cmbStation
            //
            this.panelLeft.Controls.Remove(this.cmbStation);
            // this.cmbStation = new CStationComboBox();
            this.cmbStation = new CStationComboBox_1();
            this.cmbStation.FormattingEnabled = true;
            this.cmbStation.Location          = new System.Drawing.Point(80, 96);
            this.cmbStation.Name     = "cmbStation";
            this.cmbStation.Size     = new System.Drawing.Size(117, 20);
            this.cmbStation.TabIndex = 1;
            this.panelLeft.Controls.Add(this.cmbStation);


            #region 表

            // 初始化雨量查询数据表
            m_dgvRain = new CDataGridViewRain();
            m_dgvRain.AllowUserToAddRows  = false;
            m_dgvRain.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
            //m_dgvRain.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            //m_dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
            m_dgvRain.Dock     = DockStyle.Fill;
            m_dgvRain.AutoSize = true;
            //m_dataGridView.ReadOnly = true; //只读
            m_dgvRain.AllowUserToResizeRows = false;
            m_dgvRain.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            m_dgvRain.RowHeadersWidth     = 50;
            m_dgvRain.ColumnHeadersHeight = 25;
            m_dgvRain.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
            //m_dgvRain.Dock = DockStyle.Fill;

            // 初始化水量查询数据表
            m_dgvWater = new CDataGridViewWater();
            m_dgvWater.AllowUserToAddRows  = false;
            m_dgvWater.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
            //m_dgvRain.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            //m_dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
            m_dgvWater.Dock     = DockStyle.Fill;
            m_dgvWater.AutoSize = true;
            //m_dataGridView.ReadOnly = true; //只读
            m_dgvWater.AllowUserToResizeRows = false;
            m_dgvWater.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            m_dgvWater.RowHeadersWidth     = 50;
            m_dgvWater.ColumnHeadersHeight = 25;
            m_dgvWater.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);

            // 初始化电压查询数据表
            m_dgvVoltage = new CDataGridViewVoltage();
            m_dgvVoltage.AllowUserToAddRows  = false;
            m_dgvVoltage.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
            //m_dgvVoltage.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            //m_dgvVoltage.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
            m_dgvVoltage.Dock   = DockStyle.Fill;
            m_dgvWater.AutoSize = true;
            //m_dgvVoltage.ReadOnly = true; //只读
            m_dgvVoltage.AllowUserToResizeRows = false;
            m_dgvVoltage.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            m_dgvVoltage.RowHeadersWidth     = 50;
            m_dgvVoltage.ColumnHeadersHeight = 25;
            m_dgvVoltage.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);

            m_dgvSoilData = new CDataGridViewSoilData();
            m_dgvSoilData.AllowUserToAddRows  = false;
            m_dgvSoilData.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.None;
            //m_dgvVoltage.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            //m_dgvVoltage.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
            m_dgvSoilData.Dock     = DockStyle.Fill;
            m_dgvSoilData.AutoSize = true;
            //m_dgvVoltage.ReadOnly = true; //只读
            m_dgvSoilData.AllowUserToResizeRows = false;
            m_dgvSoilData.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            m_dgvSoilData.RowHeadersWidth     = 50;
            m_dgvSoilData.ColumnHeadersHeight = 25;
            m_dgvSoilData.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);

            tLayoutRight.SuspendLayout();
            tLayoutRight.Controls.Add(m_dgvRain, 0, 0);
            tLayoutRight.Controls.Add(m_dgvWater, 0, 0);
            tLayoutRight.Controls.Add(m_dgvVoltage, 0, 0);
            tLayoutRight.Controls.Add(m_dgvSoilData, 0, 0);
            tLayoutRight.ResumeLayout(false);

            #endregion 表

            #region 图
            m_panelChart      = new Panel();
            m_panelChart.Dock = DockStyle.Bottom;
            m_chartRain       = new CChartRain();
            m_chartRain.Dock  = DockStyle.Fill;

            m_chartVoltage      = new CChartVoltage();
            m_chartVoltage.Dock = DockStyle.Fill;

            m_chartWaterFlow      = new CChartWaterStage();
            m_chartWaterFlow.Dock = DockStyle.Fill;

            m_charSoilData      = new CChartSoilData();
            m_charSoilData.Dock = DockStyle.Fill;

            m_panelChart.Controls.Add(m_chartRain);
            m_panelChart.Controls.Add(m_chartVoltage);
            m_panelChart.Controls.Add(m_chartWaterFlow);
            m_panelChart.Controls.Add(m_charSoilData);

            panelRight.Controls.Add(m_panelChart);

            m_chartVoltage.Visible   = false;
            m_chartWaterFlow.Visible = false;
            m_charSoilData.Visible   = false;

            m_panelChart.Height = panelRight.Height / 2;

            #endregion 图

            // 绑定消息
            m_dgvRain.PageNumberChanged += new EventHandler <CEventSingleArgs <int> >(this.EHPageNumberChanged);
            m_dgvRain.DataReady         += new EventHandler <CEventDBUIDataReadyArgs>(this.EHTableDataReady);

            m_dgvWater.PageNumberChanged += new EventHandler <CEventSingleArgs <int> >(this.EHPageNumberChanged);
            m_dgvWater.DataReady         += new EventHandler <CEventDBUIDataReadyArgs>(this.EHTableDataReady);

            m_dgvVoltage.PageNumberChanged += new EventHandler <CEventSingleArgs <int> >(this.EHPageNumberChanged);
            m_dgvVoltage.DataReady         += new EventHandler <CEventDBUIDataReadyArgs>(this.EHTableDataReady);

            m_dgvSoilData.PageNumberChanged += new EventHandler <CEventSingleArgs <int> >(this.EHPageNumberChanged);
            m_dgvSoilData.DataReady         += new EventHandler <CEventDBUIDataReadyArgs>(this.EHTableDataReady);

            // 初始化视图样式列表框
            cmb_ViewStyle.Items.Add(CS_CMB_ViewStyle_All);
            cmb_ViewStyle.Items.Add(CS_CMB_ViewStyle_Chart);
            cmb_ViewStyle.Items.Add(CS_CMB_ViewStyle_Table);

            cmb_ViewStyle.SelectedIndex = 0;

            // 初始化焦点切换
            FormHelper.InitControlFocusLoop(this);

            this.ResumeLayout(false);

            cmbQueryInfo.SelectedIndex   = 0;
            cmb_RainShape.SelectedIndex  = 0;
            cmb_TimeSelect.SelectedIndex = 0;

            this.cmb_SubCenter.SelectedIndexChanged += new EventHandler(EHSubCenterChanged);
        }