private void ParamSetForm_Load(object sender, EventArgs e)
 {
     if (!File.Exists(configPath))//创建配置文件夹
     {
         Directory.CreateDirectory(configPath);
     }
     if (!File.Exists(configPath + "configInfo"))//如果没有配置文件,创建一个初始的配置文件
     {
         for (int i = 0; i < HSD_EMAT.totalChannelNum; i++)
         {
             UpdateParamFromForm(i);
             AllForms.m_GageForm.UpdateGageInfoFormForm(i);
         }
         try
         {
             AllChannelsSet.SaveParamToXml(configPath + "configInfo");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     AllChannelsSet.UpdateParamFromXml(configPath + "configInfo"); //从配置中读取参数
     UpdateTrackBarFromParam(currChanNum);                         //初始化参数显示
     UpdateLableFromParam(currChanNum);
     for (int i = 0; i < HSD_EMAT.totalGageNum; i++)
     {
         AllForms.m_GageForm.UpdateGageForm(i);
     }
     AllForms.m_GageForm.UpdateGageForm(currChanNum);
     AllChannelsSet.UpDateSysAllParam();
 }
 //从xml文件中读取更新参数窗体与闸门窗体
 private void UpdateAllFormFromXml(string filePath)
 {
     AllChannelsSet.UpdateParamFromXml(filePath);//从配置中读取参数
     UpdateTrackBarFromParam(currChanNum);
     UpdateLableFromParam(currChanNum);
     AllForms.m_GageForm.UpdateGageForm(currChanNum);
 }
        private void buttonLoadConfig_Click(object sender, EventArgs e)
        {
            FindAllConfigFileName(configPath);//获取所有的文件名
            ConfigFileLoadForm configFileLoadForm = new ConfigFileLoadForm(configPathNames);

            configFileLoadForm.ShowDialog();
            if (configFileLoadForm.DialogResult == DialogResult.Cancel)
            {
                try
                {
                    AllChannelsSet.SaveParamToXml(configPath + "configInfo");//配置清空,重建默认配置
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            if (configFileLoadForm.DialogResult == DialogResult.Yes)
            {
                try
                {
                    UpdateAllFormFromXml(configPath + configFileLoadForm.fileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                AllChannelsSet.UpDateSysAllParam();
            }
        }
        private void buttonSaveConfig_Click(object sender, EventArgs e)
        {
            ConfigFileSaveForm configFileSaveForm = new ConfigFileSaveForm();

            configFileSaveForm.ShowDialog();
            if (configFileSaveForm.DialogResult == DialogResult.OK)
            {
                if (configFileSaveForm.fileName.Length == 0)
                {
                    MessageBox.Show("请输入配置文件名");
                    return;
                }
                else
                {
                    try
                    {
                        AllChannelsSet.SaveParamToXml(configPath + configFileSaveForm.fileName);
                        MessageBox.Show("配置文件保存成功");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
 private void ParamSetForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         AllChannelsSet.SaveParamToXml(configPath + "configInfo");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void buttonLoadDefaultCnfig_Click(object sender, EventArgs e)
 {
     try
     {
         UpdateAllFormFromXml(configPath + "configInfo");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     AllChannelsSet.UpDateSysAllParam();
 }