예제 #1
0
        private void btnSaveFactoryConfig_Click(object sender, EventArgs e)
        {
            string mySelectedValue = "";

            bool gIsNeedSaveBack = false;

            bool gIsNeedRestart = false;

            #region Modify Count

            if (txtMaxEnergyCountPerPixel.Text.Length > 0)
            {
                int myTempValue = 0;

                if (int.TryParse(txtMaxEnergyCountPerPixel.Text, out myTempValue))
                {
                    //Only if there is update
                    if (myTempValue != gParenetWindow.gMaxEnergyCount)
                    {
                        gParenetWindow.gMaxEnergyCount = myTempValue;

                        gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkMaxEnergyCountPerPixel, myTempValue.ToString( ));

                        gIsNeedSaveBack = true;
                    }
                }
            }

            #endregion

            #region Modify Bin Size

            if (txtBinSize.Text.Length > 0)
            {
                int myTempValue = 0;

                if (int.TryParse(txtBinSize.Text, out myTempValue))
                {
                    //Only if there is update
                    if (myTempValue != gParenetWindow.gBinSize)
                    {
                        gParenetWindow.gBinSize = myTempValue;

                        gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkBinSize, myTempValue.ToString( ));

                        gIsNeedSaveBack = true;
                    }
                }
            }

            #endregion

            #region Save Report Include Resolution Config

            if (gParenetWindow.gIsIncludeResolutionInReport)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfIncludeResolutionInReport, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfIncludeResolutionInReport, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save Report Include Energy Spectrum Config

            if (gParenetWindow.gIsIncludeEnergySpectrumInReport)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfIncludeEnergySpectrumInReport, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfIncludeEnergySpectrumInReport, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save Report Include Energy Count Config

            if (gParenetWindow.gIsIncludeEnergyCountInReport)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfIncludeCountInReport, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfIncludeCountInReport, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save Report Include Energy Count Config

            if (gParenetWindow.gIsAutoAdjustVbias)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfAutoAdjustAbias, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIfAutoAdjustAbias, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save Report Include Energy Count Config

            if (gParenetWindow.gIsUseDifferentRangesForPixels)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkUseDifferentRangesForPixels, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkUseDifferentRangesForPixels, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save IncludeResolutionGreyPic

            if (gParenetWindow.gIsIncludeResolutionGreyPic)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIncludeResolutionGreyPic, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIncludeResolutionGreyPic, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save IncludeEnergyGreyPic

            if (gParenetWindow.gIsIncludeEnergyGreyPic)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIncludeEnergyGreyPic, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIncludeEnergyGreyPic, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save IncludeCountGreyPic

            if (gParenetWindow.gIsIncludeCountGreyPic)
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIncludeCountGreyPic, "yes");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkIncludeCountGreyPic, "no");

                gIsNeedSaveBack = true;
            }

            #endregion

            #region Save Language

            if (cbLanguage.SelectedItem != null)
            {
                mySelectedValue = cbLanguage.SelectedItem.ToString();

                if (mySelectedValue.Length > 0)
                {
                    if (gParenetWindow.gDefaultLanguage != mySelectedValue)
                    {
                        gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkSelectedLanguage, mySelectedValue);

                        gIsNeedSaveBack = true;

                        gIsNeedRestart = true;
                    }
                }
                else
                {
                    MessageBox.Show("Nothing need to save");
                }
            }

            #endregion

            #region Save Qualified Type

            if (cbDefaultQualifiedType.SelectedIndex >= 0)
            {
                mySelectedValue = cbDefaultQualifiedType.SelectedIndex.ToString();

                if (mySelectedValue.Length > 0)
                {
                    if (gParenetWindow.gSelectedQualifiedType != cbDefaultQualifiedType.SelectedIndex)
                    {
                        gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkDefaultQualifiedType, mySelectedValue);

                        gIsNeedSaveBack = true;

                        //gIsNeedRestart = true;
                    }
                }
                else
                {
                    MessageBox.Show("Nothing need to save");
                }
            }

            #endregion

            #region Modify gkQualifiedPeakRangeFile

            if (txtQualifiedPeakRangeFile.Text.Length > 0)
            {
                if (gParenetWindow.gQualifiedCountFileName != txtQualifiedPeakRangeFile.Text)
                {
                    gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkQualifiedPeakRangeFile, txtQualifiedPeakRangeFile.Text.ToString());

                    gIsNeedSaveBack = true;

                    gIsNeedRestart = true;
                }
            }

            #endregion

            #region Modify gkQualifiedPeakRangeFile

            if (txtQualifiedResolutionRangeFile.Text.Length > 0)
            {
                if (gParenetWindow.gQualifiedResolutionFileName != txtQualifiedResolutionRangeFile.Text)
                {
                    gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkQualifiedResolutionRangeFile, txtQualifiedResolutionRangeFile.Text.ToString());

                    gIsNeedSaveBack = true;

                    gIsNeedRestart = true;
                }
            }

            #endregion

            #region Modify gEnablePixelReverse

            if (cbEnablePixelReverse.SelectedIndex == 0)
            {
                gParenetWindow.gEnablePixelReverse = true;

                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkEnablePixelReverse, "YES");

                gIsNeedSaveBack = true;
            }
            else
            {
                gParenetWindow.AddorModifyConfigParameter(cFactoryConfigParameter.gkEnablePixelReverse, "NO");

                gIsNeedSaveBack = true;

                gParenetWindow.gEnablePixelReverse = false;
            }

            #endregion

            #region Save back file

            if (gIsNeedSaveBack)
            {
                gParenetWindow.SaveConfigParameter(gParenetWindow.gOriginConfigDocument, gParenetWindow.gkConfigFilesPath);
            }

            #endregion

            #region Restart Program

            if (gIsNeedRestart)
            {
                DialogResult myDialogResult = MessageBox.Show("Restart application to apply changes(重启软件来应用设置)?", "Waring(警示)", MessageBoxButtons.YesNo);

                if (myDialogResult == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(Application.ExecutablePath);

                    Environment.Exit(0);
                }
            }

            #endregion
        }