using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SMAT_CE.Properties;
using SMAT_CE.Data;
using System.Xml.Linq;
using System.IO;
using DotSpatial.Controls;
using DotSpatial.Symbology;
using System.Threading;
using System.Data.OleDb;
using ZedGraph;
using DotSpatial.Data;
using System.Text.RegularExpressions;
using DotSpatial.Projections;
using DotSpatial.Topology;
using System.Drawing.Imaging;
using System.Xml;
using WinControls;
using Microsoft.Win32;
using System.Runtime.InteropServices;


namespace SMAT_CE
{
    public partial class SMAT_CE : FormBase
    {
        #region 自定义属性
        string[] strmapNameColRow = new string[6];//save the file name, species name, col.min, col.max, row.min, row.max for drawing map with lengend

        public string[] strMapNameColRow
        {
            get { return strmapNameColRow; }
            set { strmapNameColRow = value; }
        }

        DataTable dtchartTemp = null;//draw bar distribution frequency in chart (ssia)
        /// <summary>
        /// 0-bar or 1-distribution or 2-frequency - when click apply - only in ssia
        /// </summary>
        int ichartType = 0;
        private bool plotLine = false;
        private bool changeColor = false;
        private bool ssia_useMonitor = true;//flag - whether use monitor in SSIA
        public bool Ssia_useMonitor
        {
            get { return ssia_useMonitor; }
            set
            {
                if (value != ssia_useMonitor)
                {
                    SSIA_useMonitorChange(value);
                }
                ssia_useMonitor = value;
            }
        }
        //Dictionary<string, string> diclatlongTOLambert = new Dictionary<string, string>();
        Dictionary<string, Dictionary<string, double>> dicValueMAP = new Dictionary<string, Dictionary<string, double>>();
        //保存第一次读取的datatable，方便后面show all
        private DataTable _dtOutput = new DataTable();
        private int iStateName = -1;//记录statename列的索引值
        //保存select后的datatable
        private DataTable _dtSelectOutput = new DataTable();
        //保存点击treelistview选择的文件类型
        private string _fileType = "";
        //---------记录文件中数据的监测频率-----------
        private string _dataType = "";
        ////---------记录cboFilter中的value---------
        //public string _chartFilter = "";
        //-------chart默认为显示baseline和forecast value，若是用户自己选择则只选择一个值
        private bool isSelectValue = false;
        /// <summary>
        /// 表示尚未设置的图标key，（imagelist中的图片name）参数文件里的设置必须与这里一致
        /// </summary>
        private const string _unreadyImageKey = "unready";
        /// <summary>
        ///  表示已经有设置的图标key，参数文件里的设置必须与这里保持一致
        /// </summary>
        private const string _readyImageKey = "ready";
        private const string _yibuImageKey = "loading";
        private const string _saveImageKey = "savescenario";
        private const string _errorImageKey = "error";
        private bool isMaxView = false; //是否是最大的视图
        private bool isShowLegend = false;//是否show legend

        private string _ChartFilter = "";//用于chart部分，记录cbofilter的值
        //private DataTable _dtStateDataTable = null;//用于chart部分，记录根据筛选条件获得的datatable

        //实例化一个Tooltip
        ToolTip tips = new ToolTip();
        //// dataviewer 
        ToolTip tipTreelistview = new ToolTip();

        /// <summary>
        /// 提示信息内容
        /// </summary>
        private string _stips = "";

        /// <summary>
        /// 判断Next或Back
        /// </summary>
        private bool isNext;

        public TreeListViewItem item;
        bool isPolygon = false;
        string smallDomianMAP = "";
        double[] dataDomainGIS = null;
        /// <summary>
        /// 0-grid; 1-combine; 2-dispersion
        /// </summary>
        int ssiaDataOption = 0;//draw in map-- show max or min value at latlong
        /// <summary>
        /// use to distinguish the bar when showing point values 
        /// </summary>
        public List<string> lstReceptors = new List<string>();
        /// <summary>
        /// 配置图表样式，add by sclong
        /// </summary>
        ConfigureSymbol _configureSymbol = null;
        #endregion

        public SMAT_CE()
        {
            InitializeComponent();
            stcMain.Panel1.BackColor = Color.FromArgb(225, 225, 225);
            stcMain.Panel2.BackColor = Color.FromArgb(241, 241, 241);
            //---------保存获取的背景颜色-----------
            CommonClass.BackColorPick = new byte[3];
            CommonClass.BackColorPick[0] = stcGIS.Panel1.BackColor.R;
            CommonClass.BackColorPick[1] = stcGIS.Panel1.BackColor.G;
            CommonClass.BackColorPick[2] = stcGIS.Panel1.BackColor.B;
            //------------end-------------------------------------------
            CommonClass.CurrentLogChanged += new CommonClass.CurrentLogChangedStartHandler(SetRunningLog);
            // picClose.Parent = tlvRunning;
        }

        private void SMAT_CE_Load(object sender, EventArgs e)
        {
            initForm();
            //proBarRunning.Maximum = 100;//设置最大长度值
            //proBarRunning.Value = 0;//设置当前值
            //proBarRunning.Step = 1;//设置没次增长多少
            //timer1.Enabled = false ;

            //----------Add Result Filefolder
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\CFG"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\CFG");
            }
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\SHP"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\SHP");
            }
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\Batchjob"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\Batchjob");
            }
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\Picture"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\Picture");
            }
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\Output"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\Output");
            }
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\Project"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\Project");
            }
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\CSV"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\CSV");
            }
            if (!Directory.Exists(CommonClass.ResultFilePath + @"\Result\LOG"))
            {
                System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath + @"\Result\LOG");
            }

            colorBlend.CustomizeValueRange -= ResetMapColor;
            colorBlend.CustomizeValueRange += ResetMapColor;
        }

        private void tbcFunction_DrawItem(object sender, DrawItemEventArgs e)
        {
            try
            {
                //SolidBrush bru = new SolidBrush(Color.FromArgb(241, 241, 241));
                ////绘制主控件背景颜色
                //e.Graphics.FillRectangle(bru, 0, 0, tbcFunction.Width, tbcFunction.Height);
                Graphics g = e.Graphics;
                Rectangle endPageRect = tbcFunction.GetTabRect(tbcFunction.TabPages.Count - 1); //最后一个标题栏的范围   
                Rectangle TitleRect = tbcFunction.GetTabRect(e.Index);              //当前标题栏的范围   
                Rectangle HeaderBackRect = Rectangle.Empty;
                HeaderBackRect = new Rectangle(new System.Drawing.Point(endPageRect.X + endPageRect.Width, endPageRect.Y),
                      new Size(tbcFunction.Width - endPageRect.X - endPageRect.Width, endPageRect.Height));
                Brush b = new SolidBrush(Color.FromArgb(241, 241, 241));
                g.FillRectangle(b, HeaderBackRect);
                Image img = null;
                Rectangle rct;
                int i = e.Index;

                rct = tbcFunction.GetTabRect(i);
                if (this.tbcFunction.TabPages[i].Text.ToString() == "Map")
                {
                    img = Resources.map_new;
                }
                if (this.tbcFunction.TabPages[i].Text.ToString() == "GIS")
                {
                    img = Resources.Tab_GIS;
                }
                if (this.tbcFunction.TabPages[i].Text.ToString() == "Data")
                {
                    img = Resources.data_new;
                }
                if (this.tbcFunction.TabPages[i].Text.ToString() == "Chart")
                {
                    img = Resources.chart_new;
                }
                if (this.tbcFunction.TabPages[i].Text.ToString() == "Output Navigator")
                {
                    img = Resources.TabOutput1;
                }
                if (this.tbcFunction.TabPages[i].Text.ToString() == "Running")
                {
                    img = Resources.log1;
                }
                if (this.tbcFunction.TabPages[i].Text.ToString() == "Run Log")
                {
                    img = Resources.log1;
                }
                if (this.tbcFunction.TabPages[i].Text.ToString() == "Configuration & Batch")
                {
                    img = Resources.batch;
                }
                e.Graphics.DrawImage(img, rct);
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        #region 自定义函数
        /// <summary>
        /// 自动添加running log
        /// </summary>
        public void SetRunningLog()
        {
            try
            {
                if (CommonClass.CurrentLog != string.Empty)
                {
                    if (tlvRunning.Items.Count == 0)
                    {
                        item = new TreeListViewItem() { Text = CommonClass.CurrentBaseScenario.configuration.configurationName };
                        item.SubItems.Add(CommonClass.CurrentLog);
                        tlvRunning.Items.Add(item);
                    }
                    else
                    {
                        TreeListViewItem itemA = new TreeListViewItem() { };
                        item.Items.Add(itemA);
                        itemA.SubItems.Add(CommonClass.CurrentLog);
                    }
                    tlvRunning.Refresh();
                    tlvRunning.ExpandAll();
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        ///// <summary>
        ///// 根据传入的参数设定
        ///// </summary>
        //public void SetProgressBar()
        //{
        //    try
        //    {
        //        if (CommonClass.CurrentProgressBar != 0)
        //        {

        //            proBarRunning.PerformStep();
        //            proBarRunning.Refresh();
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        CommonClass.LogError(ex); 
        //    }
        //}

        /// <summary>
        /// 初始化界面
        /// </summary>
        public void initForm()
        {
            try
            {
                ssia_useMonitor = true;
                //numericUpDownResult.Value = 4;
                isMaxView = false;
                //-----------timer initialization---------
                timerLoad.Enabled = false;
                timerLoad.Interval = 5000;

                //--------------instantiate a Tooltip，and set properties----------
                tips.InitialDelay = 200;
                tips.AutoPopDelay = 10 * 1000;
                tips.ReshowDelay = 200;
                tips.ShowAlways = true;
                tips.IsBalloon = true;
                tips.BackColor = Color.FromArgb(251, 233, 169);
                tips.SetToolTip(btnUserGuide, Language.Localization.GetValue("Users' Guide"));
                tips.SetToolTip(btnAbout, Language.Localization.GetValue("About"));
                lblProjectName.Text = "";
                lblAnalysis2.Text = "";
                //--------------data view Tips setting------------
                tipTreelistview.InitialDelay = 200;
                tipTreelistview.AutoPopDelay = 10 * 1000;
                tipTreelistview.ReshowDelay = 200;
                tipTreelistview.ShowAlways = true;
                tipTreelistview.IsBalloon = false;
                //tipTreelistview.SetToolTip(tlvDataViewer, Language.Translate("Double-click or right-click to view data & map"));
                //------------hide tabpage--------------
                if (!CommonClass.IsDataViewerState)
                {
                    _dtOutput = null;
                    _dtSelectOutput = null;
                    if (tlvDataViewer.Items.Count > 0)
                    {
                        tlvDataViewer.Items.Clear();
                        colorBlend.SetValueRange(0, 0, true);
                    }
                    if (tlvLogFile.Items.Count > 0)
                        tlvLogFile.Items.Clear();
                    if (dgvDataView.Columns.Count > 0)
                        dgvDataView.Columns.Clear();
                    dgvDataView.Refresh();
                    if (clboQuantifiers.Items.Count > 0)
                        clboQuantifiers.Items.Clear();
                    if (dgvDataList.Columns.Count > 0)
                        dgvDataList.Columns.Clear();
                    dgvDataList.Refresh();
                    if (cboFilter.Items.Count > 0)
                        cboFilter.Items.Clear();
                    if (cboType.Items.Count > 0)
                        cboType.Items.Clear();
                    if (listViewCFG.Items.Count > 0)
                        listViewCFG.Items.Clear();
                    lblProjectName.Text = "";
                    lblAnalysis2.Text = "";
                    labelTips.Visible = false;
                    //if()
                    //清空ZedGraph
                    GraphPane myPane = this.zgcChart.GraphPane;
                    myPane.CurveList.Clear();
                    myPane.GraphObjList.Clear();
                    myPane.Title.Text = "";
                    myPane.XAxis.Title.Text = "";
                    myPane.YAxis.Title.Text = "";
                    myPane.XAxis.Scale.TextLabels = null;
                    myPane.Chart.Fill = new Fill();

                    lblFileName.Text = "";

                    if (mainMap.Layers.Count > 1)
                    {
                        mainMap.Layers.Clear();
                        setStandardMap();
                    }
                    dgvDataList.DataSource = null;
                    dgvDataView.DataSource = null;
                    cboType.Text = "";
                }
                this.tbcFunction.TabPages.Remove(tbpRunning);
                this.tbcFunction.TabPages.Remove(tbpLog);
                this.tbcFunction.TabPages.Remove(tbpMap);

                this.tbcFunction.TabPages.Remove(tbpGIS);
                this.tbcFunction.TabPages.Remove(tbpData);
                this.tbcFunction.TabPages.Remove(tbpChart);
                this.tbcFunction.TabPages.Remove(tbpConfigurationBatch);
                labelTips.Visible = false;

                CommonClass.speciesMonitorFile = "";
                CommonClass.speciesFractionFilePoint = "";
                CommonClass.speciesFractionFileSpatial = "";
                CommonClass.unofficialPMFile = "";
                CommonClass.officialPMFile = "";
                CommonClass.baseModelFile = "";
                CommonClass.futureModelFile = "";
                CommonClass.dispersionModelFile = "";
                CommonClass.monitorFile = "";
                CommonClass.ozoneMonitorFile = "";
                //CommonClass.improveAlgorithmNew = "";
                //CommonClass.improveAlgorithmOld = "";

                if (CommonClass.OutputNavigator == true)
                {
                    if (!CommonClass.IsDataViewerState)
                    {
                        if (tlvDataViewer.Items.Count == 0)
                        {
                            btnExtractSelected.Enabled = false;
                            btnExtractAll.Enabled = false;
                            btnLinkTo.Enabled = false;
                            rbtnVNA.Enabled = false;
                            rbtnEVNA.Enabled = false;
                            //btnOutputFor.Enabled = false;
                            tlvDataViewer.Items.Add("No data loaded");
                            //tlvDataViewer.ShowItemToolTips = false;
                        }
                        //else
                        {
                            if (CommonClass.CurrentBaseScenario != null && CommonClass.CurrentBaseScenario.configuration != null && (CommonClass.CurrentBaseScenario.configuration is BenMAPAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is BenMAPOzoneAnalysisConfiguration))
                            {
                                rbtnVNA.Enabled = true;
                                rbtnEVNA.Enabled = true;
                                btnLinkTo.Enabled = true;
                            }
                            else
                            {
                                rbtnVNA.Enabled = false;
                                rbtnEVNA.Enabled = false;
                                btnLinkTo.Enabled = false;
                            }
                        }
                        //-----added & modified by Yangwenwei 20131231-----
                        if (!LanguageOld.IsSMATChina)
                        {
                            tsmiContinentalUS.Visible = true;
                            tsmiMaryland.Visible = true;
                            tsmiNewEngland.Visible = true;
                            tsmiSouthernCalifornia.Visible = true;
                            tsmiTexas.Visible = true;
                            tsmiWashingtonDC.Visible = true;
                            tsmiChina.Visible = false;
                            tsmiYRD.Visible = false;
                            tsmiPRD.Visible = false;
                            tsmiJJJ.Visible = false;
                        }
                        else
                        {
                            tsmiContinentalUS.Visible = false;
                            tsmiMaryland.Visible = false;
                            tsmiNewEngland.Visible = false;
                            tsmiSouthernCalifornia.Visible = false;
                            tsmiTexas.Visible = false;
                            tsmiWashingtonDC.Visible = false;
                            tsmiChina.Visible = true;
                            tsmiYRD.Visible = true;
                            tsmiPRD.Visible = true;
                            tsmiJJJ.Visible = true;
                        }
                        if (cboStandardLayers.Items.Count == 0)
                        {
                            cboStandardLayers.Items.Add("US States");
                            cboStandardLayers.Items.Add("US Counties");
                            cboStandardLayers.Items.Add("Class I Area");
                            cboStandardLayers.Items.Add("Class I Area and States");
                            cboStandardLayers.Items.Add("Continental US");
                        }
                        if (cboZoomTo.Items.Count == 0)
                        {
                            cboZoomTo.Items.Add("Continental US");
                            cboZoomTo.Items.Add("Maryland");
                            cboZoomTo.Items.Add("New England");
                            cboZoomTo.Items.Add("Southern California");
                            cboZoomTo.Items.Add("Texas");
                            cboZoomTo.Items.Add("Washington DC");
                        }
                        if (LanguageOld.IsSMATChina && cboStandardLayers.Items[0].ToString() == "US States")
                        {
                            cboStandardLayers.Items.Clear();
                            cboStandardLayers.Items.Add("China");
                            cboZoomTo.Items.Clear();
                            cboZoomTo.Items.Add("China");
                            cboZoomTo.Items.Add("YRD");
                            cboZoomTo.Items.Add("PRD");
                            cboZoomTo.Items.Add("JJJ");
                        }
                        else if (!LanguageOld.IsSMATChina && cboStandardLayers.Items[0].ToString() == "China")
                        {
                            cboStandardLayers.Items.Clear();
                            cboStandardLayers.Items.Add("US States");
                            cboStandardLayers.Items.Add("US Counties");
                            cboStandardLayers.Items.Add("Class I Area");
                            cboStandardLayers.Items.Add("Class I Area and States");
                            cboStandardLayers.Items.Add("Continental US");
                            cboZoomTo.Items.Clear();
                            cboZoomTo.Items.Add("Continental US");
                            cboZoomTo.Items.Add("Maryland");
                            cboZoomTo.Items.Add("New England");
                            cboZoomTo.Items.Add("Southern California");
                            cboZoomTo.Items.Add("Texas");
                            cboZoomTo.Items.Add("Washington DC");

                        }
                        cboZoomTo.SelectedIndex = 0;
                        cboStandardLayers.SelectedIndex = 0;
                        lblProjectName.Text = "";
                        lblAnalysis2.Text = "";
                    }
                    if (dgvDataList.Columns.Count == 0)
                    {
                        //btnApply.Enabled = false;
                    }
                    if (dgvDataView.Columns.Count == 0)
                    {
                        btnShowAll.Enabled = false;
                        btnExport.Enabled = false;
                        btnApplyData.Enabled = false;
                        numericUpDownResult.Enabled = false;
                        txtDistance.Enabled = false;
                        txtThreshold.Enabled = false;
                        //btnApply.Enabled = false;
                    }

                    if (listViewCFG.Items.Count == 0)
                    {
                        btnClose.Enabled = false;
                        btnEdit.Enabled = false;
                        btnExportCFG.Enabled = false;
                        picCloseCFG.Visible = false;
                    }
                    if (tlvLogFile.Items.Count == 0)
                        picCloseLog.Visible = false;

                    pnlDataViewer.Visible = true;
                    lblProjectName.Visible = true;
                    lblAnalysis2.Visible = true;

                    //if (CommonClass.IsDataViewerState)
                    if (tlvDataViewer.Items.Count <= 1)
                        labelTips.Visible = false;
                    else
                        labelTips.Visible = true;
                    stcMain.Width = 974;
                    stcMain.Refresh();
                    stcMain.Panel1MinSize = 338;
                    stcMain.SplitterDistance = 338;
                    stcMain.FixedPanel = FixedPanel.Panel1;
                    scrRight.Panel1MinSize = 104;
                    scrRight.Refresh();
                    scrRight.SplitterDistance = 104;
                    scrRight.FixedPanel = FixedPanel.Panel1;
                    //mainMap.BackColor = Color.FromArgb(214, 231, 255);
                    this.tbcFunction.TabPages.Add(tbpGIS);
                    this.tbcFunction.TabPages.Add(tbpMap);
                    this.tbcFunction.TabPages.Add(tbpData);
                    this.tbcFunction.TabPages.Add(tbpChart);
                    this.tbcFunction.TabPages.Add(tbpLog);
                    this.tbcFunction.TabPages.Add(tbpConfigurationBatch);
                    if (CommonClass.IsFirstLoadProject == true)
                    {
                        this.tbcFunction.SelectedTab = tbpLog;
                    }
                    else
                    {
                        this.tbcFunction.SelectedTab = tbpGIS;
                    }
                    //if (this.tbcFunction.SelectedTab.Text != "Map" && this.tbcFunction.SelectedTab.Text != "Data" && this.tbcFunction.SelectedTab.Text != "Chart")
                    //    this.tbcFunction.SelectedTab = tbpMap;
                    lblAnalysis.Text = Language.Localization.GetValue("Data Viewer");
                    pboPollutant.Image = Resources.OutputNavigator;

                    lblSteps.Visible = false;
                    pboHelp.Visible = false;
                    pboOpenCFG.Visible = false;
                    pboCreateCFG.Visible = false;
                    btnSave.Visible = false;
                    btnSaveRun.Visible = false;
                    btnClear.Visible = false;
                    btnNext.Visible = false;
                    btnBack.Visible = false;
                    lblBack.Visible = false;
                    lblNext.Visible = false;
                    trvAnalysis.Visible = false;
                    pnlUserControl.Visible = false;
                    //lblProjectName.Text = CommonClass.CurrentBaseScenario.configuration.configurationName;
                    //-----------The default is to show the legend------------
                    this.stcGIS.Panel1MinSize = 185;
                    this.stcGIS.SplitterDistance = 185;
                    this.stcGIS.SplitterWidth = 1;
                    this.stcGIS.FixedPanel = FixedPanel.Panel1;
                    this.stcGIS.BorderStyle = BorderStyle.FixedSingle;
                    this.stcMap.Panel1MinSize = 185;
                    this.stcMap.SplitterDistance = 185;
                    this.stcMap.SplitterWidth = 1;
                    this.stcMap.FixedPanel = FixedPanel.Panel1;
                    this.stcMap.BorderStyle = BorderStyle.FixedSingle;
                    //this.stcMap.Panel1MinSize = 24;
                    //this.stcMap.FixedPanel = FixedPanel.Panel1;
                    //this.stcMap.SplitterDistance = 0;
                    //this.stcMap.BorderStyle = BorderStyle.None;
                    if (CommonClass.LoadProjectFromStartPageOrAnalysisPage)
                    {
                        LoadProject(CommonClass.FileName);
                        CommonClass.LoadProjectFromStartPageOrAnalysisPage = false;
                    }
                }
                else
                {
                    lblProjectName.Visible = false;
                    lblAnalysis2.Visible = false;
                    labelTips.Visible = false;
                    pnlDataViewer.Visible = false;
                    pboOpenCFG.Visible = true;
                    pboCreateCFG.Visible = true;
                    btnSave.Visible = true;
                    btnSaveRun.Visible = true;
                    btnClear.Visible = true;
                    btnNext.Visible = true;
                    btnBack.Visible = true;
                    lblBack.Visible = true;
                    lblNext.Visible = true;
                    trvAnalysis.Visible = true;
                    pnlUserControl.Visible = true;
                    lblSteps.Visible = true;
                    pboHelp.Visible = true;
                    stcMain.Panel1MinSize = 491;
                    stcMain.SplitterDistance = 491;
                    stcMain.FixedPanel = FixedPanel.Panel1;
                    scrRight.Panel1MinSize = 104;
                    scrRight.SplitterDistance = 104;
                    scrRight.FixedPanel = FixedPanel.Panel1;
                    //-----------Clear panel before loading the user control---------
                    pnlUserControl.Controls.Clear();

                    //------------Clear treeview before loading-----------
                    if (trvAnalysis.Nodes.Count > 0)
                    {
                        this.trvAnalysis.Nodes.Clear();
                    }

                    this.tbcFunction.TabPages.Add(tbpRunning);
                    //this.tbcFunction.TabPages.Add(tbpConfigurationBatch);
                    if (this.tlvRunning.Items.Count > 0)
                        tlvRunning.Items.Clear();
                    tbcFunction.Refresh();

                    //--------------set up for buttons-------------
                    btnSave.Enabled = false;
                    btnNext.Enabled = true;
                    btnNext.Image = Resources.Next1;
                    btnBack.Enabled = false;
                    btnBack.Image = Resources.Back_gray;
                    btnSaveRun.Enabled = false;

                    tips.SetToolTip(pboCreateCFG, Language.Localization.GetValue("Create a new project"));
                    tips.SetToolTip(pboOpenCFG, Language.Localization.GetValue("Open an existing project"));

                    lblSteps.Text = "Choose Desired Output";
                    string path = null;
                    if (CommonClass.OpenScenario == true)
                    {
                        //if (!CommonClass.IsDataViewer)
                        //{
                        //-----------identify current analysis------------
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.AnnualPM;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.DailyPM;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.Ozone;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.Visibility;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.SSIAAnnualPM;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.SSIADailyPM;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.SSIAOzone;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.SSIADeposition;
                        }  //added by Lijiabin
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.AnnualPMChina;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.OzoneChina;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.BenMAPAnnualPM;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration))
                        {
                            CommonClass.CurrentAnalysis = enumAnalysis.BenMAPSeasonalOzone;
                        }
                        #region//-------------different analysis has different image,name and tree nodes-------------
                        switch (CommonClass.CurrentAnalysis)
                        {
                            case enumAnalysis.AnnualPM:
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\Annual PM Analysis.xml";
                                break;
                            case enumAnalysis.DailyPM:
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("Daily PM Analysis");
                                path = Application.StartupPath + @"\Configs\Daily PM Analysis.xml";
                                break;
                            case enumAnalysis.Ozone:
                                lblAnalysis.Text = Language.Localization.GetValue("Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\Ozone Analysis.xml";
                                pboPollutant.Image = Resources.O3;
                                break;
                            case enumAnalysis.Visibility:
                                lblAnalysis.Text = Language.Localization.GetValue("Visibility Analysis");
                                path = Application.StartupPath + @"\Configs\Visibility Analysis.xml";
                                pboPollutant.Image = Resources.Haze;
                                break;
                            case enumAnalysis.SSIAAnnualPM:
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA PM Analysis.xml";
                                break;
                            case enumAnalysis.SSIADailyPM:
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Daily PM Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA PM Analysis.xml";
                                break;
                            case enumAnalysis.SSIAOzone:
                                pboPollutant.Image = Resources.O3;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA Ozone Analysis.xml";
                                break;
                            case enumAnalysis.SSIADeposition:                                         //added by Lijiabin                  
                                pboPollutant.Image = Resources.Deposition;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Deposition Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA Deposition Analysis.xml";
                                break;
                            case enumAnalysis.AnnualPMChina:
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\Annual PM Analysis China.xml";
                                break;
                            case enumAnalysis.OzoneChina:
                                pboPollutant.Image = Resources.O3;
                                lblAnalysis.Text = Language.Localization.GetValue("Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\Ozone Analysis China.xml";
                                break;
                            case enumAnalysis.BenMAPAnnualPM:
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("BenMAP - Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\BenMAP_Annual PM.xml";
                                break;
                            case enumAnalysis.BenMAPSeasonalOzone:
                                pboPollutant.Image = Resources.O3;
                                lblAnalysis.Text = Language.Localization.GetValue("BenMAP - Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\BenMAP_Ozone.xml";
                                break;
                        }
                        loadTreeNodes(trvAnalysis.Nodes, path);
                        #endregion
                        string errorTip = "";
                        #region annual pm
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                                || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null
                                || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                                && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null
                                && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkAnnualPMUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null)
                            {
                                pnlUserControl.Controls.Add(new uc_OutputA());
                                uc_OutputA _outPutA = (pnlUserControl.Controls[0] as uc_OutputA);
                                _outPutA.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                                _outPutA.choStandardAnalysisA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doStandardAnalysis;
                                _outPutA.choQuarterlyModelDataA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doQuarterlyModelData;
                                _outPutA.choQuarterlyModelDataUsedA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doUsedQuarterlyAvgModelData;
                                _outPutA.choSpeciesFractionOutputA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doSpeciesFraction;
                                _outPutA.choActionsCompletionA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doAutomaticallyExtract;
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkUCOutputAdvancedA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkUCDataInputA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[3]);
                            }
                            //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionAdvancedA != null)
                            //{
                            //    ChangeNodeImage(trvAnalysis.Nodes[4]);
                            //}
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[4]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[5]);
                            }
                        }
                        #endregion
                        #region daily
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null
                                || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null
                                || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null
                                 && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null
                                 && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkDailyPMUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null)
                            {
                                pnlUserControl.Controls.Add(new uc_OutputD());
                                uc_OutputD _outPutD = (pnlUserControl.Controls[0] as uc_OutputD);
                                _outPutD.txtScenarioNameDily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                                _outPutD.choStandardAnalysisD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doStandardAnalysis;
                                _outPutD.choQuarterlyPeakModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doQuarterlyPeakModelData;
                                _outPutD.choSpeciesFractionsFileD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doSpeciesFraction;
                                _outPutD.choActionsExtractAllD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doAutomaticallyExtract;
                                errorTip = "";
                                errorTip = CommonClass.checkUCOutputD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkUCOutputAdvancedD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkUCDataInputD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[3]);
                            }
                            //if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionAdvancedD != null)
                            //{
                            //    ChangeNodeImage(trvAnalysis.Nodes[4]);
                            //}
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[4]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[5]);
                            }
                        }
                        #endregion
                        #region Ozone added by sclong
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null
                        || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null
                                 && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkOzoneUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                            {
                                btnSaveRun.Enabled = false;
                            }

                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null)
                            {
                                pnlUserControl.Controls.Add(new uc_DesiredOutputOzone());
                                uc_DesiredOutputOzone _desiredOutputOzone = (pnlUserControl.Controls[0] as uc_DesiredOutputOzone);
                                _desiredOutputOzone.txtScenarioOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                                _desiredOutputOzone.choPointForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doPointEstimatesForecast;
                                _desiredOutputOzone.choQuarterlyModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doQuarterlyModelData;
                                _desiredOutputOzone.choSpatialOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates;
                                _desiredOutputOzone.choSpatialGradAdjOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj;
                                _desiredOutputOzone.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDownscaler;

                                _desiredOutputOzone.chkDSOnlyBase.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSBaseOnly;
                                _desiredOutputOzone.chkDSOnlyFuture.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSFutureOnly;

                                _desiredOutputOzone.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSBurn.ToString();
                                _desiredOutputOzone.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSCmaqres.ToString();
                                _desiredOutputOzone.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSNumit.ToString();
                                _desiredOutputOzone.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSThin.ToString();



                                _desiredOutputOzone.choBaseOnlyVNAOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA;
                                _desiredOutputOzone.choFutureOnlyVNAOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA;
                                _desiredOutputOzone.choBaseOnlyEvnaOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA;
                                _desiredOutputOzone.choFutureOnlyEvnaOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA;
                                //_desiredOutputOzone.choSpatialForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecast;
                                //_desiredOutputOzone.choSpatialGradAdjForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecastGradAdj;
                                _desiredOutputOzone.choNeighborFileSpatial.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doNeighborFileSpatial;
                                _desiredOutputOzone.choExtractAllOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doAutomaticallyExtract;
                                _desiredOutputOzone.choDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDesignValuePeriods;
                                _desiredOutputOzone.choMaxDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doMaxDesignValuePeriods;
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkOzoneUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[2]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[3]);
                            }
                        }
                        #endregion
                        #region Visibility added by sclong
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null
                              || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null && (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null
                               && (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkVisibilityUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                            {
                                btnSaveRun.Enabled = false;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null)
                            {
                                pnlUserControl.Controls.Add(new uc_ChooseDesiredOutputV());
                                uc_ChooseDesiredOutputV _chooseDesiredOutputV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                                _chooseDesiredOutputV.txtScenarioNameVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                                _chooseDesiredOutputV.choVisibilityLevels.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast;
                                _chooseDesiredOutputV.rbtnOldIMPROVEAlgorithmVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm;
                                _chooseDesiredOutputV.rbtnNewIMPROVEAlgorithmVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseNewVersionforIMPROVEAlgorithm;
                                _chooseDesiredOutputV.rbtnModelGridCellatMonitorVisi.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellAtMonitor;
                                _chooseDesiredOutputV.rbtnModelGridCellatClass1Visi.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellatClassIAreaCentroid;
                                _chooseDesiredOutputV.choExtractAllVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doAutomaticallyExtract;
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkVisibilityUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[2]);
                            }
                        }

                        #endregion
                        #region annual pm SSIA
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null && (((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAAnnualPMUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null)
                            {
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData;
                                _analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly;
                                _analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion;
                                _analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly;
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCModelInputA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCMonitorInputA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        #region daily pm SSIA added by Yangwenwei
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null && (((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIADailyPMUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null)
                            {
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData;
                                _analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly;
                                _analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion;
                                _analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly;
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAModelInputD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAMonitorInputD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        #region ozone SSIA
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null && (((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAOzoneUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null)
                            {
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData;
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCModelInputO(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCMonitorInputO(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        #region deposition SSIA added by Lijiabin
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null || (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null || (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null && (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null && (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIADepositionUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null)
                            {
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelData;
                                //_analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelFRMData;
                                //_analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useDispersionOnly;
                                //_analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridAndDispersion;
                                //_analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridOnly;
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCModelInputDep(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            //if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).monitorInputDep != null)
                            //{
                            //    errorTip = "";
                            //    errorTip = CommonClass.checkSSIAUCMonitorInputA(CommonClass.CurrentBaseScenario);
                            //    if (errorTip != null && errorTip.Length > 0)
                            //    {
                            //        errorNode(trvAnalysis.Nodes[2]);
                            //    }
                            //    else
                            //    {
                            //        ChangeNodeImage(trvAnalysis.Nodes[2]);
                            //    }
                            //}
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        #endregion
                        #region Annual PM China added by Yangwenwei
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkAnnualPMChina(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null)
                            {
                                pnlUserControl.Controls.Add(new uc_ModelDataChina());
                                uc_ModelDataChina modeldatachina = (pnlUserControl.Controls[0] as uc_ModelDataChina);
                                modeldatachina.InitializeControl();
                                //modeldatachina.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                                //modeldatachina.rbtnCMAQChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doInputFromCMAQ;
                                //modeldatachina.rbtnDailyAvertageDatalChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doDailyAverageDataInput;
                                //modeldatachina.rbtnQuarterlyAverageDataChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doQuarterlyAverageDataInput;
                                //CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.BaselineModelDataFile;
                                //modeldatachina.txtBaselineChina.Text = Path.GetFileName(CommonClass.baseModelFile);
                                //CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.ControlModelDataFile;
                                //modeldatachina.txtControlChina.Text = Path.GetFileName(CommonClass.futureModelFile);
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[1]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[2]);
                            }
                        }
                        #endregion
                        #region Ozone China added by Yangwenwei
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkOzoneChina(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null)
                            {
                                pnlUserControl.Controls.Add(new uc_ModelDataOzoneChina());
                                uc_ModelDataOzoneChina modeldataozonechina = (pnlUserControl.Controls[0] as uc_ModelDataOzoneChina);
                                modeldataozonechina.InitializeControl();
                                //modeldataozonechina.cboCMAQOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.doInputfromCmaq;
                                //modeldataozonechina.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                                //modeldataozonechina.txtBaselineOzone.Text = Path.GetFileName((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile);
                                //modeldataozonechina.txtForecastOzone.Text = Path.GetFileName((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile);
                                //CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile;
                                //CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile;

                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[1]);
                            }
                        }
                        #endregion
                        #region BenMAP Annual PM
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null
                                || (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile.Length > 0)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null
                                && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile.Length > 0)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkBenMAPAnnualPMUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null)
                            {
                                pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_ModelData());
                                uc_BenMAP_AnnualPM_ModelData _model = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_ModelData);
                                _model.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName;
                                _model.rbtnDailyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doDailyModelData;
                                _model.rbtnQuarterlyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doQuarterlyModelData;
                                _model.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doInputfromCMAQ;
                                CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.baselineFile;
                                _model.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.forecastFile;
                                _model.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                _model.cboSpatialGridA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.temporalAdjustmentAtMonitorGridSpatial;
                                errorTip = "";
                                errorTip = CommonClass.checkUCBenMAPPMModelData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkUCBenMAPPMMonitorData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkUCBenMAPPMSpeciesData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile.Length > 0)
                            {
                                if (!File.Exists((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile))
                                {
                                    errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        #region BenMap Ozone
                        if (CommonClass.CurrentBaseScenario.configuration == (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration))
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null
                                || (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile.Length > 0)
                            {
                                btnSave.Enabled = true;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null
                                && (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile.Length > 0)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkBenMAPOzoneUC(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    btnSaveRun.Enabled = false;
                                }
                                else
                                {
                                    btnSaveRun.Enabled = true;
                                }
                            }
                            else
                                btnSaveRun.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null)
                            {
                                pnlUserControl.Controls.Add(new uc_BenMap_Ozone_ModelData());
                                uc_BenMap_Ozone_ModelData _model = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_ModelData);
                                _model.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName;
                                _model.choCMAQOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.doInputfromCmaq;
                                CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.baselineModelDataFile;
                                _model.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.forecastModelDataFile;
                                _model.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                                errorTip = "";
                                errorTip = CommonClass.checkBenMAPOzoneModelData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null)
                            {
                                errorTip = "";
                                errorTip = CommonClass.checkBenMAPOzoneMonitorlData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }

                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile.Length > 0)
                            {
                                if (!File.Exists((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile))
                                {
                                    errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        #endregion
                        //}
                    }
                    else
                    {
                        #region 新建scenario
                        CommonClass.CurrentBaseScenario = new BaseScenario();
                        switch (CommonClass.CurrentAnalysis)
                        {
                            case enumAnalysis.AnnualPM:
                                CommonClass.CurrentBaseScenario.configuration = new AnnualPMAnalysisConfiguration();
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA = new ChooseDesiredOutputA();
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\Annual PM Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_OutputA());
                                uc_OutputA _outPutA = (pnlUserControl.Controls[0] as uc_OutputA);
                                _outPutA.choStandardAnalysisA.Checked = true;
                                _outPutA.choQuarterlyModelDataA.Checked = true;
                                _outPutA.choQuarterlyModelDataUsedA.Checked = true;
                                _outPutA.choSpeciesFractionOutputA.Checked = true;
                                _outPutA.choActionsCompletionA.Checked = true;
                                break;
                            case enumAnalysis.DailyPM:
                                CommonClass.CurrentBaseScenario.configuration = new DailyPMAnalysisConfiguration();
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD = new ChooseDesiredOutputD();
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("Daily PM Analysis");
                                path = Application.StartupPath + @"\Configs\Daily PM Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_OutputD());
                                uc_OutputD _outputD = (pnlUserControl.Controls[0] as uc_OutputD);
                                _outputD.choStandardAnalysisD.Checked = true;
                                _outputD.choQuarterlyPeakModelDataD.Checked = true;
                                _outputD.choSpeciesFractionsFileD.Checked = true;
                                _outputD.choActionsExtractAllD.Checked = true;
                                break;
                            case enumAnalysis.Ozone:
                                CommonClass.CurrentBaseScenario.configuration = new OzoneAnalysisConfiguration();
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO = new ChooseDesiredOutputO();
                                pboPollutant.Image = Resources.O3;
                                lblAnalysis.Text = Language.Localization.GetValue("Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\Ozone Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_DesiredOutputOzone());
                                uc_DesiredOutputOzone _outputO = (pnlUserControl.Controls[0] as uc_DesiredOutputOzone);
                                _outputO.choPointForecastOzone.Checked = true;
                                _outputO.choExtractAllOzone.Checked = true;
                                _outputO.choQuarterlyModelData.Checked = true;
                                break;
                            case enumAnalysis.Visibility:
                                CommonClass.CurrentBaseScenario.configuration = new VisibilityAnalysisConfiguration();
                                (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV = new ChooseDesiredOutputV();
                                pboPollutant.Image = Resources.Haze;
                                lblAnalysis.Text = Language.Localization.GetValue("Visibility Analysis");
                                path = Application.StartupPath + @"\Configs\Visibility Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_ChooseDesiredOutputV());
                                uc_ChooseDesiredOutputV _outputV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                                _outputV.choVisibilityLevels.Checked = true;
                                _outputV.rbtnNewIMPROVEAlgorithmVisibility.Checked = true;
                                _outputV.rbtnModelGridCellatMonitorVisi.Checked = true;
                                _outputV.choExtractAllVisibility.Checked = true;
                                break;
                            case enumAnalysis.SSIAAnnualPM:
                                CommonClass.CurrentBaseScenario.configuration = new SSIAAnnualPMAnalysisConfiguration();
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA PM Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                break;
                            case enumAnalysis.SSIADailyPM:
                                CommonClass.CurrentBaseScenario.configuration = new SSIADailyPMAnalysisConfiguration();
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Daily PM Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA PM Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                break;
                            case enumAnalysis.SSIAOzone:
                                CommonClass.CurrentBaseScenario.configuration = new SSIAOzoneAnalysisConfiguration();
                                pboPollutant.Image = Resources.O3;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA Ozone Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                break;
                            case enumAnalysis.SSIADeposition:                                                         //added by Lijiabin
                                CommonClass.CurrentBaseScenario.configuration = new SSIADepositionConfiguration();
                                pboPollutant.Image = Resources.Deposition;
                                lblAnalysis.Text = Language.Localization.GetValue("SSIA - Deposition Analysis");
                                path = Application.StartupPath + @"\Configs\SSIA Deposition Analysis.xml";
                                pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                                _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                                _analysisOption.choUseModelFRMData.Checked = false;
                                break;
                            case enumAnalysis.AnnualPMChina:
                                CommonClass.CurrentBaseScenario.configuration = new AnnualPMAnalysisChinaConfiguration();
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\Annual PM Analysis China.xml";
                                pnlUserControl.Controls.Add(new uc_ModelDataChina());
                                uc_ModelDataChina modelDataChina = (pnlUserControl.Controls[0] as uc_ModelDataChina);
                                modelDataChina.InitializeControl();
                                //modelDataChina.rbtnQuarterlyAverageDataChina.Checked = true;
                                //CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_Base_Quarterly.csv";
                                //modelDataChina.txtBaselineChina.Text = Path.GetFileName(CommonClass.baseModelFile);
                                //CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_L_R_0.5_0.5_Quarterly.csv";
                                //modelDataChina.txtControlChina.Text = Path.GetFileName(CommonClass.futureModelFile);
                                break;
                            case enumAnalysis.OzoneChina:
                                CommonClass.CurrentBaseScenario.configuration = new OzoneAnalysisChinaConfiguration();
                                pboPollutant.Image = Resources.O3;
                                lblAnalysis.Text = Language.Localization.GetValue("Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\Ozone Analysis China.xml";
                                pnlUserControl.Controls.Add(new uc_ModelDataOzoneChina());
                                uc_ModelDataOzoneChina modelDataOzoneChina = (pnlUserControl.Controls[0] as uc_ModelDataOzoneChina);
                                modelDataOzoneChina.InitializeControl();
                                //CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2013_YRD.csv";
                                //modelDataOzoneChina.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                                //CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2017_YRD.csv";
                                //modelDataOzoneChina.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                                break;
                            case enumAnalysis.BenMAPAnnualPM:
                                CommonClass.CurrentBaseScenario.configuration = new BenMAPAnnualPMAnalysisConfiguration();
                                pboPollutant.Image = Resources.PM;
                                lblAnalysis.Text = Language.Localization.GetValue("BenMAP - Annual PM Analysis");
                                path = Application.StartupPath + @"\Configs\BenMAP_Annual PM.xml";
                                pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_ModelData());
                                uc_BenMAP_AnnualPM_ModelData model = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_ModelData);
                                model.rbtnDailyModelA.Checked = true;
                                CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["baselineModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2011eh.camx.grid.csv";//PM_small_USA_12km_2011.csv";
                                model.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["forecastModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2017eh.camx.grid.csv";//PM_small_USA_12km_2018.csv";
                                model.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                model.cboSpatialGridA.SelectedIndex = 0;
                                break;
                            case enumAnalysis.BenMAPSeasonalOzone:
                                CommonClass.CurrentBaseScenario.configuration = new BenMAPOzoneAnalysisConfiguration();
                                pboPollutant.Image = Resources.O3;
                                lblAnalysis.Text = Language.Localization.GetValue("BenMAP - Ozone Analysis");
                                path = Application.StartupPath + @"\Configs\BenMAP_Ozone.xml";
                                pnlUserControl.Controls.Add(new uc_BenMap_Ozone_ModelData());
                                uc_BenMap_Ozone_ModelData benMapOzoneModel = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_ModelData);
                                CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["Ozone"]["baselineModelDataFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2011.csv";
                                CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["Ozone"]["forecastModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2018.csv";
                                benMapOzoneModel.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                                benMapOzoneModel.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                                break;
                            default:
                                break;
                        }
                        loadTreeNodes(trvAnalysis.Nodes, path);
                        // -------------initialize picture of all tree nodes------------
                        foreach (TreeNode tr in trvAnalysis.Nodes)
                        {
                            InitNodeImage(tr);
                            //ChangeNodeImage(tr);
                        }
                        //if (CommonClass.CurrentAnalysis==enumAnalysis.SSIADeposition)     //added by Lijiabin
                        //{
                        //    Ssia_useMonitor = false;                            
                        //}
                        #endregion
                    }
                    //_stips = "Choose Desired Output";
                    if (trvAnalysis.Nodes.Count > 0)
                        _stips = trvAnalysis.Nodes[0].Text;
                    else
                        _stips = "";
                    //if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                    //{
                    //    _stips = "Single Source Impact Analysis Option";
                    //}
                    //if (CommonClass.CurrentAnalysis == enumAnalysis.AnnualPMChina || CommonClass.CurrentAnalysis == enumAnalysis.OzoneChina)
                    //{
                    //    _stips = "Model Data Input";
                    //}
                    lblSteps.Text = Language.Localization.GetValue(_stips).Replace("&", "&&");
                    tips.SetToolTip(pboHelp, Language.Localization.GetValue(_stips));
                }
                //_stips = "Choose desired output";
                //tips.SetToolTip(pboHelp, _stips);

                #region Language added by Yangwenwei
                if (LanguageOld.CurrentLanguage() == "Ch")
                {
                    //Language.GetLanguagePath();
                    Dictionary<string, string> langdic = new Dictionary<string, string>();
                    LanguageOld.SetDicFromXml(this, langdic);
                    LanguageOld.ChangeLanguage(langdic, this);
                }
                #endregion

                #region clean map
                if (!CommonClass.IsDataViewerState)
                {
                    lstSpeciesTypeMap.Items.Clear();
                    CommonClass.dicBlend.Clear();
                    CommonClass.dicLayerValueRange.Clear();
                    cboSpeciesTypeGIS.Items.Clear();
                    lblMinMax.Visible = false;
                    lblMinMaxGIS.Visible = false; //added by Yangwenwei
                    dgvGridInfo.DataSource = null;
                    btnZoomIn.Enabled = false;
                    btnZoomOut.Enabled = false;
                    btnChangeBoundary.Enabled = false;
                    tsbtnPlotMonitors.Enabled = false; plotControl1.IsDrawMonitors = false; plotControl1.isMarkSelectedPoint = false;
                    btnSavePic.Enabled = false;
                    btnBar.Visible = false;
                    btnDistribution.Visible = false;
                    btnFrequency.Visible = false;
                    //btnSetting.Location = new System.Drawing.Point(zgcChart.Location.X + zgcChart.Size.Width - btnSetting.Size.Width, btnSetting.Location.Y);
                    //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 18);
                    //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 7);
                    lblMAPname.Text = "";
                    if (CommonClass.modelDefinition == null)
                    {
                        CommonClass.modelDefinition = new ModelDefinition();
                        CommonClass.modelDefinition.ActiveGridType = "12km";
                        CommonClass.modelDefinition.ParseModelDef("", !CommonClass.currentProjisLCC());
                    }
                    if (CommonClass.modelDefinition.ShapeLCCFiles == null)
                        CommonClass.modelDefinition.ShapeLCCFiles = new Dictionary<string, Dictionary<string, double[,]>>();
                    if (!CommonClass.modelDefinition.ShapeLCCFiles.ContainsKey(CommonClass.modelDefinition.ActiveGridType))
                        CommonClass.modelDefinition.ShapeLCCFiles.Add(CommonClass.modelDefinition.ActiveGridType, new Dictionary<string, double[,]>());
                    if (CommonClass.currentProjisLCC())
                    {
                        if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("state"))
                        {
                            CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state.csv");
                            CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("state", CommonClass.ShapeLCC);
                        }
                    }
                    else
                    {
                        if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("state_utm"))
                        {
                            CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state_utm.csv");
                            CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("state_utm", CommonClass.ShapeLCC);
                        }
                    }
                    //SMAT-China Map added by Yangwenwei
                    if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("region") && LanguageOld.IsSMATChina)
                    {
                        CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\China_Region.csv");
                        CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("region", CommonClass.ShapeLCC);
                    }
                    //slow - add when draw map
                    //if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("county"))
                    //{
                    //    CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\county.csv");
                    //    CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("county", CommonClass.ShapeLCC);
                    //}
                    CommonClass.modelDefinition.ParseModelDef("", !CommonClass.currentProjisLCC());
                    plotControl1.modelDef = CommonClass.modelDefinition.modelDef;
                    if (LanguageOld.IsSMATChina)
                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("region");
                    else if (!CommonClass.currentProjisLCC())
                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state_utm");
                    else
                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state");
                    plotControl1.ColorBlendControl = colorBlendMap;
                    colorBlendMap.ValueUnit = CommonClass.modelDefinition.modelDef.ValueUnit;
                    CommonClass.modelDefinition.GridValues = new Dictionary<string, double>();
                    plotControl1.UseInterpolation = true;
                    Dictionary<string, double> dic = new Dictionary<string, double>();
                    dic.Add("0,0", 0);
                    plotControl1.NewGridValues = dic;
                    plotControl1.UseInterpolation = false;
                    dataDomainGIS = null;
                }
                #endregion
                //added by Yangwenwei
                if ((!LanguageOld.IsSMATChina))// && groupBox3.Left == 6)
                {
                    gbxQuantifiers.Visible = true;
                    splitContainerData.Panel1MinSize = 25;
                    splitContainerData.SplitterDistance = 214;
                    //groupBox3.Width -= 220;
                    //groupBox3.Left = 226;
                }
                else if (LanguageOld.IsSMATChina)// && groupBox3.Left == 226)
                {
                    gbxQuantifiers.Visible = false;
                    splitContainerData.Panel1MinSize = 0;
                    splitContainerData.SplitterDistance = 0;
                    //groupBox3.Width += 220;
                    //groupBox3.Left = 6;
                }
               
                if (this.ParentForm != null)
                {
                    if (LanguageOld.IsSMATChina || Language.Localization.CurrentLanguage == "zh")
                        (this.ParentForm as Main).Text = "SMAT-China " + CommonClass.versionSMATChina;
                    else
                    {

                        (this.ParentForm as Main).Text = "SMAT-CE " + CommonClass.VersionNumber; //"SMAT-CE " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Count() - 4);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// 为treelistview添加数据
        /// </summary>
        /// <param name="fileName">文件路径</param>
        public void addTreeListView(string fileName)
        {
            try
            {
                tlvDataViewer.Items.Clear();
                tlvDataViewer.Sorting = SortOrder.None;
                tlvDataViewer.Items.Sortable = false;
                tlvDataViewer.ExpandAll();

                TreeListViewItem itemProject;
                TreeListViewItem itemPROJECT;
                TreeListViewItem itemConfigurationBacth;
                TreeListViewItem itemCFG;
                if (CommonClass.CurrentBaseScenario.lstOutput == null)
                {
                    itemProject = new TreeListViewItem() { Name = "project", Font = new System.Drawing.Font("Calibri", 13f, FontStyle.Underline), Text = "Project Name", Tag = CommonClass.CurrentBaseScenario.configuration.configurationName.Trim().ToLower(), ImageIndex = 0 };
                    itemProject.Expand();

                    itemPROJECT = new TreeListViewItem() { Name = CommonClass.FileName, Text = CommonClass.CurrentBaseScenario.configuration.configurationName, Tag = "proj", ImageIndex = 1 };
                    itemProject.Items.Add(itemPROJECT);

                    tlvDataViewer.Items.Add(itemProject);

                    //itemConfigurationBacth = new TreeListViewItem() { Name = "configurationbatch", Font = new System.Drawing.Font("Calibri", 13f, FontStyle.Underline), Text = "Configuration & Batch File", Tag = CommonClass.CurrentBaseScenario.configuration.configurationName.Trim().ToLower(), ImageIndex = 0 };
                    //itemConfigurationBacth.Expand();

                    //itemCFG = new TreeListViewItem() { Name = CommonClass.CurrentBaseScenario.configuration.configurationPath, Text = "Configuration & Batch File", Tag = "cfg", ImageIndex = 1 };
                    //itemConfigurationBacth.Items.Add(itemCFG);
                    //itemCFG.SubItems.Add("Configuration");
                    //itemCFG.SubItems.Add(Convert.ToString(fileName.Length) + "kb");
                    return;
                }

                itemProject = new TreeListViewItem() { Name = "project", Font = new System.Drawing.Font("Calibri", 13f, FontStyle.Underline), Text = "Project Name", Tag = CommonClass.CurrentBaseScenario.configuration.configurationName.Trim().ToLower(), ImageIndex = 0 };
                itemProject.Expand();

                itemPROJECT = new TreeListViewItem()
                {
                    Name = CommonClass.FileName,
                    Text = CommonClass.CurrentBaseScenario.configuration.configurationName,
                    Tag = "proj",
                    ImageIndex = 1,
                    ToolTipText = "Double-click to view analysis settings"
                };
                itemProject.Items.Add(itemPROJECT);

                TreeListViewItem itemLog = new TreeListViewItem() { Name = "audittrailreport", Font = new System.Drawing.Font("Calibri", 13f, FontStyle.Underline), Text = "Log & Msg", Tag = CommonClass.CurrentBaseScenario.configuration.configurationName.Trim().ToLower(), ImageIndex = 0 };
                itemLog.Expand();

                TreeListViewItem itemLOG = new TreeListViewItem()
                {
                    Name = "logfile",
                    Text = "Log & Msg",
                    Tag = "logfile",
                    ImageIndex = 1,
                    ToolTipText = "Double-click to view log"
                };
                itemLog.Items.Add(itemLOG);
                itemLOG.SubItems.Add("Run Log");
                itemLOG.SubItems.Add("0kb");

                itemConfigurationBacth = new TreeListViewItem() { Name = "configurationbatch", Font = new System.Drawing.Font("Calibri", 13f, FontStyle.Underline), Text = "Configuration & Batch File", Tag = CommonClass.CurrentBaseScenario.configuration.configurationName.Trim().ToLower(), ImageIndex = 0 };
                itemConfigurationBacth.Expand();

                itemCFG = new TreeListViewItem()
                {
                    Name = CommonClass.CurrentBaseScenario.configuration.configurationPath,
                    Text = "Configuration & Batch File",
                    Tag = "cfg",
                    ImageIndex = 1,
                    ToolTipText = "Double-click to view config"
                };
                itemConfigurationBacth.Items.Add(itemCFG);
                itemCFG.SubItems.Add("Configuration");
                itemCFG.SubItems.Add(Convert.ToString(fileName.Length) + "kb");

                TreeListViewItem itemOutput = new TreeListViewItem() { Name = "outputfiles", Font = new Font("Calibri", 13f, FontStyle.Underline), Text = "Output Files", Tag = "outputfilestitle", ImageIndex = 0 };
                itemOutput.Expand();
                itemOutput.Items.Sortable = false;
                itemOutput.Items.SortOrder = SortOrder.None;
                TreeListViewItem itemFiles = new TreeListViewItem();
                int index = -1;
                foreach (var item in CommonClass.CurrentBaseScenario.lstOutput)
                {
                    index++;
                    if (item.outputName.Contains("Annual PM25 Point") || item.outputName.Contains("Daily PM25 Point")
                        || item.outputName.Contains("Ozone Monitors -- monitor data") || item.outputName.Contains("Forecasted Visibility Data"))
                    {
                        if (index != 0)
                        {
                            CommonClass.CurrentBaseScenario.lstOutput.RemoveAt(index);
                            CommonClass.CurrentBaseScenario.lstOutput.Insert(0, item);
                        }
                        break;
                    }
                }


                foreach (BaseOutput baseOutput in CommonClass.CurrentBaseScenario.lstOutput)
                {
                    string _text = baseOutput.outputName.Substring((CommonClass.CurrentBaseScenario.configuration.configurationName + " ").Length, baseOutput.outputName.Length - (CommonClass.CurrentBaseScenario.configuration.configurationName + " ").Length);
                    if (_text.StartsWith("-"))
                    {
                        _text = _text.Substring(1).Trim();
                    }
                    itemFiles = new TreeListViewItem()
                    {
                        Name = baseOutput.outputFilePath,
                        Text = _text,
                        Tag = "outputfiles",
                        ImageIndex = 1,
                        ToolTipText = "Double-click to view data/map"
                    };
                    itemOutput.Items.Add(itemFiles);
                    itemFiles.SubItems.Add(baseOutput.outputType);
                    itemFiles.SubItems.Add(Convert.ToString(baseOutput.outputSize) + "kb");
                }
                tlvDataViewer.Items.Add(itemProject);
                tlvDataViewer.Items.Add(itemOutput);
                tlvDataViewer.Items.Add(itemLog);
                tlvDataViewer.Items.Add(itemConfigurationBacth);
                //tlvDataViewer.Refresh();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// 最大化tabcontrol，使数据展示部分最大化
        /// </summary>
        public void maxViewer()
        {
            try
            {
                Extent exLast = mainMap.ViewExtents.Clone() as Extent;
                if (!isMaxView)
                {
                    this.stcMain.Panel1MinSize = 0;
                    this.stcMain.SplitterDistance = 0;
                    this.stcMain.BorderStyle = BorderStyle.None;
                    this.scrRight.Panel1MinSize = 0;
                    this.scrRight.SplitterDistance = 0;
                    this.scrRight.FixedPanel = FixedPanel.Panel1;
                    this.scrRight.BorderStyle = BorderStyle.None;
                    //mainMap.ZoomToMaxExtent();
                    isMaxView = true;
                }
                else
                {
                    if (CommonClass.OutputNavigator)
                    {
                        this.stcMain.Panel1MinSize = 338;
                        this.stcMain.SplitterDistance = 338;
                        this.stcMain.FixedPanel = FixedPanel.Panel1;
                        this.stcMain.BorderStyle = BorderStyle.None;
                        this.scrRight.Panel1MinSize = 104;
                        this.scrRight.SplitterDistance = 104;
                        this.scrRight.FixedPanel = FixedPanel.Panel1;
                        this.scrRight.BorderStyle = BorderStyle.None;
                        //mainMap.ZoomToMaxExtent();
                    }
                    else
                    {
                        this.stcMain.Panel1MinSize = 491;
                        this.stcMain.SplitterDistance = 491;
                        this.stcMain.FixedPanel = FixedPanel.Panel1;
                        this.stcMain.BorderStyle = BorderStyle.None;
                        this.scrRight.Panel1MinSize = 104;
                        this.scrRight.SplitterDistance = 104;
                        this.scrRight.FixedPanel = FixedPanel.Panel1;
                        this.scrRight.BorderStyle = BorderStyle.None;
                    }
                    isMaxView = false;
                }
                if (mainMap.Layers.Count == 1)
                {
                    if (cboStandardLayers.SelectedItem.ToString() == "China")
                    {
                        mainMap.ViewExtents = new Extent()
                        {
                            MaxX = 2114399,
                            MaxY = 2906359,
                            MinX = -3397624,
                            MinY = -2567910
                        };
                    }
                    else
                    {
                        if (CommonClass.currentProjisLCC())
                        {
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2325850.8,
                                MaxY = 1275319.5,
                                MinX = -2274714.4,
                                MinY = -1604646.2
                            };
                        }
                        else
                        {
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2084597.7,
                                MaxY = 6873065.9,
                                MinX = -2728406.7,
                                MinY = 1935195.9
                            };

                        }
                    }
                    //mainMap.ViewExtents = mainMap.Extent;
                }
                else
                {
                    mainMap.ViewExtents = exLast;
                    //double MaxX = exLast.MaxX;
                    //double MaxY = exLast.MaxY;
                    //double MinX = exLast.MinX;
                    //double MinY = exLast.MinY;
                    //mainMap.ViewExtents = new Extent()
                    //{
                    //    MaxX = MaxX,
                    //    MaxY = MaxY,
                    //    MinX = MinX,
                    //    MinY = MinY,
                    //};
                }
                mainMap.Refresh();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //---------------dynamic loading treeview-------------------
        private void loadTreeNodes(TreeNodeCollection node, string fileName)
        {
            try
            {
                // added & modified by Yangwewei 2013 11.12
                string text = "text-" + LanguageOld.CurrentLanguage();
                string tooltip = "tooltip-" + LanguageOld.CurrentLanguage();

                var root = XElement.Load(fileName);
                foreach (var element in root.Elements())
                {
                    TreeNode tNode = new TreeNode();
                    tNode.Text = Language.Localization.GetValue(element.Attribute(text).Value);
                    tNode.Name = element.Attribute("name").Value;
                    tNode.ToolTipText = Language.Localization.GetValue(element.Attribute(tooltip).Value);
                    tNode.ImageKey = element.Attribute("icon").Value;
                    tNode.SelectedImageKey = element.Attribute("icon").Value;
                    node.Add(tNode);
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //-------------initialize picture of tree nodes----------------
        private void InitNodeImage(TreeNode node)
        {
            try
            {
                node.ImageKey = _unreadyImageKey;
                node.SelectedImageKey = _unreadyImageKey;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //-------------Change pictures of nodes---------------
        private void ChangeNodeImage(TreeNode node)
        {
            try
            {
                node.ImageKey = _readyImageKey;
                node.SelectedImageKey = _readyImageKey;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //---------------Error node----------------
        private void errorNode(TreeNode node)
        {
            try
            {
                node.ImageKey = _errorImageKey;
                node.SelectedImageKey = _errorImageKey;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }

        }

        /// <summary>
        /// create new project
        /// </summary>
        public void createCfg(int n)
        {
            try
            {
                //string msg = "";
                string path = null;
                lblSteps.Text = Language.Localization.GetValue("Choose Desired Output");
                //---------------Tips for save or not-----------------
                DialogResult rtn = MessageBox.Show(Language.Localization.GetValue("Save project?"), Language.Localization.GetValue("Tip"), MessageBoxButtons.YesNo);
                if (rtn == DialogResult.Yes)
                {

                }
                clearAll();
                switch (n)
                {
                    case 1:
                        lblAnalysis.Text = Language.Localization.GetValue("Annual PM Analysis");
                        path = Application.StartupPath + @"\Configs\Annual PM Analysis.xml";
                        pnlUserControl.Controls.Add(new uc_OutputA());
                        break;
                    case 2:
                        lblAnalysis.Text = Language.Localization.GetValue("Daily PM Analysis");
                        path = Application.StartupPath + @"\Configs\Daily PM Analysis.xml";
                        pnlUserControl.Controls.Add(new uc_OutputD());
                        break;
                    case 3:
                        lblAnalysis.Text = Language.Localization.GetValue("Ozone Analysis");
                        path = Application.StartupPath + @"\Configs\Ozone Analysis.xml";
                        pboPollutant.Image = Resources.O3;
                        pnlUserControl.Controls.Add(new uc_DesiredOutputOzone());
                        break;
                    case 4:
                        lblAnalysis.Text = Language.Localization.GetValue("Visibility Analysis");
                        path = Application.StartupPath + @"\Configs\Visibility Analysis.xml";
                        pboPollutant.Image = Resources.Haze;
                        pnlUserControl.Controls.Add(new uc_ChooseDesiredOutputV());
                        break;
                }
                loadTreeNodes(trvAnalysis.Nodes, path);
                _stips = "Choose Desired output";
                tips.SetToolTip(pboHelp, Language.Localization.GetValue(_stips));
                for (int i = 0; i < trvAnalysis.Nodes.Count; i++)
                {
                    foreach (TreeNode tr in trvAnalysis.Nodes[i].Nodes)
                    {
                        InitNodeImage(tr);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// Clear previous
        /// </summary>
        public void clearAll()
        {
            try
            {
                this.btnSave.Enabled = false;
                this.btnSaveRun.Enabled = false;
                this.pnlUserControl.Controls.Clear();
                this.trvAnalysis.Nodes.Clear();
                this.tbcFunction.SelectedTab = tbpGIS;
                if (tlvDataViewer.Items.Count > 1)
                    tlvDataViewer.Items.Clear();
                if (tlvLogFile.Items.Count > 0)
                    tlvLogFile.Items.Clear();
                if (dgvDataView.Rows.Count > 0)
                    dgvDataView.Rows.Clear();
                if (clboQuantifiers.Items.Count > 0)
                    clboQuantifiers.Items.Clear();
                if (dgvDataList.Columns.Count > 0)
                    dgvDataList.Columns.Clear();
                if (cboFilter.Items.Count > 0)
                    cboFilter.Items.Clear();
                if (cboType.Items.Count > 0)
                    cboType.Items.Clear();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        #region check UC
        public string checkDataInputA()
        {
            try
            {
                AnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_DataInputA _dataInputA = (pnlUserControl.Controls[0] as uc_DataInputA);
                if (_dataInputA.rbtnMonitorFileA.Checked)
                {
                    //check species monitor data file
                    #region
                    if (CommonClass.speciesMonitorFile != null && CommonClass.speciesMonitorFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.speciesMonitorFile))
                        { errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File does not exist!\n")); }
                        else
                        {
                            fileStream = new FileStream(CommonClass.speciesMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("no3r") && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("ocb")
                                    && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("salt") && fieldNameAdd.Contains("don") && fieldNameAdd.Contains("h2o_aim") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("so4_3s") && fieldNameAdd.Contains("crustal_alt")
                                    && fieldNameAdd.Contains("frm_mass") && fieldNameAdd.Contains("measured_fm") && fieldNameAdd.Contains("rcfm") && fieldNameAdd.Contains("al") && fieldNameAdd.Contains("ca") && fieldNameAdd.Contains("fe") && fieldNameAdd.Contains("ti") && fieldNameAdd.Contains("si") && fieldNameAdd.Contains("epa_flag")
                                    && fieldNameAdd.Contains("user_flag") && fieldNameAdd.Length == 28)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Species Monitor Data File!\n"));
                    }
                    #endregion
                    //check unofficial monitor data file
                    #region
                    if (CommonClass.unofficialPMFile != null && CommonClass.unofficialPMFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.unofficialPMFile))
                            errorTipBuilder.Append(Language.Localization.GetValue("Unofficial Daily Average PM25 Data File path does not exist!\n"));
                        else
                        {
                            fileStream = new FileStream(CommonClass.unofficialPMFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Unofficial Daily Average PM25 Data File is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date")
                                    && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("epa_flag") && fieldNameAdd.Contains("user_flag") && fieldNameAdd.Length == 8)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Unofficial Daily Average PM25 Data File is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Unofficial Daily Average PM25 Data File!\n"));
                    }
                    #endregion
                }
                else
                {
                    if (_dataInputA.rbtnFractionA.Checked)//check species fractions file
                    {
                        #region
                        if (annualPMAnalysisConfiguration.outputChoiceAdvancedA != null
                            && (annualPMAnalysisConfiguration.outputChoiceAdvancedA.doNeighborFilePoint
                            || annualPMAnalysisConfiguration.outputChoiceAdvancedA.doNeighborFileSpatial))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Using species fractions file. Disable neighbor file creation.\n"));
                            errorNode(trvAnalysis.Nodes[1]);
                        }
                        if (_dataInputA.rbtnFractionA.Checked && _dataInputA.cboSpatialA.Text == "grad adj spatial field" && annualPMAnalysisConfiguration.outputChoiceAdvancedA != null
                            && (annualPMAnalysisConfiguration.outputChoiceAdvancedA.doInterpolatedSFETempAdj || annualPMAnalysisConfiguration.outputChoiceAdvancedA.doFutureOnlyVNA || annualPMAnalysisConfiguration.outputChoiceAdvancedA.doSpeciesFractionSpatial))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Using gradient-adjustment species fractions file spatial field. Disable VNA files creation.\n"));
                            errorNode(trvAnalysis.Nodes[1]);
                        }
                        if (_dataInputA.rbtnFractionA.Checked && _dataInputA.cboSpatialA.Text == "spatial field" && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                           && ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj_GradAdj || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyEvna || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_GraAdj))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Using species fractions file spatial field. Disable eVNA files creation.\n"));
                            errorNode(trvAnalysis.Nodes[1]);
                        }
                        //if (((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null
                        //    && ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doStandardAnalysis || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doSpeciesFraction
                        //    || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doUsedQuarterlyAvgModelData)) ||
                        //    ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFilePoint))
                        //{
                        if (CommonClass.speciesFractionFilePoint != null && CommonClass.speciesFractionFilePoint.Length > 0)
                        {
                            if (!File.Exists(CommonClass.speciesFractionFilePoint))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Point Species Fractions File path does not exist!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.speciesFractionFilePoint, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Point Species Fractions File is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Contains("monitor_lat") && fieldNameAdd.Contains("monitor_long") && fieldNameAdd.Contains("quarter")
                                        && fieldNameAdd.Contains("pm25_mass_frac") && fieldNameAdd.Contains("fcr") && fieldNameAdd.Contains("fec") && fieldNameAdd.Contains("fnh4") && fieldNameAdd.Contains("focm") && fieldNameAdd.Contains("fso4")
                                        && fieldNameAdd.Contains("fno3") && fieldNameAdd.Contains("fwater") && fieldNameAdd.Contains("fsalt") && fieldNameAdd.Contains("blank_mass") && fieldNameAdd.Contains("don") && fieldNameAdd.Contains("i_so4")
                                        && fieldNameAdd.Contains("i_no3r") && fieldNameAdd.Contains("i_ocb") && fieldNameAdd.Contains("i_ec") && fieldNameAdd.Contains("i_crustal") && fieldNameAdd.Contains("i_don") && fieldNameAdd.Contains("i_nh4")
                                        && fieldNameAdd.Contains("i_no3") && fieldNameAdd.Contains("i_salt") && fieldNameAdd.Length == 26)
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Point Species Fractions File is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Point Species Fractions File!\n"));
                        }
                        //}
                        #endregion
                        //check species fractions file-spatial field
                        #region
                        if (_dataInputA.cboSpatialA.Text == "spatial field" && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                            && ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyVNA || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial))
                        {
                            if (CommonClass.speciesFractionFileSpatial != null && CommonClass.speciesFractionFileSpatial.Length > 0)
                            {
                                if (!File.Exists(CommonClass.speciesFractionFileSpatial))
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Spatial Field Species Fractions File path does not exist!\n"));
                                }
                                else
                                {
                                    fileStream = new FileStream(CommonClass.speciesFractionFileSpatial, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                    streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                    frequency = streamReader.ReadLine();
                                    if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Spatial Field Species Fractions File is ill-formatted data!\n"));
                                    }
                                    else
                                    {
                                        string fieldName = streamReader.ReadLine();
                                        string[] fieldNameAdd = new string[] { };
                                        if (fieldName != null && fieldName.Length > 0)
                                        {
                                            fieldName = fieldName.Replace(" ", "");
                                            fieldName = fieldName.Replace("\"", "");
                                            fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                        }
                                        if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("gridcell_lat") && fieldNameAdd.Contains("gridcell_long") && fieldNameAdd.Contains("quarter") && fieldNameAdd.Contains("pm25_mass_frac")
                                        && fieldNameAdd.Contains("fcr") && fieldNameAdd.Contains("fec") && fieldNameAdd.Contains("fnh4") && fieldNameAdd.Contains("focm") && fieldNameAdd.Contains("fso4")
                                        && fieldNameAdd.Contains("fno3") && fieldNameAdd.Contains("fwater") && fieldNameAdd.Contains("fsalt") && fieldNameAdd.Contains("blank_mass") && fieldNameAdd.Contains("don") && fieldNameAdd.Contains("i_so4")
                                        && fieldNameAdd.Contains("i_no3r") && fieldNameAdd.Contains("i_ocb") && fieldNameAdd.Contains("i_ec") && fieldNameAdd.Contains("i_crustal") && fieldNameAdd.Contains("i_don") && fieldNameAdd.Contains("i_nh4")
                                        && fieldNameAdd.Contains("i_no3") && fieldNameAdd.Contains("i_salt") && fieldNameAdd.Length == 24)
                                        {
                                            ok = true;
                                        }
                                        else
                                        {
                                            ok = false;
                                        }
                                        if (!ok)
                                        {
                                            errorTipBuilder.Append(Language.Localization.GetValue("Spatial Field Species Fractions File is ill-formatted data!\n"));
                                        }
                                    }
                                    ok = false;
                                    fileStream.Dispose();
                                    streamReader.Dispose();
                                }
                            }
                            else
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Please select a Spatial Field Species Fractions File!\n"));
                            }
                        }
                        else if (_dataInputA.cboSpatialA.Text == "grad adj spatial field" && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                            && ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj_GradAdj || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyEvna || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_GraAdj))
                        {
                            if (CommonClass.speciesFractionFileSpatial != null && CommonClass.speciesFractionFileSpatial.Length > 0)
                            {
                                if (!File.Exists(CommonClass.speciesFractionFileSpatial))
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Gradient-adjusted Spatial Field Species Fractions File path does not exist!\n"));
                                }
                                else
                                {
                                    fileStream = new FileStream(CommonClass.speciesFractionFileSpatial, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                    streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                    frequency = streamReader.ReadLine();
                                    if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Gradient-adjusted Spatial Field Species Fractions File is ill-formatted data!\n"));
                                    }
                                    else
                                    {
                                        string fieldName = streamReader.ReadLine();
                                        string[] fieldNameAdd = new string[] { };
                                        if (fieldName != null && fieldName.Length > 0)
                                        {
                                            fieldName = fieldName.Replace(" ", "");
                                            fieldName = fieldName.Replace("\"", "");
                                            fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                        }
                                        if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("gridcell_lat") && fieldNameAdd.Contains("gridcell_long") && fieldNameAdd.Contains("quarter") && fieldNameAdd.Contains("pm25_mass_frac_ga") && fieldNameAdd.Contains("fcr_ga") && fieldNameAdd.Contains("fec_ga")
                                            && fieldNameAdd.Contains("fnh4_ga") && fieldNameAdd.Contains("focm_ga") && fieldNameAdd.Contains("fso4_ga") && fieldNameAdd.Contains("fno3_ga") && fieldNameAdd.Contains("fwater_ga") && fieldNameAdd.Contains("fsalt_ga") && fieldNameAdd.Contains("blank_mass_ga")
                                            && fieldNameAdd.Contains("don_ga") && fieldNameAdd.Contains("i_so4_ga") && fieldNameAdd.Contains("i_no3r_ga") && fieldNameAdd.Contains("i_ocb_ga") && fieldNameAdd.Contains("i_ec_ga") && fieldNameAdd.Contains("i_crustal_ga") && fieldNameAdd.Contains("i_don_ga")
                                            && fieldNameAdd.Contains("i_nh4_ga") && fieldNameAdd.Contains("i_no3_ga") && fieldNameAdd.Contains("i_salt_ga") && fieldNameAdd.Length == 24)
                                        {
                                            ok = true;
                                        }
                                        else
                                        {
                                            ok = false;
                                        }
                                        if (!ok)
                                        {
                                            errorTipBuilder.Append(Language.Localization.GetValue("Gradient-adjusted Spatial Field Species Fractions File is ill-formatted data!\n"));
                                        }
                                    }
                                    ok = false;
                                    fileStream.Dispose();
                                    streamReader.Dispose();
                                }
                            }
                            else
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Please select a Gradient-adjusted Spatial Field Species Fractions File!\n"));
                            }
                        }
                        //}
                        #endregion
                    }
                }

                //check official monitor data
                if (CommonClass.officialPMFile != null && CommonClass.officialPMFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.officialPMFile))
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File path does not exist!\n"));
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.officialPMFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("ndays")
                                && fieldNameAdd.Contains("_substitution_code") && fieldNameAdd.Contains("completion_code") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Length == 11)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select an Official Quarterly Average FRM Data File!\n"));
                }

                if (_dataInputA.rbtnDailyModelA.Checked)//check daily model data
                {
                    //baseline model data
                    if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.baseModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Baseline Model Data File!\n"));
                    }

                    //control model data
                    if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.futureModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Forecast Model Data File!\n"));
                    }
                }

                if (_dataInputA.rbtnQuarterlyModelA.Checked)//check quarterly model data
                {
                    //baseline model data
                    if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.baseModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Baseline Model Data File!\n"));
                    }

                    //control model data
                    if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.futureModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Forecast Model Data File!\n"));
                    }
                }

                if (_dataInputA.rbtnCMAQA.Checked)//CMAQ
                {

                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkDataInputD()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_DataInputD _dataInputD = (pnlUserControl.Controls[0] as uc_DataInputD);
                if (_dataInputD.rbtnSpeciesMonitorD.Checked)
                {
                    //check species monitor data file
                    if (CommonClass.speciesMonitorFile != null && CommonClass.speciesMonitorFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.speciesMonitorFile))
                        { errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File path does not exist!\n")); }
                        else
                        {
                            fileStream = new FileStream(CommonClass.speciesMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("no3r") && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("ocb")
                                    && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("salt") && fieldNameAdd.Contains("don") && fieldNameAdd.Contains("h2o_aim") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("so4_3s") && fieldNameAdd.Contains("crustal_alt")
                                    && fieldNameAdd.Contains("frm_mass") && fieldNameAdd.Contains("measured_fm") && fieldNameAdd.Contains("rcfm") && fieldNameAdd.Contains("al") && fieldNameAdd.Contains("ca") && fieldNameAdd.Contains("fe") && fieldNameAdd.Contains("ti") && fieldNameAdd.Contains("si") && fieldNameAdd.Contains("epa_flag")
                                    && fieldNameAdd.Contains("user_flag") && fieldNameAdd.Length == 28)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Species Monitor Data File!\n"));
                    }

                    //check unofficial monitor data file
                    if (CommonClass.unofficialPMFile != null && CommonClass.unofficialPMFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.unofficialPMFile))
                            errorTipBuilder.Append(Language.Localization.GetValue("Unofficial Daily Average PM25 Data File path does not exist!\n"));
                        else
                        {
                            fileStream = new FileStream(CommonClass.unofficialPMFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Unofficial Daily Average PM25 Data File is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date")
                                    && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("epa_flag") && fieldNameAdd.Contains("user_flag") && fieldNameAdd.Length == 8)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Unofficial Daily Average PM25 Data File is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Unofficial Daily Average PM25 Data File!\n"));
                    }
                }
                else
                {
                    if (_dataInputD.rbtnSpeciesFractionD.Checked)//check species fractions file
                    {
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doNeighborFilePoint)
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Using species fractions file. Disable neighbor file creation.\n"));
                            errorNode(trvAnalysis.Nodes[1]);
                        }
                        if (CommonClass.speciesFractionFilePoint != null && CommonClass.speciesFractionFilePoint.Length > 0)
                        {
                            if (!File.Exists(CommonClass.speciesFractionFilePoint))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Point Species Fractions File path does not exist!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.speciesFractionFilePoint, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Point Species Fractions File is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Contains("monitor_lat") && fieldNameAdd.Contains("monitor_long") && fieldNameAdd.Contains("quarter")
                                        && fieldNameAdd.Contains("pm25_mass_frac") && fieldNameAdd.Contains("fcr") && fieldNameAdd.Contains("fec") && fieldNameAdd.Contains("fnh4") && fieldNameAdd.Contains("focm") && fieldNameAdd.Contains("fso4")
                                        && fieldNameAdd.Contains("fno3") && fieldNameAdd.Contains("fwater") && fieldNameAdd.Contains("fsalt") && fieldNameAdd.Contains("blank_mass") && fieldNameAdd.Contains("don") && fieldNameAdd.Contains("i_so4")
                                        && fieldNameAdd.Contains("i_no3r") && fieldNameAdd.Contains("i_ocb") && fieldNameAdd.Contains("i_ec") && fieldNameAdd.Contains("i_crustal") && fieldNameAdd.Contains("i_don") && fieldNameAdd.Contains("i_nh4")
                                        && fieldNameAdd.Contains("i_no3") && fieldNameAdd.Contains("i_salt") && fieldNameAdd.Length == 26)
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Point Species Fractions File is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Point Species Fractions File!\n"));
                        }
                    }
                }

                //check official monitor data
                if (CommonClass.officialPMFile != null && CommonClass.officialPMFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.officialPMFile))
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File path does not exist!\n"));
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.officialPMFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("98_percentile")
                                && fieldNameAdd.Contains("epa_flag") && fieldNameAdd.Contains("completion_code") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Contains("rank98") && fieldNameAdd.Length == 12)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select an Official Quarterly Average FRM Data File!\n"));
                }

                if (_dataInputD.rbtnDailyModelDataD.Checked)//check daily model data
                {
                    //baseline model data
                    if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.baseModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Daily Baseline Model Data File can not be empty!\n"));
                    }

                    //control model data
                    if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.futureModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Daily Forecast Model Data File can not be empty!\n"));
                    }
                }

                if (_dataInputD.rbtnQuarterlyPeakModelDataD.Checked)//check quarterly model data
                {
                    //baseline model data
                    if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.baseModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Quarterly Baseline Model Data File can not be empty!\n"));
                    }

                    //control model data
                    if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.futureModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Quarterly Forecast Model Data File can not be empty!\n"));
                    }
                }

                if (_dataInputD.rbtnCMAQFileD.Checked)//CMAQ
                {

                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkDataInputO()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_DataInputOzone _dataInputO = (pnlUserControl.Controls[0] as uc_DataInputOzone);
                //check monitor data file
                if (CommonClass.ozoneMonitorFile != null && CommonClass.ozoneMonitorFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.ozoneMonitorFile))
                    { errorTipBuilder.Append(Language.Localization.GetValue("Monitor Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.ozoneMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "designvalue")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Monitor Data File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("poc") && fieldNameAdd.Contains("dvyear") && fieldNameAdd.Contains("o3") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Length == 9)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Monitor Data File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a Monitor Data File!\n"));
                }

                //check model data file-baseline
                if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.baseModelFile))
                    { errorTipBuilder.Append(Language.Localization.GetValue("Model Baseline Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Model Baseline File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("o3") && fieldNameAdd.Length == 6)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Model Baseline File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a Model Baseline File!\n"));
                }

                //check model data file-forecast
                if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.futureModelFile))
                    { errorTipBuilder.Append(Language.Localization.GetValue("Model Forecast Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Model Forecast File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("o3") && fieldNameAdd.Length == 6)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Model Forecast File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a Model Forecast File!\n"));
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        #region remove to DataInputV user control, by sclong, 2017-02-17
        /*
           public string checkDataInputV()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_DataInputV _dataInputV = (pnlUserControl.Controls[0] as uc_DataInputV);
                //check monitor data file
                if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm)
                {

                    if (CommonClass.improveAlgorithmOld != null && CommonClass.improveAlgorithmOld.Length > 0)
                    {
                        if (!File.Exists(CommonClass.improveAlgorithmOld))
                        { errorTipBuilder.Append(Language.Translate("Monitor Data File path does not exist!\n")); }
                        else
                        {
                            fileStream = new FileStream(CommonClass.improveAlgorithmOld, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Translate("Monitor Data File is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("frh") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("amm_no3") && fieldNameAdd.Contains("omc") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("pm10") && fieldNameAdd.Contains("cm") && fieldNameAdd.Contains("amm_so4") && fieldNameAdd.Contains("e_amm_so4") && fieldNameAdd.Contains("e_amm_no3") && fieldNameAdd.Contains("e_omc") && fieldNameAdd.Contains("e_ec") && fieldNameAdd.Contains("e_crustal") && fieldNameAdd.Contains("e_cm") && fieldNameAdd.Contains("tbext") && fieldNameAdd.Contains("dv") && fieldNameAdd.Contains("good_year") && fieldNameAdd.Contains("group") && fieldNameAdd.Contains("possible_ndays") && fieldNameAdd.Contains("ndays") && fieldNameAdd.Contains("complete_quarter") && fieldNameAdd.Contains("sf") && fieldNameAdd.Contains("so4f") && fieldNameAdd.Length == 29)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Translate("Monitor Data File is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Translate("Please select a Monitor Data File!\n"));
                    }
                }
                else
                {
                    if (CommonClass.improveAlgorithmNew != null && CommonClass.improveAlgorithmNew.Length > 0)
                    {
                        if (!File.Exists(CommonClass.improveAlgorithmNew))
                        { errorTipBuilder.Append(Language.Translate("Monitor Data File path does not exist!\n")); }
                        else
                        {
                            fileStream = new FileStream(CommonClass.improveAlgorithmNew, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Translate("Monitor Data File is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long")
                                    && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("frh") && fieldNameAdd.Contains("fsrh") && fieldNameAdd.Contains("flrh")
                                    && fieldNameAdd.Contains("fssrh") && fieldNameAdd.Contains("ss_rayleigh") && fieldNameAdd.Contains("sea_salt") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("amm_no3") && fieldNameAdd.Contains("omc") && fieldNameAdd.Contains("ec")
                                    && fieldNameAdd.Contains("pm10") && fieldNameAdd.Contains("cm") && fieldNameAdd.Contains("amm_so4") && fieldNameAdd.Contains("large_omc")
                                    && fieldNameAdd.Contains("small_omc") && fieldNameAdd.Contains("large_amm_so4") && fieldNameAdd.Contains("small_amm_so4")
                                    && fieldNameAdd.Contains("large_amm_no3") && fieldNameAdd.Contains("small_amm_no3") && fieldNameAdd.Contains("e_amm_so4")
                                    && fieldNameAdd.Contains("e_amm_no3") && fieldNameAdd.Contains("e_omc") && fieldNameAdd.Contains("e_ec") && fieldNameAdd.Contains("e_crustal")
                                    && fieldNameAdd.Contains("e_cm") && fieldNameAdd.Contains("e_sea_salt") && fieldNameAdd.Contains("tbext") && fieldNameAdd.Contains("dv")
                                    && fieldNameAdd.Contains("good_year") && fieldNameAdd.Contains("group") && fieldNameAdd.Contains("possible_ndays") && fieldNameAdd.Contains("ndays")
                                    && fieldNameAdd.Contains("complete_quarter") && fieldNameAdd.Contains("sf") && fieldNameAdd.Contains("so4f") && fieldNameAdd.Length == 41)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Translate("Monitor Data File is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Translate("Please select a Monitor Data File!\n"));
                    }
                }

                //check model data file
                if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.baseModelFile))
                    { errorTipBuilder.Append(Language.Translate("Model Baseline Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Translate("Model Baseline File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Translate("Model Baseline File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Translate("Please select a Model Baseline File!\n"));
                }

                if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.futureModelFile))
                    { errorTipBuilder.Append(Language.Translate("Model Forecast Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Translate("Model Forecast File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Translate("Model Forecast File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Translate("Please select a Model Forecast File!\n"));
                }

                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
         */
        #endregion remove to DataInputV user control, by sclong, 2017-02-17


        public string checkSSIAModelInputA()
        {
            try
            {
                SSIAAnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_ModelDataInputA _dataInputA = (pnlUserControl.Controls[0] as uc_ModelDataInputA);

                if (!annualPMAnalysisConfiguration.analysisOptionA.useDispersionOnly)
                {
                    if (_dataInputA.rbtnDailyModelA.Checked)//check daily model data
                    {
                        #region baseline model data
                        if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.baseModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "day")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Baseline Model Data File!\n"));
                        }
                        #endregion
                        #region control model data
                        if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.futureModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "day")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                        && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        #endregion
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Forecast Model Data File!\n"));
                        }
                    }

                    if (_dataInputA.rbtnQuarterlyModelA.Checked)//check quarterly model data
                    {
                        #region baseline model data
                        if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.baseModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Baseline Model Data File!\n"));
                        }
                        #endregion
                        #region control model data
                        if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.futureModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Forecast Model Data File!\n"));
                        }
                        #endregion
                    }
                }
                if (!annualPMAnalysisConfiguration.analysisOptionA.useGridOnly)
                {
                    if (CommonClass.dispersionModelFile != null && CommonClass.dispersionModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.dispersionModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Dispersion model file path does not exits!\n"));
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Dispersion Model Data File!\n"));
                    }
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkSSIAMonitorInputA()
        {
            try
            {
                SSIAAnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_MonitorDataInputA _dataInputA = (pnlUserControl.Controls[0] as uc_MonitorDataInputA);

                #region check official monitor data
                if (CommonClass.officialPMFile != null && CommonClass.officialPMFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.officialPMFile))
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File path does not exist!\n"));
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.officialPMFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                            return errorTips = errorTipBuilder.ToString();
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("ndays")
                                && fieldNameAdd.Contains("_substitution_code") && fieldNameAdd.Contains("completion_code") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Length == 11)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                                return errorTips = errorTipBuilder.ToString();
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select an Official Quarterly Average FRM Data File!\n"));
                    return errorTips = errorTipBuilder.ToString();
                }
                #endregion

                if (Convert.ToInt16(_dataInputA.cboEndYearA.Text) < Convert.ToInt16(_dataInputA.cboStartYearA.Text))
                    errorTipBuilder.Append(Language.Localization.GetValue("End Year should be later than Start Year!\n"));
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        public string checkSSIAModelInputO()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_ModelDataInputO _dataInputO = (pnlUserControl.Controls[0] as uc_ModelDataInputO);

                //check model data file-baseline
                if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.baseModelFile))
                    { errorTipBuilder.Append(Language.Localization.GetValue("Model Baseline Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Model Baseline File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("o3") && fieldNameAdd.Length == 6)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Model Baseline File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a Model Baseline File!\n"));
                }

                //check model data file-forecast
                if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.futureModelFile))
                    { errorTipBuilder.Append(Language.Localization.GetValue("Model Forecast Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Model Forecast File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("o3") && fieldNameAdd.Length == 6)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Model Forecast File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a Model Forecast File!\n"));
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        public string checkSSIAMonitorInputO()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_ModelDataInputO _dataInputO = (pnlUserControl.Controls[0] as uc_ModelDataInputO);
                //check monitor data file
                if (CommonClass.ozoneMonitorFile != null && CommonClass.ozoneMonitorFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.ozoneMonitorFile))
                    { errorTipBuilder.Append(Language.Localization.GetValue("Monitor Data File path does not exist!\n")); }
                    else
                    {
                        fileStream = new FileStream(CommonClass.ozoneMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "designvalue")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Monitor Data File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("poc") && fieldNameAdd.Contains("dvyear") && fieldNameAdd.Contains("o3") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Length == 9)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Monitor Data File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a Monitor Data File!\n"));
                }

                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        //---check SSIA Daily added by Yangwenwei
        public string checkSSIAModelInputD()
        {
            try
            {
                SSIADailyPMAnalysisConfiguration dailyPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_ModelDataInputD _dataInputD = (pnlUserControl.Controls[0] as uc_ModelDataInputD);

                if (!dailyPMAnalysisConfiguration.analysisOptionD.useDispersionOnly)
                {
                    if (_dataInputD.rbtnDailyModelDataD.Checked)//check daily model data
                    {
                        #region baseline model data
                        if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.baseModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "day")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Baseline Model Data File!\n"));
                        }
                        #endregion
                        #region control model data
                        if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.futureModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "day")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                        && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        #endregion
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Forecast Model Data File!\n"));
                        }
                    }

                    if (_dataInputD.rbtnQuarterlyPeakModelDataD.Checked)//check quarterly model data
                    {
                        #region baseline model data
                        if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.baseModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Baseline Model Data File!\n"));
                        }
                        #endregion
                        #region control model data
                        if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.futureModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                        && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Forecast Model Data File!\n"));
                        }
                        #endregion
                    }
                }
                if (!dailyPMAnalysisConfiguration.analysisOptionD.useGridOnly)
                {
                    if (CommonClass.dispersionModelFile != null && CommonClass.dispersionModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.dispersionModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Dispersion model file path does not exits!\n"));
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Dispersion Model Data File!\n"));
                    }
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkSSIAMonitorInputD()
        {
            try
            {
                SSIADailyPMAnalysisConfiguration dailyPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                if (CommonClass.officialPMFile != null && CommonClass.officialPMFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.officialPMFile))
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File path does not exist!\n"));
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.officialPMFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("98_percentile")
                                && fieldNameAdd.Contains("epa_flag") && fieldNameAdd.Contains("completion_code") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name") && fieldNameAdd.Contains("rank98") && fieldNameAdd.Length == 12)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Official Quarterly Average FRM Data File is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select an Official Quarterly Average FRM Data File!\n"));
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        public string checkSSIAModelInputDep()    //added by Lijiabin
        {
            try
            {
                SSIADepositionConfiguration depositionAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_ModelDataInputDep _dataInputDep = (pnlUserControl.Controls[0] as uc_ModelDataInputDep);
                if (!depositionAnalysisConfiguration.analysisOptionDep.useDispersionOnly)
                {
                    if (_dataInputDep.rbtnDailyModelDataDep.Checked)//check daily model data
                    {
                        #region baseline model data
                        if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.baseModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "day")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("tsdep")
                                        && fieldNameAdd.Contains("tndep"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Baseline Model Data File!\n"));
                        }
                        #endregion
                        #region control model data
                        if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.futureModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "day")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("tsdep")
                                        && fieldNameAdd.Contains("tndep"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        #endregion
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Forecast Model Data File!\n"));
                        }
                    }

                    if (_dataInputDep.rbtnQuarterlyModelDataDep.Checked)//check quarterly model data
                    {
                        #region baseline model data
                        if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.baseModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("tsdep")
                                        && fieldNameAdd.Contains("tndep"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Baseline Model Data File!\n"));
                        }
                        #endregion
                        #region control model data
                        if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                        {
                            if (!File.Exists(CommonClass.futureModelFile))
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("tsdep")
                                        && fieldNameAdd.Contains("tndep"))
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Forecast Model Data File!\n"));
                        }
                        #endregion
                    }
                }
                if (!depositionAnalysisConfiguration.analysisOptionDep.useGridOnly)
                {
                    //if (CommonClass.dispersionModelFile != null && CommonClass.dispersionModelFile.Length > 0)
                    //{
                    //    if (!File.Exists(CommonClass.dispersionModelFile))
                    //    {
                    //        errorTipBuilder.Append(Language.Translate("Dispersion model file path does not exits!\n"));
                    //    }
                    //}
                    //else
                    //{
                    //    errorTipBuilder.Append(Language.Translate("Please select a Dispersion Model Data File!\n"));
                    //}
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        //----check data added by Yangwenwei
        public string checkPMChinaModelInput()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_ModelDataChina _dataInputPMChina = (pnlUserControl.Controls[0] as uc_ModelDataChina);

                if (_dataInputPMChina.rbtnQuarterlyAverageDataChina.Checked)//check quarter model data
                {
                    #region baseline model data
                    if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.baseModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("quarter") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Baseline Model Data File!\n"));
                    }
                    #endregion
                    #region control model data
                    if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.futureModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Control file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Control file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("quarter") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("cm") && fieldNameAdd.Length == 13)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Control file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                        #endregion
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Forecast Model Data File!\n"));
                    }
                }

                if (_dataInputPMChina.rbtnDailyAvertageDatalChina.Checked)//check daily model data
                {
                }

                if (_dataInputPMChina.rbtnCMAQChina.Checked)//CMAQ
                {

                }

                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkPMChinaMonitorInput()
        {
            try
            {
                AnnualPMAnalysisChinaConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_MonitorDataChina _dataInputPMChina = (pnlUserControl.Controls[0] as uc_MonitorDataChina);

                #region check quarter monitor data
                if (_dataInputPMChina.rbtnQuarterlyMonitorChina.Checked)
                {
                    if (CommonClass.monitorFile != null && CommonClass.monitorFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.monitorFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Quarterly Monitor Data File path does not exist!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.monitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Quarterly Monitor Data File is ill-formatted data!\n"));
                                return errorTips = errorTipBuilder.ToString();
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("quarter_dv") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("location_name")
                                    && fieldNameAdd.Contains("station_name") && fieldNameAdd.Length == 8)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Quarterly Monitor Data File is ill-formatted data!\n"));
                                    return errorTips = errorTipBuilder.ToString();
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Monitor Data File!\n"));
                        return errorTips = errorTipBuilder.ToString();
                    }
                }
                #endregion

                if (_dataInputPMChina.rbtnDailyMonitorChina.Checked)
                {
                }
                if (Convert.ToInt16(_dataInputPMChina.cboEndYearChina.Text) < Convert.ToInt16(_dataInputPMChina.cboStartYearChina.Text))
                    errorTipBuilder.Append(Language.Localization.GetValue("End Year should be later than Start Year!\n"));
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        public string checkPMChinaSpecies()
        {
            try
            {
                AnnualPMAnalysisChinaConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_PM25SpeciesOptionChina _dataInputPMChina = (pnlUserControl.Controls[0] as uc_PM25SpeciesOptionChina);
                if (_dataInputPMChina.chkSpeciesFractionDataChina.Checked)
                {
                    //check species monitor data file
                    #region
                    if (CommonClass.speciesMonitorFile != null && CommonClass.speciesMonitorFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.speciesMonitorFile))
                        { errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File does not exist!\n")); }
                        else
                        {
                            fileStream = new FileStream(CommonClass.speciesMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("quarter_dv") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("oc")
                                    && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("h2o") && fieldNameAdd.Contains("other") && fieldNameAdd.Contains("location_name") && fieldNameAdd.Contains("station_name") && fieldNameAdd.Length == 15)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Species Monitor Data File is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Species Monitor Data File!\n"));
                    }
                    #endregion
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkOzoneChinaModelInput()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_ModelDataOzoneChina _dataInputOzoneChina = (pnlUserControl.Controls[0] as uc_ModelDataOzoneChina);

                #region baseline model data
                if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.baseModelFile))
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "season")
                        //if(false)
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                        }
                        else
                        {
                            streamReader.ReadLine();
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("season") && fieldNameAdd.Contains("o3") && fieldNameAdd.Length == 6)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a Baseline Model Data File!\n"));
                }
                #endregion
                #region control model data
                if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.futureModelFile))
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Control file path does not exits!\n"));
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "season")
                        //if (false)
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Control file is ill-formatted data!\n"));
                        }
                        else
                        {
                            streamReader.ReadLine();
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("season") && fieldNameAdd.Contains("o3") && fieldNameAdd.Length == 6)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Control file is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a  Forecast Model Data File!\n"));
                }
                #endregion

                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkOzoneChinaMonitorInput()
        {
            try
            {
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_MonitorDataOzoneChina _dataInputOzoneChina = (pnlUserControl.Controls[0] as uc_MonitorDataOzoneChina);

                if (CommonClass.ozoneMonitorFile != null && CommonClass.ozoneMonitorFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.ozoneMonitorFile))
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Monitor file path does not exits!\n"));
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.ozoneMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "designvalue")
                        //if(false)
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Monitor file is ill-formatted data!\n"));
                        }
                        else
                        {
                            streamReader.ReadLine();
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("season_dv") && fieldNameAdd.Contains("o3")
                                && fieldNameAdd.Contains("location_name") && fieldNameAdd.Contains("station_name") && fieldNameAdd.Length == 8)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Monitor file is ill-formatted data!\n"));
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorTipBuilder.Append(Language.Localization.GetValue("Please select a  Monitor Data File!\n"));
                }
                if (Convert.ToInt16(_dataInputOzoneChina.cboEndYearOzone.Text) < Convert.ToInt16(_dataInputOzoneChina.cboEndYearOzone.Text))
                    errorTipBuilder.Append(Language.Localization.GetValue("End Year should be later than Start Year!\n"));
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }

        }

        public string checkBenMAPAnnualPMModelInput()
        {
            try
            {
                BenMAPAnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorTipBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_BenMAP_AnnualPM_ModelData _dataInputA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_ModelData);

                if (_dataInputA.rbtnDailyModelA.Checked)//check daily model data
                {
                    #region baseline model data
                    if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.baseModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Baseline Model Data File!\n"));
                    }
                    #endregion
                    #region control model data
                    if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.futureModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25")
                                    && fieldNameAdd.Contains("cm"))
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                        #endregion
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Daily Forecast Model Data File!\n"));
                    }
                }

                if (_dataInputA.rbtnQuarterlyModelA.Checked)//check quarterly model data
                {
                    #region baseline model data
                    if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.baseModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Baseline file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Baseline file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Baseline Model Data File!\n"));
                    }
                    #endregion
                    #region control model data
                    if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.futureModelFile))
                        {
                            errorTipBuilder.Append(Language.Localization.GetValue("Forecast file path does not exits!\n"));
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                            {
                                errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("crustal")
                                    && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("pm25") && fieldNameAdd.Contains("cm"))
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorTipBuilder.Append(Language.Localization.GetValue("Forecast file is ill-formatted data!\n"));
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorTipBuilder.Append(Language.Localization.GetValue("Please select a Quarterly Forecast Model Data File!\n"));
                    }
                    #endregion
                }
                return errorTips = errorTipBuilder.ToString();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        public string checkBenMAPAnnualPMMonitorInput()
        {
            try
            {
                BenMAPAnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_BenMAP_AnnualPM_MonitorData _dataInputA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_MonitorData);

                if (CommonClass.unofficialPMFile != null && CommonClass.unofficialPMFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.unofficialPMFile))
                    {
                        errorBuilder.Append("Unofficial Daily Average PM25 Data File path does not exist!\n");
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.unofficialPMFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorBuilder.Append("Unofficial Daily Average PM25 Data File is ill-formatted data!\n");
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("pm25")
                                && fieldNameAdd.Contains("epa_flag") && fieldNameAdd.Contains("user_flag") && fieldNameAdd.Length == 8)
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorBuilder.Append("Unofficial Daily Average PM25 Data File is ill-formatted data!\n");
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorBuilder.Append("Unofficial Daily Average PM25 Data File can't be empty!\n");
                }

                if (!string.IsNullOrEmpty(errorBuilder.ToString()))
                    return errorTips = errorBuilder.ToString();

                if (Convert.ToInt16(_dataInputA.cboEndYearA.Text) < Convert.ToInt16(_dataInputA.cboStartYearA.Text))
                    errorBuilder.Append(Language.Localization.GetValue("End Year should be later than Start Year!\n"));
                return errorTips = errorBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        public string checkBenMAPAnnualPMSpeciesInput()
        {
            try
            {
                BenMAPAnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration;
                FileStream fileStream;
                StreamReader streamReader;
                StringBuilder errorBuilder = new StringBuilder("");
                string errorTips = "";
                string frequency = "";
                bool ok = false;
                uc_BenMAP_AnnualPM_SpeciesData _dataInputA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_SpeciesData);

                //check species monitor data file path
                #region
                if (_dataInputA.rbtnMonitorFileA.Checked)
                {
                    if (CommonClass.speciesMonitorFile != null && CommonClass.speciesMonitorFile.Length > 0)
                    {
                        if (!File.Exists(CommonClass.speciesMonitorFile))
                        {
                            errorBuilder.Append("Species Monitor Data File path does not exist!\n");
                        }
                        else
                        {
                            fileStream = new FileStream(CommonClass.speciesMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                            frequency = streamReader.ReadLine();
                            if (frequency.Trim().ToLower().Replace(",", "") != "day")
                            {
                                errorBuilder.Append("Species Monitor Data File is ill-formatted data!\n");
                            }
                            else
                            {
                                string fieldName = streamReader.ReadLine();
                                string[] fieldNameAdd = new string[] { };
                                if (fieldName != null && fieldName.Length > 0)
                                {
                                    fieldName = fieldName.Replace(" ", "");
                                    fieldName = fieldName.Replace("\"", "");
                                    fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                }
                                if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("so4") && fieldNameAdd.Contains("no3r") && fieldNameAdd.Contains("nh4") && fieldNameAdd.Contains("ocb")
                                    && fieldNameAdd.Contains("ec") && fieldNameAdd.Contains("crustal") && fieldNameAdd.Contains("salt") && fieldNameAdd.Contains("don") && fieldNameAdd.Contains("h2o_aim") && fieldNameAdd.Contains("oc") && fieldNameAdd.Contains("no3") && fieldNameAdd.Contains("so4_3s") && fieldNameAdd.Contains("crustal_alt")
                                    && fieldNameAdd.Contains("frm_mass") && fieldNameAdd.Contains("measured_fm") && fieldNameAdd.Contains("rcfm") && fieldNameAdd.Contains("al") && fieldNameAdd.Contains("ca") && fieldNameAdd.Contains("fe") && fieldNameAdd.Contains("ti") && fieldNameAdd.Contains("si") && fieldNameAdd.Contains("epa_flag")
                                    && fieldNameAdd.Contains("user_flag") && fieldNameAdd.Length == 28)
                                {
                                    ok = true;
                                }
                                else
                                {
                                    ok = false;
                                }
                                if (!ok)
                                {
                                    errorBuilder.Append("Species Monitor Data File is ill-formatted data!\n");
                                }
                            }
                            ok = false;
                            fileStream.Dispose();
                            streamReader.Dispose();
                        }
                    }
                    else
                    {
                        errorBuilder.Append("Species Monitor Data File can't be empty!\n");
                    }
                }
                #endregion
                if (_dataInputA.rbtnFractionA.Checked)
                {
                    //check species fractions file-spatial field
                    #region
                    if (annualPMAnalysisConfiguration.monitorInput.useVNA)
                    {
                        if (CommonClass.speciesFractionFilePoint != null && CommonClass.speciesFractionFilePoint.Length > 0)
                        {
                            if (!File.Exists(CommonClass.speciesFractionFilePoint))
                            {
                                errorBuilder.Append("Spatial Field Species Fractions File path does not exist!\n");
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.speciesFractionFilePoint, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorBuilder.Append("Spatial Field Species Fractions File is ill-formatted data!\n");
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("gridcell_lat") && fieldNameAdd.Contains("gridcell_long") && fieldNameAdd.Contains("quarter") && fieldNameAdd.Contains("pm25_mass_frac")
                                    && fieldNameAdd.Contains("fcr") && fieldNameAdd.Contains("fec") && fieldNameAdd.Contains("fnh4") && fieldNameAdd.Contains("focm") && fieldNameAdd.Contains("fso4")
                                    && fieldNameAdd.Contains("fno3") && fieldNameAdd.Contains("fwater") && fieldNameAdd.Contains("fsalt") && fieldNameAdd.Contains("blank_mass") && fieldNameAdd.Contains("don") && fieldNameAdd.Contains("i_so4")
                                    && fieldNameAdd.Contains("i_no3r") && fieldNameAdd.Contains("i_ocb") && fieldNameAdd.Contains("i_ec") && fieldNameAdd.Contains("i_crustal") && fieldNameAdd.Contains("i_don") && fieldNameAdd.Contains("i_nh4")
                                    && fieldNameAdd.Contains("i_no3") && fieldNameAdd.Contains("i_salt") && fieldNameAdd.Length == 24)
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorBuilder.Append("Spatial Field Species Fractions File is ill-formatted data!\n");
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorBuilder.Append("Spatial Field Species Fractions File can't be empty!\n");
                        }
                    }
                    else if (annualPMAnalysisConfiguration.monitorInput.useEVNA)
                    {
                        if (CommonClass.speciesFractionFileSpatial != null && CommonClass.speciesFractionFileSpatial.Length > 0)
                        {
                            if (!File.Exists(CommonClass.speciesFractionFileSpatial))
                            {
                                errorBuilder.Append("Gradient-adjusted Spatial Field Species Fractions File path does not exist!\n");
                            }
                            else
                            {
                                fileStream = new FileStream(CommonClass.speciesFractionFileSpatial, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                                frequency = streamReader.ReadLine();
                                if (frequency.Trim().ToLower().Replace(",", "") != "quarter")
                                {
                                    errorBuilder.Append("Gradient-adjusted Spatial Field Species Fractions File is ill-formatted data!\n");
                                }
                                else
                                {
                                    string fieldName = streamReader.ReadLine();
                                    string[] fieldNameAdd = new string[] { };
                                    if (fieldName != null && fieldName.Length > 0)
                                    {
                                        fieldName = fieldName.Replace(" ", "");
                                        fieldName = fieldName.Replace("\"", "");
                                        fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                                    }
                                    if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("gridcell_lat") && fieldNameAdd.Contains("gridcell_long") && fieldNameAdd.Contains("quarter") && fieldNameAdd.Contains("pm25_mass_frac_ga") && fieldNameAdd.Contains("fcr_ga") && fieldNameAdd.Contains("fec_ga")
                                        && fieldNameAdd.Contains("fnh4_ga") && fieldNameAdd.Contains("focm_ga") && fieldNameAdd.Contains("fso4_ga") && fieldNameAdd.Contains("fno3_ga") && fieldNameAdd.Contains("fwater_ga") && fieldNameAdd.Contains("fsalt_ga") && fieldNameAdd.Contains("blank_mass_ga")
                                        && fieldNameAdd.Contains("don_ga") && fieldNameAdd.Contains("i_so4_ga") && fieldNameAdd.Contains("i_no3r_ga") && fieldNameAdd.Contains("i_ocb_ga") && fieldNameAdd.Contains("i_ec_ga") && fieldNameAdd.Contains("i_crustal_ga") && fieldNameAdd.Contains("i_don_ga")
                                        && fieldNameAdd.Contains("i_nh4_ga") && fieldNameAdd.Contains("i_no3_ga") && fieldNameAdd.Contains("i_salt_ga") && fieldNameAdd.Length == 24)
                                    {
                                        ok = true;
                                    }
                                    else
                                    {
                                        ok = false;
                                    }
                                    if (!ok)
                                    {
                                        errorBuilder.Append("Gradient-adjusted Spatial Field Species Fractions File is ill-formatted data!\n");
                                    }
                                }
                                ok = false;
                                fileStream.Dispose();
                                streamReader.Dispose();
                            }
                        }
                        else
                        {
                            errorBuilder.Append("Gradient-adjusted Spatial Field Species Fractions File can't be empty!\n");
                        }
                    }
                    #endregion
                }

                if (!string.IsNullOrEmpty(errorBuilder.ToString()))
                    return errorTips = errorBuilder.ToString();

                if (Convert.ToInt16(_dataInputA.cboEndYearA.Text) < Convert.ToInt16(_dataInputA.cboStartYearA.Text))
                    errorBuilder.Append(Language.Localization.GetValue("End Year should be later than Start Year!\n"));
                return errorTips = errorBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
        #endregion

        #region BenMapOzone
        public string checkBenMAPOzoneModel()
        {
            try
            {
                bool ok = false;
                StringBuilder errorBuilder = new StringBuilder("");
                string errorTips = "";
                FileStream fileStream;
                StreamReader streamReader;
                string frequency = "";

                //check model file-baseline
                if (CommonClass.baseModelFile != null && CommonClass.baseModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.baseModelFile))
                    {
                        errorBuilder.Append("Model Baseline File path does not exist!\n");
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.baseModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorBuilder.Append("Model Baseline File is ill-formatted data!\n");
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("o3"))
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorBuilder.Append("Model Baseline File is ill-formatted data!\n");
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorBuilder.Append("Model Baseline File can't be empty!\n");
                }

                //check model file-forecast
                if (CommonClass.futureModelFile != null && CommonClass.futureModelFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.futureModelFile))
                    {
                        errorBuilder.Append("Model Forecast File path does not exist!\n");
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.futureModelFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "day")
                        {
                            errorBuilder.Append("Model Forecast File is ill-formatted data!\n");
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("date") && fieldNameAdd.Contains("o3"))
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorBuilder.Append("Model Forecast File is ill-formatted data!\n");
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorBuilder.Append("Model Forecast File can't be empty!\n");
                }

                return errorTips = errorBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        public string checkBenMAPOzoneMonitor()
        {
            try
            {
                bool ok = false;
                StringBuilder errorBuilder = new StringBuilder("");
                string errorTips = "";
                FileStream fileStream;
                StreamReader streamReader;
                string frequency = "";
                //check monitor data file path
                if (CommonClass.ozoneMonitorFile != null && CommonClass.ozoneMonitorFile.Length > 0)
                {
                    if (!File.Exists(CommonClass.ozoneMonitorFile))
                    {
                        errorBuilder.Append("Monitor Data File path does not exist!\n");
                    }
                    else
                    {
                        fileStream = new FileStream(CommonClass.ozoneMonitorFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
                        frequency = streamReader.ReadLine();
                        if (frequency.Trim().ToLower().Replace(",", "") != "designvalue")
                        {
                            errorBuilder.Append("Monitor Data File is ill-formatted data!\n");
                        }
                        else
                        {
                            string fieldName = streamReader.ReadLine();
                            string[] fieldNameAdd = new string[] { };
                            if (fieldName != null && fieldName.Length > 0)
                            {
                                fieldName = fieldName.Replace(" ", "");
                                fieldName = fieldName.Replace("\"", "");
                                fieldNameAdd = fieldName.Trim().ToLower().Split(',');
                            }
                            if (fieldNameAdd.Contains("_id") && fieldNameAdd.Contains("_type") && fieldNameAdd.Contains("lat") && fieldNameAdd.Contains("long") && fieldNameAdd.Contains("poc") && fieldNameAdd.Contains("dvyear") && fieldNameAdd.Contains("o3") && fieldNameAdd.Contains("_state_name") && fieldNameAdd.Contains("_county_name"))
                            {
                                ok = true;
                            }
                            else
                            {
                                ok = false;
                            }
                            if (!ok)
                            {
                                errorBuilder.Append("Monitor Data File is ill-formatted data!\n");
                            }
                        }
                        ok = false;
                        fileStream.Dispose();
                        streamReader.Dispose();
                    }
                }
                else
                {
                    errorBuilder.Append("Monitor Data File can't be empty!\n");
                }

                return errorTips = errorBuilder.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
        #endregion


        /// <summary>
        /// Save configuration
        /// </summary>
        public string SaveCurrentUCConfiguration()
        {
            try
            {
                string errorTip = "";
                StringBuilder errorBuilder = new StringBuilder("");
                if (pnlUserControl.Controls.Count == 0)//by Devin,修正dataview界面下，语言切换时选择保存当前项目时出错
                {
                    return errorTip;
                }
                switch (pnlUserControl.Controls[0].Name)
                {
                    #region annual pm
                    case "uc_OutputA":
                        uc_OutputA _outPutA = (pnlUserControl.Controls[0] as uc_OutputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA = new ChooseDesiredOutputA();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName = _outPutA.txtScenarioName.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doStandardAnalysis = _outPutA.choStandardAnalysisA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doQuarterlyModelData = _outPutA.choQuarterlyModelDataA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doUsedQuarterlyAvgModelData = _outPutA.choQuarterlyModelDataUsedA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doSpeciesFraction = _outPutA.choSpeciesFractionOutputA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doAutomaticallyExtract = _outPutA.choActionsCompletionA.Checked;
                        break;
                    case "uc_OutputAdvancedA":
                        uc_OutputAdvancedA _outputAdvancedA = (pnlUserControl.Controls[0] as uc_OutputAdvancedA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA = new OutputChoiceAdvancedA();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj = _outputAdvancedA.choIFRMSpeA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyVNA = _outputAdvancedA.choBaseOnlyVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyVNA = _outputAdvancedA.choFutureOnlyVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj_GradAdj = _outputAdvancedA.choIAdjustedFRMSpeA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyEvna = _outputAdvancedA.choBaseOnlyEvna.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyEvna = _outputAdvancedA.choFutureOnlyEvna.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFilePoint = _outputAdvancedA.choQuaPointA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial = _outputAdvancedA.choQuaSpatialA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_GraAdj = _outputAdvancedA.choQuaSpaGraAdjA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doHighCountySites = _outputAdvancedA.choFileCA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial = _outputAdvancedA.choSpeSpatialFieldA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_GraAdj = _outputAdvancedA.choSpeSpaGraAdjA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgSpeciatedMonitors = _outputAdvancedA.choFileEA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doDesignValuePeriods = _outputAdvancedA.choDVPeriods.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doNeighborFilePoint = _outputAdvancedA.choNeiPointA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doNeighborFileSpatial = _outputAdvancedA.choNeiSpatialA.Checked;

                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doDS = _outputAdvancedA.chkDS.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyDS = _outputAdvancedA.chkDSOnlyBase.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyDS = _outputAdvancedA.chkDSOnlyFuture.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Burn = Convert.ToInt32(_outputAdvancedA.txtDSBurn.Text);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Cmaqres = Convert.ToInt32(_outputAdvancedA.txtDSCmaqres.Text);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Thin = Convert.ToInt32(_outputAdvancedA.txtDSThin.Text);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Numit = Convert.ToInt32(_outputAdvancedA.txtDSNumit.Text);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_DS = _outputAdvancedA.choQuaSpaDSA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_DS = _outputAdvancedA.choSpeSpaDSA.Checked;

                        break;
                    case "uc_DataInputA":
                        uc_DataInputA _dataInputA = (pnlUserControl.Controls[0] as uc_DataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA = new DataInputA();
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.speciesMonitorDataFile == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.speciesMonitorDataFile = CommonClass.speciesMonitorFile;
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.officialMonitorDataFile == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.officialMonitorDataFile = CommonClass.officialPMFile;
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.unofficialMonitorDataFile == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.unofficialMonitorDataFile = CommonClass.unofficialPMFile;

                        //绑定species fraction calculations窗体中的IMPROVE-STN monitor data year，来自‘Species -for-fractions-0206-v2.csv’文件
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears == null || CommonClass.speciesMonitorFile != (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.speciesMonitorDataFile)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            List<string> lstYears = CommonClass.getListYearsFromCSV(CommonClass.speciesMonitorFile);
                            if (lstYears == null)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.speciesMonitorFile) + "\"");
                            else
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears = new List<string>();
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.speciesMonitorDataFile = CommonClass.speciesMonitorFile;
                                foreach (string item in lstYears)
                                {
                                    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears.Add(item);
                                }
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears.Sort();
                            }
                        }
                        //绑定species fraction calculations窗体中的PM25 monitor data years，来自‘PM25-for-fractions-0206-v3.csv’文件
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears == null || CommonClass.unofficialPMFile != (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.unofficialMonitorDataFile)
                        {
                            WaitChangeMsg(Language.Localization.GetValue("working..."));
                            List<string> lstYears = CommonClass.getListYearsFromCSV(CommonClass.unofficialPMFile);
                            if (lstYears == null)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.unofficialPMFile) + "\"");
                            else
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears = new List<string>();
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.unofficialMonitorDataFile = CommonClass.unofficialPMFile;
                                foreach (string item in lstYears)
                                {
                                    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears.Add(item);
                                }
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears.Sort();
                            }
                        }
                        //}
                        //绑定PM25 Calculations Options窗体中的PM25 Monitors Data Years，来自‘Annual-official-FRM-99-08-v2.csv’文件
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears == null || CommonClass.officialPMFile != (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.officialMonitorDataFile)
                        {
                            WaitChangeMsg(Language.Localization.GetValue("working..."));
                            List<string> lstYears = CommonClass.getListYearsFromCSV(CommonClass.officialPMFile);
                            if (lstYears == null)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.officialPMFile) + "\"");
                            else
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears = new List<string>();
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.officialMonitorDataFile = CommonClass.officialPMFile;
                                foreach (string item in lstYears)
                                {
                                    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Add(item);
                                }
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Sort();
                            }
                        }
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.doSpeciesMonitorDataFile = _dataInputA.rbtnMonitorFileA.Checked;
                        //(CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.speciesMonitorDataFile = CommonClass.speciesMonitorFile == null ? "" : CommonClass.speciesMonitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.doSpeciesFractionFile = _dataInputA.rbtnFractionA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.specFracModePoint = _dataInputA.cboPointA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.specFracPointFile = CommonClass.speciesFractionFilePoint == null ? "" : CommonClass.speciesFractionFilePoint;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.specFracModeSpatial = _dataInputA.cboSpatialA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.specFracSpatialFile = CommonClass.speciesFractionFileSpatial == null ? "" : CommonClass.speciesFractionFileSpatial;
                        //(CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.unofficialMonitorDataFile = CommonClass.unofficialPMFile == null ? "" : CommonClass.unofficialPMFile;
                        //(CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.officialMonitorDataFile = CommonClass.officialPMFile == null ? "" : CommonClass.officialPMFile;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.doDailyModelDataInput = _dataInputA.rbtnDailyModelA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.doQuarterlyModelDataInput = _dataInputA.rbtnQuarterlyModelA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.doInputFromCmaq = _dataInputA.rbtnCMAQA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.forecastModelDataFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        WaitClose();
                        break;
                    case "uc_SpeciesFractionsCalculationOptionsA":
                        uc_SpeciesFractionsCalculationOptionsA _speciesFractionOptionsA = (pnlUserControl.Controls[0] as uc_SpeciesFractionsCalculationOptionsA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA = new SpeciesFractionOptionsA();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_StartYear = _speciesFractionOptionsA.cboIMPROVEStartYaerA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_EndYear = _speciesFractionOptionsA.cboIMPROVEEndYaerA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_EPADeletionChoice = _speciesFractionOptionsA.choIMPROVEEPADeletionsA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_UserDeletionChoice = _speciesFractionOptionsA.choIMPROVEUserDeletionA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinDays = Convert.ToInt32(_speciesFractionOptionsA.nudownIMPROVEMinDaysA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinYear = Convert.ToInt32(_speciesFractionOptionsA.nudownIMPROVEMinYearsA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinSeasons = Convert.ToInt32(_speciesFractionOptionsA.nudownIMPROVEMinSeasonsA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialStartYear = _speciesFractionOptionsA.cboPMStartYaerA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialEndYear = _speciesFractionOptionsA.cboPMEndYaerA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialEPADeletionChoice = _speciesFractionOptionsA.choPMEPADeletionsA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialUserDeletionChoice = _speciesFractionOptionsA.choPMUserDeletionA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinDays = Convert.ToInt32(_speciesFractionOptionsA.nudownPMMinDaysA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinYears = Convert.ToInt32(_speciesFractionOptionsA.nudownPMMinYearsA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinSeasonsPoint = Convert.ToInt32(_speciesFractionOptionsA.nudownPMMinPointA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinSeasonsSpatial = Convert.ToInt32(_speciesFractionOptionsA.nudownPMMinSpatialA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doAdvancedOptionsForSpeciesFraction = _speciesFractionOptionsA.choAdvancedOptions.Checked;
                        #region species fraction advanced
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodPM25 = _speciesFractionOptionsA.cboItpPM25A.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distancePM25 = Convert.ToInt64(_speciesFractionOptionsA.nudownPM25DistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodSO4 = _speciesFractionOptionsA.cboItpSO4A.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceSO4 = Convert.ToInt64(_speciesFractionOptionsA.nudownSO4DistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodNO3 = _speciesFractionOptionsA.cboItpNO3A.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceNO3 = Convert.ToInt64(_speciesFractionOptionsA.nudownNO3DistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodEC = _speciesFractionOptionsA.cboItpECA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceEC = Convert.ToInt64(_speciesFractionOptionsA.nudownECDistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodSalt = _speciesFractionOptionsA.cboItpSaltA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceSalt = Convert.ToInt64(_speciesFractionOptionsA.nudownSaltDistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodCrustal = _speciesFractionOptionsA.cboItpCrustalA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceCrustal = Convert.ToInt64(_speciesFractionOptionsA.nudownCrustalDistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodDON = _speciesFractionOptionsA.cboItpDONA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceDON = Convert.ToInt64(_speciesFractionOptionsA.nudownDONDistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodOC = _speciesFractionOptionsA.cboItpOCA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceOC = Convert.ToInt64(_speciesFractionOptionsA.nudownOCDistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodNH4 = _speciesFractionOptionsA.cboItpNH4A.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceNH4 = Convert.ToInt64(_speciesFractionOptionsA.nudownNH4DistanceA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doUseDonValues = _speciesFractionOptionsA.rbtnDONA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doUseAmmoniumValues = _speciesFractionOptionsA.rbtnMeasuredA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.nh4PercentageEvaporating = Convert.ToInt32(_speciesFractionOptionsA.nudownNH4PercentageA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.defaultBlankMass = _speciesFractionOptionsA.nudownDefaultMassA.Value;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.floorOCMMB = _speciesFractionOptionsA.nudownOCmbFloorA.Value;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.ceilingOCMMB = _speciesFractionOptionsA.nudownOCmbCeilingA.Value;
                        #endregion
                        break;
                    case "uc_PM25CalculationOptionsA":
                        uc_PM25CalculationOptionsA _pmCalculationA = (pnlUserControl.Controls[0] as uc_PM25CalculationOptionsA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA = new PM25CalculationOptionsA();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.officialPM25StartYear = _pmCalculationA.cboStartYearA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.officialPM25EndYear = _pmCalculationA.cboEndYearA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.choiceOfficialDV = _pmCalculationA.rbtnOfficialA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.choiceCustomDV = _pmCalculationA.rbtnCustomA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minDaysForValidFRMQuarters = Convert.ToInt32(_pmCalculationA.nudownMinDaysA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minQuartersForValidFRMDesignValues = Convert.ToInt32(_pmCalculationA.nudownMinQuarterA.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minNumDVPeriodsForValidFRMMonitors = Convert.ToInt32(_pmCalculationA.nudownMinNumDV.Value);
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.requiredDVPeriodsForValidFRMMonitors = _pmCalculationA.txtRequiredA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.doCalcNH4fromDON = _pmCalculationA.rbtnNH4DONA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.doCalcNH4fromRRF = _pmCalculationA.rbtnNH4RRFA.Checked;
                        break;
                    case "uc_ModelDataA":
                        uc_ModelDataA _modelDataA = (pnlUserControl.Controls[0] as uc_ModelDataA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA = new ModelDataOptionsA();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA.temporalAdjustmentAtMonitorGrid = _modelDataA.cboPointGridA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA.temporalAdjustmentAtMonitorGridSpatial = _modelDataA.cboSpatialGridA.Text;
                        break;
                    case "uc_OutputD":
                        uc_OutputD _outputD = (pnlUserControl.Controls[0] as uc_OutputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD = new ChooseDesiredOutputD();
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName = _outputD.txtScenarioNameDily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doStandardAnalysis = _outputD.choStandardAnalysisD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doQuarterlyPeakModelData = _outputD.choQuarterlyPeakModelDataD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doSpeciesFraction = _outputD.choSpeciesFractionsFileD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doAutomaticallyExtract = _outputD.choActionsExtractAllD.Checked;
                        break;
                    #endregion
                    #region daily pm
                    case "uc_OutputAdvancedD":
                        uc_OutputAdvancedD _outputAdvancedD = (pnlUserControl.Controls[0] as uc_OutputAdvancedD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD = new OutputChoiceAdvancedD();
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doQuarterlyPeakFilesPoint = _outputAdvancedD.choQuarterlyAvgFilePointD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doHighCountySites = _outputAdvancedD.choFileCD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doQuarterlyPeakSpeciatedMonitors = _outputAdvancedD.choFileED.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doDesignValuePeriods = _outputAdvancedD.choDVPeriodsD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doNeighborFilePoint = _outputAdvancedD.choNeighborFilePointD.Checked;
                        break;
                    #region dian
                    case "uc_DataInputD":
                        uc_DataInputD _dataInputD = (pnlUserControl.Controls[0] as uc_DataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD = new DataInputD();
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.speciesMonitorDataFile == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.speciesMonitorDataFile = CommonClass.speciesMonitorFile;
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.officialMonitorFile == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.officialMonitorFile = CommonClass.officialPMFile;
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.unofficialMonitorFile == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.unofficialMonitorFile = CommonClass.unofficialPMFile;
                        //绑定species fraction calculations窗体中的IMPROVE-STN monitor data year，来自‘Species -for-fractions-0206-v2.csv’文件
                        //test dian
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears == null || CommonClass.speciesMonitorFile != (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.speciesMonitorDataFile)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            List<string> lstYears = CommonClass.getListYearsFromCSV(CommonClass.speciesMonitorFile);
                            if (lstYears == null)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.speciesMonitorFile) + "\"");
                            else
                            {
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears = new List<string>();
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.speciesMonitorDataFile = CommonClass.speciesMonitorFile;
                                foreach (string item in lstYears)
                                { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears.Add(item); }
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears.Sort();
                            }
                        }
                        //---pm-for-fractions--------------unofficial pm25----------
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears == null || CommonClass.unofficialPMFile != (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.unofficialMonitorFile)
                        {
                            WaitChangeMsg(Language.Localization.GetValue("working..."));
                            List<string> lstYears = CommonClass.getListYearsFromCSV(CommonClass.unofficialPMFile);
                            if (lstYears == null)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.unofficialPMFile) + "\"");
                            else
                            {
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears = new List<string>();
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.unofficialMonitorFile = CommonClass.unofficialPMFile;
                                foreach (string item in lstYears)
                                { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears.Add(item); }
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears.Sort();
                            }

                        }
                        //---------offcial-annual-pm25-----------
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears == null || CommonClass.officialPMFile != (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.officialMonitorFile)
                        {
                            WaitChangeMsg(Language.Localization.GetValue("working..."));
                            List<string> lstYears = CommonClass.getListYearsFromCSV(CommonClass.officialPMFile);
                            if (lstYears == null)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.officialPMFile) + "\"");
                            else
                            {
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears = new List<string>();
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.officialMonitorFile = CommonClass.officialPMFile;
                                foreach (string item in lstYears)
                                { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Add(item); }
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Sort();
                            }
                        }
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.doSpeciesMonitorDataFile = _dataInputD.rbtnSpeciesMonitorD.Checked;
                        //(CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.speciesMonitorDataFile = CommonClass.speciesMonitorFile == null ? "" : CommonClass.speciesMonitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.doSpeciesFractionFile = _dataInputD.rbtnSpeciesFractionD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.specFracModePoint = _dataInputD.cboSpeciesFractionsPointD.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.specFracModeSpatial = _dataInputD.cboSpeciesFractionsSpatialD.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.specFracPointFile = CommonClass.speciesFractionFilePoint == null ? "" : CommonClass.speciesFractionFilePoint;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.specFracSpatialFile = CommonClass.speciesFractionFileSpatial == null ? "" : CommonClass.speciesFractionFileSpatial;
                        //(CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.unofficialMonitorFile = CommonClass.unofficialPMFile == null ? "" : CommonClass.unofficialPMFile;
                        //(CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.officialMonitorFile = CommonClass.officialPMFile == null ? "" : CommonClass.officialPMFile;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.doDailyModelDataInput = _dataInputD.rbtnDailyModelDataD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.doQuarterlyPeakModelDataInput = _dataInputD.rbtnQuarterlyPeakModelDataD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.doInputfromCmaq = _dataInputD.rbtnCMAQFileD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.baselineModelFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.forecastModelFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        WaitClose();
                        break;
                    #endregion
                    case "uc_SpeciesFrctionD":
                        uc_SpeciesFrctionD _speciesFractionsD = (pnlUserControl.Controls[0] as uc_SpeciesFrctionD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD = new SpeciesFractionOptionsD();
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_StartYear = _speciesFractionsD.cboIMPROVEMonitorStartYearDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_EndYear = _speciesFractionsD.cboIMPROVEMonitorEndYearDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_EPADeletionChoice = _speciesFractionsD.choEPASpecifiedIMPROVEDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_UserDeletionChoice = _speciesFractionsD.choUserSpecifiedIMPROVEDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinDays = Convert.ToInt32(_speciesFractionsD.nudownMinDaysIMPROVEDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinQuarters = Convert.ToInt32(_speciesFractionsD.nudownMinQuartersIMPROVEDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinYear = Convert.ToInt32(_speciesFractionsD.nudownMinYearsIMPROVEDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialStartYear = _speciesFractionsD.cboPMMonitorStartYearDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialEndYear = _speciesFractionsD.cboPMMonitorEndYearDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialEPADeletionChoice = _speciesFractionsD.choEPASpecifiedPMDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialUserDeletionChoice = _speciesFractionsD.choUserSpecifiedPMDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinDays = Convert.ToInt32(_speciesFractionsD.nudownMinDaysPMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinQuartersPoint = Convert.ToInt32(_speciesFractionsD.nudownMinQuartersPMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinYears = Convert.ToInt32(_speciesFractionsD.nudownMinYearsPMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doAdvancedOptionsForSpeciesFraction = _speciesFractionsD.choAdvancedOptions.Checked;

                        #region advanced options
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoTopXPercent = _speciesFractionsD.rbtnTopPercMonitorIMPROVEDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_TopXPercent = Convert.ToInt32(_speciesFractionsD.nudownTopPercMonitorIMPROVEDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoUseAlldailyMonitorValuesGreaterThan = _speciesFractionsD.rbtnAllMonitorGreaterIMPROVEDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_UseAlldailyMonitorValuesGreaterThan = Convert.ToInt32(_speciesFractionsD.nudownAllMonitorGreaterIMPROVEDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_MinumumNumberOfDaysRequiredAboveFixedAmount = Convert.ToInt32(_speciesFractionsD.nudownMinNumAboveIMPROVEDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoUseTopXNumber = _speciesFractionsD.rbtnTopNumMonitorIMPROVEDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_UseTopXNumber = Convert.ToInt32(_speciesFractionsD.nudownTopNumMonitorIMPROVEDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoTopXPercent = _speciesFractionsD.rbtnTopPercMonitorPMDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_TopXPercent = Convert.ToInt32(_speciesFractionsD.nudownTopPercMonitorPMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoUseAlldailyMonitorValuesGreaterThan = _speciesFractionsD.rbtnAllMonitorGreaterPMDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_UseAlldailyMonitorValuesGreaterThan = Convert.ToInt32(_speciesFractionsD.nudownAllMonitorGreaterPMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_MinumumNumberOfDaysRequiredAboveFixedAmount = Convert.ToInt32(_speciesFractionsD.nudownMinNumAbovePMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoTopXNumber = _speciesFractionsD.rbtnTopNumMonitorPMDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_TopXNumber = Convert.ToInt32(_speciesFractionsD.nudownTopNumMonitorPMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodPM25 = _speciesFractionsD.cboPM25InterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodSO4 = _speciesFractionsD.cboSO4InterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodNO3 = _speciesFractionsD.cboNO3InterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodEC = _speciesFractionsD.cboECInterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodSalt = _speciesFractionsD.cboSaltInterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodCrustal = _speciesFractionsD.cboCrastalInterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodDON = _speciesFractionsD.cboDONInterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodOC = _speciesFractionsD.cboOCInterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodNH4 = _speciesFractionsD.cboNH4InterpolationDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distancePM25 = Convert.ToInt64(_speciesFractionsD.nudownPM25DistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceSO4 = Convert.ToInt64(_speciesFractionsD.nudownSO4DistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceNO3 = Convert.ToInt64(_speciesFractionsD.nudownNO3DistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceEC = Convert.ToInt64(_speciesFractionsD.nudownECDistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceSalt = Convert.ToInt64(_speciesFractionsD.nudownSaltDistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceCrustal = Convert.ToInt64(_speciesFractionsD.nudownCrustalDistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceDON = Convert.ToInt64(_speciesFractionsD.nudownDONDistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceOC = Convert.ToInt64(_speciesFractionsD.nudownOCDistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceNH4 = Convert.ToInt64(_speciesFractionsD.nudownNH4DistanceDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doUseDonValues = _speciesFractionsD.rbtnDONValueDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doUseMeasuredAmmonium = _speciesFractionsD.rbtnMeasuredAmmoniumDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.nh4PercentageEvaporating = Convert.ToInt32(_speciesFractionsD.nudownNH4PercDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.defaultBlankMass = Convert.ToDecimal(_speciesFractionsD.nudownDefaultBMDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.floorOCMMB = Convert.ToDecimal(_speciesFractionsD.nudownOCmbFloorDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.ceilingOCMMB = Convert.ToDecimal(_speciesFractionsD.nudownOCmbCeilingDaily.Value);
                        #endregion
                        break;
                    case "uc_PM25CalculationD":
                        uc_PM25CalculationD _pmCalculationD = (pnlUserControl.Controls[0] as uc_PM25CalculationD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD = new PM25CalculationOptionsD();
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.officialPM25StartYear = _pmCalculationD.cboStartYearD.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.officialPM25EndYear = _pmCalculationD.cboEndYearD.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.minNumDVPeriodsForValidFRMMonitors = Convert.ToInt32(_pmCalculationD.nudownMinNumDVD.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.requiredDesignValuePeriodsForValidFRMMonitors = _pmCalculationD.txtRequiredDVD.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.doCalcNH4fromDON = _pmCalculationD.rbtnCalculateNH4byDON.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.doCalcNH4fromRRF = _pmCalculationD.rbtnCalculateNH4byRRF.Checked;
                        break;
                    case "uc_ModelDataD":
                        uc_ModelDataD _modelDataD = (pnlUserControl.Controls[0] as uc_ModelDataD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD = new ModelDataOptionsD();
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentAtMonitorGridPoint = _modelDataD.cboGridPointModelOptionDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentAtMonitorGridSpatial = _modelDataD.choGridforSpatialForecast.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentType = _modelDataD.cboStatisticMethodDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseXTopPercent = _modelDataD.rbtnTopPerceRRFDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseXTopPercent = Convert.ToInt32(_modelDataD.nudownTopPerceRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_MinumumNumberOfDaysRequiredAboveFixedAmount = Convert.ToInt32(_modelDataD.nudownMinNumDaysGreaterRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseTopXNumber = _modelDataD.rbtnTopNumRRFDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseTopXNumber = Convert.ToInt32(_modelDataD.nudownTopNumRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseAllModelDaysGreaterThan = Convert.ToInt32(_modelDataD.nudownAllDailyGreaterRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseAllModelDaysGreaterThan = _modelDataD.rbtnAllDailyGreaterRRFDaily.Checked;
                        break;
                    #endregion
                    #region ozone
                    case "uc_DesiredOutputOzone":
                        uc_DesiredOutputOzone _outputO = (pnlUserControl.Controls[0] as uc_DesiredOutputOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO = new ChooseDesiredOutputO();
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName = _outputO.txtScenarioOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doPointEstimatesForecast = _outputO.choPointForecastOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doQuarterlyModelData = _outputO.choQuarterlyModelData.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates = _outputO.choSpatialOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj = _outputO.choSpatialGradAdjOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA = _outputO.choBaseOnlyVNAOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA = _outputO.choFutureOnlyVNAOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA = _outputO.choBaseOnlyEvnaOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDownscaler = _outputO.chkDS.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSBaseOnly = _outputO.chkDSOnlyBase.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSFutureOnly = _outputO.chkDSOnlyFuture.Checked;

                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSBurn = Convert.ToInt16(_outputO.txtDSBurn.Text);
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSCmaqres = Convert.ToInt16(_outputO.txtDSCmaqres.Text);
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSNumit = Convert.ToInt16(_outputO.txtDSNumit.Text);
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSThin = Convert.ToInt16(_outputO.txtDSThin.Text);

                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA = _outputO.choFutureOnlyEvnaOzone.Checked;
                        //(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecast = _outputO.choSpatialForecastOzone.Checked;
                        //(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecastGradAdj = _outputO.choSpatialGradAdjForecastOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doNeighborFileSpatial = _outputO.choNeighborFileSpatial.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doAutomaticallyExtract = _outputO.choExtractAllOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDesignValuePeriods = _outputO.choDVPeriods.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doMaxDesignValuePeriods = _outputO.choMaxDVPeriods.Checked;
                        break;
                    case "uc_DataInputOzone":
                        uc_DataInputOzone _dataInputO = (pnlUserControl.Controls[0] as uc_DataInputOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO = new DataInputO();
                        #region added by sclong 20120915
                        //绑定Filtering/InterPolation窗体中的monitor data year，来自‘OZONE_SMAT_CE_input_9908-v2.csv’文件
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData == null || CommonClass.ozoneMonitorFile != (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.ozoneMonitorDataFile)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            List<string> lstYears = CommonClass.getListYearsFromCSV(CommonClass.ozoneMonitorFile);
                            if (lstYears == null)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.ozoneMonitorFile) + "\"");
                            else
                            {
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData = new List<string>();
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.ozoneMonitorDataFile = CommonClass.ozoneMonitorFile;
                                foreach (string item in lstYears)
                                {
                                    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData.Add(item);
                                }
                                //ds = CommonClass.getDataSetFromCSVAndFirstLine((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.ozoneDataFile, ref refString);
                                //foreach (DataRow dr in ds.Tables[0].Rows)
                                //{
                                //    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData.Add(dr["DVYEAR"].ToString());
                                //}
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData.Distinct().ToList();
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData.Sort();

                            }
                            //ds.Dispose();
                        }
                        #endregion
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.ozoneMonitorDataFile = CommonClass.ozoneMonitorFile;
                        //(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.ozoneMonitorDataFile = CommonClass.ozoneMonitorFile == null ? "" : CommonClass.ozoneMonitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.doInputfromCmaq = _dataInputO.cboCMAQOzone.Checked;
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays <= 0 || CommonClass.baseModelFile != (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.baselineModelDataFile)
                        {
                            int maxOzoneDays = CommonClass.getOzoneModelMaxDays(CommonClass.baseModelFile);
                            if (maxOzoneDays <= 0)
                                errorBuilder.Append("Fail to read data \"" + Path.GetFileName(CommonClass.baseModelFile) + "\"");
                            else
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays = maxOzoneDays;
                        }
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.forecastModelDataFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.temporalAdjustmentAtMonitorGrid = _dataInputO.cboGridOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.temporalAdjustmentType = _dataInputO.cboStatisticOzone.Text;
                        WaitClose();
                        break;
                    case "uc_FilteringorInterpolationOzone":
                        uc_FilteringorInterpolationOzone _filteringInterpolationO = (pnlUserControl.Controls[0] as uc_FilteringorInterpolationOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO = new FilteringInterpolationO();
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.ozoneStartYear = _filteringInterpolationO.cboStartYearOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.ozoneEndYear = _filteringInterpolationO.cboEndYearOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.minNumDV = Convert.ToInt32(_filteringInterpolationO.nudownMinNumDVO.Value);
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.requiredDVPeriods = _filteringInterpolationO.txtRequiredDVOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.defaultInterpolationMethod = _filteringInterpolationO.cboDefaultItpOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.doCheckToSetMaxDistance = _filteringInterpolationO.choMaxItpDistanceOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.maxDistance = Convert.ToInt32(_filteringInterpolationO.nudownMaxItpDistanceOzone.Value);
                        break;
                    case "uc_RRForSpatialGradientOzone":
                        uc_RRForSpatialGradientOzone _rrfO = (pnlUserControl.Controls[0] as uc_RRForSpatialGradientOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO = new RRFSpatialGradientO();
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.useInitialThreshold = _rrfO.rbtnInitial.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.initialThresholdValue = _rrfO.txtInitialValueOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minNumofDaysAtorAboveThreshold = _rrfO.txtAboveThresholdOzone.Text;
                        int i = 0;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.topXDays = int.TryParse(_rrfO.txtTopX.Text, out i) ? i : 0;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minAllowableThresholdValue = _rrfO.txtAllowableValueOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minNumDaysAtorAboveMinAllowableThreshold = _rrfO.txtAboveAllowableThresholdOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.doBackstop = _rrfO.choEnableBackstopOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.backstopMinThresholdforSpatialField = _rrfO.txtBackstopMinOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.subrangeFirstDay = Convert.ToInt32(_rrfO.nudownSubrangeFirstOzone.Value);
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.subrangeLastDay = Convert.ToInt32(_rrfO.nudownSubrangeLastOzone.Value);
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.doPairDays = _rrfO.choPairDaysOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.SRF_StartValue = _rrfO.txtStartValueOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.SRF_EndValue = _rrfO.txtEndValueOzone.Text;
                        break;
                    #endregion
                    #region visibility
                    case "uc_ChooseDesiredOutputV":
                        uc_ChooseDesiredOutputV _outputV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV == null)
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV = new ChooseDesiredOutputV();
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName = _outputV.txtScenarioNameVisibility.Text;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast = _outputV.choVisibilityLevels.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm = _outputV.rbtnOldIMPROVEAlgorithmVisibility.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseNewVersionforIMPROVEAlgorithm = _outputV.rbtnNewIMPROVEAlgorithmVisibility.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellAtMonitor = _outputV.rbtnModelGridCellatMonitorVisi.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellatClassIAreaCentroid = _outputV.rbtnModelGridCellatClass1Visi.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doAutomaticallyExtract = _outputV.choExtractAllVisibility.Checked;
                        break;
                    case "uc_DataInputV":
                        uc_DataInputV _dataInputV = (pnlUserControl.Controls[0] as uc_DataInputV);
                        WaitShow(Language.Localization.GetValue("working..."));
                        string msg = _dataInputV.SaveDataInputV();
                        if (msg != "")
                        {
                            errorBuilder.Append(msg + "\"");
                        }
                        //WaitClose();
                        while (!sFlog)
                        {
                            WaitClose();
                        }
                        break;
                    case "uc_FilteringV":
                        uc_FilteringV _filteringV = (pnlUserControl.Controls[0] as uc_FilteringV);
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV == null)
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV = new FilteringV();
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.startMonitorYear = _filteringV.cboStartYearVisibility.Text;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.endMonitorYear = _filteringV.cboEndYearVisibility.Text;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.baseModelYear = _filteringV.cboBaseYearVisibility.Text;
                        (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.minYearsForValidVisibilityMonitors = _filteringV.txtMinYearVisibility.Text;
                        break;
                    #endregion
                    #region SSIA
                    case "uc_AnalysisOption":
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                        {
                            uc_AnalysisOption _AnalysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA = new SSIAAnalysisOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName = _AnalysisOption.txtScenarioName.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelData = _AnalysisOption.choUseModelData.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData = _AnalysisOption.choUseModelFRMData.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion = _AnalysisOption.rbtnGridAndDispersion.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly = _AnalysisOption.rbtnGridOnly.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly = _AnalysisOption.rbtnDispersionOnly.Checked;
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null && _AnalysisOption.rbtnDispersionOnly.Checked)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useVNA = true;
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useEVNA = false;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                        {
                            uc_AnalysisOption _AnalysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD = new SSIAAnalysisOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName = _AnalysisOption.txtScenarioName.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelData = _AnalysisOption.choUseModelData.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData = _AnalysisOption.choUseModelFRMData.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion = _AnalysisOption.rbtnGridAndDispersion.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly = _AnalysisOption.rbtnGridOnly.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly = _AnalysisOption.rbtnDispersionOnly.Checked;
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                        {
                            uc_AnalysisOption _AnalysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO = new SSIAAnalysisOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName = _AnalysisOption.txtScenarioName.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelData = _AnalysisOption.choUseModelData.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData = _AnalysisOption.choUseModelFRMData.Checked;
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)    //added by Lijiabin
                        {
                            uc_AnalysisOption _AnalysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep = new SSIAAnalysisOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName = _AnalysisOption.txtScenarioName.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelData = _AnalysisOption.choUseModelData.Checked;
                            /*(CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelFRMData = _AnalysisOption.choUseModelFRMData.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridAndDispersion = _AnalysisOption.rbtnGridAndDispersion.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridOnly = _AnalysisOption.rbtnGridOnly.Checked;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useDispersionOnly = _AnalysisOption.rbtnDispersionOnly.Checked;
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).monitorInputDep != null && _AnalysisOption.rbtnDispersionOnly.Checked)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).monitorInputDep.useVNA = true;
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).monitorInputDep.useEVNA = false;
                            }*/
                        }
                        break;
                    case "uc_ModelDataInputA":
                        uc_ModelDataInputA _modelDataInput = (pnlUserControl.Controls[0] as uc_ModelDataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA = new SSIAModelDataInputA();
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.DailyModelDataInput = _modelDataInput.rbtnDailyModelA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.QuarterlyModelDataInput = _modelDataInput.rbtnQuarterlyModelA.Checked;
                        //(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.InputFromCMAQ = _modelDataInput.rbtnCMAQA.Checked;
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile = CommonClass.dispersionModelFile == null ? "" : CommonClass.dispersionModelFile;
                        }
                        else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile = null;
                        }
                        else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile = null;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile = null;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile = CommonClass.dispersionModelFile == null ? "" : CommonClass.dispersionModelFile;
                        }

                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.SourceCoordinateFile = CommonClass.ssiasourcefile == null ? "" : CommonClass.ssiasourcefile;
                        break;
                    case "uc_MonitorDataInputA":
                        uc_MonitorDataInputA _monitorDataInput = (pnlUserControl.Controls[0] as uc_MonitorDataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA = new SSIAMonitorDataInputA();
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.officialMonitorDataFile = CommonClass.officialPMFile == null ? "" : CommonClass.officialPMFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.monitorDataStartYear = _monitorDataInput.cboStartYearA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.monitorDataEndYear = _monitorDataInput.cboEndYearA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useVNA = _monitorDataInput.choVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useEVNA = _monitorDataInput.choEVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.temporalAdjustmentAtMonitorGrid = _monitorDataInput.cboPointGridA.Text;
                        break;
                    case "uc_ModelDataInputD":
                        uc_ModelDataInputD _modelDataInputD = (pnlUserControl.Controls[0] as uc_ModelDataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD = new SSIAModelDataInputD();
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.DailyModelDataInput = _modelDataInputD.rbtnDailyModelDataD.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.QuarterlyModelDataInput = _modelDataInputD.rbtnQuarterlyPeakModelDataD.Checked;
                        //(CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.InputFromCMAQ = _modelDataInputD.rbtnCMAQFileD.Checked;
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile = CommonClass.dispersionModelFile == null ? "" : CommonClass.dispersionModelFile;
                        }
                        else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile = null;
                        }
                        else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile = null;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile = null;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile = CommonClass.dispersionModelFile == null ? "" : CommonClass.dispersionModelFile;
                        }
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentAtMonitorGridPoint = _modelDataInputD.cboGridPointModelOptionDaily.Text;
                        //(CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentAtMonitorGridSpatial = _modelDataInputD.cboGridforSpatialForecast.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentType = _modelDataInputD.cboStatisticMethodDaily.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseXTopPercent = _modelDataInputD.rbtnTopPerceRRFDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseXTopPercent = Convert.ToInt32(_modelDataInputD.nudownTopPerceRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_MinumumNumberOfDaysRequiredAboveFixedAmount = Convert.ToInt32(_modelDataInputD.nudownMinNumDaysGreaterRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseTopXNumber = _modelDataInputD.rbtnTopNumRRFDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseTopXNumber = Convert.ToInt32(_modelDataInputD.nudownTopNumRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseAllModelDaysGreaterThan = Convert.ToInt32(_modelDataInputD.nudownAllDailyGreaterRRFDaily.Value);
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseAllModelDaysGreaterThan = _modelDataInputD.rbtnAllDailyGreaterRRFDaily.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile = CommonClass.dispersionModelFile == null ? "" : CommonClass.dispersionModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.SourceCoordinateFile = CommonClass.ssiasourcefile == null ? "" : CommonClass.ssiasourcefile;
                        break;
                    case "uc_MonitorDataInputD":
                        uc_MonitorDataInputD _monitorDataInputD = (pnlUserControl.Controls[0] as uc_MonitorDataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD = new SSIAMonitorDataInputD();
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.officialMonitorDataFile = CommonClass.officialPMFile == null ? "" : CommonClass.officialPMFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.monitorDataStartYear = _monitorDataInputD.cboStartYearD.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.monitorDataEndYear = _monitorDataInputD.cboEndYearD.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useVNA = _monitorDataInputD.choVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useEVNA = _monitorDataInputD.choEVNA.Checked;

                        break;
                    case "uc_ModelDataInputO":
                        uc_ModelDataInputO _modelDataInputO = (pnlUserControl.Controls[0] as uc_ModelDataInputO);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO = new SSIAModelDataInputO();
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.doInputfromCmaq = _modelDataInputO.choCMAQOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.forecastModelDataFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.dispersionFile = CommonClass.dispersionModelFile == null ? "" : CommonClass.dispersionModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.SourceCoordinateFile = CommonClass.ssiasourcefile == null ? "" : CommonClass.ssiasourcefile;
                        break;
                    case "uc_MonitorDataInputO":
                        uc_MonitorDataInputO _monitorDataInputO = (pnlUserControl.Controls[0] as uc_MonitorDataInputO);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO = new SSIAMonitorDataInputO();
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneMonitorDataFile = CommonClass.ozoneMonitorFile == null ? "" : CommonClass.ozoneMonitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneStartYear = _monitorDataInputO.cboStartYearOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneEndYear = _monitorDataInputO.cboEndYearOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useVNA = _monitorDataInputO.choVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useEVNA = _monitorDataInputO.choEVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useDownscaler = _monitorDataInputO.chkDS.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSBurn = Convert.ToInt16(_monitorDataInputO.txtDSBurn.Text);
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSCmaqres = Convert.ToInt16(_monitorDataInputO.txtDSCmaqres.Text);
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSNumit = Convert.ToInt16(_monitorDataInputO.txtDSNumit.Text);
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSThin = Convert.ToInt16(_monitorDataInputO.txtDSThin.Text);



                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.temporalAdjustmentAtMonitorGrid = _monitorDataInputO.cboGridOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.temporalAdjustmentType = _monitorDataInputO.cboStatisticOzone.Text;
                        break;
                    case "uc_ModelDataInputDep":                     //added by Lijiabin
                        uc_ModelDataInputDep _modelDataInputDep = (pnlUserControl.Controls[0] as uc_ModelDataInputDep);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep = new SSIAModelDataInputDep();
                        (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.DailyModelDataInput = _modelDataInputDep.rbtnDailyModelDataDep.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.QuarterlyModelDataInput = _modelDataInputDep.rbtnQuarterlyModelDataDep.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.alternativeScenarioFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.SourceCoordinateFile = CommonClass.ssiasourcefile == null ? "" : CommonClass.ssiasourcefile;
                        break;
                    case "uc_CalculationOption":
                        uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                        if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS = _calculation.txtNAAQS.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold = _calculation.txtThreshold.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.startPercentage = Convert.ToInt16(_calculation.nupdStartPercentage.Value);
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.endPercentage = Convert.ToInt16(_calculation.nupdEndPercentage.Value);
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS = _calculation.txtNAAQS.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold = _calculation.txtThreshold.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.startPercentage = Convert.ToInt16(_calculation.nupdStartPercentage.Value);
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.endPercentage = Convert.ToInt16(_calculation.nupdEndPercentage.Value);
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS = _calculation.txtNAAQS.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold = _calculation.txtThreshold.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.startPercentage = Convert.ToInt16(_calculation.nupdStartPercentage.Value);
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.endPercentage = Convert.ToInt16(_calculation.nupdEndPercentage.Value);
                        }
                        if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)    //added by Lijiabin
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption = new SSIACalculationOption();
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.NAAQS = _calculation.txtNAAQS.Text;
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.threshold = _calculation.txtThreshold.Text;
                            //(CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.startPercentage = Convert.ToInt16(_calculation.nupdStartPercentage.Value);
                            //(CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.endPercentage = Convert.ToInt16(_calculation.nupdEndPercentage.Value);
                        }
                        break;
                    #endregion
                    #region Annual PM China added by Yangwenwei
                    case "uc_ModelDataChina":
                        uc_ModelDataChina modeldatachina = (pnlUserControl.Controls[0] as uc_ModelDataChina);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina = new ModelDataInputChina();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doInputFromCMAQ = modeldatachina.rbtnCMAQChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doDailyAverageDataInput = modeldatachina.rbtnDailyAvertageDatalChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doQuarterlyAverageDataInput = modeldatachina.rbtnQuarterlyAverageDataChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName = modeldatachina.txtScenarioName.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.BaselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.ControlModelDataFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        break;
                    case "uc_MonitorDataChina":
                        uc_MonitorDataChina monitordatachina = (pnlUserControl.Controls[0] as uc_MonitorDataChina);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina = new MonitorDataInputChina();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doQuarterlyMonitorDataInput = monitordatachina.rbtnQuarterlyMonitorChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doDailyMonitorDataInput = monitordatachina.rbtnDailyMonitorChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doInterpolateFRM = monitordatachina.choIFRMChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doInterpolateAdjustedFRM = monitordatachina.choIAdjustedFRMChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.dowVNA = monitordatachina.chkwVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.dowVNAAdvancedOption = monitordatachina.chkwVNA.Checked && monitordatachina.chkwVNAAdvance.Checked;
                        double d;
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.dowVNAAdvancedOption && !string.IsNullOrWhiteSpace(monitordatachina.txtwVNAWeight.Text))
                        {
                            if (double.TryParse (monitordatachina.txtwVNAWeight.Text,out d))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.wVNAWeight = d;
                            }
                        }
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doNS = monitordatachina.chkNS.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataInputFile = CommonClass.monitorFile == null ? "" : CommonClass.monitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear = monitordatachina.cboStartYearChina.Text;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear = monitordatachina.cboEndYearChina.Text;

                        break;
                    case "uc_PM25SpeciesOptionChina":
                        uc_PM25SpeciesOptionChina speciesoptionchina = (pnlUserControl.Controls[0] as uc_PM25SpeciesOptionChina);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina = new PM25SpeciesOptionChina();
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina.PM25SpeciesFractionDataAvailable = speciesoptionchina.chkSpeciesFractionDataChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina.SpeciesMonitorDataFile = CommonClass.speciesMonitorFile == null ? "" : CommonClass.speciesMonitorFile;
                        break;
                    #endregion
                    #region Ozone China added by Yangwenwei
                    case "uc_ModelDataOzoneChina":
                        uc_ModelDataOzoneChina modeldataozonechina = (pnlUserControl.Controls[0] as uc_ModelDataOzoneChina);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina = new ModelDataOzoneChina();
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.doInputfromCmaq = modeldataozonechina.cboCMAQOzone.Checked;
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile == null || CommonClass.baseModelFile != (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile = CommonClass.baseModelFile;
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile == null || CommonClass.futureModelFile != (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile = CommonClass.futureModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName = modeldataozonechina.txtScenarioName.Text;
                        break;
                    case "uc_MonitorDataOzoneChina":
                        uc_MonitorDataOzoneChina monitordataozonechina = (pnlUserControl.Controls[0] as uc_MonitorDataOzoneChina);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina = new MonitorDataOzoneChina();
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useEVNA = monitordataozonechina.choIAdjustedFRMChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useVNA = monitordataozonechina.choIFRMChina.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNA = monitordataozonechina.chkwVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNAAdvancedOption = monitordataozonechina.chkwVNA.Checked && monitordataozonechina.chkwVNAAdvance.Checked;
                        double c;
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNAAdvancedOption && !string.IsNullOrWhiteSpace(monitordataozonechina.txtwVNAWeight.Text))
                        {
                            if (double.TryParse(monitordataozonechina.txtwVNAWeight.Text, out c))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNAWeight = c;
                            }
                        }
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useNS = monitordataozonechina.chkNS.Checked;
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneMonitorDataFile == null || CommonClass.ozoneMonitorFile != (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneMonitorDataFile)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneMonitorDataFile = CommonClass.ozoneMonitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear = monitordataozonechina.cboEndYearOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear = monitordataozonechina.cboStartYearOzone.Text;
                        break;
                    #endregion
                    #region BenMAP Annual PM
                    case "uc_BenMAP_AnnualPM_ModelData":
                        uc_BenMAP_AnnualPM_ModelData model = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput = new BenMAPAnnualPMModel();
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doInputfromCMAQ = model.rbtnCMAQA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doDailyModelData = model.rbtnDailyModelA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doQuarterlyModelData = model.rbtnQuarterlyModelA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName = model.txtScenarioName.Text;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.baselineFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.forecastFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.temporalAdjustmentAtMonitorGridSpatial = model.cboSpatialGridA.Text;
                        break;
                    case "uc_BenMAP_AnnualPM_MonitorData":
                        uc_BenMAP_AnnualPM_MonitorData monitor = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput = new BenMAPAnnualPMMonitor();
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.unofficialFile = CommonClass.unofficialPMFile == null ? "" : CommonClass.unofficialPMFile;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.startYear = monitor.cboStartYearA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.endYear = monitor.cboEndYearA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.useVNA = monitor.choIFRMSpeA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.useEVNA = monitor.choIAdjustedFRMSpeA.Checked;

                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.doDownscaler = monitor.chkDS.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Burn = Convert.ToInt32(monitor.txtDSBurn.Text);
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Cmaqres = Convert.ToInt32(monitor.txtDSCmaqres.Text);
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Numit = Convert.ToInt32(monitor.txtDSNumit.Text);
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Thin = Convert.ToInt32(monitor.txtDSThin.Text);
                        break;
                    case "uc_BenMAP_AnnualPM_SpeciesData":
                        uc_BenMAP_AnnualPM_SpeciesData species = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_SpeciesData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput = new BenMAPAnnualPMSpecies();
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.doSpeciesMonitorDataFile = species.rbtnMonitorFileA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.speciesMonitorDataFile = CommonClass.speciesMonitorFile == null ? "" : CommonClass.speciesMonitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.doSpeciesFractionFile = species.rbtnFractionA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.specFracSpatialFile = CommonClass.speciesFractionFilePoint == null ? "" : CommonClass.speciesFractionFilePoint;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.gradAdjSpecFracSpatialFile = CommonClass.speciesFractionFileSpatial == null ? "" : CommonClass.speciesFractionFileSpatial;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.startYear = species.cboStartYearA.Text;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.endYear = species.cboEndYearA.Text;
                        break;
                    case "uc_BenMAP_GridDefinition":
                        uc_BenMAP_GridDefinition grid = (pnlUserControl.Controls[0] as uc_BenMAP_GridDefinition);
                        if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPAnnualPM)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile == null)
                                (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile = "";
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile = CommonClass.shapefile == null ? "" : CommonClass.shapefile;
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile == null)
                                (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile = "";
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile = CommonClass.shapefile == null ? "" : CommonClass.shapefile;
                        }
                        break;
                    #endregion
                    #region BenMAP Ozone
                    case "uc_BenMap_Ozone_ModelData":
                        uc_BenMap_Ozone_ModelData BenMapOzoneModel = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput = new BenMAPOzoneModel();
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.doInputfromCmaq = BenMapOzoneModel.choCMAQOzone.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName = BenMapOzoneModel.txtScenarioName.Text;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.baselineModelDataFile = CommonClass.baseModelFile == null ? "" : CommonClass.baseModelFile;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.forecastModelDataFile = CommonClass.futureModelFile == null ? "" : CommonClass.futureModelFile;
                        break;
                    case "uc_BenMap_Ozone_MonitorData":
                        uc_BenMap_Ozone_MonitorData BenMapOzoneMonitor = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput = new BenMapOzoneMonitor();
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneMonitorDataFile = CommonClass.ozoneMonitorFile == null ? "" : CommonClass.ozoneMonitorFile;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneStartYear = BenMapOzoneMonitor.cboStartYearOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneEndYear = BenMapOzoneMonitor.cboEndYearOzone.Text;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.useVNA = BenMapOzoneMonitor.choVNA.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.useEVNA = BenMapOzoneMonitor.choEVNA.Checked;
                        //(CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.temporalAdjustmentAtMonitorGrid = BenMapOzoneMonitor.cboGridOzone.Text;
                        //(CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.temporalAdjustmentType = BenMapOzoneMonitor.cboStatisticOzone.Text;

                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.doDownscaler = BenMapOzoneMonitor.chkDS.Checked;
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSBurn = Convert.ToInt32(BenMapOzoneMonitor.txtDSBurn.Text);
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSCmaqres = Convert.ToInt32(BenMapOzoneMonitor.txtDSCmaqres.Text);
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSNumit = Convert.ToInt32(BenMapOzoneMonitor.txtDSNumit.Text);
                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSThin = Convert.ToInt32(BenMapOzoneMonitor.txtDSThin.Text);

                        break;
                    //case "uc_BenMAP_GridDefinition":
                    //break;


                    #endregion
                }

                //改变树的节点颜色
                #region
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        #region annual pm
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null)
                        {
                            if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                        }
                        //Relationship between all the output files.
                        if (pnlUserControl.Controls[0].Name == "uc_OutputAdvancedA" || pnlUserControl.Controls[0].Name == "uc_OutputA")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null)
                            {
                                errorTip = CommonClass.checkUCOutputAdvancedA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_DataInputA")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null)
                            {
                                errorTip = CommonClass.checkUCDataInputA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_SpeciesFractionsCalculationOptionsA")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null)
                            {
                                errorTip = CommonClass.checkUCSpeciesFractionOptionsA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[3].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[3].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_PM25CalculationOptionsA")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null)
                            {
                                errorTip = CommonClass.checkUCPMCalculationOptionsA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[4].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[4]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[4].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[4]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataA")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                            {
                                if (trvAnalysis.Nodes[5].ImageKey != _readyImageKey)
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[5]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.DailyPM:
                        #region daily add by dian
                        errorBuilder = new StringBuilder("");
                        if (pnlUserControl.Controls[0].Name == "uc_OutputD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null)
                            {
                                errorTip = CommonClass.checkUCOutputD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[0].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                        }

                        if (pnlUserControl.Controls[0].Name == "uc_OutputAdvancedD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null)
                            {
                                errorTip = CommonClass.checkUCOutputAdvancedD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }

                        if (pnlUserControl.Controls[0].Name == "uc_DataInputD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null)
                            {
                                errorTip = CommonClass.checkUCDataInputD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_SpeciesFrctionD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null)
                            {
                                errorTip = CommonClass.checkUCSpeciesFractionOptionsD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[3].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[3].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_PM25CalculationD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null)
                            {
                                errorTip = CommonClass.checkUCPMCalculationOptionsD(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[4].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[4]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[4].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[4]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                            {
                                if (trvAnalysis.Nodes[5].ImageKey != _readyImageKey)
                                {
                                    ChangeNodeImage(trvAnalysis.Nodes[5]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.Ozone:
                        #region Ozone added by longsc 20120916
                        if (pnlUserControl.Controls[0].Name == "uc_DesiredOutputOzone")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null)
                            {
                                errorTip = CommonClass.checkUCOutputO(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[0].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_DataInputOzone")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null)
                            {
                                errorTip = CommonClass.checkUCDataInputO(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_FilteringorInterpolationOzone")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null)
                            {
                                errorTip = CommonClass.checkUCFilteringInterpolationO(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_RRForSpatialGradientOzone")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                            {
                                errorTip = CommonClass.checkUCRRFSpatialGradientO(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[3].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[3].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.Visibility:
                        #region Ozone added by longsc 20120916

                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null)
                        {
                            if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_DataInputV")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null)
                            {
                                errorTip = CommonClass.checkUCDataInputV(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_FilteringV")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                            {
                                errorTip = CommonClass.checkUCFilteringV(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.SSIAAnnualPM:
                        #region SSIA-Annual
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null)
                        {
                            if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputA")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null)
                            {
                                errorTip = CommonClass.checkSSIAUCModelInputA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null && ssia_useMonitor)
                            {
                                errorTip = CommonClass.checkSSIAUCMonitorInputA(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_CalculationOption")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[3].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[3].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.SSIADailyPM:
                        #region SSIA-Daily
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null)
                        {
                            if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null)
                            {
                                //errorTip = CommonClass.checkUCDataInputV(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputD")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null && ssia_useMonitor)
                            {
                                //errorTip = CommonClass.checkUCFilteringV(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_CalculationOption")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[3].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[3].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.SSIAOzone:
                        #region SSIA-Ozone
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null)
                        {
                            if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputO")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null)
                            {
                                //errorTip = CommonClass.checkUCDataInputV(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputO")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null && ssia_useMonitor)
                            {
                                //errorTip = CommonClass.checkUCFilteringV(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_CalculationOption")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                            {
                                errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[3].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[3]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[3].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[3]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.SSIADeposition:
                        #region SSIA-Deposition added by Lijiabin
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null)
                        {
                            if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                            {
                                ChangeNodeImage(trvAnalysis.Nodes[0]);
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputDep")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null)
                            {
                                //errorTip = CommonClass.checkSSIAUCModelInputDep(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        //if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA")
                        //{
                        //    if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null && ssia_useMonitor)
                        //    {
                        //        errorTip = CommonClass.checkSSIAUCMonitorInputA(CommonClass.CurrentBaseScenario);
                        //        if (errorTip != null && errorTip.Length > 0)
                        //        {
                        //            errorBuilder.Append(errorTip);
                        //            if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                        //                errorNode(trvAnalysis.Nodes[2]);
                        //        }
                        //        else
                        //        {
                        //            if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                        //                ChangeNodeImage(trvAnalysis.Nodes[2]);
                        //        }
                        //    }
                        //}
                        if (pnlUserControl.Controls[0].Name == "uc_CalculationOption")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                            {
                                //errorTip = CommonClass.checkSSIAUCCalculationOption(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.AnnualPMChina:
                        #region Annual PM China added by Yangwenwei
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataChina")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null)
                            {
                                errorTip = "";
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[0].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_MonitorDataChina")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null)
                            {
                                errorTip = "";
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_PM25SpeciesOptionChina")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                            {
                                errorTip = "";
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.OzoneChina:
                        #region Ozone China added by Yangwenwei
                        if (pnlUserControl.Controls[0].Name == "uc_ModelDataOzoneChina")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null)
                            {
                                errorTip = "";
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[0].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }

                        }
                        if (pnlUserControl.Controls[0].Name == "uc_MonitorDataOzoneChina")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                            {
                                errorTip = "";
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.BenMAPAnnualPM:
                        #region BenMAP Annual PM
                        if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_ModelData")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null)
                            {
                                errorTip = CommonClass.checkUCBenMAPPMModelData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[0].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_MonitorData")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null)
                            {
                                errorTip = CommonClass.checkUCBenMAPPMMonitorData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_SpeciesData")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null)
                            {
                                errorTip = CommonClass.checkUCBenMAPPMSpeciesData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[2]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[2]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                        {
                            if (string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile) || !File.Exists((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile))
                            {
                                if (trvAnalysis.Nodes[3].ImageKey != _errorImageKey)
                                    errorNode(trvAnalysis.Nodes[3]);
                            }
                            else
                            {
                                if (trvAnalysis.Nodes[3].ImageKey != _readyImageKey)
                                    ChangeNodeImage(trvAnalysis.Nodes[3]);
                            }
                        }
                        #endregion
                        break;
                    case enumAnalysis.BenMAPSeasonalOzone:
                        #region BenMAP Ozone
                        if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_ModelData")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null)
                            {
                                errorTip = CommonClass.checkBenMAPOzoneModelData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[0].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[0]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[0].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[0]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_MonitorData")
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null)
                            {
                                errorTip = CommonClass.checkBenMAPOzoneMonitorlData(CommonClass.CurrentBaseScenario);
                                if (errorTip != null && errorTip.Length > 0)
                                {
                                    errorBuilder.Append(errorTip);
                                    if (trvAnalysis.Nodes[1].ImageKey != _errorImageKey)
                                        errorNode(trvAnalysis.Nodes[1]);
                                }
                                else
                                {
                                    if (trvAnalysis.Nodes[1].ImageKey != _readyImageKey)
                                        ChangeNodeImage(trvAnalysis.Nodes[1]);
                                }
                            }
                        }
                        if (pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                        {
                            if (string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile) || !File.Exists((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile))
                            {
                                if (trvAnalysis.Nodes[2].ImageKey != _errorImageKey)
                                    errorNode(trvAnalysis.Nodes[2]);
                            }
                            else
                            {
                                if (trvAnalysis.Nodes[2].ImageKey != _readyImageKey)
                                    ChangeNodeImage(trvAnalysis.Nodes[2]);
                            }
                        }
                        #endregion
                        break;
                }
                #endregion
                trvAnalysis.Refresh();
                pnlUserControl.Refresh();
                lblSteps.Refresh();
                errorTip = errorBuilder.ToString();
                if (errorTip != null && errorTip.Length > 0)
                {
                    this.btnSaveRun.Enabled = false;
                    this.btnSave.Enabled = false;
                }
                return errorTip;
                //if (errorTip != null && errorTip.Length > 0)
                //{
                //    MessageBox.Show(errorTip, "Tip", MessageBoxButtons.OK);
                //}
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return ex.ToString();
            }
        }

        /// <summary>
        /// Double-click tree nodes, load corresponding uc
        /// </summary>
        public void TreeNodeLoad()
        {
            try
            {
                string errorTips = SaveCurrentUCConfiguration();
                if (errorTips != null && errorTips.Length > 0)
                {
                    MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                    return;
                }

                //判断data input是否已经进行设置
                #region
                string nodeName = trvAnalysis.SelectedNode.Name.ToLower().ToString();
                switch (nodeName)
                {
                    case "speciesa":
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select a Species Monitor Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "calculationoptionsa":
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select Official Quarterly Averge FRM Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "speciesd":
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select a Species Monitor Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "calculationoptionsd":
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select Official Quarterly Averge FRM Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "filteringinterpolationo"://Ozone added by sclong 20120913 16:50
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select Ozone Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "filteringv"://Visibility added by sclong
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select a Monitor Data File in Data Input!"));
                            return;
                        }
                        break;
                }
                #endregion
                if (this.pnlUserControl.Controls.Count != 0)
                {
                    this.pnlUserControl.Controls.Clear();
                }
                this.lblSteps.Text = trvAnalysis.SelectedNode.Text;
                switch (nodeName)
                {
                    #region annual pm
                    case "outputa":
                        pnlUserControl.Controls.Add(new uc_OutputA());
                        uc_OutputA _outPutA = (pnlUserControl.Controls[0] as uc_OutputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA = new ChooseDesiredOutputA();
                        _outPutA.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                        _outPutA.choStandardAnalysisA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doStandardAnalysis;
                        _outPutA.choQuarterlyModelDataA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doQuarterlyModelData;
                        _outPutA.choQuarterlyModelDataUsedA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doUsedQuarterlyAvgModelData;
                        _outPutA.choSpeciesFractionOutputA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doSpeciesFraction;
                        _outPutA.choActionsCompletionA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doAutomaticallyExtract;
                        break;
                    case "outputadvanceda":
                        pnlUserControl.Controls.Add(new uc_OutputAdvancedA());
                        uc_OutputAdvancedA _outputAdvancedA = (pnlUserControl.Controls[0] as uc_OutputAdvancedA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA = new OutputChoiceAdvancedA();
                            _outputAdvancedA.choQuaPointA.Checked = true;
                            _outputAdvancedA.choFileCA.Checked = true;
                            _outputAdvancedA.choFileEA.Checked = true;
                        }
                        else
                        {
                            _outputAdvancedA.choIFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj;
                            _outputAdvancedA.choIAdjustedFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj_GradAdj;
                            _outputAdvancedA.choBaseOnlyVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyVNA;
                            _outputAdvancedA.choFutureOnlyVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyVNA;
                            _outputAdvancedA.choBaseOnlyEvna.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyEvna;
                            _outputAdvancedA.choFutureOnlyEvna.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyEvna;
                            _outputAdvancedA.choQuaPointA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFilePoint;
                            _outputAdvancedA.choQuaSpatialA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial;
                            _outputAdvancedA.choQuaSpaGraAdjA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_GraAdj;
                            _outputAdvancedA.choFileCA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doHighCountySites;
                            _outputAdvancedA.choSpeSpatialFieldA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial;
                            _outputAdvancedA.choSpeSpaGraAdjA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_GraAdj;
                            _outputAdvancedA.choFileEA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgSpeciatedMonitors;
                            _outputAdvancedA.choDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doDesignValuePeriods;
                            _outputAdvancedA.choNeiPointA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doNeighborFilePoint;
                            _outputAdvancedA.choNeiSpatialA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doNeighborFileSpatial;

                            _outputAdvancedA.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doDS;
                            _outputAdvancedA.chkDSOnlyBase.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyDS;
                            _outputAdvancedA.chkDSOnlyFuture.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyDS;
                            _outputAdvancedA.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Burn.ToString();
                            _outputAdvancedA.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Cmaqres.ToString();
                            _outputAdvancedA.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Thin.ToString();
                            _outputAdvancedA.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Numit.ToString();
                            _outputAdvancedA.choQuaSpaDSA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_DS;
                            _outputAdvancedA.choSpeSpaDSA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_DS;
                        }
                        _outputAdvancedA.choChangedHeightAndTop();
                        break;
                    case "datainputa":
                        pnlUserControl.Controls.Add(new uc_DataInputA());
                        uc_DataInputA _dataInputA = (pnlUserControl.Controls[0] as uc_DataInputA);
                        //DataInputFile dataInputFile = new DataInputFile();
                        _dataInputA.InitializeControl();
                        break;
                    case "speciesa":
                        pnlUserControl.Controls.Add(new uc_SpeciesFractionsCalculationOptionsA());
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        uc_SpeciesFractionsCalculationOptionsA _speciesFractionOptionsA = (pnlUserControl.Controls[0] as uc_SpeciesFractionsCalculationOptionsA);
                        _speciesFractionOptionsA.cboIMPROVEStartYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFractionOptionsA.cboIMPROVEEndYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFractionOptionsA.cboPMStartYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFractionOptionsA.cboPMEndYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA = new SpeciesFractionOptionsA();
                            _speciesFractionOptionsA.choIMPROVEEPADeletionsA.Checked = true;
                            _speciesFractionOptionsA.choPMEPADeletionsA.Checked = true;
                            if (_speciesFractionOptionsA.cboIMPROVEStartYaerA.Items.Count >= 9)
                                _speciesFractionOptionsA.cboIMPROVEStartYaerA.SelectedIndex = 8;
                            else
                                _speciesFractionOptionsA.cboIMPROVEStartYaerA.SelectedIndex = _speciesFractionOptionsA.cboIMPROVEStartYaerA.Items.Count - 1;
                            if (_speciesFractionOptionsA.cboIMPROVEEndYaerA.Items.Count >= 11)
                            {
                                _speciesFractionOptionsA.cboIMPROVEEndYaerA.SelectedIndex = 10;
                            }
                            else
                            {
                                _speciesFractionOptionsA.cboIMPROVEEndYaerA.SelectedIndex = _speciesFractionOptionsA.cboIMPROVEEndYaerA.Items.Count - 1;
                            }
                            if (_speciesFractionOptionsA.cboPMStartYaerA.Items.Count >= 9)
                                _speciesFractionOptionsA.cboPMStartYaerA.SelectedIndex = 8;
                            else
                                _speciesFractionOptionsA.cboPMStartYaerA.SelectedIndex = _speciesFractionOptionsA.cboPMStartYaerA.Items.Count - 1;
                            if (_speciesFractionOptionsA.cboPMEndYaerA.Items.Count >= 11)
                            {
                                _speciesFractionOptionsA.cboPMEndYaerA.SelectedIndex = 10;
                            }
                            else
                            {
                                _speciesFractionOptionsA.cboPMEndYaerA.SelectedIndex = _speciesFractionOptionsA.cboPMEndYaerA.Items.Count - 1;
                            }
                            _speciesFractionOptionsA.nudownIMPROVEMinDaysA.Value = 11;
                            _speciesFractionOptionsA.nudownIMPROVEMinYearsA.Value = 1;
                            _speciesFractionOptionsA.nudownIMPROVEMinSeasonsA.Value = 1;
                            _speciesFractionOptionsA.nudownPMMinDaysA.Value = 11;
                            _speciesFractionOptionsA.nudownPMMinYearsA.Value = 1;
                            _speciesFractionOptionsA.nudownPMMinPointA.Value = 4;
                            _speciesFractionOptionsA.nudownPMMinSpatialA.Value = 1;

                            #region species options advanced
                            //(CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionAdvancedA = new SpeciesFractionAdvancedA();
                            _speciesFractionOptionsA.cboItpCrustalA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpDONA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpECA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpNH4A.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpNO3A.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpOCA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpPM25A.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpSaltA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpSO4A.SelectedIndex = 2;
                            _speciesFractionOptionsA.nudownCrustalDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownDONDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownECDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownNH4DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownNO3DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownOCDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownPM25DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownSaltDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownSO4DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.cboItpPM25A.Enabled = false;
                            _speciesFractionOptionsA.nudownPM25DistanceA.Enabled = false;
                            _speciesFractionOptionsA.rbtnDONA.Checked = true;
                            _speciesFractionOptionsA.cboItpNH4A.Enabled = false;
                            _speciesFractionOptionsA.nudownNH4DistanceA.Enabled = false;
                            _speciesFractionOptionsA.nudownNH4PercentageA.Enabled = false;
                            _speciesFractionOptionsA.nudownNH4PercentageA.Value = 0;
                            _speciesFractionOptionsA.nudownDefaultMassA.Value = 0.2M;
                            _speciesFractionOptionsA.nudownOCmbFloorA.Value = 1;
                            _speciesFractionOptionsA.nudownOCmbCeilingA.Value = 0.8M;
                            #endregion
                        }
                        else
                        {
                            _speciesFractionOptionsA.cboIMPROVEStartYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_StartYear;
                            _speciesFractionOptionsA.cboIMPROVEEndYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_EndYear;
                            _speciesFractionOptionsA.choIMPROVEEPADeletionsA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_EPADeletionChoice;
                            _speciesFractionOptionsA.choIMPROVEUserDeletionA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_UserDeletionChoice;
                            _speciesFractionOptionsA.nudownIMPROVEMinDaysA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinDays;
                            _speciesFractionOptionsA.nudownIMPROVEMinYearsA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinYear;
                            _speciesFractionOptionsA.nudownIMPROVEMinSeasonsA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinSeasons;
                            _speciesFractionOptionsA.cboPMStartYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialStartYear;
                            _speciesFractionOptionsA.cboPMEndYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialEndYear;
                            _speciesFractionOptionsA.choPMEPADeletionsA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialEPADeletionChoice;
                            _speciesFractionOptionsA.choPMUserDeletionA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialUserDeletionChoice;
                            _speciesFractionOptionsA.nudownPMMinDaysA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinDays;
                            _speciesFractionOptionsA.nudownPMMinYearsA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinYears;
                            _speciesFractionOptionsA.nudownPMMinPointA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinSeasonsPoint;
                            _speciesFractionOptionsA.nudownPMMinSpatialA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinSeasonsSpatial;

                            #region
                            _speciesFractionOptionsA.cboItpPM25A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodPM25;
                            _speciesFractionOptionsA.nudownPM25DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distancePM25;
                            _speciesFractionOptionsA.cboItpSO4A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodSO4;
                            _speciesFractionOptionsA.nudownSO4DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceSO4;
                            _speciesFractionOptionsA.cboItpNO3A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodNO3;
                            _speciesFractionOptionsA.nudownNO3DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceNO3;
                            _speciesFractionOptionsA.cboItpECA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodEC;
                            _speciesFractionOptionsA.nudownECDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceEC;
                            _speciesFractionOptionsA.cboItpSaltA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodSalt;
                            _speciesFractionOptionsA.nudownSaltDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceSalt;
                            _speciesFractionOptionsA.cboItpCrustalA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodCrustal;
                            _speciesFractionOptionsA.nudownCrustalDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceCrustal;
                            _speciesFractionOptionsA.cboItpDONA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodDON;
                            _speciesFractionOptionsA.nudownDONDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceDON;
                            _speciesFractionOptionsA.cboItpOCA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodOC;
                            _speciesFractionOptionsA.nudownOCDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceOC;
                            _speciesFractionOptionsA.cboItpNH4A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodNH4;
                            _speciesFractionOptionsA.nudownNH4DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceNH4;
                            _speciesFractionOptionsA.rbtnDONA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doUseDonValues;
                            _speciesFractionOptionsA.rbtnMeasuredA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doUseAmmoniumValues;
                            _speciesFractionOptionsA.nudownNH4PercentageA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.nh4PercentageEvaporating;
                            _speciesFractionOptionsA.nudownDefaultMassA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.defaultBlankMass;
                            _speciesFractionOptionsA.nudownOCmbFloorA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.floorOCMMB;
                            _speciesFractionOptionsA.nudownOCmbCeilingA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.ceilingOCMMB;
                            #endregion
                        }
                        break;
                    case "calculationoptionsa":
                        pnlUserControl.Controls.Add(new uc_PM25CalculationOptionsA());
                        lblSteps.Refresh();
                        pnlUserControl.Refresh();
                        uc_PM25CalculationOptionsA _pmCalculationA = (pnlUserControl.Controls[0] as uc_PM25CalculationOptionsA);
                        int n = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Count;
                        string[] dvString = new string[n];
                        for (int i = 0; i < n; i++)
                        {
                            dvString[i] = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears[i];
                        }
                        for (int i = 0; i < n; i++)
                        {
                            if (i + 2 < n)
                            {
                                _pmCalculationA.clboRequiredDV.Items.Add(dvString[i] + "-" + dvString[i + 2]);
                            }
                        }
                        _pmCalculationA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        _pmCalculationA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA = new PM25CalculationOptionsA();
                            _pmCalculationA.rbtnOfficialA.Checked = true;
                            _pmCalculationA.rbtnNH4DONA.Checked = true;
                            if (_pmCalculationA.cboStartYearA.Items.Count >= 8)//12
                                _pmCalculationA.cboStartYearA.SelectedIndex = 7;//11
                            else
                                _pmCalculationA.cboStartYearA.SelectedIndex = _pmCalculationA.cboStartYearA.Items.Count - 1;
                            if (_pmCalculationA.cboEndYearA.Items.Count >= 12)//14
                            {
                                _pmCalculationA.cboEndYearA.SelectedIndex = 11;//13
                            }
                            else
                            {
                                _pmCalculationA.cboEndYearA.SelectedIndex = _pmCalculationA.cboEndYearA.Items.Count - 1;
                            }
                            _pmCalculationA.txtRequiredA.Text = "None selected";
                            _pmCalculationA.nudownMinDaysA.Value = 11;
                            _pmCalculationA.nudownMinQuarterA.Value = 12;
                            _pmCalculationA.nudownMinNumDV.Value = 1;
                        }
                        else
                        {
                            _pmCalculationA.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.officialPM25StartYear;
                            _pmCalculationA.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.officialPM25EndYear;
                            _pmCalculationA.rbtnOfficialA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.choiceOfficialDV;
                            _pmCalculationA.rbtnCustomA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.choiceCustomDV;
                            _pmCalculationA.nudownMinDaysA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minDaysForValidFRMQuarters;
                            _pmCalculationA.nudownMinQuarterA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minQuartersForValidFRMDesignValues;
                            _pmCalculationA.nudownMinNumDV.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minNumDVPeriodsForValidFRMMonitors;
                            _pmCalculationA.txtRequiredA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.requiredDVPeriodsForValidFRMMonitors;
                            if (_pmCalculationA.txtRequiredA.Text != "None selected")
                            {
                                string[] requireDV = _pmCalculationA.txtRequiredA.Text.Split(',');
                                foreach (string s in requireDV)
                                {
                                    _pmCalculationA.clboRequiredDV.SetItemChecked(_pmCalculationA.clboRequiredDV.Items.IndexOf(s), true);
                                }
                            }
                            _pmCalculationA.rbtnNH4DONA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.doCalcNH4fromDON;
                            _pmCalculationA.rbtnNH4RRFA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.doCalcNH4fromRRF;
                        }
                        break;
                    case "modela":
                        pnlUserControl.Controls.Add(new uc_ModelDataA());
                        uc_ModelDataA _modelDataA = (pnlUserControl.Controls[0] as uc_ModelDataA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA = new ModelDataOptionsA();
                            _modelDataA.cboPointGridA.SelectedIndex = 1;
                            _modelDataA.cboSpatialGridA.SelectedIndex = 0;
                        }
                        else
                        {
                            _modelDataA.cboPointGridA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA.temporalAdjustmentAtMonitorGrid;
                            _modelDataA.cboSpatialGridA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA.temporalAdjustmentAtMonitorGridSpatial;
                        }
                        break;
                    #endregion
                    #region Daily dian
                    case "outputd":
                        pnlUserControl.Controls.Add(new uc_OutputD());
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Choose Desired Output";
                        uc_OutputD _outputD = (pnlUserControl.Controls[0] as uc_OutputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD = new ChooseDesiredOutputD();
                            _outputD.choStandardAnalysisD.Checked = true;
                            _outputD.choQuarterlyPeakModelDataD.Checked = true;
                            _outputD.choSpeciesFractionsFileD.Checked = true;
                            _outputD.choActionsExtractAllD.Checked = true;
                        }
                        else
                        {
                            _outputD.txtScenarioNameDily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                            _outputD.choStandardAnalysisD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doStandardAnalysis;
                            _outputD.choQuarterlyPeakModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doQuarterlyPeakModelData;
                            _outputD.choSpeciesFractionsFileD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doSpeciesFraction;
                            _outputD.choActionsExtractAllD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doAutomaticallyExtract;
                        }
                        break;
                    case "outputadvancedd"://all unchecked?
                        pnlUserControl.Controls.Add(new uc_OutputAdvancedD());
                        lblSteps.Text = trvAnalysis.Nodes[1].Text;
                        _stips = "Select advanced output choices";
                        uc_OutputAdvancedD _outputAdvancedD = (pnlUserControl.Controls[0] as uc_OutputAdvancedD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD = new OutputChoiceAdvancedD();
                            _outputAdvancedD.choQuarterlyAvgFilePointD.Checked = true;
                            _outputAdvancedD.choFileCD.Checked = true;
                            _outputAdvancedD.choFileED.Checked = true;
                        }
                        else
                        {
                            _outputAdvancedD.choQuarterlyAvgFilePointD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doQuarterlyPeakFilesPoint;
                            _outputAdvancedD.choFileCD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doHighCountySites;
                            _outputAdvancedD.choFileED.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doQuarterlyPeakSpeciatedMonitors;
                            _outputAdvancedD.choDVPeriodsD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doDesignValuePeriods;
                            _outputAdvancedD.choNeighborFilePointD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doNeighborFilePoint;
                        }
                        break;
                    case "datainputd":
                        pnlUserControl.Controls.Add(new uc_DataInputD());
                        lblSteps.Text = trvAnalysis.Nodes[2].Text;
                        _stips = "Select input files for the analysis";
                        uc_DataInputD _dataInputD = (pnlUserControl.Controls[0] as uc_DataInputD);
                        _dataInputD.InitializeControl();
                        break;
                    case "speciesd":
                        pnlUserControl.Controls.Add(new uc_SpeciesFrctionD());
                        lblSteps.Text = trvAnalysis.Nodes[3].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Set up species fraction options";
                        uc_SpeciesFrctionD _speciesFrctionD = (pnlUserControl.Controls[0] as uc_SpeciesFrctionD);
                        _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFrctionD.cboPMMonitorStartYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFrctionD.cboPMMonitorEndYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD = new SpeciesFractionOptionsD();
                            if (_speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Items.Count >= 9)
                                _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.SelectedIndex = 8;
                            else
                                _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.SelectedIndex = _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Items.Count - 1;
                            if (_speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Items.Count >= 11)
                                _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.SelectedIndex = 10;
                            else
                                _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.SelectedIndex = _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Items.Count - 1;
                            if (_speciesFrctionD.cboPMMonitorStartYearDaily.Items.Count >= 9)
                                _speciesFrctionD.cboPMMonitorStartYearDaily.SelectedIndex = 8;
                            else
                                _speciesFrctionD.cboPMMonitorStartYearDaily.SelectedIndex = _speciesFrctionD.cboPMMonitorStartYearDaily.Items.Count - 1;
                            if (_speciesFrctionD.cboPMMonitorEndYearDaily.Items.Count >= 11)
                                _speciesFrctionD.cboPMMonitorEndYearDaily.SelectedIndex = 10;
                            else
                                _speciesFrctionD.cboPMMonitorEndYearDaily.SelectedIndex = _speciesFrctionD.cboPMMonitorEndYearDaily.Items.Count - 1;
                            _speciesFrctionD.choEPASpecifiedIMPROVEDaily.Checked = true;
                            _speciesFrctionD.choEPASpecifiedPMDaily.Checked = true;
                            _speciesFrctionD.nudownMinDaysIMPROVEDaily.Value = 11;
                            _speciesFrctionD.nudownMinQuartersIMPROVEDaily.Value = 1;
                            _speciesFrctionD.nudownMinYearsIMPROVEDaily.Value = 1;
                            _speciesFrctionD.nudownMinDaysPMDaily.Value = 11;
                            _speciesFrctionD.nudownMinQuartersPMDaily.Value = 4;
                            _speciesFrctionD.nudownMinYearsPMDaily.Value = 1;
                            #region advanced options
                            _speciesFrctionD.rbtnTopPercMonitorIMPROVEDaily.Checked = true;
                            _speciesFrctionD.rbtnTopPercMonitorPMDaily.Checked = true;
                            _speciesFrctionD.nudownTopPercMonitorIMPROVEDaily.Value = 10;
                            _speciesFrctionD.nudownAllMonitorGreaterIMPROVEDaily.Value = 0;
                            _speciesFrctionD.nudownMinNumAboveIMPROVEDaily.Value = 1;
                            _speciesFrctionD.nudownTopNumMonitorIMPROVEDaily.Value = 25;
                            _speciesFrctionD.nudownTopPercMonitorPMDaily.Value = 10;
                            _speciesFrctionD.nudownAllMonitorGreaterPMDaily.Value = 0;
                            _speciesFrctionD.nudownMinNumAbovePMDaily.Value = 1;
                            _speciesFrctionD.nudownTopNumMonitorPMDaily.Value = 25;
                            _speciesFrctionD.cboPM25InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboSO4InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboNO3InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboECInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboSaltInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboCrastalInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboDONInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboOCInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboNH4InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.nudownPM25DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownSO4DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownNO3DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownECDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownSaltDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownCrustalDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownDONDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownOCDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownNH4DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.cboPM25InterpolationDaily.Enabled = false;
                            _speciesFrctionD.nudownPM25DistanceDaily.Enabled = false;
                            _speciesFrctionD.cboNH4InterpolationDaily.Enabled = false;
                            _speciesFrctionD.nudownNH4DistanceDaily.Enabled = false;
                            _speciesFrctionD.rbtnDONValueDaily.Checked = true;
                            _speciesFrctionD.nudownNH4PercDaily.Enabled = false;
                            _speciesFrctionD.nudownDefaultBMDaily.Value = (decimal)0.2;
                            _speciesFrctionD.nudownOCmbFloorDaily.Value = 1;
                            _speciesFrctionD.nudownOCmbCeilingDaily.Value = (decimal)0.8;
                            #endregion
                        }
                        else
                        {
                            _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_StartYear;
                            _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_EndYear;
                            _speciesFrctionD.choEPASpecifiedIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_EPADeletionChoice;
                            _speciesFrctionD.choUserSpecifiedIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_UserDeletionChoice;
                            _speciesFrctionD.nudownMinDaysIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinDays;
                            _speciesFrctionD.nudownMinQuartersIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinQuarters;
                            _speciesFrctionD.nudownMinYearsIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinYear;
                            _speciesFrctionD.cboPMMonitorStartYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialStartYear;
                            _speciesFrctionD.cboPMMonitorEndYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialEndYear;
                            _speciesFrctionD.choEPASpecifiedPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialEPADeletionChoice;
                            _speciesFrctionD.choUserSpecifiedPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialUserDeletionChoice;
                            _speciesFrctionD.nudownMinDaysPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinDays;
                            _speciesFrctionD.nudownMinQuartersPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinQuartersPoint;
                            _speciesFrctionD.nudownMinYearsPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinYears;
                            #region advanced options
                            _speciesFrctionD.rbtnTopPercMonitorIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoTopXPercent;
                            _speciesFrctionD.rbtnAllMonitorGreaterIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoUseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.rbtnTopNumMonitorIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoUseTopXNumber;
                            _speciesFrctionD.rbtnTopPercMonitorPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoTopXPercent;
                            _speciesFrctionD.rbtnAllMonitorGreaterPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoUseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.rbtnTopNumMonitorPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoTopXNumber;
                            _speciesFrctionD.nudownTopPercMonitorIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_TopXPercent;
                            _speciesFrctionD.nudownAllMonitorGreaterIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_UseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.nudownMinNumAboveIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_MinumumNumberOfDaysRequiredAboveFixedAmount;
                            _speciesFrctionD.nudownTopNumMonitorIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_UseTopXNumber;
                            _speciesFrctionD.nudownTopPercMonitorPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_TopXPercent;
                            _speciesFrctionD.nudownAllMonitorGreaterPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_UseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.nudownMinNumAbovePMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_MinumumNumberOfDaysRequiredAboveFixedAmount;
                            _speciesFrctionD.nudownTopNumMonitorPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_TopXNumber;
                            _speciesFrctionD.cboPM25InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodPM25;
                            _speciesFrctionD.nudownPM25DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distancePM25;
                            _speciesFrctionD.cboSO4InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodSO4;
                            _speciesFrctionD.nudownSO4DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceSO4;
                            _speciesFrctionD.cboNO3InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodNO3;
                            _speciesFrctionD.nudownNO3DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceNO3;
                            _speciesFrctionD.cboECInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodEC;
                            _speciesFrctionD.nudownECDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceEC;
                            _speciesFrctionD.cboSaltInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodSalt;
                            _speciesFrctionD.nudownSaltDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceSalt;
                            _speciesFrctionD.cboCrastalInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodCrustal;
                            _speciesFrctionD.nudownCrustalDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceCrustal;
                            _speciesFrctionD.cboDONInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodDON;
                            _speciesFrctionD.nudownDONDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceDON;
                            _speciesFrctionD.cboOCInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodOC;
                            _speciesFrctionD.nudownOCDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceOC;
                            _speciesFrctionD.cboNH4InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodNH4;
                            _speciesFrctionD.nudownNH4DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceNH4;
                            _speciesFrctionD.rbtnDONValueDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doUseDonValues;
                            _speciesFrctionD.rbtnMeasuredAmmoniumDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doUseMeasuredAmmonium;
                            _speciesFrctionD.cboPM25InterpolationDaily.Enabled = false;
                            _speciesFrctionD.nudownPM25DistanceDaily.Enabled = false;
                            if (_speciesFrctionD.rbtnDONValueDaily.Checked == true)
                            {
                                _speciesFrctionD.cboDONInterpolationDaily.Enabled = true;
                                _speciesFrctionD.nudownDONDistanceDaily.Enabled = true;
                                _speciesFrctionD.cboNH4InterpolationDaily.Enabled = false;
                                _speciesFrctionD.nudownNH4DistanceDaily.Enabled = false;
                                _speciesFrctionD.nudownNH4PercDaily.Enabled = false;
                            }
                            if (_speciesFrctionD.rbtnMeasuredAmmoniumDaily.Checked == true)
                            {
                                _speciesFrctionD.cboDONInterpolationDaily.Enabled = false;
                                _speciesFrctionD.nudownDONDistanceDaily.Enabled = false;
                                _speciesFrctionD.cboNH4InterpolationDaily.Enabled = true;
                                _speciesFrctionD.nudownNH4DistanceDaily.Enabled = true;
                                _speciesFrctionD.nudownNH4PercDaily.Enabled = true;
                            }
                            _speciesFrctionD.nudownNH4PercDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.nh4PercentageEvaporating;
                            _speciesFrctionD.nudownDefaultBMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.defaultBlankMass;
                            _speciesFrctionD.nudownOCmbFloorDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.floorOCMMB;
                            _speciesFrctionD.nudownOCmbCeilingDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.ceilingOCMMB;
                            #endregion
                        }
                        break;
                    case "calculationoptionsd":
                        pnlUserControl.Controls.Add(new uc_PM25CalculationD());
                        lblSteps.Text = trvAnalysis.Nodes[4].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Set up pm25 calculation options";
                        uc_PM25CalculationD _pmCalculationD = (pnlUserControl.Controls[0] as uc_PM25CalculationD);

                        //----------------bind required dv,according to start year-------------
                        n = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Count;
                        dvString = new string[n];
                        for (int i = 0; i < n; i++)
                        {
                            dvString[i] = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears[i];
                        }
                        for (int i = 0; i < n; i++)
                        {
                            if (i + 2 < n)
                            {
                                _pmCalculationD.clboRequiredDV.Items.Add(dvString[i] + "-" + dvString[i + 2]);
                            }
                        }

                        _pmCalculationD.cboStartYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        _pmCalculationD.cboEndYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD = new PM25CalculationOptionsD();
                            if (_pmCalculationD.cboStartYearD.Items.Count >= 8)
                                _pmCalculationD.cboStartYearD.SelectedIndex = 7;
                            else
                                _pmCalculationD.cboStartYearD.SelectedIndex = _pmCalculationD.cboStartYearD.Items.Count - 1;
                            if (_pmCalculationD.cboEndYearD.Items.Count >= 12)
                                _pmCalculationD.cboEndYearD.SelectedIndex = 11;
                            else
                                _pmCalculationD.cboEndYearD.SelectedIndex = _pmCalculationD.cboEndYearD.Items.Count - 1;
                            _pmCalculationD.nudownMinNumDVD.Value = 1;
                            _pmCalculationD.txtRequiredDVD.Text = "None selected";
                            _pmCalculationD.rbtnCalculateNH4byDON.Checked = true;
                        }
                        else
                        {
                            _pmCalculationD.cboStartYearD.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.officialPM25StartYear;
                            _pmCalculationD.cboEndYearD.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.officialPM25EndYear;
                            _pmCalculationD.nudownMinNumDVD.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.minNumDVPeriodsForValidFRMMonitors;
                            _pmCalculationD.txtRequiredDVD.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.requiredDesignValuePeriodsForValidFRMMonitors;
                            if (_pmCalculationD.txtRequiredDVD.Text != "None selected")
                            {
                                string[] requireDV = _pmCalculationD.txtRequiredDVD.Text.Split(',');
                                foreach (string s in requireDV)
                                {
                                    _pmCalculationD.clboRequiredDV.SetItemChecked(_pmCalculationD.clboRequiredDV.Items.IndexOf(s), true);
                                }
                            }
                            _pmCalculationD.rbtnCalculateNH4byDON.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.doCalcNH4fromDON;
                            _pmCalculationD.rbtnCalculateNH4byRRF.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.doCalcNH4fromRRF;
                        }
                        break;
                    case "modeld":
                        pnlUserControl.Controls.Add(new uc_ModelDataD());
                        lblSteps.Text = trvAnalysis.Nodes[5].Text;
                        _stips = "Set up model options";
                        uc_ModelDataD _modelDataD = (pnlUserControl.Controls[0] as uc_ModelDataD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD = new ModelDataOptionsD();
                            _modelDataD.cboGridPointModelOptionDaily.SelectedIndex = 0;
                            _modelDataD.choGridforSpatialForecast.SelectedIndex = 0;
                            _modelDataD.cboStatisticMethodDaily.SelectedIndex = 0;
                            _modelDataD.rbtnTopPerceRRFDaily.Checked = true;
                            _modelDataD.nudownTopPerceRRFDaily.Value = 10;
                            _modelDataD.nudownAllDailyGreaterRRFDaily.Value = 0;
                            _modelDataD.nudownMinNumDaysGreaterRRFDaily.Value = 1;
                            _modelDataD.nudownTopNumRRFDaily.Value = 25;
                        }
                        else
                        {
                            _modelDataD.cboGridPointModelOptionDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentAtMonitorGridPoint;
                            _modelDataD.choGridforSpatialForecast.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentAtMonitorGridSpatial;
                            _modelDataD.cboStatisticMethodDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentType;
                            _modelDataD.rbtnTopPerceRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseXTopPercent;
                            _modelDataD.nudownTopPerceRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseXTopPercent;
                            _modelDataD.rbtnAllDailyGreaterRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseAllModelDaysGreaterThan;
                            _modelDataD.nudownAllDailyGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseAllModelDaysGreaterThan;
                            _modelDataD.nudownMinNumDaysGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_MinumumNumberOfDaysRequiredAboveFixedAmount;
                            _modelDataD.rbtnTopNumRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseTopXNumber;
                            _modelDataD.nudownTopNumRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseTopXNumber;
                        }
                        break;
                    #endregion
                    #region Ozone added by sclong
                    case "outputo":
                        #region Desired Output
                        pnlUserControl.Controls.Add(new uc_DesiredOutputOzone());

                        uc_DesiredOutputOzone _desiredOutputOzone = (pnlUserControl.Controls[0] as uc_DesiredOutputOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO = new ChooseDesiredOutputO();
                            _desiredOutputOzone.choPointForecastOzone.Checked = true;
                            _desiredOutputOzone.choSpatialOzone.Checked = false;
                            _desiredOutputOzone.choSpatialGradAdjOzone.Checked = false;
                            _desiredOutputOzone.choBaseOnlyVNAOzone.Checked = false;
                            _desiredOutputOzone.choFutureOnlyVNAOzone.Checked = false;
                            _desiredOutputOzone.chkDS.Checked = false;
                            _desiredOutputOzone.txtDSBurn.Text = "500";
                            _desiredOutputOzone.txtDSCmaqres.Text = "12";
                            _desiredOutputOzone.txtDSNumit.Text = "2500";
                            _desiredOutputOzone.txtDSThin.Text = "1";

                            _desiredOutputOzone.choBaseOnlyEvnaOzone.Checked = false;
                            _desiredOutputOzone.choFutureOnlyEvnaOzone.Checked = false;
                            //_desiredOutputOzone.choSpatialForecastOzone.Checked = false;
                            //_desiredOutputOzone.choSpatialGradAdjForecastOzone.Checked = false;
                            _desiredOutputOzone.choNeighborFileSpatial.Checked = false;
                            _desiredOutputOzone.choQuarterlyModelData.Checked = true;
                            _desiredOutputOzone.choExtractAllOzone.Checked = true;
                            _desiredOutputOzone.choDVPeriods.Checked = false;
                        }
                        else
                        {
                            _desiredOutputOzone.txtScenarioOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                            _desiredOutputOzone.choPointForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doPointEstimatesForecast;
                            _desiredOutputOzone.choQuarterlyModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doQuarterlyModelData;
                            _desiredOutputOzone.choSpatialOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates;
                            _desiredOutputOzone.choSpatialGradAdjOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj;
                            _desiredOutputOzone.choBaseOnlyVNAOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA;
                            _desiredOutputOzone.choFutureOnlyVNAOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA;
                            _desiredOutputOzone.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDownscaler;
                            _desiredOutputOzone.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSBurn.ToString();
                            _desiredOutputOzone.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSCmaqres.ToString();
                            _desiredOutputOzone.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSNumit.ToString();
                            _desiredOutputOzone.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSThin.ToString();


                            _desiredOutputOzone.choBaseOnlyEvnaOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA;
                            _desiredOutputOzone.choFutureOnlyEvnaOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA;
                            //_desiredOutputOzone.choSpatialForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecast;
                            //_desiredOutputOzone.choSpatialGradAdjForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecastGradAdj;
                            _desiredOutputOzone.choNeighborFileSpatial.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doNeighborFileSpatial;
                            _desiredOutputOzone.choExtractAllOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doAutomaticallyExtract;
                            _desiredOutputOzone.choDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDesignValuePeriods;
                            _desiredOutputOzone.choMaxDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doMaxDesignValuePeriods;
                        }
                        #endregion
                        break;
                    case "datainputo":
                        #region Data Input
                        pnlUserControl.Controls.Add(new uc_DataInputOzone());
                        uc_DataInputOzone _dataInputOzone = (pnlUserControl.Controls[0] as uc_DataInputOzone);
                        _dataInputOzone.InitializeControl();
                        #endregion
                        break;
                    case "filteringinterpolationo":
                        #region Filtering/Interpolation
                        pnlUserControl.Controls.Add(new uc_FilteringorInterpolationOzone());
                        uc_FilteringorInterpolationOzone _filteringorInterpolationOzone = (pnlUserControl.Controls[0] as uc_FilteringorInterpolationOzone);

                        //----------------bind required dv,according to start year-------------
                        int j = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData.Count;
                        string[] dvStringOzone = new string[j];
                        for (int i = 0; i < j; i++)
                        {
                            dvStringOzone[i] = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData[i];
                        }

                        _filteringorInterpolationOzone.clboRequiredDV.Items.Add((Convert.ToInt32(dvStringOzone[0]) - 2).ToString() + "-" + dvStringOzone[0]);
                        _filteringorInterpolationOzone.clboRequiredDV.Items.Add((Convert.ToInt32(dvStringOzone[0]) - 1).ToString() + "-" + dvStringOzone[1]);
                        for (int i = 0; i < j; i++)
                        {
                            if (i + 2 < j)
                            {
                                _filteringorInterpolationOzone.clboRequiredDV.Items.Add(dvStringOzone[i] + "-" + dvStringOzone[i + 2]);
                            }
                        }
                        foreach (var item in _filteringorInterpolationOzone.clboRequiredDV.Items)
                        {
                            _filteringorInterpolationOzone.cboStartYearOzone.Items.Add(item);
                            _filteringorInterpolationOzone.cboEndYearOzone.Items.Add(item);
                        };
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO = new FilteringInterpolationO();
                            if (_filteringorInterpolationOzone.cboStartYearOzone.Items.Count >= 10)
                                _filteringorInterpolationOzone.cboStartYearOzone.SelectedIndex = 9;
                            else
                                _filteringorInterpolationOzone.cboStartYearOzone.SelectedIndex = _filteringorInterpolationOzone.cboStartYearOzone.Items.Count - 1;
                            if (_filteringorInterpolationOzone.cboEndYearOzone.Items.Count >= 12)
                                _filteringorInterpolationOzone.cboEndYearOzone.SelectedIndex = 11;
                            else
                                _filteringorInterpolationOzone.cboEndYearOzone.SelectedIndex = _filteringorInterpolationOzone.cboEndYearOzone.Items.Count - 1;
                            _filteringorInterpolationOzone.nudownMinNumDVO.Value = 1;
                            _filteringorInterpolationOzone.txtRequiredDVOzone.Text = "None selected";
                            _filteringorInterpolationOzone.cboDefaultItpOzone.SelectedIndex = 1;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Checked = false;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Value = 100;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Enabled = false;
                        }
                        else
                        {
                            _filteringorInterpolationOzone.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.ozoneStartYear;
                            _filteringorInterpolationOzone.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.ozoneEndYear;
                            _filteringorInterpolationOzone.nudownMinNumDVO.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.minNumDV;
                            _filteringorInterpolationOzone.txtRequiredDVOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.requiredDVPeriods;
                            if (_filteringorInterpolationOzone.txtRequiredDVOzone.Text != "None selected")
                            {
                                string[] requireDV = _filteringorInterpolationOzone.txtRequiredDVOzone.Text.Split(',');
                                foreach (string s in requireDV)
                                {
                                    _filteringorInterpolationOzone.clboRequiredDV.SetItemChecked(_filteringorInterpolationOzone.clboRequiredDV.Items.IndexOf(s), true);
                                }
                            }
                            _filteringorInterpolationOzone.cboDefaultItpOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.defaultInterpolationMethod;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.doCheckToSetMaxDistance;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Enabled = _filteringorInterpolationOzone.choMaxItpDistanceOzone.Checked ? true : false;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.maxDistance;
                        }
                        //Turn gray or not(Filteringor/Interpolation) by according to the Spatial Field item(Desired Output)checked or not
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates == false && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj == false
                            && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA == false && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA == false
                            && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA == false && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA == false)
                        {
                            _filteringorInterpolationOzone.cboDefaultItpOzone.Enabled = false;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Enabled = false;
                        }
                        else
                        {
                            _filteringorInterpolationOzone.cboDefaultItpOzone.Enabled = true;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Enabled = true;
                        }
                        #endregion
                        break;
                    case "rrfspatialgradiento":
                        #region RRF/Spatial Gradient
                        pnlUserControl.Controls.Add(new uc_RRForSpatialGradientOzone());
                        uc_RRForSpatialGradientOzone _rrforSpatialGradientOzone = (pnlUserControl.Controls[0] as uc_RRForSpatialGradientOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO = new RRFSpatialGradientO();
                            _rrforSpatialGradientOzone.rbtnInitial.Checked = false;
                            _rrforSpatialGradientOzone.rbtnTopX.Checked = true;
                            _rrforSpatialGradientOzone.txtInitialValueOzone.Text = "85";
                            _rrforSpatialGradientOzone.txtAboveThresholdOzone.Text = "10";
                            _rrforSpatialGradientOzone.txtTopX.Text = "10";
                            _rrforSpatialGradientOzone.txtAllowableValueOzone.Text = "60";
                            _rrforSpatialGradientOzone.txtAboveAllowableThresholdOzone.Text = "5";
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked = false;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Enabled = false;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Text = "60";
                            _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Value = 1;
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays > 0)
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                            }
                            else
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = 366;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = 366;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = 366;
                            }
                            _rrforSpatialGradientOzone.choPairDaysOzone.Checked = false;
                            _rrforSpatialGradientOzone.txtStartValueOzone.Text = "1";
                            _rrforSpatialGradientOzone.txtEndValueOzone.Text = "5";
                        }
                        else
                        {
                            _rrforSpatialGradientOzone.rbtnInitial.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.useInitialThreshold;
                            _rrforSpatialGradientOzone.rbtnTopX.Checked = !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.useInitialThreshold;
                            _rrforSpatialGradientOzone.txtInitialValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.initialThresholdValue;
                            _rrforSpatialGradientOzone.txtAboveThresholdOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minNumofDaysAtorAboveThreshold;
                            _rrforSpatialGradientOzone.txtTopX.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.topXDays.ToString();
                            _rrforSpatialGradientOzone.txtAllowableValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minAllowableThresholdValue;
                            _rrforSpatialGradientOzone.txtAboveAllowableThresholdOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minNumDaysAtorAboveMinAllowableThreshold;
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.doBackstop;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.backstopMinThresholdforSpatialField;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Enabled = _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked ? true : false;
                            _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.subrangeFirstDay;
                            _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.subrangeLastDay;
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays > 0)
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                            }
                            else
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = 366;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = 366;
                            }
                            _rrforSpatialGradientOzone.choPairDaysOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.doPairDays;
                            _rrforSpatialGradientOzone.txtStartValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.SRF_StartValue;
                            _rrforSpatialGradientOzone.txtEndValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.SRF_EndValue;
                        }
                        //some control will turn gray(Unable to use) if it meets these requirements in Desired Output
                        if (!(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj
                            && !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA
                            //&& !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates
                            //&& !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA
                            )
                        {
                            _rrforSpatialGradientOzone.txtStartValueOzone.Text = "1";
                            _rrforSpatialGradientOzone.txtEndValueOzone.Text = "5";
                            _rrforSpatialGradientOzone.txtStartValueOzone.Enabled = false;
                            _rrforSpatialGradientOzone.txtEndValueOzone.Enabled = false;
                        }
                        else
                        {
                            _rrforSpatialGradientOzone.txtStartValueOzone.Enabled = true;
                            _rrforSpatialGradientOzone.txtEndValueOzone.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates
|| (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj
|| (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA
|| (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA)
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Enabled = true;
                        else
                        {
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Enabled = false;
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked = false;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Enabled = false;
                        }
                        #endregion
                        break;
                    #endregion
                    #region Visibility added by sclong

                    case "outputv":
                        #region uc_ChooseDesiredOutputV
                        pnlUserControl.Controls.Add(new uc_ChooseDesiredOutputV());
                        uc_ChooseDesiredOutputV _outPutV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV = new ChooseDesiredOutputV();
                            _outPutV.choVisibilityLevels.Checked = true;
                            _outPutV.rbtnOldIMPROVEAlgorithmVisibility.Checked = false;
                            _outPutV.rbtnNewIMPROVEAlgorithmVisibility.Checked = true;
                            _outPutV.rbtnModelGridCellatMonitorVisi.Checked = false;
                            _outPutV.rbtnModelGridCellatClass1Visi.Checked = false;
                            _outPutV.choExtractAllVisibility.Checked = true;
                        }
                        else
                        {
                            _outPutV.txtScenarioNameVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                            _outPutV.choVisibilityLevels.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast;
                            _outPutV.rbtnOldIMPROVEAlgorithmVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm;
                            _outPutV.rbtnNewIMPROVEAlgorithmVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseNewVersionforIMPROVEAlgorithm;
                            _outPutV.rbtnModelGridCellatMonitorVisi.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellAtMonitor;
                            _outPutV.rbtnModelGridCellatClass1Visi.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellatClassIAreaCentroid;
                            _outPutV.choExtractAllVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doAutomaticallyExtract;
                        }
                        #endregion
                        break;
                    case "datainputv":
                        #region uc_DataInputV
                        pnlUserControl.Controls.Add(new uc_DataInputV());
                        uc_DataInputV _dataInputV = (pnlUserControl.Controls[0] as uc_DataInputV);
                        _dataInputV.InitializeControl();

                        #endregion
                        break;
                    case "filteringv":
                        #region uc_FilteringV
                        pnlUserControl.Controls.Add(new uc_FilteringV());
                        uc_FilteringV _filteringV = (pnlUserControl.Controls[0] as uc_FilteringV);
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm)
                        {
                            _filteringV.cboStartYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataOld.Distinct().ToList();
                            _filteringV.cboEndYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataOld.Distinct().ToList();
                            _filteringV.cboBaseYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataOld.Distinct().ToList();
                        }
                        else
                        {
                            _filteringV.cboStartYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataNew.Distinct().ToList();
                            _filteringV.cboEndYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataNew.Distinct().ToList();
                            _filteringV.cboBaseYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataNew.Distinct().ToList();
                        }


                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV = new FilteringV();
                            if (_filteringV.cboStartYearVisibility.Items.Count > 11)
                                _filteringV.cboStartYearVisibility.SelectedIndex = 10;
                            else
                                _filteringV.cboStartYearVisibility.SelectedIndex = _filteringV.cboStartYearVisibility.Items.Count - 1;
                            if (_filteringV.cboEndYearVisibility.Items.Count > 13)
                                _filteringV.cboEndYearVisibility.SelectedIndex = 12;
                            else
                                _filteringV.cboEndYearVisibility.SelectedIndex = _filteringV.cboEndYearVisibility.Items.Count - 1;
                            if (_filteringV.cboBaseYearVisibility.Items.Count > 12)
                                _filteringV.cboBaseYearVisibility.SelectedIndex = 11;
                            else
                                _filteringV.cboBaseYearVisibility.SelectedIndex = _filteringV.cboBaseYearVisibility.Items.Count - 1;
                            _filteringV.txtMinYearVisibility.Text = "3";
                        }
                        else
                        {
                            _filteringV.cboStartYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.startMonitorYear;
                            _filteringV.cboEndYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.endMonitorYear;
                            _filteringV.cboBaseYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.baseModelYear;
                            _filteringV.txtMinYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.minYearsForValidVisibilityMonitors;

                        }
                        #endregion
                        break;
                    #endregion
                    #region SSIA
                    case "ssiaoption":
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                        {
                            _stips = "PM Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = true;
                                _analysisOption.rbtnGridAndDispersion.Checked = false;
                                _analysisOption.rbtnGridOnly.Checked = true;
                                _analysisOption.rbtnDispersionOnly.Checked = false;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData;
                                _analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion;
                                _analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly;
                                _analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                        {
                            _stips = "PM Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = true;
                                _analysisOption.rbtnGridAndDispersion.Checked = false;
                                _analysisOption.rbtnGridOnly.Checked = true;
                                _analysisOption.rbtnDispersionOnly.Checked = false;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData;
                                _analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion;
                                _analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly;
                                _analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                        {
                            _stips = "Ozone Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = true;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData;
                            }
                        }
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)    //added by Lijiabin
                        {
                            _stips = "Deposition Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = false;
                                _analysisOption.rbtnGridAndDispersion.Checked = false;
                                _analysisOption.rbtnGridOnly.Checked = false;
                                _analysisOption.rbtnDispersionOnly.Checked = false;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelFRMData;
                                //_analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridAndDispersion;
                                //_analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridOnly;
                                //_analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useDispersionOnly;
                            }
                        }
                        break;
                    case "ssiamodelinput":
                        lblSteps.Text = Language.Localization.GetValue("Model Data Input & Option");
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                        {
                            pnlUserControl.Controls.Add(new uc_ModelDataInputA());
                            uc_ModelDataInputA _modelInput = (pnlUserControl.Controls[0] as uc_ModelDataInputA);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA = new SSIAModelDataInputA();
                                if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion)
                                {
                                    _modelInput.rbtnDailyModelA.Checked = true;
                                    _modelInput.rbtnQuarterlyModelA.Checked = false;
                                    //_modelInput.rbtnCMAQA.Checked = false;
                                    if (CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM"))
                                    {
                                        //
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"];
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"]; ;
                                        CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"];
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                        CommonClass.dispersionModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                    }
                                    _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly)
                                {
                                    _modelInput.rbtnDailyModelA.Checked = true;
                                    _modelInput.rbtnQuarterlyModelA.Checked = false;
                                    //_modelInput.rbtnCMAQA.Checked = false;
                                    if (CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM"))
                                    {
                                        //
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"];
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"];
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                    }

                                    _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    _modelInput.panelDispersion.Visible = false;
                                    _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.pnlSourceFile.Location.X, _modelInput.pnlSourceFile.Location.Y - _modelInput.panelDispersion.Height);
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                                {
                                    if (CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM"))
                                    {
                                        CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"];
                                    }
                                    else
                                    {
                                        CommonClass.dispersionModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                    }

                                    _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    _modelInput.panelGrid.Visible = false;
                                    _modelInput.panelDispersion.Location = new System.Drawing.Point(_modelInput.panelGrid.Location.X, _modelInput.panelGrid.Location.Y);
                                    _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.pnlSourceFile.Location.X, _modelInput.pnlSourceFile.Location.Y - _modelInput.panelGrid.Height);
                                }
                                if (CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM"))
                                {
                                    CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["sourceCoordinatesFile"];
                                }
                                else
                                {
                                    CommonClass.ssiasourcefile = Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                                }
                                _modelInput.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                            }
                            else
                            {
                                if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion)
                                {
                                    _modelInput.rbtnDailyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.DailyModelDataInput;
                                    _modelInput.rbtnQuarterlyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.QuarterlyModelDataInput;
                                    //_modelInput.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.InputFromCMAQ;
                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile))
                                    {
                                        CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile;
                                        _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        //CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }

                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile))
                                    {
                                        CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile;
                                        _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                        _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }

                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile))
                                    {
                                        CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile;
                                        _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                        _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly)
                                {
                                    _modelInput.rbtnDailyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.DailyModelDataInput;
                                    _modelInput.rbtnQuarterlyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.QuarterlyModelDataInput;
                                    //_modelInput.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.InputFromCMAQ;
                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile))
                                    {
                                        CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile;
                                        _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }

                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile))
                                    {
                                        CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile;
                                        _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                        _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }
                                    _modelInput.panelDispersion.Visible = false;
                                    _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.pnlSourceFile.Location.X, _modelInput.pnlSourceFile.Location.Y - _modelInput.panelDispersion.Height);
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                                {
                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile))
                                    {
                                        CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile;
                                        _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                        _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                    _modelInput.panelGrid.Visible = false;
                                    _modelInput.panelDispersion.Location = new System.Drawing.Point(_modelInput.panelGrid.Location.X, _modelInput.panelGrid.Location.Y);
                                    _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.pnlSourceFile.Location.X, _modelInput.pnlSourceFile.Location.Y - _modelInput.panelGrid.Height);
                                }
                                CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.SourceCoordinateFile;
                                _modelInput.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                        {
                            pnlUserControl.Controls.Add(new uc_ModelDataInputD());
                            uc_ModelDataInputD _modelInputD = (pnlUserControl.Controls[0] as uc_ModelDataInputD);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD = new SSIAModelDataInputD();
                                if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion)
                                {
                                    _modelInputD.rbtnDailyModelDataD.Checked = true;
                                    _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = false;
                                    //_modelInputD.rbtnCMAQFileD.Checked = false;
                                    if (CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM"))
                                    {
                                        //
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"];
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"]; ;
                                        CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"];
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                        CommonClass.dispersionModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                                    }
                                    _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly)
                                {
                                    _modelInputD.rbtnDailyModelDataD.Checked = true;
                                    _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = false;
                                    //_modelInputD.rbtnCMAQFileD.Checked = false;
                                    if (CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM"))
                                    {
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"];
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"];
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                    }

                                    _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    _modelInputD.panelDispersion.Visible = false;
                                    _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y);
                                    _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.pnlSourceFile.Location.Y - _modelInputD.panelDispersion.Height);
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)
                                {
                                    CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";

                                    _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    _modelInputD.panelGrid.Visible = false;
                                    _modelInputD.panelDispersion.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y - _modelInputD.panelGrid.Size.Height);
                                    _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelOptions.Location.X, _modelInputD.panelOptions.Location.Y - _modelInputD.panelGrid.Size.Height);
                                    _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.pnlSourceFile.Location.Y - _modelInputD.panelGrid.Height);
                                }
                                _modelInputD.cboGridPointModelOptionDaily.SelectedIndex = 0;
                                //_modelInputD.cboGridforSpatialForecast.SelectedIndex = 0;
                                _modelInputD.cboStatisticMethodDaily.SelectedIndex = 0;
                                _modelInputD.rbtnTopPerceRRFDaily.Checked = true;
                                _modelInputD.nudownTopPerceRRFDaily.Value = 10;
                                _modelInputD.nudownAllDailyGreaterRRFDaily.Value = 0;
                                _modelInputD.nudownMinNumDaysGreaterRRFDaily.Value = 1;
                                _modelInputD.nudownTopNumRRFDaily.Value = 25;

                                CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["sourceCoordinatesFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                                _modelInputD.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                            }
                            else
                            {
                                if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion)
                                {
                                    _modelInputD.rbtnDailyModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.DailyModelDataInput;
                                    _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.QuarterlyModelDataInput;
                                    //_modelInputD.rbtnCMAQFileD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.InputFromCMAQ;
                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile))
                                    {
                                        CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile;
                                        _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }

                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile))
                                    {
                                        CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile;
                                        _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                        _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }

                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile))
                                    {
                                        CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile;
                                        _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                                        _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly)
                                {
                                    _modelInputD.rbtnDailyModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.DailyModelDataInput;
                                    _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.QuarterlyModelDataInput;
                                    //_modelInputD.rbtnCMAQFileD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.InputFromCMAQ;
                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile))
                                    {
                                        CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile;
                                        _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                        _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                    }

                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile))
                                    {
                                        CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile;
                                        _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                        _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                    }
                                    _modelInputD.panelDispersion.Visible = false;
                                    _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y);
                                    _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.pnlSourceFile.Location.Y - _modelInputD.panelDispersion.Height);
                                }
                                else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)
                                {
                                    if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile))
                                    {
                                        CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile;
                                        _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                    else
                                    {
                                        CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                                        _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                    }
                                    _modelInputD.panelGrid.Visible = false;
                                    _modelInputD.panelDispersion.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y - _modelInputD.panelGrid.Size.Height);
                                    _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelOptions.Location.X, _modelInputD.panelOptions.Location.Y - _modelInputD.panelGrid.Size.Height);
                                    _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.pnlSourceFile.Location.Y - _modelInputD.panelGrid.Height);
                                }
                                _modelInputD.cboGridPointModelOptionDaily.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentAtMonitorGridPoint;
                                //_modelInputD.cboGridforSpatialForecast.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentAtMonitorGridSpatial;
                                _modelInputD.cboStatisticMethodDaily.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentType;
                                _modelInputD.rbtnTopPerceRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseXTopPercent;
                                _modelInputD.nudownTopPerceRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseXTopPercent;
                                _modelInputD.rbtnAllDailyGreaterRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseAllModelDaysGreaterThan;
                                _modelInputD.nudownAllDailyGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseAllModelDaysGreaterThan;
                                _modelInputD.nudownMinNumDaysGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_MinumumNumberOfDaysRequiredAboveFixedAmount;
                                _modelInputD.rbtnTopNumRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseTopXNumber;
                                _modelInputD.nudownTopNumRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseTopXNumber;

                                CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.SourceCoordinateFile;
                                _modelInputD.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                        {
                            pnlUserControl.Controls.Add(new uc_ModelDataInputO());
                            _stips = "Model Data Input & Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            uc_ModelDataInputO _modelDataInputO = (pnlUserControl.Controls[0] as uc_ModelDataInputO);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO = new SSIAModelDataInputO();
                                _modelDataInputO.choCMAQOzone.Checked = false;
                                if (CommonClass.dicExampleConfiguration.ContainsKey("SSIAOzone"))
                                {
                                    //
                                    CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["baselineModelFile"];
                                    CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["forecastModelFile"]; ;
                                    CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIAOzone"]["sourceCoordinatesFile"];
                                }
                                else
                                {
                                    CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.O3.4ATL1.2007ee_07f_BASE.csv";
                                    CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.O3.4ATL1.2007ee_07f_ALT.csv";
                                    CommonClass.ssiasourcefile = Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                                }
                                _modelDataInputO.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                                _modelDataInputO.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                                _modelDataInputO.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                            }
                            else
                            {
                                _modelDataInputO.choCMAQOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.doInputfromCmaq;
                                CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.baselineModelDataFile;
                                _modelDataInputO.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.forecastModelDataFile;
                                _modelDataInputO.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                                CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.SourceCoordinateFile;
                                _modelDataInputO.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                            }
                        }
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)    //added by Lijiabin
                        {
                            pnlUserControl.Controls.Add(new uc_ModelDataInputDep());
                            uc_ModelDataInputDep _modelInputDep = (pnlUserControl.Controls[0] as uc_ModelDataInputDep);
                            _modelInputDep.rbtnQuarterlyModelDataDep.Enabled = false;
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep = new SSIAModelDataInputDep();
                                _modelInputDep.rbtnDailyModelDataDep.Checked = true;
                                _modelInputDep.rbtnQuarterlyModelDataDep.Checked = false;
                                ////_modelInput.rbtnCMAQA.Checked = false;
                                ///
                                if (CommonClass.dicExampleConfiguration.ContainsKey("SSIADeposition"))
                                {
                                    //
                                    CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADeposition"]["baselineModelFile"];
                                    CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADeposition"]["forecastModelFile"]; ;
                                    CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIADeposition"]["sourceCoordinatesFile"];
                                }
                                else
                                {
                                    CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_baseline.csv";
                                    CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_13.csv";
                                    CommonClass.ssiasourcefile = Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.sourcecoords.12WUS1.tag013.csv";
                                }

                                _modelInputDep.txtBaselineDep.Text = Path.GetFileName(CommonClass.baseModelFile);

                                _modelInputDep.txtForecastDep.Text = Path.GetFileName(CommonClass.futureModelFile);

                                _modelInputDep.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                                //CommonClass.dispersionModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                //_modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);                              
                            }
                            else
                            {
                                _modelInputDep.rbtnDailyModelDataDep.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.DailyModelDataInput;
                                _modelInputDep.rbtnQuarterlyModelDataDep.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.QuarterlyModelDataInput;
                                ////_modelInput.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.InputFromCMAQ;
                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.baselineModelDataFile))
                                {
                                    CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.baselineModelDataFile;
                                    _modelInputDep.txtBaselineDep.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }
                                else
                                {
                                    CommonClass.baseModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADeposition") ? CommonClass.dicExampleConfiguration["SSIADeposition"]["baselineModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_baseline.csv";
                                    _modelInputDep.txtBaselineDep.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }

                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.alternativeScenarioFile))
                                {
                                    CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.alternativeScenarioFile;
                                    _modelInputDep.txtForecastDep.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                                else
                                {
                                    CommonClass.futureModelFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADeposition") ? CommonClass.dicExampleConfiguration["SSIADeposition"]["forecastModelFile"] : Application.StartupPath + @"\Data\SampleData\SSIA\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_13.csv";
                                    _modelInputDep.txtForecastDep.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                            }
                            CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.SourceCoordinateFile;
                            _modelInputDep.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        break;
                    case "ssiamonitorinput":
                        lblSteps.Text = Language.Localization.GetValue("Monitor Data Input & Option");
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                        {
                            pnlUserControl.Controls.Add(new uc_MonitorDataInputA());
                            uc_MonitorDataInputA _monitorInput = (pnlUserControl.Controls[0] as uc_MonitorDataInputA);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA = new SSIAMonitorDataInputA();

                                CommonClass.officialPMFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["officialMonitorFile"] : (Application.StartupPath + @"\Data\SampleData\Monitor_data\official_annual-PM25_2002thru2017.csv");//official_annual-PM25_allFRM 121013.csv";official_annual-PM25_allFRM.NID2002thru2015_v2.csv
                                CommonClass.getmonitorYear("");
                                _monitorInput.txtOfficialMonitorA.Text = Path.GetFileName(CommonClass.officialPMFile);
                                _monitorInput.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                _monitorInput.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                if (_monitorInput.cboStartYearA.Items.Count > 7)
                                    _monitorInput.cboStartYearA.SelectedIndex = 6;
                                else
                                    _monitorInput.cboStartYearA.SelectedIndex = _monitorInput.cboStartYearA.Items.Count - 1;
                                if (_monitorInput.cboEndYearA.Items.Count > 11)
                                {
                                    _monitorInput.cboEndYearA.SelectedIndex = 10;
                                }
                                else
                                {
                                    _monitorInput.cboEndYearA.SelectedIndex = _monitorInput.cboEndYearA.Items.Count - 1;
                                }
                                _monitorInput.choVNA.Checked = true;
                                _monitorInput.choEVNA.Checked = true;
                                _monitorInput.cboPointGridA.Text = "1x1";
                            }
                            else
                            {
                                CommonClass.officialPMFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.officialMonitorDataFile;
                                _monitorInput.txtOfficialMonitorA.Text = Path.GetFileName(CommonClass.officialPMFile);
                                _monitorInput.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                _monitorInput.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                _monitorInput.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.monitorDataStartYear;
                                _monitorInput.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.monitorDataEndYear;
                                _monitorInput.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useVNA;
                                _monitorInput.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useEVNA;
                                _monitorInput.cboPointGridA.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.temporalAdjustmentAtMonitorGrid;
                            }
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                            {
                                _monitorInput.choVNA.Checked = true;
                                _monitorInput.choEVNA.Checked = false;
                                _monitorInput.choVNA.Enabled = false;
                                _monitorInput.choEVNA.Enabled = false;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                        {
                            pnlUserControl.Controls.Add(new uc_MonitorDataInputD());
                            uc_MonitorDataInputD _monitorInputD = (pnlUserControl.Controls[0] as uc_MonitorDataInputD);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD = new SSIAMonitorDataInputD();

                                CommonClass.officialPMFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIADailyPM") ? CommonClass.dicExampleConfiguration["SSIADailyPM"]["officialMonitorFile"] : Application.StartupPath + @"\Data\SampleData\Monitor_data\official_24-hr-PM25.NID2002thru2015_v2.csv";
                                CommonClass.getmonitorYear("");
                                _monitorInputD.txtOfficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.officialPMFile);
                                _monitorInputD.cboStartYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                _monitorInputD.cboEndYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                if (_monitorInputD.cboStartYearD.Items.Count > 7)
                                    _monitorInputD.cboStartYearD.SelectedIndex = 6;
                                else
                                    _monitorInputD.cboStartYearD.SelectedIndex = _monitorInputD.cboStartYearD.Items.Count - 1;
                                if (_monitorInputD.cboEndYearD.Items.Count > 11)
                                {
                                    _monitorInputD.cboEndYearD.SelectedIndex = 10;
                                }
                                else
                                {
                                    _monitorInputD.cboEndYearD.SelectedIndex = _monitorInputD.cboEndYearD.Items.Count - 1;
                                }
                                _monitorInputD.choEVNA.Checked = true;
                                _monitorInputD.choVNA.Checked = true;
                            }
                            else
                            {
                                CommonClass.officialPMFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.officialMonitorDataFile;
                                _monitorInputD.txtOfficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.officialPMFile);
                                _monitorInputD.cboStartYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                _monitorInputD.cboEndYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                                _monitorInputD.cboStartYearD.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.monitorDataStartYear;
                                _monitorInputD.cboEndYearD.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.monitorDataEndYear;
                                _monitorInputD.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useEVNA;
                                _monitorInputD.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useVNA;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                        {
                            pnlUserControl.Controls.Add(new uc_MonitorDataInputO());
                            uc_MonitorDataInputO _monitorInputO = (pnlUserControl.Controls[0] as uc_MonitorDataInputO);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO = new SSIAMonitorDataInputO();
                                CommonClass.ozoneMonitorFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAOzone") ? CommonClass.dicExampleConfiguration["SSIAOzone"]["officialMonitorFile"] : Application.StartupPath + @"\Data\SampleData\Monitor_data\SMAT_OZONE_MAX4DV_STD70_2002_2015.CSV";
                                //MATS_OZONE_DV_2012_V2_off.csv";
                                CommonClass.getmonitorYear("");
                                _monitorInputO.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);

                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData.Sort();
                                List<string> year = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData;
                                for (int i = 0; i < year.Count; i++)
                                {
                                    _monitorInputO.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                    _monitorInputO.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                }

                                if (_monitorInputO.cboStartYearOzone.Items.Count >= 5)
                                    _monitorInputO.cboStartYearOzone.SelectedIndex = 4;
                                else
                                    _monitorInputO.cboStartYearOzone.SelectedIndex = _monitorInputO.cboStartYearOzone.Items.Count - 1;
                                if (_monitorInputO.cboEndYearOzone.Items.Count > 7)
                                    _monitorInputO.cboEndYearOzone.SelectedIndex = 6;
                                else
                                    _monitorInputO.cboEndYearOzone.SelectedIndex = _monitorInputO.cboEndYearOzone.Items.Count - 1;
                                _monitorInputO.choVNA.Checked = true;
                                _monitorInputO.choEVNA.Checked = true;
                                _monitorInputO.cboGridOzone.SelectedIndex = 1;
                                _monitorInputO.cboStatisticOzone.SelectedIndex = 2;

                                _monitorInputO.chkDS.Checked = false;
                                _monitorInputO.txtDSThin.Text = "1";
                                _monitorInputO.txtDSNumit.Text = "2500";
                                _monitorInputO.txtDSCmaqres.Text = "12";
                                _monitorInputO.txtDSBurn.Text = "500";
                            }
                            else
                            {
                                CommonClass.ozoneMonitorFile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneMonitorDataFile;
                                _monitorInputO.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);

                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData.Sort();
                                List<string> year = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData;
                                for (int i = 0; i < year.Count; i++)
                                {
                                    _monitorInputO.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                    _monitorInputO.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                }
                                _monitorInputO.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneStartYear;
                                _monitorInputO.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneEndYear;
                                _monitorInputO.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useVNA;
                                _monitorInputO.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useEVNA;
                                _monitorInputO.cboGridOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.temporalAdjustmentAtMonitorGrid;
                                _monitorInputO.cboStatisticOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.temporalAdjustmentType;

                                _monitorInputO.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useDownscaler;
                                _monitorInputO.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSThin.ToString();
                                _monitorInputO.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSNumit.ToString();
                                _monitorInputO.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSCmaqres.ToString();
                                _monitorInputO.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSBurn.ToString();
                            }
                        }
                        break;
                    case "ssiacalculationoption":
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                        {
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    _calculation.txtNAAQS.Text = CommonClass.IniReadValue("annual pm calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("annual pm calculation option", "Threshold_value", iniPath);
                                    _calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "Start_percentage", iniPath);
                                    _calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    _calculation.txtNAAQS.Text = "12";
                                    _calculation.txtThreshold.Text = "1";
                                    _calculation.nupdStartPercentage.Text = "0";
                                    _calculation.nupdEndPercentage.Text = "100";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold.ToString();
                                _calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.startPercentage.ToString();
                                _calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "(μg/m3) ";
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                        {
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    _calculation.txtNAAQS.Text = CommonClass.IniReadValue("daily pm calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("daily pm calculation option", "Threshold_value", iniPath);
                                    _calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("daily pm calculation option", "Start_percentage", iniPath);
                                    _calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("daily pm calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    _calculation.txtNAAQS.Text = "35";
                                    _calculation.txtThreshold.Text = "1";
                                    _calculation.nupdStartPercentage.Text = "95";
                                    _calculation.nupdEndPercentage.Text = "98";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold.ToString();
                                _calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.startPercentage.ToString();
                                _calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "(μg/m3) ";
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                        {
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    _calculation.txtNAAQS.Text = CommonClass.IniReadValue("ozone calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("ozone calculation option", "Threshold_value", iniPath);
                                    _calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("ozone calculation option", "Start_percentage", iniPath);
                                    _calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("ozone calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    _calculation.txtNAAQS.Text = "70";
                                    _calculation.txtThreshold.Text = "1";
                                    _calculation.nupdStartPercentage.Text = "95";
                                    _calculation.nupdEndPercentage.Text = "98";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold.ToString();
                                _calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.startPercentage.ToString();
                                _calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "(ppb) ";
                        }
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)    //added by Lijiabin
                        {
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            _calculation.label5.Hide();
                            _calculation.label6.Hide();
                            _calculation.label7.Hide();
                            _calculation.label8.Hide();
                            _calculation.label9.Hide();
                            _calculation.nupdStartPercentage.Hide();
                            _calculation.nupdEndPercentage.Hide();
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    //_calculation.txtNAAQS.Text = CommonClass.IniReadValue("deposition calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("deposition calculation option", "Threshold_value", iniPath);
                                    //_calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "Start_percentage", iniPath);
                                    //_calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    //_calculation.txtNAAQS.Text = "0";
                                    _calculation.txtThreshold.Text = "0";
                                    //_calculation.nupdStartPercentage.Text = "0";
                                    //_calculation.nupdEndPercentage.Text = "100";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.threshold.ToString();
                                //_calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.startPercentage.ToString();
                                //_calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "";
                        }
                        break;
                    #endregion
                    #region Annual PM China added by Yangwenwei
                    case "modeldatainput":
                        pnlUserControl.Controls.Add(new uc_ModelDataChina());
                        uc_ModelDataChina modeldatachina = (pnlUserControl.Controls[0] as uc_ModelDataChina);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina == null)
                        {
                            //(CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina = new ModelDataInputChina();
                            //CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_Base_Quarterly.csv";
                            //modeldatachina.txtBaselineChina.Text = Path.GetFileName(CommonClass.baseModelFile);
                            //CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_L_R_0.5_0.5_Quarterly.csv";
                            //modeldatachina.txtControlChina.Text = Path.GetFileName(CommonClass.futureModelFile);
                            modeldatachina.InitializeControl();
                        }
                        else
                        {
                            modeldatachina.InitializeControl();
                            //modeldatachina.rbtnQuarterlyAverageDataChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doQuarterlyAverageDataInput;
                            //modeldatachina.rbtnDailyAvertageDatalChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doDailyAverageDataInput;
                            //modeldatachina.rbtnCMAQChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doInputFromCMAQ;
                            //modeldatachina.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            //CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.BaselineModelDataFile;
                            //modeldatachina.txtBaselineChina.Text = Path.GetFileName(CommonClass.baseModelFile);
                            //CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.ControlModelDataFile;
                            //modeldatachina.txtControlChina.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        break;
                    case "monitordatainput":
                        pnlUserControl.Controls.Add(new uc_MonitorDataChina());
                        uc_MonitorDataChina monitordatachina = (pnlUserControl.Controls[0] as uc_MonitorDataChina);
                        monitordatachina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina = new MonitorDataInputChina();
                        //    CommonClass.monitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\陕西省PM25测点季度均值.csv";
                        //    monitordatachina.txtOfficialMonitorChina.Text = Path.GetFileName(CommonClass.monitorFile);
                        //    CommonClass.getmonitorYear("");
                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear);
                        //    for (int i = start; i <= end; i++)
                        //    {
                        //        monitordatachina.cboEndYearChina.Items.Add(i);
                        //        monitordatachina.cboStartYearChina.Items.Add(i);
                        //    }
                        //    monitordatachina.cboStartYearChina.SelectedIndex = 0;
                        //    monitordatachina.cboEndYearChina.SelectedIndex = end - start;
                        //}
                        //else
                        //{
                        //    monitordatachina.rbtnDailyMonitorChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doDailyMonitorDataInput;
                        //    monitordatachina.rbtnQuarterlyMonitorChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doQuarterlyMonitorDataInput;
                        //    monitordatachina.choIAdjustedFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doInterpolateAdjustedFRM;
                        //    monitordatachina.choIFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doInterpolateFRM;
                        //    monitordatachina.chkwVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.dowVNA;
                        //    monitordatachina.chkwVNAAdvance.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.dowVNAAdvancedOption;
                        //    monitordatachina.txtwVNAWeight.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.wVNAWeight.ToString();
                        //    monitordatachina.chkNS.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doNS;
                        //    monitordatachina.txtOfficialMonitorChina.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataInputFile;
                        //    monitordatachina.cboStartYearChina.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear;
                        //    monitordatachina.cboEndYearChina.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear;

                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear);
                        //    for (int i = start; i <= end; i++)
                        //    {
                        //        monitordatachina.cboEndYearChina.Items.Add(i);
                        //        monitordatachina.cboStartYearChina.Items.Add(i);
                        //    }
                        //    monitordatachina.cboStartYearChina.SelectedIndex = 0;
                        //    monitordatachina.cboEndYearChina.SelectedIndex = end - start;
                        //}
                        break;
                    case "pm25speciesoption":
                        pnlUserControl.Controls.Add(new uc_PM25SpeciesOptionChina());
                        uc_PM25SpeciesOptionChina speciesoptionchina = (pnlUserControl.Controls[0] as uc_PM25SpeciesOptionChina);
                        speciesoptionchina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina = new PM25SpeciesOptionChina();
                        //    CommonClass.speciesMonitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\PM25_Species_Fraction_Quarterly_2013_YRD.csv";
                        //    speciesoptionchina.txtSpeciesDataChina.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                        //}
                        //else
                        //{
                        //    speciesoptionchina.chkSpeciesFractionDataChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina.PM25SpeciesFractionDataAvailable;
                        //    speciesoptionchina.txtSpeciesDataChina.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina.SpeciesMonitorDataFile;
                        //}
                        break;
                    #endregion
                    #region Ozone China added by Yangwenwei
                    case "modeldatainputozone":
                        pnlUserControl.Controls.Add(new uc_ModelDataOzoneChina());
                        uc_ModelDataOzoneChina modeldataozonechina = (pnlUserControl.Controls[0] as uc_ModelDataOzoneChina);
                        modeldataozonechina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina = new ModelDataOzoneChina();
                        //    CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2013_YRD.csv";
                        //    modeldataozonechina.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                        //    CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2017_YRD.csv";
                        //    modeldataozonechina.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        //}
                        //else
                        //{
                        //    modeldataozonechina.cboCMAQOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.doInputfromCmaq;
                        //    modeldataozonechina.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                        //    CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile;
                        //    modeldataozonechina.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                        //    CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile;
                        //    modeldataozonechina.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        //}
                        break;
                    case "monitordatainputozone":
                        pnlUserControl.Controls.Add(new uc_MonitorDataOzoneChina());
                        uc_MonitorDataOzoneChina monitordataozonechina = (pnlUserControl.Controls[0] as uc_MonitorDataOzoneChina);
                        monitordataozonechina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina = new MonitorDataOzoneChina();
                        //    CommonClass.ozoneMonitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Ozone_Data_Seasonal_2013_YRD.csv";
                        //    monitordataozonechina.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);

                        //    CommonClass.getmonitorYear("");
                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear);
                        //    for (int i = start; i <= end; i++)
                        //    {
                        //        monitordataozonechina.cboEndYearOzone.Items.Add(i);
                        //        monitordataozonechina.cboStartYearOzone.Items.Add(i);
                        //    }
                        //    monitordataozonechina.cboStartYearOzone.SelectedIndex = 0;
                        //    monitordataozonechina.cboEndYearOzone.SelectedIndex = end - start;
                        //}
                        //else
                        //{
                        //    monitordataozonechina.choIFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useVNA;
                        //    monitordataozonechina.choIAdjustedFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useEVNA;
                        //    monitordataozonechina.chkwVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNA;
                        //    monitordataozonechina.chkwVNAAdvance.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNAAdvancedOption;
                        //    monitordataozonechina.chkNS.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useNS;
                        //    monitordataozonechina.txtwVNAWeight.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNAWeight.ToString();
                        //    CommonClass.ozoneMonitorFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneMonitorDataFile;
                        //    monitordataozonechina.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                        //    monitordataozonechina.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear;
                        //    monitordataozonechina.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear;

                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear);
                        //    for (int i = start; i <= end; i++)
                        //    {
                        //        monitordataozonechina.cboEndYearOzone.Items.Add(i);
                        //        monitordataozonechina.cboStartYearOzone.Items.Add(i);
                        //    }
                        //    monitordataozonechina.cboStartYearOzone.SelectedIndex = 0;
                        //    monitordataozonechina.cboEndYearOzone.SelectedIndex = end - start;
                        //}
                        break;
                    #endregion
                    #region BenMAP annual pm
                    case "modeldata":
                        pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_ModelData());
                        _stips = trvAnalysis.Nodes[0].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMAP_AnnualPM_ModelData _modelA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput = new BenMAPAnnualPMModel();
                            _modelA.rbtnDailyModelA.Checked = true;
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["baselineModelDataFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2011eh.camx.grid.csv";//PM_small_USA_12km_2011.csv";
                            _modelA.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["forecastModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2017eh.camx.grid.csv";//PM_small_USA_12km_2018.csv";
                            _modelA.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                            _modelA.cboSpatialGridA.SelectedIndex = 0;
                        }
                        else
                        {
                            _modelA.rbtnDailyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doDailyModelData;
                            _modelA.rbtnQuarterlyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doQuarterlyModelData;
                            _modelA.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doInputfromCMAQ;
                            CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.baselineFile;
                            _modelA.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.forecastFile;
                            _modelA.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                            _modelA.cboSpatialGridA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.temporalAdjustmentAtMonitorGridSpatial;
                        }
                        break;
                    case "monitordata":
                        pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_MonitorData());
                        _stips = trvAnalysis.Nodes[1].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMAP_AnnualPM_MonitorData _monitorA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput = new BenMAPAnnualPMMonitor();
                            CommonClass.unofficialPMFile = CommonClass.dicExampleConfiguration["AnnualPM"]["unofficialMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\PM25ForFractions2002to2017.csv";//PM25ForFractions2002to2012.csv;
                            _monitorA.txtUnofficialMonitorA.Text = Path.GetFileName(CommonClass.unofficialPMFile);
                            CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_MonitorData");
                            _monitorA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            _monitorA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            if (_monitorA.cboStartYearA.Items.Count >= 9)
                                _monitorA.cboStartYearA.SelectedIndex = 8;
                            else
                                _monitorA.cboStartYearA.SelectedIndex = _monitorA.cboStartYearA.Items.Count - 1;
                            if (_monitorA.cboEndYearA.Items.Count >= 11)
                            {
                                _monitorA.cboEndYearA.SelectedIndex = 10;
                            }
                            else
                            {
                                _monitorA.cboEndYearA.SelectedIndex = _monitorA.cboEndYearA.Items.Count - 1;
                            }
                            _monitorA.choIFRMSpeA.Checked = true;
                            _monitorA.choIAdjustedFRMSpeA.Checked = true;

                            _monitorA.chkDS.Checked = false;
                            _monitorA.txtDSBurn.Text = "500";
                            _monitorA.txtDSCmaqres.Text = "12";
                            _monitorA.txtDSThin.Text = "1";
                            _monitorA.txtDSNumit.Text = "2500";
                        }
                        else
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear == null)
                            {
                                CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_MonitorData");
                            }
                            _monitorA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            _monitorA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            _monitorA.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.startYear;
                            _monitorA.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.endYear;
                            CommonClass.unofficialPMFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.unofficialFile;
                            _monitorA.txtUnofficialMonitorA.Text = Path.GetFileName(CommonClass.unofficialPMFile);
                            _monitorA.choIFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.useVNA;
                            _monitorA.choIAdjustedFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.useEVNA;


                            _monitorA.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.doDownscaler;
                            _monitorA.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Numit.ToString();
                            _monitorA.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Cmaqres.ToString();
                            _monitorA.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Thin.ToString();
                            _monitorA.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Burn.ToString();
                        }
                        break;
                    case "speciesdata":
                        pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_SpeciesData());
                        _stips = trvAnalysis.Nodes[2].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMAP_AnnualPM_SpeciesData _speciesA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_SpeciesData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput = new BenMAPAnnualPMSpecies();
                            _speciesA.rbtnMonitorFileA.Checked = true;
                            CommonClass.speciesMonitorFile = CommonClass.dicExampleConfiguration["AnnualPM"]["speciesMonitorDataFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\SpeciesForFractions2002to2015_v2.csv";//SpeciesForFractions2002to2012.csv;
                            _speciesA.txtMonitorFileA.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                            CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_SpeciesData");
                            _speciesA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            _speciesA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            if (_speciesA.cboStartYearA.Items.Count >= 9)
                                _speciesA.cboStartYearA.SelectedIndex = 8;
                            else
                                _speciesA.cboStartYearA.SelectedIndex = _speciesA.cboStartYearA.Items.Count - 1;
                            if (_speciesA.cboEndYearA.Items.Count >= 11)
                            {
                                _speciesA.cboEndYearA.SelectedIndex = 10;
                            }
                            else
                            {
                                _speciesA.cboEndYearA.SelectedIndex = _speciesA.cboEndYearA.Items.Count - 1;
                            }
                        }
                        else
                        {
                            _speciesA.rbtnMonitorFileA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.doSpeciesMonitorDataFile;
                            CommonClass.speciesMonitorFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.speciesMonitorDataFile;
                            _speciesA.txtMonitorFileA.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear == null)
                                CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_SpeciesData");
                            _speciesA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            _speciesA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            _speciesA.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.startYear;
                            _speciesA.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.endYear;
                            _speciesA.rbtnFractionA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.doSpeciesFractionFile;
                            CommonClass.speciesFractionFilePoint = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.specFracSpatialFile;
                            _speciesA.txtFractionSpatialA.Text = Path.GetFileName(CommonClass.speciesFractionFilePoint);
                            CommonClass.speciesFractionFileSpatial = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.gradAdjSpecFracSpatialFile;
                            _speciesA.txtgradadjFractionSpatialA.Text = Path.GetFileName(CommonClass.speciesFractionFileSpatial);
                        }
                        break;
                    case "griddefinition":
                        pnlUserControl.Controls.Add(new uc_BenMAP_GridDefinition());
                        lblSteps.Text = trvAnalysis.Nodes[3].Text;
                        _stips = lblSteps.Text;
                        uc_BenMAP_GridDefinition _grid = (pnlUserControl.Controls[0] as uc_BenMAP_GridDefinition);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile == null)
                        {
                            CommonClass.shapefile = Application.StartupPath + @"\Data\ShapeFiles\CMAQ_12km_Nation.shp";
                            _grid.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                        }
                        else
                        {
                            CommonClass.shapefile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile;
                            _grid.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                        }
                        break;
                    #endregion
                    #region BenMap Ozone
                    case "benmapozonemodeldata":
                        pnlUserControl.Controls.Add(new uc_BenMap_Ozone_ModelData());
                        _stips = trvAnalysis.Nodes[0].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMap_Ozone_ModelData BenMapOzoneModel = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput = new BenMAPOzoneModel();
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["Ozone"]["baselineModelDataFile"];//Application.StartupPath + @"\Data\SampleData\O3_small_USA_12km_2011.csv";
                            BenMapOzoneModel.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["Ozone"]["forecastModelDataFile"];//   Application.StartupPath + @"\Data\SampleData\O3_small_USA_12km_2018.csv";
                            BenMapOzoneModel.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        else
                        {
                            CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.baselineModelDataFile;
                            BenMapOzoneModel.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.forecastModelDataFile;
                            BenMapOzoneModel.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        break;
                    case "benmapozonemonitordata":
                        pnlUserControl.Controls.Add(new uc_BenMap_Ozone_MonitorData());
                        _stips = trvAnalysis.Nodes[1].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMap_Ozone_MonitorData BenMapOzoneMonitor = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput = new BenMapOzoneMonitor();
                            CommonClass.ozoneMonitorFile = CommonClass.dicExampleConfiguration["Ozone"]["ozoneMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\SMAT_OZONE_MAX4DV_STD70_2002_2015.CSV";//MATS_OZONE_DV_2012_V2_off.csv";
                            BenMapOzoneMonitor.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                            BenMapOzoneMonitor.choVNA.Checked = true;
                            BenMapOzoneMonitor.choEVNA.Checked = true;
                            CommonClass.getmonitorYear("uc_BenMap_Ozone_MonitorData");

                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData.Sort();
                            List<string> year = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData;
                            for (int i = 0; i < year.Count; i++)
                            {
                                BenMapOzoneMonitor.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                BenMapOzoneMonitor.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                            }

                            if (BenMapOzoneMonitor.cboStartYearOzone.Items.Count >= 9) BenMapOzoneMonitor.cboStartYearOzone.SelectedIndex = 8;
                            else BenMapOzoneMonitor.cboStartYearOzone.SelectedIndex = BenMapOzoneMonitor.cboStartYearOzone.Items.Count - 1;
                            if (BenMapOzoneMonitor.cboEndYearOzone.Items.Count > 10) BenMapOzoneMonitor.cboEndYearOzone.SelectedIndex = 9;
                            else BenMapOzoneMonitor.cboEndYearOzone.SelectedIndex = BenMapOzoneMonitor.cboEndYearOzone.Items.Count - 1;
                        }
                        else
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData == null)
                            {
                                CommonClass.getmonitorYear("uc_BenMap_Ozone_MonitorData");
                            }
                            List<string> year = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData;
                            for (int i = 0; i < year.Count; i++)
                            {
                                BenMapOzoneMonitor.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                BenMapOzoneMonitor.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                            }
                            BenMapOzoneMonitor.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneStartYear;
                            BenMapOzoneMonitor.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneEndYear;

                            CommonClass.ozoneMonitorFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneMonitorDataFile;
                            BenMapOzoneMonitor.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                            BenMapOzoneMonitor.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.useVNA;
                            BenMapOzoneMonitor.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.useEVNA;
                        }
                        break;
                    case "benmapozonegriddefinition":
                        pnlUserControl.Controls.Add(new uc_BenMAP_GridDefinition());
                        lblSteps.Text = trvAnalysis.Nodes[2].Text;
                        _stips = lblSteps.Text;
                        uc_BenMAP_GridDefinition _gridozone = (pnlUserControl.Controls[0] as uc_BenMAP_GridDefinition);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile == null)
                        {
                            CommonClass.shapefile = Application.StartupPath + @"\Data\ShapeFiles\CMAQ_12km_Nation.shp";
                            _gridozone.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                        }
                        else
                        {
                            CommonClass.shapefile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile;
                            _gridozone.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                        }
                        break;
                        #endregion
                }
                _stips = trvAnalysis.SelectedNode.ToolTipText.ToString();
                tips.SetToolTip(pboHelp, _stips);
                pnlUserControl.Refresh();
                lblSteps.Refresh();
                trvAnalysis.Refresh();
                //As long as user do some setting, the save scenario button is enabled.
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                            && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null
                            && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    case enumAnalysis.DailyPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null
                        || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null
                        || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null
                            && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null
                           && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    case enumAnalysis.Ozone:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null
                           || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null
                          && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    case enumAnalysis.Visibility:
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null
                            || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null && (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null
                            && (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    case enumAnalysis.SSIAAnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null && (((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    case enumAnalysis.SSIADailyPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null && (((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    case enumAnalysis.SSIAOzone:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null && (((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    case enumAnalysis.SSIADeposition:    //added by Lijiabin
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null || (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null || (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).monitorInputDep != null || (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null && (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null && (((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).monitorInputDep != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    #region Annual PM China added by Yangwenwei
                    case enumAnalysis.AnnualPMChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    #endregion
                    #region Ozone China added by Yangwenwei
                    case enumAnalysis.OzoneChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    #endregion
                    #region BenMap Annual
                    case enumAnalysis.BenMAPAnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null || !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile))
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null && !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile))
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                    #endregion
                    #region BenMap Ozone
                    case enumAnalysis.BenMAPSeasonalOzone:
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null || !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile))
                        {
                            btnSave.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null && !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile))
                        {
                            btnSaveRun.Enabled = true;
                        }
                        break;
                        #endregion
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }

        }

        /// <summary>
        /// operation for next/back button
        /// </summary>
        public void NextBackOperation()
        {
            try
            {
                string errorTips = SaveCurrentUCConfiguration();
                if (errorTips != null && errorTips.Length > 0)
                {
                    MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                    return;
                }

                string loadUCName = "";
                if (isNext)
                {
                    switch (pnlUserControl.Controls[0].Name)
                    {
                        #region annual pm
                        case "uc_OutputA":
                            loadUCName = "uc_OutputAdvancedA";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_OutputAdvancedA":
                            loadUCName = "uc_DataInputA";
                            break;
                        case "uc_DataInputA":
                            loadUCName = "uc_SpeciesFractionsCalculationOptionsA";
                            break;
                        case "uc_SpeciesFractionsCalculationOptionsA":
                            loadUCName = "uc_PM25CalculationOptionsA";
                            break;
                        case "uc_PM25CalculationOptionsA":
                            loadUCName = "uc_ModelDataA";
                            break;
                        #endregion
                        #region Daily
                        case "uc_OutputD":
                            loadUCName = "uc_OutputAdvancedD";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_OutputAdvancedD":
                            loadUCName = "uc_DataInputD";
                            break;
                        case "uc_DataInputD":
                            loadUCName = "uc_SpeciesFrctionD";
                            break;
                        case "uc_SpeciesFrctionD":
                            loadUCName = "uc_PM25CalculationD";
                            break;
                        case "uc_PM25CalculationD":
                            loadUCName = "uc_ModelDataD";
                            break;
                        #endregion
                        #region Ozone added by sclong
                        case "uc_DesiredOutputOzone":
                            loadUCName = "uc_DataInputOzone";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_DataInputOzone":
                            loadUCName = "uc_FilteringorInterpolationOzone";
                            break;
                        case "uc_FilteringorInterpolationOzone":
                            loadUCName = "uc_RRForSpatialGradientOzone";
                            break;
                        #endregion
                        #region Visibility added by sclong
                        case "uc_ChooseDesiredOutputV":
                            loadUCName = "uc_DataInputV";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_DataInputV":
                            loadUCName = "uc_FilteringV";
                            break;
                        #endregion
                        #region SSIA
                        case "uc_AnalysisOption":
                            if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                                loadUCName = "uc_ModelDataInputA";
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                                loadUCName = "uc_ModelDataInputD";
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                                loadUCName = "uc_ModelDataInputO";
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)    //added by Lijiabin
                                loadUCName = "uc_ModelDataInputDep";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_ModelDataInputA":
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData)
                                loadUCName = "uc_MonitorDataInputA";
                            else
                                loadUCName = "uc_CalculationOption";
                            break;
                        case "uc_ModelDataInputD":
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData)
                                loadUCName = "uc_MonitorDataInputD";
                            else
                                loadUCName = "uc_CalculationOption";
                            break;
                        case "uc_ModelDataInputO":
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData)
                                loadUCName = "uc_MonitorDataInputO";
                            else
                                loadUCName = "uc_CalculationOption";
                            break;
                        case "uc_ModelDataInputDep":                      //added by Lijiabin     
                            loadUCName = "uc_CalculationOption";
                            break;
                        case "uc_MonitorDataInputA":
                            loadUCName = "uc_CalculationOption";
                            break;
                        case "uc_MonitorDataInputD":
                            loadUCName = "uc_CalculationOption";
                            break;
                        case "uc_MonitorDataInputO":
                            loadUCName = "uc_CalculationOption";
                            break;
                        #endregion
                        #region Annual PM China
                        case "uc_ModelDataChina":
                            loadUCName = "uc_MonitorDataChina";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_MonitorDataChina":
                            loadUCName = "uc_PM25SpeciesOptionChina";
                            break;
                        #endregion
                        #region Ozone China
                        case "uc_ModelDataOzoneChina":
                            loadUCName = "uc_MonitorDataOzoneChina";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        #endregion
                        #region BenMAP annual pm
                        case "uc_BenMAP_AnnualPM_ModelData":
                            loadUCName = "uc_BenMAP_AnnualPM_MonitorData";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_BenMAP_AnnualPM_MonitorData":
                            loadUCName = "uc_BenMAP_AnnualPM_SpeciesData";
                            break;
                        case "uc_BenMAP_AnnualPM_SpeciesData":
                            loadUCName = "uc_BenMAP_GridDefinition";
                            break;
                        #endregion
                        #region BenMAP Ozone
                        case "uc_BenMap_Ozone_ModelData":
                            loadUCName = "uc_BenMap_Ozone_MonitorData";
                            btnBack.Enabled = true;
                            btnBack.Image = Resources.Back;
                            break;
                        case "uc_BenMap_Ozone_MonitorData":
                            loadUCName = "uc_BenMAP_GridDefinition";
                            break;
                            #endregion
                    }
                }
                else
                {
                    switch (pnlUserControl.Controls[0].Name)
                    {
                        #region annual pm
                        case "uc_OutputAdvancedA":
                            loadUCName = "uc_OutputA";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_DataInputA":
                            loadUCName = "uc_OutputAdvancedA";
                            break;
                        case "uc_SpeciesFractionsCalculationOptionsA":
                            loadUCName = "uc_DataInputA";
                            break;
                        //case "uc_SpeciesFractionAdvancedA":
                        //    loadUCName = "uc_SpeciesFractionsCalculationOptionsA";
                        //    break;
                        case "uc_PM25CalculationOptionsA":
                            loadUCName = "uc_SpeciesFractionsCalculationOptionsA";
                            break;
                        case "uc_ModelDataA":
                            loadUCName = "uc_PM25CalculationOptionsA";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "":
                            break;
                        #endregion
                        #region Daily
                        case "uc_OutputAdvancedD":
                            loadUCName = "uc_OutputD";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_DataInputD":
                            loadUCName = "uc_OutputAdvancedD";
                            break;
                        case "uc_SpeciesFrctionD":
                            loadUCName = "uc_DataInputD";
                            break;
                        //case "uc_SpeciesFractionAdvancedD":
                        //    loadUCName = "uc_SpeciesFrctionD";
                        //    break;
                        case "uc_PM25CalculationD":
                            loadUCName = "uc_SpeciesFrctionD";
                            break;
                        case "uc_ModelDataD":
                            loadUCName = "uc_PM25CalculationD";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        #endregion
                        #region Ozone added by sclong
                        case "uc_DataInputOzone":
                            loadUCName = "uc_DesiredOutputOzone";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_FilteringorInterpolationOzone":
                            loadUCName = "uc_DataInputOzone";
                            break;
                        case "uc_RRForSpatialGradientOzone":
                            loadUCName = "uc_FilteringorInterpolationOzone";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        #endregion
                        #region Visibility added by sclong
                        case "uc_DataInputV":
                            loadUCName = "uc_ChooseDesiredOutputV";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;

                        case "uc_FilteringV":
                            loadUCName = "uc_DataInputV";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;

                        #endregion
                        #region SSIA
                        case "uc_ModelDataInputA":
                            loadUCName = "uc_AnalysisOption";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_MonitorDataInputA":
                            loadUCName = "uc_ModelDataInputA";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_ModelDataInputD":
                            loadUCName = "uc_AnalysisOption";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_ModelDataInputDep":                 //added by Lijiabin
                            loadUCName = "uc_AnalysisOption";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_MonitorDataInputD":
                            loadUCName = "uc_ModelDataInputD";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_ModelDataInputO":
                            loadUCName = "uc_AnalysisOption";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_MonitorDataInputO":
                            loadUCName = "uc_ModelDataInputO";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_CalculationOption":
                            if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                            {
                                if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData)
                                    loadUCName = "uc_MonitorDataInputA";
                                else
                                    loadUCName = "uc_ModelDataInputA";
                            }
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                            {
                                if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData)
                                    loadUCName = "uc_MonitorDataInputD";
                                else
                                    loadUCName = "uc_ModelDataInputD";
                            }
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                            {
                                if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData)
                                    loadUCName = "uc_MonitorDataInputO";
                                else
                                    loadUCName = "uc_ModelDataInputO";
                            }
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)    //added by Lijiabin
                            {
                                loadUCName = "uc_ModelDataInputDep";
                            }
                            break;
                        #endregion
                        #region Annual PM China
                        case "uc_MonitorDataChina":
                            loadUCName = "uc_ModelDataChina";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_PM25SpeciesOptionChina":
                            loadUCName = "uc_MonitorDataChina";
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        #endregion
                        #region Ozone China
                        case "uc_MonitorDataOzoneChina":
                            loadUCName = "uc_ModelDataOzoneChina";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        #endregion
                        #region BenMAP annual pm
                        case "uc_BenMAP_AnnualPM_MonitorData":
                            loadUCName = "uc_BenMAP_AnnualPM_ModelData";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            btnNext.Enabled = true;
                            btnNext.Image = Resources.Next1;
                            break;
                        case "uc_BenMAP_AnnualPM_SpeciesData":
                            loadUCName = "uc_BenMAP_AnnualPM_MonitorData";
                            break;
                        case "uc_BenMAP_GridDefinition":
                            if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPAnnualPM) loadUCName = "uc_BenMAP_AnnualPM_SpeciesData";
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone) loadUCName = "uc_BenMap_Ozone_MonitorData";
                            break;
                        #endregion
                        #region BenMAP Ozone
                        case "uc_BenMap_Ozone_MonitorData":
                            loadUCName = "uc_BenMap_Ozone_ModelData";
                            btnBack.Enabled = false;
                            btnBack.Image = Resources.Back_gray;
                            break;
                            //case "uc_BenMAP_GridDefinition":
                            //    loadUCName = "uc_BenMap_Ozone_MonitorData";
                            //break;
                            #endregion
                    }
                }

                if (this.pnlUserControl.Controls.Count != 0)
                {
                    this.pnlUserControl.Controls.Clear();
                }
                switch (loadUCName)
                {
                    #region annual
                    case "uc_OutputA":
                        pnlUserControl.Controls.Add(new uc_OutputA());
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Choose Desired Output";
                        uc_OutputA _outPutA = (pnlUserControl.Controls[0] as uc_OutputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA = new ChooseDesiredOutputA();
                            _outPutA.choStandardAnalysisA.Checked = true;
                            _outPutA.choQuarterlyModelDataA.Checked = true;
                            _outPutA.choQuarterlyModelDataUsedA.Checked = true;
                            _outPutA.choSpeciesFractionOutputA.Checked = true;
                            _outPutA.choActionsCompletionA.Checked = true;
                        }
                        else
                        {
                            _outPutA.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                            _outPutA.choStandardAnalysisA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doStandardAnalysis;
                            _outPutA.choQuarterlyModelDataA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doQuarterlyModelData;
                            _outPutA.choQuarterlyModelDataUsedA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doUsedQuarterlyAvgModelData;
                            _outPutA.choSpeciesFractionOutputA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doSpeciesFraction;
                            _outPutA.choActionsCompletionA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doAutomaticallyExtract;
                        }
                        break;
                    case "uc_OutputAdvancedA":
                        pnlUserControl.Controls.Add(new uc_OutputAdvancedA());
                        lblSteps.Text = trvAnalysis.Nodes[1].Text;
                        _stips = "Select advanced output choices";
                        uc_OutputAdvancedA _outputAdvancedA = (pnlUserControl.Controls[0] as uc_OutputAdvancedA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA = new OutputChoiceAdvancedA();
                            _outputAdvancedA.choQuaPointA.Checked = true;
                            _outputAdvancedA.choFileCA.Checked = true;
                            _outputAdvancedA.choFileEA.Checked = true;
                        }
                        else
                        {
                            _outputAdvancedA.choIFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj;
                            _outputAdvancedA.choBaseOnlyVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyVNA;
                            _outputAdvancedA.choFutureOnlyVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyVNA;
                            _outputAdvancedA.choIAdjustedFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doInterpolatedSFETempAdj_GradAdj;
                            _outputAdvancedA.choBaseOnlyEvna.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyEvna;
                            _outputAdvancedA.choFutureOnlyEvna.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyEvna;
                            _outputAdvancedA.choQuaPointA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFilePoint;
                            _outputAdvancedA.choQuaSpatialA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial;
                            _outputAdvancedA.choQuaSpaGraAdjA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_GraAdj;
                            _outputAdvancedA.choFileCA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doHighCountySites;
                            _outputAdvancedA.choSpeSpatialFieldA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial;
                            _outputAdvancedA.choSpeSpaGraAdjA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_GraAdj;
                            _outputAdvancedA.choFileEA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgSpeciatedMonitors;
                            _outputAdvancedA.choDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doDesignValuePeriods;
                            _outputAdvancedA.choNeiPointA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doNeighborFilePoint;
                            _outputAdvancedA.choNeiSpatialA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doNeighborFileSpatial;

                            _outputAdvancedA.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doDS;
                            _outputAdvancedA.chkDSOnlyBase.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doBaseOnlyDS;
                            _outputAdvancedA.chkDSOnlyFuture.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doFutureOnlyDS;
                            _outputAdvancedA.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Burn.ToString();
                            _outputAdvancedA.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Cmaqres.ToString();
                            _outputAdvancedA.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Thin.ToString();
                            _outputAdvancedA.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.DS_Numit.ToString();
                            _outputAdvancedA.choQuaSpaDSA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_DS;
                            _outputAdvancedA.choSpeSpaDSA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA.doSpeciesFractionSpatial_DS;


                        }
                        break;
                    case "uc_DataInputA":
                        pnlUserControl.Controls.Add(new uc_DataInputA());
                        uc_DataInputA _dataInputA = (pnlUserControl.Controls[0] as uc_DataInputA);
                        lblSteps.Text = trvAnalysis.Nodes[2].Text;
                        _stips = "Select input files for the analysis";
                        //DataInputFile dataInputFile = new DataInputFile();
                        _dataInputA.InitializeControl();
                        break;
                    case "uc_SpeciesFractionsCalculationOptionsA":
                        pnlUserControl.Controls.Add(new uc_SpeciesFractionsCalculationOptionsA());
                        lblSteps.Text = trvAnalysis.Nodes[3].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Set up species fraction options";
                        uc_SpeciesFractionsCalculationOptionsA _speciesFractionOptionsA = (pnlUserControl.Controls[0] as uc_SpeciesFractionsCalculationOptionsA);
                        _speciesFractionOptionsA.cboIMPROVEStartYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFractionOptionsA.cboIMPROVEEndYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFractionOptionsA.cboPMStartYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFractionOptionsA.cboPMEndYaerA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA = new SpeciesFractionOptionsA();
                            if (_speciesFractionOptionsA.cboIMPROVEStartYaerA.Items.Count >= 9)
                                _speciesFractionOptionsA.cboIMPROVEStartYaerA.SelectedIndex = 8;
                            else
                                _speciesFractionOptionsA.cboIMPROVEStartYaerA.SelectedIndex = _speciesFractionOptionsA.cboIMPROVEStartYaerA.Items.Count - 1;
                            if (_speciesFractionOptionsA.cboIMPROVEEndYaerA.Items.Count >= 11)
                            {
                                _speciesFractionOptionsA.cboIMPROVEEndYaerA.SelectedIndex = 10;
                            }
                            else
                            {
                                _speciesFractionOptionsA.cboIMPROVEEndYaerA.SelectedIndex = _speciesFractionOptionsA.cboIMPROVEEndYaerA.Items.Count - 1;
                            }
                            if (_speciesFractionOptionsA.cboPMStartYaerA.Items.Count >= 9)
                                _speciesFractionOptionsA.cboPMStartYaerA.SelectedIndex = 8;
                            else
                                _speciesFractionOptionsA.cboPMStartYaerA.SelectedIndex = _speciesFractionOptionsA.cboPMStartYaerA.Items.Count - 1;
                            if (_speciesFractionOptionsA.cboPMEndYaerA.Items.Count >= 11)
                            {
                                _speciesFractionOptionsA.cboPMEndYaerA.SelectedIndex = 10;
                            }
                            else
                            {
                                _speciesFractionOptionsA.cboPMEndYaerA.SelectedIndex = _speciesFractionOptionsA.cboPMEndYaerA.Items.Count - 1;
                            }
                            _speciesFractionOptionsA.choIMPROVEEPADeletionsA.Checked = true;
                            _speciesFractionOptionsA.choPMEPADeletionsA.Checked = true;
                            _speciesFractionOptionsA.nudownIMPROVEMinDaysA.Value = 11;
                            _speciesFractionOptionsA.nudownIMPROVEMinYearsA.Value = 1;
                            _speciesFractionOptionsA.nudownIMPROVEMinSeasonsA.Value = 1;
                            _speciesFractionOptionsA.nudownPMMinDaysA.Value = 11;
                            _speciesFractionOptionsA.nudownPMMinYearsA.Value = 1;
                            _speciesFractionOptionsA.nudownPMMinPointA.Value = 4;
                            _speciesFractionOptionsA.nudownPMMinSpatialA.Value = 1;
                            _speciesFractionOptionsA.choAdvancedOptions.Checked = false;

                            #region species options advanced
                            _speciesFractionOptionsA.cboItpCrustalA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpDONA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpECA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpNH4A.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpNO3A.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpOCA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpPM25A.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpSaltA.SelectedIndex = 2;
                            _speciesFractionOptionsA.cboItpSO4A.SelectedIndex = 2;
                            _speciesFractionOptionsA.nudownCrustalDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownDONDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownECDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownNH4DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownNO3DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownOCDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownPM25DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownSaltDistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.nudownSO4DistanceA.Value = 9000000000;
                            _speciesFractionOptionsA.cboItpPM25A.Enabled = false;
                            _speciesFractionOptionsA.nudownPM25DistanceA.Enabled = false;
                            _speciesFractionOptionsA.rbtnDONA.Checked = true;
                            _speciesFractionOptionsA.cboItpNH4A.Enabled = false;
                            _speciesFractionOptionsA.nudownNH4DistanceA.Enabled = false;
                            _speciesFractionOptionsA.nudownNH4PercentageA.Enabled = false;
                            _speciesFractionOptionsA.nudownNH4PercentageA.Value = 0;
                            _speciesFractionOptionsA.nudownDefaultMassA.Value = 0.2M;
                            _speciesFractionOptionsA.nudownOCmbFloorA.Value = 1;
                            _speciesFractionOptionsA.nudownOCmbCeilingA.Value = 0.8M;
                            #endregion
                        }
                        else
                        {
                            _speciesFractionOptionsA.cboIMPROVEStartYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_StartYear;
                            _speciesFractionOptionsA.cboIMPROVEEndYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_EndYear;
                            _speciesFractionOptionsA.choIMPROVEEPADeletionsA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_EPADeletionChoice;
                            _speciesFractionOptionsA.choIMPROVEUserDeletionA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_UserDeletionChoice;
                            _speciesFractionOptionsA.nudownIMPROVEMinDaysA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinDays;
                            _speciesFractionOptionsA.nudownIMPROVEMinYearsA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinYear;
                            _speciesFractionOptionsA.nudownIMPROVEMinSeasonsA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.IMPROVESTN_MinSeasons;
                            _speciesFractionOptionsA.cboPMStartYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialStartYear;
                            _speciesFractionOptionsA.cboPMEndYaerA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialEndYear;
                            _speciesFractionOptionsA.choPMEPADeletionsA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialEPADeletionChoice;
                            _speciesFractionOptionsA.choPMUserDeletionA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialUserDeletionChoice;
                            _speciesFractionOptionsA.nudownPMMinDaysA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinDays;
                            _speciesFractionOptionsA.nudownPMMinYearsA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinYears;
                            _speciesFractionOptionsA.nudownPMMinPointA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinSeasonsPoint;
                            _speciesFractionOptionsA.nudownPMMinSpatialA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.unofficialMinSeasonsSpatial;
                            _speciesFractionOptionsA.choAdvancedOptions.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doAdvancedOptionsForSpeciesFraction;

                            #region advanced options
                            _speciesFractionOptionsA.cboItpPM25A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodPM25;
                            _speciesFractionOptionsA.nudownPM25DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distancePM25;
                            _speciesFractionOptionsA.cboItpSO4A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodSO4;
                            _speciesFractionOptionsA.nudownSO4DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceSO4;
                            _speciesFractionOptionsA.cboItpNO3A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodNO3;
                            _speciesFractionOptionsA.nudownNO3DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceNO3;
                            _speciesFractionOptionsA.cboItpECA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodEC;
                            _speciesFractionOptionsA.nudownECDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceEC;
                            _speciesFractionOptionsA.cboItpSaltA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodSalt;
                            _speciesFractionOptionsA.nudownSaltDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceSalt;
                            _speciesFractionOptionsA.cboItpCrustalA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodCrustal;
                            _speciesFractionOptionsA.nudownCrustalDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceCrustal;
                            _speciesFractionOptionsA.cboItpDONA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodDON;
                            _speciesFractionOptionsA.nudownDONDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceDON;
                            _speciesFractionOptionsA.cboItpOCA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodOC;
                            _speciesFractionOptionsA.nudownOCDistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceOC;
                            _speciesFractionOptionsA.cboItpNH4A.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.interpolationMethodNH4;
                            _speciesFractionOptionsA.nudownNH4DistanceA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.distanceNH4;
                            _speciesFractionOptionsA.rbtnDONA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doUseDonValues;
                            _speciesFractionOptionsA.rbtnMeasuredA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.doUseAmmoniumValues;
                            _speciesFractionOptionsA.nudownNH4PercentageA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.nh4PercentageEvaporating;
                            _speciesFractionOptionsA.nudownDefaultMassA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.defaultBlankMass;
                            _speciesFractionOptionsA.nudownOCmbFloorA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.floorOCMMB;
                            _speciesFractionOptionsA.nudownOCmbCeilingA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA.ceilingOCMMB;
                            #endregion
                        }
                        //if (Convert.ToInt32(_speciesFractionOptionsA.cboIMPROVEEndYaerA.Text) < Convert.ToInt32(_speciesFractionOptionsA.cboIMPROVEStartYaerA.Text))
                        //    MessageBox.Show("End Year should be later than Start Year.");
                        //if (Convert.ToInt32(cboPMEndYaerA.Text) < Convert.ToInt32(cboPMStartYaerA.Text))
                        //    MessageBox.Show("End Year should be later than Start Year.");
                        break;
                    case "uc_PM25CalculationOptionsA":
                        pnlUserControl.Controls.Add(new uc_PM25CalculationOptionsA());
                        lblSteps.Text = trvAnalysis.Nodes[4].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Set up pm25 calculation options";
                        uc_PM25CalculationOptionsA _pmCalculationA = (pnlUserControl.Controls[0] as uc_PM25CalculationOptionsA);

                        //----------------bind required dv,according to start year-------------
                        int n = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Count;
                        string[] dvString = new string[n];
                        for (int i = 0; i < n; i++)
                        {
                            dvString[i] = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears[i];
                        }
                        for (int i = 0; i < n; i++)
                        {
                            if (i + 2 < n)
                            {
                                _pmCalculationA.clboRequiredDV.Items.Add(dvString[i] + "-" + dvString[i + 2]);
                            }
                        }

                        _pmCalculationA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        _pmCalculationA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA = new PM25CalculationOptionsA();
                            if (_pmCalculationA.cboStartYearA.Items.Count >= 8)// >= 12
                                _pmCalculationA.cboStartYearA.SelectedIndex = 7;// = 11
                            else
                                _pmCalculationA.cboStartYearA.SelectedIndex = _pmCalculationA.cboStartYearA.Items.Count - 1;
                            if (_pmCalculationA.cboEndYearA.Items.Count >= 12)//
                            {
                                _pmCalculationA.cboEndYearA.SelectedIndex = 11;//13
                            }
                            else
                            {
                                _pmCalculationA.cboEndYearA.SelectedIndex = _pmCalculationA.cboEndYearA.Items.Count - 1;
                            }
                            _pmCalculationA.rbtnOfficialA.Checked = true;
                            _pmCalculationA.rbtnNH4DONA.Checked = true;
                            _pmCalculationA.txtRequiredA.Text = "None selected";
                            _pmCalculationA.nudownMinDaysA.Value = 11;
                            _pmCalculationA.nudownMinQuarterA.Value = 12;
                            _pmCalculationA.nudownMinNumDV.Value = 1;
                        }
                        else
                        {
                            _pmCalculationA.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.officialPM25StartYear;
                            _pmCalculationA.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.officialPM25EndYear;
                            _pmCalculationA.rbtnOfficialA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.choiceOfficialDV;
                            _pmCalculationA.rbtnCustomA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.choiceCustomDV;
                            _pmCalculationA.nudownMinDaysA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minDaysForValidFRMQuarters;
                            _pmCalculationA.nudownMinQuarterA.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minQuartersForValidFRMDesignValues;
                            _pmCalculationA.nudownMinNumDV.Value = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.minNumDVPeriodsForValidFRMMonitors;
                            _pmCalculationA.txtRequiredA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.requiredDVPeriodsForValidFRMMonitors;
                            if (_pmCalculationA.txtRequiredA.Text != "None selected")
                            {
                                string[] requireDV = _pmCalculationA.txtRequiredA.Text.Split(',');
                                foreach (string s in requireDV)
                                {
                                    _pmCalculationA.clboRequiredDV.SetItemChecked(_pmCalculationA.clboRequiredDV.Items.IndexOf(s), true);
                                }
                            }
                            _pmCalculationA.rbtnNH4DONA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.doCalcNH4fromDON;
                            _pmCalculationA.rbtnNH4RRFA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA.doCalcNH4fromRRF;
                        }
                        break;
                    case "uc_ModelDataA":
                        pnlUserControl.Controls.Add(new uc_ModelDataA());
                        lblSteps.Text = trvAnalysis.Nodes[5].Text;
                        _stips = "Set up model options";
                        uc_ModelDataA _modelDataA = (pnlUserControl.Controls[0] as uc_ModelDataA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA = new ModelDataOptionsA();
                            _modelDataA.cboPointGridA.SelectedIndex = 1;
                            _modelDataA.cboSpatialGridA.SelectedIndex = 0;
                        }
                        else
                        {
                            _modelDataA.cboPointGridA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA.temporalAdjustmentAtMonitorGrid;
                            _modelDataA.cboSpatialGridA.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA.temporalAdjustmentAtMonitorGridSpatial;
                        }
                        break;
                    #endregion
                    #region Daily
                    case "uc_OutputD":
                        pnlUserControl.Controls.Add(new uc_OutputD());
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Choose Desired Output";
                        uc_OutputD _outputD = (pnlUserControl.Controls[0] as uc_OutputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD = new ChooseDesiredOutputD();
                            _outputD.choStandardAnalysisD.Checked = true;
                            _outputD.choQuarterlyPeakModelDataD.Checked = true;
                            _outputD.choSpeciesFractionsFileD.Checked = true;
                            _outputD.choActionsExtractAllD.Checked = true;
                        }
                        else
                        {
                            _outputD.txtScenarioNameDily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                            _outputD.choStandardAnalysisD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doStandardAnalysis;
                            _outputD.choQuarterlyPeakModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doQuarterlyPeakModelData;
                            _outputD.choSpeciesFractionsFileD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doSpeciesFraction;
                            _outputD.choActionsExtractAllD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doAutomaticallyExtract;
                        }
                        break;
                    case "uc_OutputAdvancedD"://all unchecked?
                        pnlUserControl.Controls.Add(new uc_OutputAdvancedD());
                        lblSteps.Text = trvAnalysis.Nodes[1].Text;
                        _stips = "Select advanced output choices";
                        uc_OutputAdvancedD _outputAdvancedD = (pnlUserControl.Controls[0] as uc_OutputAdvancedD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD = new OutputChoiceAdvancedD();
                            _outputAdvancedD.choQuarterlyAvgFilePointD.Checked = true;
                            _outputAdvancedD.choFileCD.Checked = true;
                            _outputAdvancedD.choFileED.Checked = true;
                        }
                        else
                        {
                            _outputAdvancedD.choQuarterlyAvgFilePointD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doQuarterlyPeakFilesPoint;
                            _outputAdvancedD.choFileCD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doHighCountySites;
                            _outputAdvancedD.choFileED.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doQuarterlyPeakSpeciatedMonitors;
                            _outputAdvancedD.choDVPeriodsD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doDesignValuePeriods;
                            _outputAdvancedD.choNeighborFilePointD.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD.doNeighborFilePoint;
                        }
                        break;
                    case "uc_DataInputD":
                        pnlUserControl.Controls.Add(new uc_DataInputD());
                        lblSteps.Text = trvAnalysis.Nodes[2].Text;
                        _stips = "Select input files for the analysis";
                        uc_DataInputD _dataInputD = (pnlUserControl.Controls[0] as uc_DataInputD);
                        _dataInputD.InitializeControl();
                        break;
                    case "uc_SpeciesFrctionD":
                        pnlUserControl.Controls.Add(new uc_SpeciesFrctionD());
                        lblSteps.Text = trvAnalysis.Nodes[3].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Set up species fraction options";
                        uc_SpeciesFrctionD _speciesFrctionD = (pnlUserControl.Controls[0] as uc_SpeciesFrctionD);
                        _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstSTNFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFrctionD.cboPMMonitorStartYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        _speciesFrctionD.cboPMMonitorEndYearDaily.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMForFractionsMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD = new SpeciesFractionOptionsD();
                            if (_speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Items.Count >= 9)
                                _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.SelectedIndex = 8;
                            else
                                _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.SelectedIndex = _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Items.Count - 1;
                            if (_speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Items.Count >= 11)
                                _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.SelectedIndex = 10;
                            else
                                _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.SelectedIndex = _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Items.Count - 1;
                            if (_speciesFrctionD.cboPMMonitorStartYearDaily.Items.Count >= 9)
                                _speciesFrctionD.cboPMMonitorStartYearDaily.SelectedIndex = 8;
                            else
                                _speciesFrctionD.cboPMMonitorStartYearDaily.SelectedIndex = _speciesFrctionD.cboPMMonitorStartYearDaily.Items.Count - 1;
                            if (_speciesFrctionD.cboPMMonitorEndYearDaily.Items.Count >= 11)
                                _speciesFrctionD.cboPMMonitorEndYearDaily.SelectedIndex = 10;
                            else
                                _speciesFrctionD.cboPMMonitorEndYearDaily.SelectedIndex = _speciesFrctionD.cboPMMonitorEndYearDaily.Items.Count - 1;
                            _speciesFrctionD.choEPASpecifiedIMPROVEDaily.Checked = true;
                            _speciesFrctionD.choEPASpecifiedPMDaily.Checked = true;
                            _speciesFrctionD.nudownMinDaysIMPROVEDaily.Value = 11;
                            _speciesFrctionD.nudownMinQuartersIMPROVEDaily.Value = 1;
                            _speciesFrctionD.nudownMinYearsIMPROVEDaily.Value = 1;
                            _speciesFrctionD.nudownMinDaysPMDaily.Value = 11;
                            _speciesFrctionD.nudownMinQuartersPMDaily.Value = 4;
                            _speciesFrctionD.nudownMinYearsPMDaily.Value = 1;
                            _speciesFrctionD.choAdvancedOptions.Checked = false;
                            #region advanced options
                            _speciesFrctionD.rbtnTopPercMonitorIMPROVEDaily.Checked = true;
                            _speciesFrctionD.rbtnTopPercMonitorPMDaily.Checked = true;
                            _speciesFrctionD.nudownTopPercMonitorIMPROVEDaily.Value = 10;
                            _speciesFrctionD.nudownAllMonitorGreaterIMPROVEDaily.Value = 0;
                            _speciesFrctionD.nudownMinNumAboveIMPROVEDaily.Value = 1;
                            _speciesFrctionD.nudownTopNumMonitorIMPROVEDaily.Value = 25;
                            _speciesFrctionD.nudownTopPercMonitorPMDaily.Value = 10;
                            _speciesFrctionD.nudownAllMonitorGreaterPMDaily.Value = 0;
                            _speciesFrctionD.nudownMinNumAbovePMDaily.Value = 1;
                            _speciesFrctionD.nudownTopNumMonitorPMDaily.Value = 25;
                            _speciesFrctionD.cboPM25InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboSO4InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboNO3InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboECInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboSaltInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboCrastalInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboDONInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboOCInterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.cboNH4InterpolationDaily.SelectedIndex = 2;
                            _speciesFrctionD.nudownPM25DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownSO4DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownNO3DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownECDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownSaltDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownCrustalDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownDONDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownOCDistanceDaily.Value = 9000000000;
                            _speciesFrctionD.nudownNH4DistanceDaily.Value = 9000000000;
                            _speciesFrctionD.cboPM25InterpolationDaily.Enabled = false;
                            _speciesFrctionD.nudownPM25DistanceDaily.Enabled = false;
                            _speciesFrctionD.cboNH4InterpolationDaily.Enabled = false;
                            _speciesFrctionD.nudownNH4DistanceDaily.Enabled = false;
                            _speciesFrctionD.rbtnDONValueDaily.Checked = true;
                            _speciesFrctionD.nudownNH4PercDaily.Enabled = false;
                            _speciesFrctionD.nudownDefaultBMDaily.Value = (decimal)0.2;
                            _speciesFrctionD.nudownOCmbFloorDaily.Value = 1;
                            _speciesFrctionD.nudownOCmbCeilingDaily.Value = (decimal)0.8;
                            #endregion
                        }
                        else
                        {
                            _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_StartYear;
                            _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_EndYear;
                            _speciesFrctionD.choEPASpecifiedIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_EPADeletionChoice;
                            _speciesFrctionD.choUserSpecifiedIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_UserDeletionChoice;
                            _speciesFrctionD.nudownMinDaysIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinDays;
                            _speciesFrctionD.nudownMinQuartersIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinQuarters;
                            _speciesFrctionD.nudownMinYearsIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVE_MinYear;
                            _speciesFrctionD.cboPMMonitorStartYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialStartYear;
                            _speciesFrctionD.cboPMMonitorEndYearDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialEndYear;
                            _speciesFrctionD.choEPASpecifiedPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialEPADeletionChoice;
                            _speciesFrctionD.choUserSpecifiedPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialUserDeletionChoice;
                            _speciesFrctionD.nudownMinDaysPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinDays;
                            _speciesFrctionD.nudownMinQuartersPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinQuartersPoint;
                            _speciesFrctionD.nudownMinYearsPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialMinYears;
                            _speciesFrctionD.choAdvancedOptions.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doAdvancedOptionsForSpeciesFraction;
                            #region advanced options
                            _speciesFrctionD.rbtnTopPercMonitorIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoTopXPercent;
                            _speciesFrctionD.rbtnAllMonitorGreaterIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoUseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.rbtnTopNumMonitorIMPROVEDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_DoUseTopXNumber;
                            _speciesFrctionD.rbtnTopPercMonitorPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoTopXPercent;
                            _speciesFrctionD.rbtnAllMonitorGreaterPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoUseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.rbtnTopNumMonitorPMDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_DoTopXNumber;
                            _speciesFrctionD.nudownTopPercMonitorIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_TopXPercent;
                            _speciesFrctionD.nudownAllMonitorGreaterIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_UseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.nudownMinNumAboveIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_MinumumNumberOfDaysRequiredAboveFixedAmount;
                            _speciesFrctionD.nudownTopNumMonitorIMPROVEDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.IMPROVESTN_UseTopXNumber;
                            _speciesFrctionD.nudownTopPercMonitorPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_TopXPercent;
                            _speciesFrctionD.nudownAllMonitorGreaterPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_UseAlldailyMonitorValuesGreaterThan;
                            _speciesFrctionD.nudownMinNumAbovePMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_MinumumNumberOfDaysRequiredAboveFixedAmount;
                            _speciesFrctionD.nudownTopNumMonitorPMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.unofficialPM25_TopXNumber;
                            _speciesFrctionD.cboPM25InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodPM25;
                            _speciesFrctionD.nudownPM25DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distancePM25;
                            _speciesFrctionD.cboSO4InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodSO4;
                            _speciesFrctionD.nudownSO4DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceSO4;
                            _speciesFrctionD.cboNO3InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodNO3;
                            _speciesFrctionD.nudownNO3DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceNO3;
                            _speciesFrctionD.cboECInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodEC;
                            _speciesFrctionD.nudownECDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceEC;
                            _speciesFrctionD.cboSaltInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodSalt;
                            _speciesFrctionD.nudownSaltDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceSalt;
                            _speciesFrctionD.cboCrastalInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodCrustal;
                            _speciesFrctionD.nudownCrustalDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceCrustal;
                            _speciesFrctionD.cboDONInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodDON;
                            _speciesFrctionD.nudownDONDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceDON;
                            _speciesFrctionD.cboOCInterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodOC;
                            _speciesFrctionD.nudownOCDistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceOC;
                            _speciesFrctionD.cboNH4InterpolationDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.interpolationMethodNH4;
                            _speciesFrctionD.nudownNH4DistanceDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.distanceNH4;
                            _speciesFrctionD.rbtnDONValueDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doUseDonValues;
                            _speciesFrctionD.rbtnMeasuredAmmoniumDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.doUseMeasuredAmmonium;
                            _speciesFrctionD.cboPM25InterpolationDaily.Enabled = false;
                            _speciesFrctionD.nudownPM25DistanceDaily.Enabled = false;
                            if (_speciesFrctionD.rbtnDONValueDaily.Checked == true)
                            {
                                _speciesFrctionD.cboDONInterpolationDaily.Enabled = true;
                                _speciesFrctionD.nudownDONDistanceDaily.Enabled = true;
                                _speciesFrctionD.cboNH4InterpolationDaily.Enabled = false;
                                _speciesFrctionD.nudownNH4DistanceDaily.Enabled = false;
                                _speciesFrctionD.nudownNH4PercDaily.Enabled = false;
                            }
                            if (_speciesFrctionD.rbtnMeasuredAmmoniumDaily.Checked == true)
                            {
                                _speciesFrctionD.cboDONInterpolationDaily.Enabled = false;
                                _speciesFrctionD.nudownDONDistanceDaily.Enabled = false;
                                _speciesFrctionD.cboNH4InterpolationDaily.Enabled = true;
                                _speciesFrctionD.nudownNH4DistanceDaily.Enabled = true;
                                _speciesFrctionD.nudownNH4PercDaily.Enabled = true;
                            }
                            _speciesFrctionD.nudownNH4PercDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.nh4PercentageEvaporating;
                            _speciesFrctionD.nudownDefaultBMDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.defaultBlankMass;
                            _speciesFrctionD.nudownOCmbFloorDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.floorOCMMB;
                            _speciesFrctionD.nudownOCmbCeilingDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD.ceilingOCMMB;
                            #endregion
                        }
                        break;
                    case "uc_PM25CalculationD":
                        pnlUserControl.Controls.Add(new uc_PM25CalculationD());
                        lblSteps.Text = trvAnalysis.Nodes[4].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Set up pm25 calculation options";
                        uc_PM25CalculationD _pmCalculationD = (pnlUserControl.Controls[0] as uc_PM25CalculationD);

                        //----------------bind required dv,according to start year-------------
                        n = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Count;
                        dvString = new string[n];
                        for (int i = 0; i < n; i++)
                        {
                            dvString[i] = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears[i];
                        }
                        for (int i = 0; i < n; i++)
                        {
                            if (i + 2 < n)
                            {
                                _pmCalculationD.clboRequiredDV.Items.Add(dvString[i] + "-" + dvString[i + 2]);
                            }
                        }

                        _pmCalculationD.cboStartYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        _pmCalculationD.cboEndYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD = new PM25CalculationOptionsD();
                            if (_pmCalculationD.cboStartYearD.Items.Count >= 8)
                                _pmCalculationD.cboStartYearD.SelectedIndex = 7;
                            else
                                _pmCalculationD.cboStartYearD.SelectedIndex = _pmCalculationD.cboStartYearD.Items.Count - 1;
                            if (_pmCalculationD.cboEndYearD.Items.Count >= 12)
                                _pmCalculationD.cboEndYearD.SelectedIndex = 11;
                            else
                                _pmCalculationD.cboEndYearD.SelectedIndex = _pmCalculationD.cboEndYearD.Items.Count - 1;
                            _pmCalculationD.nudownMinNumDVD.Value = 1;
                            _pmCalculationD.txtRequiredDVD.Text = "None selected";
                            _pmCalculationD.rbtnCalculateNH4byDON.Checked = true;
                        }
                        else
                        {
                            _pmCalculationD.cboStartYearD.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.officialPM25StartYear;
                            _pmCalculationD.cboEndYearD.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.officialPM25EndYear;
                            _pmCalculationD.nudownMinNumDVD.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.minNumDVPeriodsForValidFRMMonitors;
                            _pmCalculationD.txtRequiredDVD.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.requiredDesignValuePeriodsForValidFRMMonitors;
                            if (_pmCalculationD.txtRequiredDVD.Text != "None selected")
                            {
                                string[] requireDV = _pmCalculationD.txtRequiredDVD.Text.Split(',');
                                foreach (string s in requireDV)
                                {
                                    _pmCalculationD.clboRequiredDV.SetItemChecked(_pmCalculationD.clboRequiredDV.Items.IndexOf(s), true);
                                }
                            }
                            _pmCalculationD.rbtnCalculateNH4byDON.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.doCalcNH4fromDON;
                            _pmCalculationD.rbtnCalculateNH4byRRF.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD.doCalcNH4fromRRF;
                        }
                        break;
                    case "uc_ModelDataD":
                        pnlUserControl.Controls.Add(new uc_ModelDataD());
                        lblSteps.Text = trvAnalysis.Nodes[5].Text;
                        _stips = "Set up model options";
                        uc_ModelDataD _modelDataD = (pnlUserControl.Controls[0] as uc_ModelDataD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD = new ModelDataOptionsD();
                            _modelDataD.cboGridPointModelOptionDaily.SelectedIndex = 0;
                            _modelDataD.choGridforSpatialForecast.SelectedIndex = 0;
                            _modelDataD.cboStatisticMethodDaily.SelectedIndex = 0;
                            _modelDataD.rbtnTopPerceRRFDaily.Checked = true;
                            _modelDataD.nudownTopPerceRRFDaily.Value = 10;
                            _modelDataD.nudownAllDailyGreaterRRFDaily.Value = 0;
                            _modelDataD.nudownMinNumDaysGreaterRRFDaily.Value = 1;
                            _modelDataD.nudownTopNumRRFDaily.Value = 25;
                        }
                        else
                        {
                            _modelDataD.cboGridPointModelOptionDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentAtMonitorGridPoint;
                            _modelDataD.choGridforSpatialForecast.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentAtMonitorGridSpatial;
                            _modelDataD.cboStatisticMethodDaily.Text = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.temporalAdjustmentType;
                            _modelDataD.rbtnTopPerceRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseXTopPercent;
                            _modelDataD.nudownTopPerceRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseXTopPercent;
                            _modelDataD.rbtnAllDailyGreaterRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseAllModelDaysGreaterThan;
                            _modelDataD.nudownAllDailyGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseAllModelDaysGreaterThan;
                            _modelDataD.nudownMinNumDaysGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_MinumumNumberOfDaysRequiredAboveFixedAmount;
                            _modelDataD.rbtnTopNumRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_DoUseTopXNumber;
                            _modelDataD.nudownTopNumRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD.RRF_UseTopXNumber;
                        }
                        break;

                    #endregion
                    #region Ozone added by sclong
                    case "uc_DesiredOutputOzone":
                        #region uc_DesiredOutputOzone
                        pnlUserControl.Controls.Add(new uc_DesiredOutputOzone());
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Choose Desired Output";
                        uc_DesiredOutputOzone _desiredOutputOzone = (pnlUserControl.Controls[0] as uc_DesiredOutputOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO = new ChooseDesiredOutputO();
                            _desiredOutputOzone.choPointForecastOzone.Checked = true;
                            _desiredOutputOzone.choSpatialOzone.Checked = false;
                            _desiredOutputOzone.choSpatialGradAdjOzone.Checked = false;
                            _desiredOutputOzone.choBaseOnlyVNAOzone.Checked = false;
                            _desiredOutputOzone.choFutureOnlyVNAOzone.Checked = false;
                            _desiredOutputOzone.choBaseOnlyEvnaOzone.Checked = false;
                            _desiredOutputOzone.choFutureOnlyEvnaOzone.Checked = false;
                            _desiredOutputOzone.choQuarterlyModelData.Checked = true;
                            //_desiredOutputOzone.choSpatialForecastOzone.Checked = false;
                            //_desiredOutputOzone.choSpatialGradAdjForecastOzone.Checked = false;
                            _desiredOutputOzone.choNeighborFileSpatial.Checked = false;
                            _desiredOutputOzone.choExtractAllOzone.Checked = true;
                            _desiredOutputOzone.choDVPeriods.Checked = false;
                            _desiredOutputOzone.chkDS.Checked = false;
                            _desiredOutputOzone.chkDSOnlyBase.Checked = false;
                            _desiredOutputOzone.chkDSOnlyFuture.Checked = false;

                            _desiredOutputOzone.txtDSBurn.Text = "500";
                            _desiredOutputOzone.txtDSCmaqres.Text = "12";
                            _desiredOutputOzone.txtDSNumit.Text = "2500";
                            _desiredOutputOzone.txtDSThin.Text = "1";
                        }
                        else
                        {
                            _desiredOutputOzone.txtScenarioOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                            _desiredOutputOzone.choPointForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doPointEstimatesForecast;
                            _desiredOutputOzone.choQuarterlyModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doQuarterlyModelData;
                            _desiredOutputOzone.choSpatialOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates;
                            _desiredOutputOzone.choSpatialGradAdjOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj;
                            _desiredOutputOzone.choBaseOnlyVNAOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA;
                            _desiredOutputOzone.choFutureOnlyVNAOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA;
                            _desiredOutputOzone.choBaseOnlyEvnaOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA;
                            _desiredOutputOzone.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDownscaler;
                            _desiredOutputOzone.chkDSOnlyBase.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSBaseOnly;
                            _desiredOutputOzone.chkDSOnlyFuture.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSFutureOnly;

                            _desiredOutputOzone.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSBurn.ToString();
                            _desiredOutputOzone.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSCmaqres.ToString();
                            _desiredOutputOzone.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSNumit.ToString();
                            _desiredOutputOzone.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.DSThin.ToString();

                            _desiredOutputOzone.choFutureOnlyEvnaOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA;
                            //_desiredOutputOzone.choSpatialForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecast;
                            //_desiredOutputOzone.choSpatialGradAdjForecastOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesForecastGradAdj;
                            _desiredOutputOzone.choNeighborFileSpatial.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doNeighborFileSpatial;
                            _desiredOutputOzone.choExtractAllOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doAutomaticallyExtract;
                            _desiredOutputOzone.choDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDesignValuePeriods;
                            _desiredOutputOzone.choMaxDVPeriods.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doMaxDesignValuePeriods;
                        }
                        #endregion
                        break;
                    case "uc_DataInputOzone":
                        #region uc_DataInputOzone
                        pnlUserControl.Controls.Add(new uc_DataInputOzone());
                        lblSteps.Text = trvAnalysis.Nodes[1].Text;
                        _stips = "Select input files for the analysis";
                        uc_DataInputOzone _dataInputOzone = (pnlUserControl.Controls[0] as uc_DataInputOzone);
                        _dataInputOzone.InitializeControl();
                        #endregion
                        break;
                    case "uc_FilteringorInterpolationOzone":
                        #region uc_FilteringorInterpolationOzone
                        pnlUserControl.Controls.Add(new uc_FilteringorInterpolationOzone());
                        lblSteps.Text = trvAnalysis.Nodes[2].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Select the filter and interpolation methods";//??
                        uc_FilteringorInterpolationOzone _filteringorInterpolationOzone = (pnlUserControl.Controls[0] as uc_FilteringorInterpolationOzone);

                        //----------------bind required dv,according to start year-------------
                        int j = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData.Count;
                        string[] dvStringOzone = new string[j];
                        for (int i = 0; i < j; i++)
                        {
                            dvStringOzone[i] = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.lstOzoneMonitorData[i];
                        }

                        _filteringorInterpolationOzone.clboRequiredDV.Items.Add((Convert.ToInt32(dvStringOzone[0]) - 2).ToString() + "-" + dvStringOzone[0]);
                        _filteringorInterpolationOzone.clboRequiredDV.Items.Add((Convert.ToInt32(dvStringOzone[0]) - 1).ToString() + "-" + dvStringOzone[1]);
                        for (int i = 0; i < j; i++)
                        {
                            if (i + 2 < j)
                            {
                                _filteringorInterpolationOzone.clboRequiredDV.Items.Add(dvStringOzone[i] + "-" + dvStringOzone[i + 2]);
                            }
                        }
                        foreach (var item in _filteringorInterpolationOzone.clboRequiredDV.Items)
                        {
                            _filteringorInterpolationOzone.cboStartYearOzone.Items.Add(item);
                            _filteringorInterpolationOzone.cboEndYearOzone.Items.Add(item);
                        }

                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO = new FilteringInterpolationO();
                            if (_filteringorInterpolationOzone.cboStartYearOzone.Items.Count >= 10)//>= 9)
                                _filteringorInterpolationOzone.cboStartYearOzone.SelectedIndex = 9;//= 8
                            else
                                _filteringorInterpolationOzone.cboStartYearOzone.SelectedIndex = _filteringorInterpolationOzone.cboStartYearOzone.Items.Count - 1;
                            if (_filteringorInterpolationOzone.cboEndYearOzone.Items.Count >= 12)//>= 10
                                _filteringorInterpolationOzone.cboEndYearOzone.SelectedIndex = 11;//= 9
                            else
                                _filteringorInterpolationOzone.cboEndYearOzone.SelectedIndex = _filteringorInterpolationOzone.cboEndYearOzone.Items.Count - 1;
                            _filteringorInterpolationOzone.nudownMinNumDVO.Value = 1;
                            _filteringorInterpolationOzone.txtRequiredDVOzone.Text = "None selected";
                            _filteringorInterpolationOzone.cboDefaultItpOzone.SelectedIndex = 1;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Checked = false;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Value = 100;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Enabled = false;
                        }
                        else
                        {
                            _filteringorInterpolationOzone.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.ozoneStartYear;
                            _filteringorInterpolationOzone.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.ozoneEndYear;
                            _filteringorInterpolationOzone.nudownMinNumDVO.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.minNumDV;
                            _filteringorInterpolationOzone.txtRequiredDVOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.requiredDVPeriods;
                            if (_filteringorInterpolationOzone.txtRequiredDVOzone.Text != "None selected")
                            {
                                string[] requireDV = _filteringorInterpolationOzone.txtRequiredDVOzone.Text.Split(',');
                                foreach (string s in requireDV)
                                {
                                    _filteringorInterpolationOzone.clboRequiredDV.SetItemChecked(_filteringorInterpolationOzone.clboRequiredDV.Items.IndexOf(s), true);
                                }
                            }
                            _filteringorInterpolationOzone.cboDefaultItpOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.defaultInterpolationMethod;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.doCheckToSetMaxDistance;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Enabled = _filteringorInterpolationOzone.choMaxItpDistanceOzone.Checked ? true : false;
                            _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO.maxDistance;
                        }
                        //Turn gray or not(Filteringor/Interpolation) by according to the Spatial Field item(Desired Output)checked or not
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates == false && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj == false
                            && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA == false && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA == false
                            && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA == false && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA == false
                            )
                        {
                            _filteringorInterpolationOzone.cboDefaultItpOzone.Enabled = false;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Enabled = false;
                        }
                        else
                        {
                            _filteringorInterpolationOzone.cboDefaultItpOzone.Enabled = true;
                            _filteringorInterpolationOzone.choMaxItpDistanceOzone.Enabled = true;
                        }
                        #endregion
                        break;
                    case "uc_RRForSpatialGradientOzone":
                        #region uc_RRForSpatialGradientOzone
                        pnlUserControl.Controls.Add(new uc_RRForSpatialGradientOzone());
                        lblSteps.Text = trvAnalysis.Nodes[3].Text;
                        _stips = "Set up for RRF and spatial gradient";//?
                        uc_RRForSpatialGradientOzone _rrforSpatialGradientOzone = (pnlUserControl.Controls[0] as uc_RRForSpatialGradientOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO = new RRFSpatialGradientO();
                            _rrforSpatialGradientOzone.rbtnInitial.Checked = false;
                            _rrforSpatialGradientOzone.rbtnTopX.Checked = true;
                            _rrforSpatialGradientOzone.txtInitialValueOzone.Text = "85";
                            _rrforSpatialGradientOzone.txtAboveThresholdOzone.Text = "10";
                            _rrforSpatialGradientOzone.txtTopX.Text = "10";
                            _rrforSpatialGradientOzone.txtAllowableValueOzone.Text = "60";
                            _rrforSpatialGradientOzone.txtAboveAllowableThresholdOzone.Text = "5";
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked = false;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Enabled = false;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Text = "0";
                            _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Value = 1;
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays > 0)
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                            }
                            else
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = 366;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = 366;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = 366;
                            }
                            _rrforSpatialGradientOzone.choPairDaysOzone.Checked = false;
                            _rrforSpatialGradientOzone.txtStartValueOzone.Text = "1";
                            _rrforSpatialGradientOzone.txtEndValueOzone.Text = "5";
                        }
                        else
                        {
                            _rrforSpatialGradientOzone.rbtnInitial.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.useInitialThreshold;
                            _rrforSpatialGradientOzone.rbtnTopX.Checked = !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.useInitialThreshold;
                            _rrforSpatialGradientOzone.txtInitialValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.initialThresholdValue;
                            _rrforSpatialGradientOzone.txtAboveThresholdOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minNumofDaysAtorAboveThreshold;
                            _rrforSpatialGradientOzone.txtTopX.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.topXDays.ToString();
                            _rrforSpatialGradientOzone.txtAllowableValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minAllowableThresholdValue;
                            _rrforSpatialGradientOzone.txtAboveAllowableThresholdOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.minNumDaysAtorAboveMinAllowableThreshold;
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.doBackstop;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Enabled = _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked ? true : false;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.backstopMinThresholdforSpatialField;
                            _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.subrangeFirstDay;
                            _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.subrangeLastDay;
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays > 0)
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                            }
                            else
                            {
                                _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = 366;
                                _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = 366;
                            }
                            _rrforSpatialGradientOzone.choPairDaysOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.doPairDays;
                            _rrforSpatialGradientOzone.txtStartValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.SRF_StartValue;
                            _rrforSpatialGradientOzone.txtEndValueOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO.SRF_EndValue;
                        }
                        //some control will turn gray(Unable to use) if it meets these requirements in Desired Output
                        if (!(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj
                            && !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA
                            //&& !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates
                            //&& !(CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA
                            )
                        {
                            _rrforSpatialGradientOzone.txtStartValueOzone.Text = "1";
                            _rrforSpatialGradientOzone.txtEndValueOzone.Text = "5";
                            _rrforSpatialGradientOzone.txtStartValueOzone.Enabled = false;
                            _rrforSpatialGradientOzone.txtEndValueOzone.Enabled = false;
                        }
                        else
                        {
                            _rrforSpatialGradientOzone.txtStartValueOzone.Enabled = true;
                            _rrforSpatialGradientOzone.txtEndValueOzone.Enabled = true;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates
|| (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj
|| (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA
|| (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA)
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Enabled = true;
                        else
                        {
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Enabled = false;
                            _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked = false;
                            _rrforSpatialGradientOzone.txtBackstopMinOzone.Enabled = false;
                        }

                        #endregion
                        break;
                    #endregion
                    #region Visibility added by sclong
                    case "uc_ChooseDesiredOutputV":
                        #region uc_ChooseDesiredOutputV
                        pnlUserControl.Controls.Add(new uc_ChooseDesiredOutputV());
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Choose Desired Output";
                        uc_ChooseDesiredOutputV _outPutV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV = new ChooseDesiredOutputV();
                            _outPutV.choVisibilityLevels.Checked = true;
                            _outPutV.rbtnOldIMPROVEAlgorithmVisibility.Checked = false;
                            _outPutV.rbtnNewIMPROVEAlgorithmVisibility.Checked = true;
                            _outPutV.rbtnModelGridCellatMonitorVisi.Checked = false;
                            _outPutV.rbtnModelGridCellatClass1Visi.Checked = false;
                            _outPutV.choExtractAllVisibility.Checked = true;
                        }
                        else
                        {
                            _outPutV.txtScenarioNameVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                            _outPutV.choVisibilityLevels.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast;
                            _outPutV.rbtnOldIMPROVEAlgorithmVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm;
                            _outPutV.rbtnNewIMPROVEAlgorithmVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseNewVersionforIMPROVEAlgorithm;
                            _outPutV.rbtnModelGridCellatMonitorVisi.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellAtMonitor;
                            _outPutV.rbtnModelGridCellatClass1Visi.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellatClassIAreaCentroid;
                            _outPutV.choExtractAllVisibility.Checked = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doAutomaticallyExtract;
                        }
                        #endregion
                        break;
                    case "uc_DataInputV":
                        #region uc_DataInputV
                        pnlUserControl.Controls.Add(new uc_DataInputV());
                        uc_DataInputV _dataInputV = (pnlUserControl.Controls[0] as uc_DataInputV);
                        lblSteps.Text = trvAnalysis.Nodes[1].Text;
                        _stips = "Select input files for the analysis";
                        _dataInputV.InitializeControl();
                        #endregion
                        break;
                    case "uc_FilteringV":
                        #region uc_FilteringV
                        pnlUserControl.Controls.Add(new uc_FilteringV());
                        lblSteps.Text = trvAnalysis.Nodes[2].Text;
                        pnlUserControl.Refresh();
                        lblSteps.Refresh();
                        trvAnalysis.Refresh();
                        _stips = "Set up filtering options";
                        uc_FilteringV _filteringV = (pnlUserControl.Controls[0] as uc_FilteringV);
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm)
                        {
                            _filteringV.cboStartYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataOld.Distinct().ToList();
                            _filteringV.cboEndYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataOld.Distinct().ToList();
                            _filteringV.cboBaseYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataOld.Distinct().ToList();
                        }
                        else
                        {
                            _filteringV.cboStartYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataNew.Distinct().ToList();
                            _filteringV.cboEndYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataNew.Distinct().ToList();
                            _filteringV.cboBaseYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorDataNew.Distinct().ToList();
                        }


                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV = new FilteringV();
                            if (_filteringV.cboStartYearVisibility.Items.Count > 11)
                                _filteringV.cboStartYearVisibility.SelectedIndex = 9;//Use default 5 years “2009-2013” in GUI (instead of current 3 years),add by sclong,2017-02-14
                            else
                                _filteringV.cboStartYearVisibility.SelectedIndex = _filteringV.cboStartYearVisibility.Items.Count - 1;
                            if (_filteringV.cboEndYearVisibility.Items.Count > 13)
                                _filteringV.cboEndYearVisibility.SelectedIndex = 13;//Use default 5 years “2009-2013” in GUI (instead of current 3 years),add by sclong,2017-02-14
                            else
                                _filteringV.cboEndYearVisibility.SelectedIndex = _filteringV.cboEndYearVisibility.Items.Count - 1;
                            if (_filteringV.cboBaseYearVisibility.Items.Count > 12)
                                _filteringV.cboBaseYearVisibility.SelectedIndex = 11;
                            else
                                _filteringV.cboBaseYearVisibility.SelectedIndex = _filteringV.cboBaseYearVisibility.Items.Count - 1;
                            _filteringV.txtMinYearVisibility.Text = "3";
                        }
                        else
                        {
                            _filteringV.cboStartYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.startMonitorYear;
                            _filteringV.cboEndYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.endMonitorYear;
                            _filteringV.cboBaseYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.baseModelYear;
                            _filteringV.txtMinYearVisibility.Text = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV.minYearsForValidVisibilityMonitors;
                        }
                        #endregion
                        break;
                    #endregion
                    #region SSIA
                    case "uc_AnalysisOption":
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Single Source Impact Analysis Option";
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                        {
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = true;
                                _analysisOption.rbtnGridAndDispersion.Checked = false;
                                _analysisOption.rbtnGridOnly.Checked = true;
                                _analysisOption.rbtnDispersionOnly.Checked = false;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData;
                                _analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion;
                                _analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly;
                                _analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                        {
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = true;
                                _analysisOption.rbtnGridAndDispersion.Checked = false;
                                _analysisOption.rbtnGridOnly.Checked = true;
                                _analysisOption.rbtnDispersionOnly.Checked = false;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData;
                                _analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion;
                                _analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly;
                                _analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                        {
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = true;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData;
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)    //added by Lijiabin
                        {
                            pnlUserControl.Controls.Add(new uc_AnalysisOption(this));
                            uc_AnalysisOption _analysisOption = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep = new SSIAAnalysisOption();
                                _analysisOption.choUseModelData.Checked = true;
                                _analysisOption.choUseModelFRMData.Checked = false;
                                _analysisOption.rbtnGridAndDispersion.Checked = false;
                                _analysisOption.rbtnGridOnly.Checked = false;
                                _analysisOption.rbtnDispersionOnly.Checked = false;
                            }
                            else
                            {
                                _analysisOption.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                                _analysisOption.choUseModelData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelData;
                                _analysisOption.choUseModelFRMData.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useModelFRMData;
                                //_analysisOption.rbtnGridAndDispersion.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridAndDispersion;
                                //_analysisOption.rbtnGridOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useGridOnly;
                                //_analysisOption.rbtnDispersionOnly.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.useDispersionOnly;
                            }
                        }
                        break;
                    case "uc_ModelDataInputA":
                        pnlUserControl.Controls.Add(new uc_ModelDataInputA());
                        _stips = "Model Data Input && Option";
                        lblSteps.Text = Language.Localization.GetValue(_stips);
                        uc_ModelDataInputA _modelInput = (pnlUserControl.Controls[0] as uc_ModelDataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA = new SSIAModelDataInputA();
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion)
                            {
                                _modelInput.rbtnDailyModelA.Checked = true;
                                _modelInput.rbtnQuarterlyModelA.Checked = false;
                                //_modelInput.rbtnCMAQA.Checked = false;
                                CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"];//  Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly)
                            {
                                _modelInput.rbtnDailyModelA.Checked = true;
                                _modelInput.rbtnQuarterlyModelA.Checked = false;
                                //_modelInput.rbtnCMAQA.Checked = false;
                                CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                _modelInput.panelDispersion.Visible = false;
                                _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.panelDispersion.Location.X, _modelInput.panelDispersion.Location.Y);
                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                            {
                                CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                _modelInput.panelGrid.Visible = false;
                                _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.pnlSourceFile.Location.X, _modelInput.pnlSourceFile.Location.Y - _modelInput.panelGrid.Height);
                                _modelInput.panelDispersion.Location = new System.Drawing.Point(_modelInput.panelGrid.Location.X, _modelInput.panelGrid.Location.Y);
                            }
                            CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["sourceCoordinatesFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                            _modelInput.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        else
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridAndDispersion)
                            {
                                _modelInput.rbtnDailyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.DailyModelDataInput;
                                _modelInput.rbtnQuarterlyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.QuarterlyModelDataInput;
                                //_modelInput.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.InputFromCMAQ;
                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile))
                                {
                                    CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile;
                                    _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }
                                else
                                {
                                    CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                    _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }

                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile))
                                {
                                    CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile;
                                    _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                                else
                                {
                                    CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                    _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }

                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile))
                                {
                                    CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile;
                                    _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                else
                                {
                                    CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                    _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly)
                            {
                                _modelInput.rbtnDailyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.DailyModelDataInput;
                                _modelInput.rbtnQuarterlyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.QuarterlyModelDataInput;
                                //_modelInput.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.InputFromCMAQ;
                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile))
                                {
                                    CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.baselineModelDataFile;
                                    _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }
                                else
                                {
                                    CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                    _modelInput.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }

                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile))
                                {
                                    CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.alternativeScenarioFile;
                                    _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                                else
                                {
                                    CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                    _modelInput.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                                _modelInput.panelDispersion.Visible = false;
                                _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.panelDispersion.Location.X, _modelInput.panelDispersion.Location.Y);

                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                            {
                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile))
                                {
                                    CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.dispersionFile;
                                    _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                else
                                {
                                    CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                                    _modelInput.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                _modelInput.panelGrid.Visible = false;
                                _modelInput.pnlSourceFile.Location = new System.Drawing.Point(_modelInput.panelDispersion.Location.X, _modelInput.pnlSourceFile.Location.Y - _modelInput.panelGrid.Height);
                                _modelInput.panelDispersion.Location = new System.Drawing.Point(_modelInput.panelGrid.Location.X, _modelInput.panelGrid.Location.Y);
                            }
                            CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA.SourceCoordinateFile;
                            _modelInput.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        break;
                    case "uc_MonitorDataInputA":
                        pnlUserControl.Controls.Add(new uc_MonitorDataInputA());
                        _stips = "Monitor Data Input & Option";
                        lblSteps.Text = Language.Localization.GetValue(_stips);
                        uc_MonitorDataInputA _monitorInput = (pnlUserControl.Controls[0] as uc_MonitorDataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA == null)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA = new SSIAMonitorDataInputA();
                            CommonClass.officialPMFile = CommonClass.dicExampleConfiguration.ContainsKey("SSIAAnnualPM") ? CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["officialMonitorFile"] : Application.StartupPath + @"\Data\SampleData\Monitor_data\official_annual-PM25_2002thru2017.csv";//official_annual-PM25_allFRM.NID2002thru2015_v2.csv//official_annual-PM25_allFRM 121013.csv";
                            CommonClass.getmonitorYear("");
                            _monitorInput.txtOfficialMonitorA.Text = Path.GetFileName(CommonClass.officialPMFile);
                            _monitorInput.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            _monitorInput.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            if (_monitorInput.cboStartYearA.Items.Count > 7)
                                _monitorInput.cboStartYearA.SelectedIndex = 6;
                            else
                                _monitorInput.cboStartYearA.SelectedIndex = _monitorInput.cboStartYearA.Items.Count - 1;
                            if (_monitorInput.cboEndYearA.Items.Count > 11)
                            {
                                _monitorInput.cboEndYearA.SelectedIndex = 10;
                            }
                            else
                            {
                                _monitorInput.cboEndYearA.SelectedIndex = _monitorInput.cboEndYearA.Items.Count - 1;
                            }
                            _monitorInput.choVNA.Checked = true;
                            _monitorInput.choEVNA.Checked = true;
                            _monitorInput.cboPointGridA.Text = "1x1";
                            WaitClose();
                        }
                        else
                        {
                            CommonClass.officialPMFile = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.officialMonitorDataFile;
                            _monitorInput.txtOfficialMonitorA.Text = Path.GetFileName(CommonClass.officialPMFile);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears == null)
                            {
                                CommonClass.getmonitorYear("");
                            }
                            _monitorInput.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            _monitorInput.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            _monitorInput.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.monitorDataStartYear;
                            _monitorInput.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.monitorDataEndYear;
                            _monitorInput.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useVNA;
                            _monitorInput.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useEVNA;
                            _monitorInput.cboPointGridA.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.temporalAdjustmentAtMonitorGrid;
                        }
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                        {
                            _monitorInput.choVNA.Checked = true;
                            _monitorInput.choEVNA.Checked = false;
                            _monitorInput.choVNA.Enabled = false;
                            _monitorInput.choEVNA.Enabled = false;
                        }
                        break;
                    case "uc_ModelDataInputD":
                        pnlUserControl.Controls.Add(new uc_ModelDataInputD());
                        _stips = "Model Data Input && Option";
                        lblSteps.Text = Language.Localization.GetValue(_stips);
                        uc_ModelDataInputD _modelInputD = (pnlUserControl.Controls[0] as uc_ModelDataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD = new SSIAModelDataInputD();
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion)
                            {
                                _modelInputD.rbtnDailyModelDataD.Checked = true;
                                _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = false;
                                //_modelInputD.rbtnCMAQFileD.Checked = false;
                                CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                                _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly)
                            {
                                _modelInputD.rbtnDailyModelDataD.Checked = true;
                                _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = false;
                                //_modelInputD.rbtnCMAQFileD.Checked = false;
                                CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                _modelInputD.panelDispersion.Visible = false;
                                _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y);
                                _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.panelDispersion.Location.Y);
                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)
                            {
                                CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                                _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                _modelInputD.panelGrid.Visible = false;
                                _modelInputD.panelDispersion.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y - _modelInputD.panelGrid.Size.Height);
                                _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelOptions.Location.X, _modelInputD.panelOptions.Location.Y - _modelInputD.panelGrid.Size.Height);
                                _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.panelGrid.Location.Y);
                            }
                            _modelInputD.cboGridPointModelOptionDaily.SelectedIndex = 0;
                            //_modelInputD.cboGridforSpatialForecast.SelectedIndex = 0;
                            _modelInputD.cboStatisticMethodDaily.SelectedIndex = 0;
                            _modelInputD.rbtnTopPerceRRFDaily.Checked = true;
                            _modelInputD.nudownTopPerceRRFDaily.Value = 10;
                            _modelInputD.nudownAllDailyGreaterRRFDaily.Value = 0;
                            _modelInputD.nudownMinNumDaysGreaterRRFDaily.Value = 1;
                            _modelInputD.nudownTopNumRRFDaily.Value = 25;
                            CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["sourceCoordinatesFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                            _modelInputD.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        else
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridAndDispersion)
                            {
                                _modelInputD.rbtnDailyModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.DailyModelDataInput;
                                _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.QuarterlyModelDataInput;
                                //_modelInputD.rbtnCMAQFileD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.InputFromCMAQ;
                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile))
                                {
                                    CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile;
                                    _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }
                                else
                                {
                                    CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"];//  Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                    _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }

                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile))
                                {
                                    CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile;
                                    _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                                else
                                {
                                    CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                    _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }

                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile))
                                {
                                    CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile;
                                    _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                else
                                {
                                    CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                                    _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly)
                            {
                                _modelInputD.rbtnDailyModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.DailyModelDataInput;
                                _modelInputD.rbtnQuarterlyPeakModelDataD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.QuarterlyModelDataInput;
                                //_modelInputD.rbtnCMAQFileD.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.InputFromCMAQ;
                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile))
                                {
                                    CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.baselineModelDataFile;
                                    _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }
                                else
                                {
                                    CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                                    _modelInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                                }

                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile))
                                {
                                    CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.alternativeScenarioFile;
                                    _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                                else
                                {
                                    CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                                    _modelInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                                }
                                _modelInputD.panelDispersion.Visible = false;
                                _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y);
                                _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.panelDispersion.Location.Y);
                            }
                            else if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)
                            {
                                if (!string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile))
                                {
                                    CommonClass.dispersionModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.dispersionFile;
                                    _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                else
                                {
                                    CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                                    _modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                                }
                                _modelInputD.panelGrid.Visible = false;
                                _modelInputD.panelDispersion.Location = new System.Drawing.Point(_modelInputD.panelDispersion.Location.X, _modelInputD.panelDispersion.Location.Y - _modelInputD.panelGrid.Size.Height);
                                _modelInputD.panelOptions.Location = new System.Drawing.Point(_modelInputD.panelOptions.Location.X, _modelInputD.panelOptions.Location.Y - _modelInputD.panelGrid.Size.Height);
                                _modelInputD.pnlSourceFile.Location = new System.Drawing.Point(_modelInputD.pnlSourceFile.Location.X, _modelInputD.panelGrid.Location.Y);
                            }
                            _modelInputD.cboGridPointModelOptionDaily.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentAtMonitorGridPoint;
                            //_modelInputD.cboGridforSpatialForecast.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentAtMonitorGridSpatial;
                            _modelInputD.cboStatisticMethodDaily.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.temporalAdjustmentType;
                            _modelInputD.rbtnTopPerceRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseXTopPercent;
                            _modelInputD.nudownTopPerceRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseXTopPercent;
                            _modelInputD.rbtnAllDailyGreaterRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseAllModelDaysGreaterThan;
                            _modelInputD.nudownAllDailyGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseAllModelDaysGreaterThan;
                            _modelInputD.nudownMinNumDaysGreaterRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_MinumumNumberOfDaysRequiredAboveFixedAmount;
                            _modelInputD.rbtnTopNumRRFDaily.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_DoUseTopXNumber;
                            _modelInputD.nudownTopNumRRFDaily.Value = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.RRF_UseTopXNumber;
                            CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD.SourceCoordinateFile;
                            _modelInputD.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        break;
                    case "uc_MonitorDataInputD":
                        pnlUserControl.Controls.Add(new uc_MonitorDataInputD());
                        _stips = "Monitor Data Input & Option";
                        lblSteps.Text = Language.Localization.GetValue(_stips);
                        uc_MonitorDataInputD _monitorInputD = (pnlUserControl.Controls[0] as uc_MonitorDataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD == null)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD = new SSIAMonitorDataInputD();
                            CommonClass.officialPMFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["officialMonitorFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\official_24-hr-PM25.NID2002thru2015_v2.csv";
                            CommonClass.getmonitorYear("");
                            _monitorInputD.txtOfficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.officialPMFile);
                            _monitorInputD.cboStartYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            _monitorInputD.cboEndYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            if (_monitorInputD.cboStartYearD.Items.Count > 7)
                                _monitorInputD.cboStartYearD.SelectedIndex = 6;
                            else
                                _monitorInputD.cboStartYearD.SelectedIndex = _monitorInputD.cboStartYearD.Items.Count - 1;
                            if (_monitorInputD.cboEndYearD.Items.Count > 11)
                            {
                                _monitorInputD.cboEndYearD.SelectedIndex = 10;
                            }
                            else
                            {
                                _monitorInputD.cboEndYearD.SelectedIndex = _monitorInputD.cboEndYearD.Items.Count - 1;
                            }
                            _monitorInputD.choEVNA.Checked = true;
                            _monitorInputD.choVNA.Checked = true;
                            WaitClose();
                        }
                        else
                        {
                            CommonClass.officialPMFile = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.officialMonitorDataFile;
                            _monitorInputD.txtOfficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.officialPMFile);
                            _monitorInputD.cboStartYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            _monitorInputD.cboEndYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                            _monitorInputD.cboStartYearD.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.monitorDataStartYear;
                            _monitorInputD.cboEndYearD.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.monitorDataEndYear;
                            _monitorInputD.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useEVNA; ;
                            _monitorInputD.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useVNA; ;
                        }
                        break;
                    case "uc_ModelDataInputO":
                        pnlUserControl.Controls.Add(new uc_ModelDataInputO());
                        _stips = "Model Data Input && Option";
                        lblSteps.Text = Language.Localization.GetValue(_stips);
                        uc_ModelDataInputO _modelDataInputO = (pnlUserControl.Controls[0] as uc_ModelDataInputO);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO = new SSIAModelDataInputO();
                            _modelDataInputO.choCMAQOzone.Checked = false;
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["baselineModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.O3.4ATL1.2007ee_07f_BASE.csv";
                            _modelDataInputO.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.O3.4ATL1.2007ee_07f_ALT.csv";
                            _modelDataInputO.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                            CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIAOzone"]["sourceCoordinatesFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                            _modelDataInputO.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        else
                        {
                            _modelDataInputO.choCMAQOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.doInputfromCmaq;
                            CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.baselineModelDataFile;
                            _modelDataInputO.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.forecastModelDataFile;
                            _modelDataInputO.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                            CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO.SourceCoordinateFile;
                            _modelDataInputO.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        break;
                    case "uc_MonitorDataInputO":
                        pnlUserControl.Controls.Add(new uc_MonitorDataInputO());
                        _stips = "Monitor Data Input & Option";
                        lblSteps.Text = Language.Localization.GetValue(_stips);
                        uc_MonitorDataInputO _monitorInputO = (pnlUserControl.Controls[0] as uc_MonitorDataInputO);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO == null)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO = new SSIAMonitorDataInputO();
                            CommonClass.ozoneMonitorFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["officialMonitorFile"];//Application.StartupPath + @"\Data\SampleData\Monitor_data\SMAT_OZONE_MAX4DV_STD70_2002_2015.CSV";//MATS_OZONE_DV_2012_V2_off.csv";
                            CommonClass.getmonitorYear("");
                            _monitorInputO.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);

                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData.Sort();
                            List<string> year = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData;
                            for (int i = 0; i < year.Count; i++)
                            {
                                _monitorInputO.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                _monitorInputO.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                            }

                            if (_monitorInputO.cboStartYearOzone.Items.Count >= 5)
                                _monitorInputO.cboStartYearOzone.SelectedIndex = 4;
                            else
                                _monitorInputO.cboStartYearOzone.SelectedIndex = _monitorInputO.cboStartYearOzone.Items.Count - 1;
                            if (_monitorInputO.cboEndYearOzone.Items.Count > 7)
                                _monitorInputO.cboEndYearOzone.SelectedIndex = 6;
                            else
                                _monitorInputO.cboEndYearOzone.SelectedIndex = _monitorInputO.cboEndYearOzone.Items.Count - 1;
                            _monitorInputO.choVNA.Checked = true;
                            _monitorInputO.choEVNA.Checked = true;
                            _monitorInputO.chkDS.Checked = false;
                            _monitorInputO.txtDSThin.Text = "1";
                            _monitorInputO.txtDSNumit.Text = "2500";
                            _monitorInputO.txtDSCmaqres.Text = "12";
                            _monitorInputO.txtDSBurn.Text = "500";
                            _monitorInputO.cboGridOzone.SelectedIndex = 1;
                            _monitorInputO.cboStatisticOzone.SelectedIndex = 2;
                            WaitClose();
                        }
                        else
                        {
                            CommonClass.ozoneMonitorFile = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneMonitorDataFile;
                            _monitorInputO.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData == null)
                            {
                                CommonClass.getmonitorYear("");
                            }
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData.Sort();
                            List<string> year = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData;
                            for (int i = 0; i < year.Count; i++)
                            {
                                _monitorInputO.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                _monitorInputO.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                            }
                            _monitorInputO.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneStartYear;
                            _monitorInputO.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.ozoneEndYear;
                            _monitorInputO.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useVNA;
                            _monitorInputO.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useEVNA;
                            _monitorInputO.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useDownscaler;
                            _monitorInputO.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSThin.ToString();
                            _monitorInputO.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSNumit.ToString();
                            _monitorInputO.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSCmaqres.ToString();
                            _monitorInputO.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.DSBurn.ToString();

                            _monitorInputO.cboGridOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.temporalAdjustmentAtMonitorGrid;
                            _monitorInputO.cboStatisticOzone.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.temporalAdjustmentType;
                        }
                        break;
                    case "uc_ModelDataInputDep":                                    //added by Lijiabin
                        pnlUserControl.Controls.Add(new uc_ModelDataInputDep());
                        _stips = "Model Data Input && Option";
                        lblSteps.Text = Language.Localization.GetValue(_stips);
                        uc_ModelDataInputDep _modelDataInputDep = (pnlUserControl.Controls[0] as uc_ModelDataInputDep);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep = new SSIAModelDataInputDep();
                            _modelDataInputDep.rbtnDailyModelDataDep.Checked = true;
                            _modelDataInputDep.rbtnQuarterlyModelDataDep.Checked = false;
                            _modelDataInputDep.rbtnQuarterlyModelDataDep.Enabled = false;
                            ////_modelInputD.rbtnCMAQFileD.Checked = false;
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADeposition"]["baselineModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_baseline.csv";
                            _modelDataInputDep.txtBaselineDep.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADeposition"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_13.csv";
                            _modelDataInputDep.txtForecastDep.Text = Path.GetFileName(CommonClass.futureModelFile);
                            CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIADeposition"]["sourceCoordinatesFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.sourcecoords.12WUS1.tag013.csv";
                            _modelDataInputDep.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                            //CommonClass.dispersionModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                            //_modelInputD.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                        }
                        else
                        {
                            _modelDataInputDep.rbtnDailyModelDataDep.Checked = true;
                            _modelDataInputDep.rbtnQuarterlyModelDataDep.Checked = false;
                            _modelDataInputDep.rbtnQuarterlyModelDataDep.Enabled = false;
                            CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.baselineModelDataFile;
                            _modelDataInputDep.txtBaselineDep.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.alternativeScenarioFile;
                            _modelDataInputDep.txtForecastDep.Text = Path.GetFileName(CommonClass.futureModelFile);
                            CommonClass.ssiasourcefile = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep.SourceCoordinateFile;
                            _modelDataInputDep.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        }
                        break;
                    case "uc_CalculationOption":
                        if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                        {
                            _stips = "PM Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    _calculation.txtNAAQS.Text = CommonClass.IniReadValue("annual pm calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("annual pm calculation option", "Threshold_value", iniPath);
                                    _calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "Start_percentage", iniPath);
                                    _calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    _calculation.txtNAAQS.Text = "12";
                                    _calculation.txtThreshold.Text = "1";
                                    _calculation.nupdStartPercentage.Text = "0";
                                    _calculation.nupdEndPercentage.Text = "100";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold.ToString();
                                _calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.startPercentage.ToString();
                                _calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "(μg/m3) ";
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                        {
                            _stips = "PM Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    _calculation.txtNAAQS.Text = CommonClass.IniReadValue("daily pm calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("daily pm calculation option", "Threshold_value", iniPath);
                                    _calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("daily pm calculation option", "Start_percentage", iniPath);
                                    _calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("daily pm calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    _calculation.txtNAAQS.Text = "35";
                                    _calculation.txtThreshold.Text = "1";
                                    _calculation.nupdStartPercentage.Text = "95";
                                    _calculation.nupdEndPercentage.Text = "98";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold.ToString();
                                _calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.startPercentage.ToString();
                                _calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "(μg/m3) ";
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                        {
                            _stips = "Ozone Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    _calculation.txtNAAQS.Text = CommonClass.IniReadValue("ozone calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("ozone calculation option", "Threshold_value", iniPath);
                                    _calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("ozone calculation option", "Start_percentage", iniPath);
                                    _calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("ozone calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    _calculation.txtNAAQS.Text = "70";
                                    _calculation.txtThreshold.Text = "1";
                                    _calculation.nupdStartPercentage.Text = "0";
                                    _calculation.nupdEndPercentage.Text = "100";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold.ToString();
                                _calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.startPercentage.ToString();
                                _calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "(ppb) ";
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)      //added by Lijiabin
                        {
                            _stips = "Deposition Calculation Option";
                            lblSteps.Text = Language.Localization.GetValue(_stips);
                            pnlUserControl.Controls.Add(new uc_CalculationOption());
                            uc_CalculationOption _calculation = (pnlUserControl.Controls[0] as uc_CalculationOption);
                            _calculation.label5.Hide();
                            _calculation.label6.Hide();
                            _calculation.label7.Hide();
                            _calculation.label8.Hide();
                            _calculation.label9.Hide();
                            _calculation.nupdStartPercentage.Hide();
                            _calculation.nupdEndPercentage.Hide();
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption == null)
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption = new SSIACalculationOption();
                                string iniPath = Application.StartupPath + @"\SMAT.ini";
                                if (File.Exists(iniPath))
                                {
                                    //_calculation.txtNAAQS.Text = CommonClass.IniReadValue("deposition calculation option", "NAAQS_value", iniPath);
                                    _calculation.txtThreshold.Text = CommonClass.IniReadValue("deposition calculation option", "Threshold_value", iniPath);
                                    //_calculation.nupdStartPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "Start_percentage", iniPath);
                                    //_calculation.nupdEndPercentage.Text = CommonClass.IniReadValue("annual pm calculation option", "End_percentage", iniPath);
                                }
                                else
                                {
                                    //_calculation.txtNAAQS.Text = "0";
                                    _calculation.txtThreshold.Text = "0";
                                    //_calculation.nupdStartPercentage.Text = "0";
                                    //_calculation.nupdEndPercentage.Text = "100";
                                }
                            }
                            else
                            {
                                _calculation.txtNAAQS.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.NAAQS.ToString();
                                _calculation.txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.threshold.ToString();
                                //_calculation.nupdStartPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.startPercentage.ToString();
                                //_calculation.nupdEndPercentage.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.endPercentage.ToString();
                            }
                            _calculation.lblNAAQS_Unit.Text = "";
                        }
                        break;
                    #endregion
                    #region Annual PM China added by Yangwenwei
                    case "uc_ModelDataChina":
                        pnlUserControl.Controls.Add(new uc_ModelDataChina());
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Set up Model data input.";
                        uc_ModelDataChina modeldatachina = (pnlUserControl.Controls[0] as uc_ModelDataChina);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina = new ModelDataInputChina();
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["baselineModelDataFile"];// Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_Base_Quarterly.csv";
                            modeldatachina.txtBaselineChina.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["forecastModelDataFile"];// Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_L_R_0.5_0.5_Quarterly.csv";
                            modeldatachina.txtControlChina.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        else
                        {
                            modeldatachina.rbtnQuarterlyAverageDataChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doQuarterlyAverageDataInput;
                            modeldatachina.rbtnDailyAvertageDatalChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doDailyAverageDataInput;
                            modeldatachina.rbtnCMAQChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.doInputFromCMAQ;
                            modeldatachina.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.BaselineModelDataFile;
                            modeldatachina.txtBaselineChina.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.ControlModelDataFile;
                            modeldatachina.txtControlChina.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        break;
                    case "uc_MonitorDataChina":
                        pnlUserControl.Controls.Add(new uc_MonitorDataChina());
                        lblSteps.Text = trvAnalysis.Nodes[1].Text;
                        _stips = "Set up Monitor data input";
                        uc_MonitorDataChina monitordatachina = (pnlUserControl.Controls[0] as uc_MonitorDataChina);
                        monitordatachina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina = new MonitorDataInputChina();
                        //    monitordatachina.rbtnQuarterlyMonitorChina.Checked = true;
                        //    CommonClass.monitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\陕西省PM25测点季度均值.csv";
                        //    monitordatachina.txtOfficialMonitorChina.Text = Path.GetFileName(CommonClass.monitorFile);
                        //    CommonClass.getmonitorYear("");
                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear);
                        //    for (int i = start; i <= end; i++)
                        //    {
                        //        monitordatachina.cboEndYearChina.Items.Add(i);
                        //        monitordatachina.cboStartYearChina.Items.Add(i);
                        //    }
                        //    monitordatachina.cboStartYearChina.SelectedIndex = 0;
                        //    monitordatachina.cboEndYearChina.SelectedIndex = end - start;
                        //}
                        //else
                        //{
                        //    monitordatachina.choIAdjustedFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doInterpolateAdjustedFRM;
                        //    monitordatachina.choIFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doInterpolateFRM;
                        //    monitordatachina.chkwVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.dowVNA;
                        //    monitordatachina.chkwVNAAdvance.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.dowVNAAdvancedOption;
                        //    monitordatachina.txtwVNAWeight.Text = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.wVNAWeight.ToString();
                        //    monitordatachina.chkNS.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doNS;
                        //    monitordatachina.rbtnQuarterlyMonitorChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doQuarterlyMonitorDataInput;
                        //    monitordatachina.rbtnDailyMonitorChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.doDailyMonitorDataInput;
                        //    CommonClass.monitorFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataInputFile;
                        //    monitordatachina.txtOfficialMonitorChina.Text = Path.GetFileName(CommonClass.monitorFile);
                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear);
                        //    for (int i = start; i <= end; i++)
                        //    {
                        //        monitordatachina.cboEndYearChina.Items.Add(i);
                        //        monitordatachina.cboStartYearChina.Items.Add(i);
                        //    }
                        //    monitordatachina.cboStartYearChina.SelectedIndex = 0;
                        //    monitordatachina.cboEndYearChina.SelectedIndex = end - start;
                        //}
                        break;
                    case "uc_PM25SpeciesOptionChina":
                        pnlUserControl.Controls.Add(new uc_PM25SpeciesOptionChina());
                        lblSteps.Text = trvAnalysis.Nodes[2].Text;
                        _stips = "Set up PM2.5 species option";
                        uc_PM25SpeciesOptionChina speciesoptionchina = (pnlUserControl.Controls[0] as uc_PM25SpeciesOptionChina);
                        speciesoptionchina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina = new PM25SpeciesOptionChina();
                        //    CommonClass.speciesMonitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\PM25_Species_Fraction_Quarterly_2013_YRD.csv";
                        //    speciesoptionchina.txtSpeciesDataChina.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                        //}
                        //else
                        //{
                        //    speciesoptionchina.chkSpeciesFractionDataChina.Checked = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina.PM25SpeciesFractionDataAvailable;
                        //    CommonClass.speciesMonitorFile = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina.SpeciesMonitorDataFile;
                        //    speciesoptionchina.txtSpeciesDataChina.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                        //}
                        break;
                    #endregion
                    #region Ozone China added by Yangwenwei
                    case "uc_ModelDataOzoneChina":
                        pnlUserControl.Controls.Add(new uc_ModelDataOzoneChina());
                        lblSteps.Text = trvAnalysis.Nodes[0].Text;
                        _stips = "Set up Model data input.";
                        uc_ModelDataOzoneChina modeldataozonechina = (pnlUserControl.Controls[0] as uc_ModelDataOzoneChina);
                        modeldataozonechina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina = new ModelDataOzoneChina();
                        //    CommonClass.baseModelFile = CommonClass.monitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2013_YRD.csv";
                        //    modeldataozonechina.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                        //    CommonClass.futureModelFile = CommonClass.monitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2017_YRD.csv";
                        //    modeldataozonechina.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        //}
                        //else
                        //{
                        //    modeldataozonechina.cboCMAQOzone.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.doInputfromCmaq;
                        //    modeldataozonechina.txtScenarioName.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                        //    modeldataozonechina.txtBaselineOzone.Text = Path.GetFileName((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile);
                        //    modeldataozonechina.txtForecastOzone.Text = Path.GetFileName((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile);
                        //    CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.baselineModelDataFile;
                        //    CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.forecastModelDataFile;
                        //}
                        break;
                    case "uc_MonitorDataOzoneChina":
                        pnlUserControl.Controls.Add(new uc_MonitorDataOzoneChina());
                        lblSteps.Text = trvAnalysis.Nodes[1].Text;
                        _stips = "Set up Monitor data input";
                        uc_MonitorDataOzoneChina monitordataozonechina = (pnlUserControl.Controls[0] as uc_MonitorDataOzoneChina);
                        monitordataozonechina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina == null)
                        //{
                        //    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina = new MonitorDataOzoneChina();
                        //    CommonClass.ozoneMonitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Ozone_Data_Seasonal_2013_YRD.csv";
                        //    monitordataozonechina.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);

                        //    CommonClass.getmonitorYear("");
                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear);
                        //    foreach (var item in (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.lstOzoneMonitorData)
                        //    {
                        //        monitordataozonechina.cboEndYearOzone.Items.Add(item);
                        //        monitordataozonechina.cboStartYearOzone.Items.Add(item);
                        //    }
                        //    monitordataozonechina.cboStartYearOzone.SelectedIndex = 0;
                        //    monitordataozonechina.cboEndYearOzone.SelectedIndex = end - start;
                        //}
                        //else
                        //{
                        //    monitordataozonechina.choIAdjustedFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useEVNA;
                        //    monitordataozonechina.choIFRMChina.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useVNA;
                        //    monitordataozonechina.chkwVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNA;
                        //    monitordataozonechina.chkwVNAAdvance.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNAAdvancedOption;
                        //    monitordataozonechina.chkNS.Checked = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.useNS;
                        //    monitordataozonechina.txtwVNAWeight.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.usewVNAWeight.ToString();
                        //    monitordataozonechina.txtOzoneData.Text = Path.GetFileName((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneMonitorDataFile);
                        //    CommonClass.ozoneMonitorFile = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneMonitorDataFile;
                        //    monitordataozonechina.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear;
                        //    monitordataozonechina.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear;

                        //    int start = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear);
                        //    int end = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear);
                        //    for (int i = start; i <= end; i++)
                        //    {
                        //        monitordataozonechina.cboEndYearOzone.Items.Add(i);
                        //        monitordataozonechina.cboStartYearOzone.Items.Add(i);
                        //    }
                        //    monitordataozonechina.cboStartYearOzone.SelectedIndex = 0;
                        //    monitordataozonechina.cboEndYearOzone.SelectedIndex = end - start;
                        //}
                        break;
                    #endregion
                    #region BenMAP annual pm
                    case "uc_BenMAP_AnnualPM_ModelData":
                        pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_ModelData());
                        _stips = trvAnalysis.Nodes[0].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMAP_AnnualPM_ModelData _modelA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput = new BenMAPAnnualPMModel();
                            _modelA.rbtnDailyModelA.Checked = true;
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["baselineModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2011eh.camx.grid.csv";//PM_small_USA_12km_2011.csv";
                            _modelA.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["forecastModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2017eh.camx.grid.csv";//PM_small_USA_12km_2018.csv";
                            _modelA.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                            _modelA.cboSpatialGridA.SelectedIndex = 0;
                        }
                        else
                        {
                            _modelA.rbtnDailyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doDailyModelData;
                            _modelA.rbtnQuarterlyModelA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doQuarterlyModelData;
                            _modelA.rbtnCMAQA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.doInputfromCMAQ;
                            CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.baselineFile;
                            _modelA.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.forecastFile;
                            _modelA.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                            _modelA.cboSpatialGridA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.temporalAdjustmentAtMonitorGridSpatial;
                        }
                        break;
                    case "uc_BenMAP_AnnualPM_MonitorData":
                        pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_MonitorData());
                        _stips = trvAnalysis.Nodes[1].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMAP_AnnualPM_MonitorData _monitorA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput == null)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput = new BenMAPAnnualPMMonitor();
                            CommonClass.unofficialPMFile = CommonClass.dicExampleConfiguration["AnnualPM"]["unofficialMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\PM25ForFractions2002to2017.csv";//PM25ForFractions2002to2012.csv;
                            _monitorA.txtUnofficialMonitorA.Text = Path.GetFileName(CommonClass.unofficialPMFile);
                            CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_MonitorData");
                            _monitorA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            _monitorA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            if (_monitorA.cboStartYearA.Items.Count >= 9)
                                _monitorA.cboStartYearA.SelectedIndex = 8;
                            else
                                _monitorA.cboStartYearA.SelectedIndex = _monitorA.cboStartYearA.Items.Count - 1;
                            if (_monitorA.cboEndYearA.Items.Count >= 11)
                            {
                                _monitorA.cboEndYearA.SelectedIndex = 10;
                            }
                            else
                            {
                                _monitorA.cboEndYearA.SelectedIndex = _monitorA.cboEndYearA.Items.Count - 1;
                            }
                            _monitorA.choIFRMSpeA.Checked = true;
                            _monitorA.choIAdjustedFRMSpeA.Checked = true;

                            _monitorA.chkDS.Checked = false;
                            _monitorA.txtDSBurn.Text = "500";
                            _monitorA.txtDSCmaqres.Text = "12";
                            _monitorA.txtDSThin.Text = "1";
                            _monitorA.txtDSNumit.Text = "2500";

                            WaitClose();
                        }
                        else
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear == null)
                            {
                                CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_MonitorData");
                            }
                            _monitorA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            _monitorA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                            _monitorA.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.startYear;
                            _monitorA.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.endYear;
                            CommonClass.unofficialPMFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.unofficialFile;
                            _monitorA.txtUnofficialMonitorA.Text = Path.GetFileName(CommonClass.unofficialPMFile);
                            _monitorA.choIFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.useVNA;
                            _monitorA.choIAdjustedFRMSpeA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.useEVNA;

                            _monitorA.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.doDownscaler;
                            _monitorA.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Numit.ToString();
                            _monitorA.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Cmaqres.ToString();
                            _monitorA.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Thin.ToString();
                            _monitorA.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.DS_Burn.ToString();
                        }
                        break;
                    case "uc_BenMAP_AnnualPM_SpeciesData":
                        pnlUserControl.Controls.Add(new uc_BenMAP_AnnualPM_SpeciesData());
                        _stips = trvAnalysis.Nodes[2].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMAP_AnnualPM_SpeciesData _speciesA = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_SpeciesData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput == null)
                        {
                            WaitShow(Language.Localization.GetValue("working..."));
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput = new BenMAPAnnualPMSpecies();
                            _speciesA.rbtnMonitorFileA.Checked = true;
                            CommonClass.speciesMonitorFile = CommonClass.dicExampleConfiguration["AnnualPM"]["speciesMonitorDataFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\SpeciesForFractions2002to2015_v2.csv";//SpeciesForFractions2002to2012.csv;
                            _speciesA.txtMonitorFileA.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                            CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_SpeciesData");
                            _speciesA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            _speciesA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            if (_speciesA.cboStartYearA.Items.Count >= 9)
                                _speciesA.cboStartYearA.SelectedIndex = 8;
                            else
                                _speciesA.cboStartYearA.SelectedIndex = _speciesA.cboStartYearA.Items.Count - 1;
                            if (_speciesA.cboEndYearA.Items.Count >= 11)
                            {
                                _speciesA.cboEndYearA.SelectedIndex = 10;
                            }
                            else
                            {
                                _speciesA.cboEndYearA.SelectedIndex = _speciesA.cboEndYearA.Items.Count - 1;
                            }
                            WaitClose();
                        }
                        else
                        {
                            _speciesA.rbtnMonitorFileA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.doSpeciesMonitorDataFile;
                            CommonClass.speciesMonitorFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.speciesMonitorDataFile;
                            _speciesA.txtMonitorFileA.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear == null)
                                CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_SpeciesData");
                            _speciesA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            _speciesA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                            _speciesA.cboStartYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.startYear;
                            _speciesA.cboEndYearA.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.endYear;
                            _speciesA.rbtnFractionA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.doSpeciesFractionFile;
                            CommonClass.speciesFractionFilePoint = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.specFracSpatialFile;
                            _speciesA.txtFractionSpatialA.Text = Path.GetFileName(CommonClass.speciesFractionFilePoint);
                            CommonClass.speciesFractionFileSpatial = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.gradAdjSpecFracSpatialFile;
                            _speciesA.txtgradadjFractionSpatialA.Text = Path.GetFileName(CommonClass.speciesFractionFileSpatial);
                        }
                        break;
                    case "uc_BenMAP_GridDefinition":
                        if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPAnnualPM)
                        {
                            pnlUserControl.Controls.Add(new uc_BenMAP_GridDefinition());
                            lblSteps.Text = trvAnalysis.Nodes[3].Text;
                            _stips = lblSteps.Text;
                            uc_BenMAP_GridDefinition _grid = (pnlUserControl.Controls[0] as uc_BenMAP_GridDefinition);
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile == null)
                            {
                                CommonClass.shapefile = Application.StartupPath + @"\Data\ShapeFiles\CMAQ_12km_Nation.shp";
                                (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile = CommonClass.shapefile;
                                _grid.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                            }
                            else
                            {
                                CommonClass.shapefile = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile;
                                _grid.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                            }
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone)
                        {
                            pnlUserControl.Controls.Add(new uc_BenMAP_GridDefinition());
                            lblSteps.Text = trvAnalysis.Nodes[2].Text;
                            _stips = lblSteps.Text;
                            uc_BenMAP_GridDefinition _grid = (pnlUserControl.Controls[0] as uc_BenMAP_GridDefinition);
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile == null)
                            {
                                CommonClass.shapefile = Application.StartupPath + @"\Data\ShapeFiles\CMAQ_12km_Nation.shp";
                                (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile = CommonClass.shapefile;
                                _grid.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                            }
                            else
                            {
                                CommonClass.shapefile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile;
                                _grid.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                            }
                        }
                        break;
                    #endregion
                    #region BenMAP Ozone
                    case "uc_BenMap_Ozone_ModelData":
                        pnlUserControl.Controls.Add(new uc_BenMap_Ozone_ModelData());
                        _stips = trvAnalysis.Nodes[0].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMap_Ozone_ModelData BenMapOzoneModel = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput = new BenMAPOzoneModel();
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["Ozone"]["baselineModelDataFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2011.csv";
                            BenMapOzoneModel.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["Ozone"]["forecastModelDataFile"];//   Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2018.csv";
                            BenMapOzoneModel.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        else
                        {
                            CommonClass.baseModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.baselineModelDataFile;
                            BenMapOzoneModel.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.forecastModelDataFile;
                            BenMapOzoneModel.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        break;
                    case "uc_BenMap_Ozone_MonitorData":
                        pnlUserControl.Controls.Add(new uc_BenMap_Ozone_MonitorData());
                        _stips = trvAnalysis.Nodes[1].Text;
                        lblSteps.Text = _stips.Replace("&", "&&");
                        uc_BenMap_Ozone_MonitorData BenMapOzoneMonitor = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput == null)
                        {
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput = new BenMapOzoneMonitor();
                            CommonClass.ozoneMonitorFile = CommonClass.dicExampleConfiguration["Ozone"]["ozoneMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\SMAT_OZONE_MAX4DV_STD70_2002_2015.CSV";//MATS_OZONE_DV_2012_V2_off.csv";
                            BenMapOzoneMonitor.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                            BenMapOzoneMonitor.choVNA.Checked = true;
                            BenMapOzoneMonitor.choEVNA.Checked = true;
                            CommonClass.getmonitorYear("uc_BenMap_Ozone_MonitorData");

                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData.Sort();
                            List<string> year = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData;
                            for (int i = 0; i < year.Count; i++)
                            {
                                BenMapOzoneMonitor.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                BenMapOzoneMonitor.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                            }

                            if (BenMapOzoneMonitor.cboStartYearOzone.Items.Count >= 9) BenMapOzoneMonitor.cboStartYearOzone.SelectedIndex = 8;
                            else BenMapOzoneMonitor.cboStartYearOzone.SelectedIndex = BenMapOzoneMonitor.cboStartYearOzone.Items.Count - 1;
                            if (BenMapOzoneMonitor.cboEndYearOzone.Items.Count > 10) BenMapOzoneMonitor.cboEndYearOzone.SelectedIndex = 9;
                            else BenMapOzoneMonitor.cboEndYearOzone.SelectedIndex = BenMapOzoneMonitor.cboEndYearOzone.Items.Count - 1;


                            BenMapOzoneMonitor.chkDS.Checked = false;
                            BenMapOzoneMonitor.txtDSBurn.Text = "500";
                            BenMapOzoneMonitor.txtDSCmaqres.Text = "12";
                            BenMapOzoneMonitor.txtDSNumit.Text = "2500";
                            BenMapOzoneMonitor.txtDSThin.Text = "1";
                        }
                        else
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData == null)
                            {
                                CommonClass.getmonitorYear("uc_BenMap_Ozone_MonitorData");
                            }
                            List<string> year = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData;
                            for (int i = 0; i < year.Count; i++)
                            {
                                BenMapOzoneMonitor.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                                BenMapOzoneMonitor.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                            }
                            BenMapOzoneMonitor.cboStartYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneStartYear;
                            BenMapOzoneMonitor.cboEndYearOzone.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneEndYear;

                            CommonClass.ozoneMonitorFile = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.ozoneMonitorDataFile;
                            BenMapOzoneMonitor.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                            BenMapOzoneMonitor.choVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.useVNA;
                            BenMapOzoneMonitor.choEVNA.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.useEVNA;

                            BenMapOzoneMonitor.chkDS.Checked = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.doDownscaler;
                            BenMapOzoneMonitor.txtDSBurn.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSBurn.ToString();
                            BenMapOzoneMonitor.txtDSCmaqres.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSCmaqres.ToString();
                            BenMapOzoneMonitor.txtDSNumit.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSNumit.ToString();
                            BenMapOzoneMonitor.txtDSThin.Text = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.DSThin.ToString();
                        }
                        break;
                        //case "uc_BenMAP_GridDefinition":
                        //break;
                        #endregion

                }
                tips.SetToolTip(pboHelp, Language.Localization.GetValue(_stips));
                pnlUserControl.Refresh();
                lblSteps.Refresh();
                trvAnalysis.Refresh();

                //--------------------As long as user do some setting, the save scenario button is enabled.----------------
                #region annual pm
                if (CommonClass.CurrentAnalysis == enumAnalysis.AnnualPM)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                      || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null
                      || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null
                        && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null
                        && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region daily pm add by dian
                if (CommonClass.CurrentAnalysis == enumAnalysis.DailyPM)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null
                        || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null
                        || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null
                        && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null
                        && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region Ozone added by sclong
                if (CommonClass.CurrentAnalysis == enumAnalysis.Ozone)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null
                || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null
               && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region Visibility added by sclong
                if (CommonClass.CurrentAnalysis == enumAnalysis.Visibility)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null
                      || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV != null && (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null
                        && (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region SSIA annual pm
                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null && (((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region SSIA daily pm added by Yangwenwei
                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null && (((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region SSIA O3
                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null || (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO != null && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO != null && (((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null) || (!(CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.useModelFRMData)) && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region SSIA deposition added by Lijiabin
                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null || (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null ||
                        (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep != null && (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep != null && (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region Annual PM China added by Yangwenwei
                if (CommonClass.CurrentAnalysis == enumAnalysis.AnnualPMChina)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region Ozone China added by Yangwenwei
                if (CommonClass.CurrentAnalysis == enumAnalysis.OzoneChina)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region BenMAP Annual PM
                if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPAnnualPM)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null || !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile))
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput != null && !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile))
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion
                #region BenMap Ozone
                if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone)
                {
                    if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null || (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null || !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile))
                    {
                        btnSave.Enabled = true;
                    }
                    if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput != null && (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput != null && !string.IsNullOrEmpty((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).gridDefinitionFile))
                    {
                        btnSaveRun.Enabled = true;
                    }
                }
                #endregion

            }
            catch (Exception ex)
            {
                WaitClose();
                CommonClass.LogError(ex);
            }
        }

        //--------自动导出所选择的output files------------
        public void ExtractAllOutput(string fileName, string filePath)
        {
            try
            {
                string originFile = "";
                string newFile = "";
                foreach (BaseOutput baseOutput in CommonClass.CurrentBaseScenario.lstOutput)
                {
                    originFile = baseOutput.outputFilePath;
                    //switch (CommonClass.CurrentAnalysis)
                    //{
                    //    case enumAnalysis.AnnualPM:
                    //        originFile = baseOutput.outputFilePath;
                    //        //originFile = Application.StartupPath + @"\Result\Output\" + (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName + @"\" + baseOutput.outputName + ".csv";
                    //        //newFile = filePath + @"\" + fileName + " " + baseOutput.outputName.Substring(CommonClass.CurrentBaseScenario.configuration.configurationName.Length, baseOutput.outputName.Length - CommonClass.CurrentBaseScenario.configuration.configurationName.Length).Trim() + ".csv";
                    //        break;
                    //    case enumAnalysis.DailyPM:
                    //        originFile = baseOutput.outputFilePath;
                    //        //originFile = Application.StartupPath + @"\Result\Output\" + (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName + @"\" + baseOutput.outputName + ".csv";
                    //        //newFile = filePath + @"\" + fileName + " " + baseOutput.outputName.Substring(CommonClass.CurrentBaseScenario.configuration.configurationName.Length, baseOutput.outputName.Length - CommonClass.CurrentBaseScenario.configuration.configurationName.Length).Trim() + ".csv";
                    //        break;
                    //    case enumAnalysis.Ozone:
                    //        //originFile = Application.StartupPath + @"\Result\Output\" + (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName + @"\" + baseOutput.outputName + ".csv";
                    //        //newFile = filePath + @"\" + fileName + " " + baseOutput.outputName.Substring(CommonClass.CurrentBaseScenario.configuration.configurationName.Length, baseOutput.outputName.Length - CommonClass.CurrentBaseScenario.configuration.configurationName.Length).Trim() + ".csv";
                    //        break;
                    //    case enumAnalysis.Visibility:
                    //        //originFile = Application.StartupPath + @"\Result\Output\" + (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName + @"\" + baseOutput.outputName + ".csv";
                    //        //newFile = filePath + @"\" + fileName + " " + baseOutput.outputName.Substring(CommonClass.CurrentBaseScenario.configuration.configurationName.Length, baseOutput.outputName.Length - CommonClass.CurrentBaseScenario.configuration.configurationName.Length).Trim() + ".csv";
                    //        break;
                    //}
                    //originFile = Application.StartupPath + @"\Result\Output\" + (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName + @"\" + baseOutput.outputName + ".csv";
                    newFile = filePath + @"\" + fileName + " " + baseOutput.outputName.Substring(CommonClass.CurrentBaseScenario.configuration.configurationName.Length, baseOutput.outputName.Length - CommonClass.CurrentBaseScenario.configuration.configurationName.Length).Trim() + ".csv";
                    // BenMAP-ready导出文件不包含经纬度2列 ty
                    if (originFile.Contains("BenMAP-ready"))
                    {
                        //tsmiExportOutputs_Click(null, null);
                        string dataType = "";
                        DataTable dt = null;
                        bool errorOccur = false;
                        dt = CommonClass.getDataSetFromCSVAndFirstLine(originFile, ref dataType, ref errorOccur, true);
                        CommonClass.SaveCSV(dt, newFile, dataType);
                    }
                    //
                    else
                    {
                        File.Copy(originFile, newFile, true);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// 从checklistbox中获取quantitifiers
        /// </summary>
        /// <returns></returns>
        public DataTable getQuantifiers(DataTable dt)
        {
            try
            {
                DataTable dtSelected = dt.Clone();
                string strWhere = "";
                Dictionary<string, string> dicQuarter = new Dictionary<string, string>();
                StringBuilder builder = new StringBuilder(string.Format("1=1"));
                if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                {
                    for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                    {
                        if (clboQuantifiers.GetItemChecked(i))
                        {
                            string quantifier = clboQuantifiers.Items[i].ToString();
                            //quantifier = quantifier.Replace("Threshold", (Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold) * 0.01 * Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS)).ToString());
                            quantifier = quantifier.Replace("Threshold", (Convert.ToDouble(txtThreshold.Text) * 0.01 * Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS)).ToString());
                            quantifier = quantifier.Replace("NAAQS", (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS.ToString());
                            int location = quantifier.LastIndexOf('>');
                            if (quantifier.Contains("_q"))
                            {
                                if (!dicQuarter.ContainsKey(quantifier.Substring(quantifier.LastIndexOf("_q") + 2, 1)))
                                    dicQuarter.Add(quantifier.Substring(quantifier.LastIndexOf("_q") + 2, 1), "[" + quantifier.Substring(0, location - 4).Trim() + "]" + quantifier.Substring(location));
                                else
                                    dicQuarter[quantifier.Substring(quantifier.LastIndexOf("_q") + 2, 1)] += " and [" + quantifier.Substring(0, location - 4).Trim() + "]" + quantifier.Substring(location);
                            }
                            else if (quantifier.Contains("max distance from source"))
                            {
                                quantifier = string.Format(" and [Cell center distance from source(km)]<={0}", txtDistance.Text);
                                builder.Append(quantifier);
                            }
                            else
                            {
                                quantifier = " and [" + quantifier.Substring(0, location - 1).Trim() + "]" + quantifier.Substring(location);
                                builder.Append(quantifier);
                            }
                        }
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                {
                    for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                    {
                        if (clboQuantifiers.GetItemChecked(i))
                        {
                            string quantifier = clboQuantifiers.Items[i].ToString();
                            //quantifier = quantifier.Replace("Threshold", (Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold) * 0.01 * Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS)).ToString());
                            quantifier = quantifier.Replace("Threshold", (Convert.ToDouble(txtThreshold.Text) * 0.01 * Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS)).ToString());
                            quantifier = quantifier.Replace("NAAQS", (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS.ToString());
                            int location = quantifier.LastIndexOf('>');
                            if (quantifier.Contains("_q"))
                            {
                                if (!dicQuarter.ContainsKey(quantifier.Substring(quantifier.LastIndexOf("_q") + 2, 1)))
                                    dicQuarter.Add(quantifier.Substring(quantifier.LastIndexOf("_q") + 2, 1), "[" + quantifier.Substring(0, location - 4).Trim() + "]" + quantifier.Substring(location));
                                else
                                    dicQuarter[quantifier.Substring(quantifier.LastIndexOf("_q") + 2, 1)] += " and [" + quantifier.Substring(0, location - 4).Trim() + "]" + quantifier.Substring(location);
                            }
                            else if (quantifier.Contains("max distance from source"))
                            {
                                quantifier = string.Format(" and [Cell center distance from source(km)]<={0}", txtDistance.Text);
                                builder.Append(quantifier);
                            }
                            else
                            {
                                quantifier = " and [" + quantifier.Substring(0, location - 1).Trim() + "]" + quantifier.Substring(location);
                                builder.Append(quantifier);
                            }
                        }
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                {
                    for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                    {
                        if (clboQuantifiers.GetItemChecked(i))
                        {
                            string quantifier = clboQuantifiers.Items[i].ToString();
                            //quantifier = quantifier.Replace("Threshold", (Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold) * 0.01 * Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS)).ToString());
                            quantifier = quantifier.Replace("Threshold", (Convert.ToDouble(txtThreshold.Text) * 0.01 * Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS)).ToString());
                            quantifier = quantifier.Replace("NAAQS", (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS.ToString());
                            if (quantifier.Contains("max distance from source"))
                            {
                                quantifier = string.Format(" and [Cell center distance from source(km)]<={0}", txtDistance.Text);
                                builder.Append(quantifier);
                            }
                            else
                            {
                                int location = quantifier.LastIndexOf('>');
                                quantifier = " and [" + quantifier.Substring(0, location - 1).Trim() + "]" + quantifier.Substring(location);
                                builder.Append(quantifier);
                            }

                        }
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)             //added by Lijiabin
                {
                    for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                    {
                        if (clboQuantifiers.GetItemChecked(i))
                        {
                            string quantifier = clboQuantifiers.Items[i].ToString();
                            //quantifier = quantifier.Replace("Threshold", (Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold) * 0.01 * Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS)).ToString());
                            quantifier = quantifier.Replace("Threshold", txtThreshold.Text);
                            //quantifier = quantifier.Replace("NAAQS", (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.NAAQS.ToString());
                            //int location = quantifier.LastIndexOf('>');
                            if (quantifier.Contains("max distance from source"))
                            {
                                quantifier = string.Format(" and [Cell center distance from source(km)]<={0}", txtDistance.Text);
                                builder.Append(quantifier);
                            }
                            else
                            {
                                int location = quantifier.LastIndexOf('>');
                                quantifier = " and [" + quantifier.Substring(0, location - 1).Trim() + "]" + quantifier.Substring(location);
                                builder.Append(quantifier);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                    {
                        if (clboQuantifiers.GetItemChecked(i))
                        {
                            builder.Append(string.Format(" and [{0}] >= 0 ", clboQuantifiers.Items[i].ToString()));
                        }
                    }
                }
                if (dicQuarter.Count > 0)
                {
                    for (int i = 1; i < 5; i++)
                    {
                        if (!dicQuarter.ContainsKey(i.ToString()))
                            dicQuarter.Add(i.ToString(), "1=1");
                        DataRow[] drs = dt.Select(dicQuarter[i.ToString()] + " and [quarter]=" + i);
                        for (int j = 0; j < drs.Count(); j++)
                        {
                            dtSelected.ImportRow(drs[j]);
                        }
                    }
                    return dtSelected;
                }
                strWhere = builder.ToString();
                DataRow[] drArray = null;
                drArray = dt.Select(strWhere);
                for (int i = 0; i < drArray.Length; i++)
                {
                    dtSelected.ImportRow(drArray[i]);
                }
                return dtSelected;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
                return null;
            }
        }

        /// <summary>
        /// 画柱状图
        /// </summary>
        /// <param name="zdControl">ZedGraphControl</param>
        /// <param name="stringValue">在Y轴上显示的变量名称</param>
        /// <param name="fileType">文件类型，不同的文件需要从不同的list中读取数据</param>
        private void createGraph(ZedGraphControl zdControl, string stringValue)
        {
            try
            {
                lstReceptors = new List<string>();
                //----------画图------------
                zdControl.GraphPane = new GraphPane(new Rectangle(0, 0, zdControl.Width, zdControl.Height), "", "", "");
                GraphPane myPane = this.zgcChart.GraphPane;
                List<string> lstPane = new List<string>();
                myPane.CurveList.Clear();
                //----清空图中添加的文本----------
                myPane.GraphObjList.Clear();
                myPane.Title.Text = "";
                myPane.XAxis.Title.Text = "";
                myPane.YAxis.Title.Text = "";
                myPane.XAxis.Scale.TextLabels = null;
                myPane.YAxis.Scale.TextLabels = null;
                //myPane.YAxis.Scale.c
                if (cboType.Text == "")
                {
                    zgcChart.AxisChange();
                    zgcChart.Refresh();
                    return;
                }
                int count = 0;
                for (int i = 0; i < dgvDataList.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                    if (Convert.ToBoolean(checkCell.Value) == true)
                        count++;
                }

                if (count == 0)
                {
                    WaitClose();
                    MessageBox.Show(Language.Localization.GetValue("Please select data!"));
                    myPane.Title.Text = "";
                    myPane.XAxis.Title.Text = "";
                    myPane.YAxis.Title.Text = "";
                    myPane.XAxis.Scale.TextLabels = null;
                    myPane.YAxis.Scale.TextLabels = null;
                    zgcChart.AxisChange();
                    zgcChart.Refresh();
                    return;
                }
                PointPairList pointPairList = new PointPairList();
                string[] xLables = new string[count];
                string[] xStateName = new string[count];
                double[] arrayY = new double[count];
                double x = 0;
                int j = 0;
                int columnNum = -1, columnCounty = -1;
                int columnState = -1;
                int columnID = -1;
                //, columnBase = -1, columnFuture = -1
                for (int i = 0; i < dgvDataList.Columns.Count; i++)
                {
                    if (stringValue == dgvDataList.Columns[i].Name)
                    {
                        columnNum = i;
                    }
                    if (dgvDataList.Columns[i].Name.Trim().ToLower().Contains("county") || dgvDataList.Columns[i].Name.Trim().ToLower().Contains("station_name"))
                    {
                        columnCounty = i;
                    }
                    if (dgvDataList.Columns[i].Name.Trim().ToLower().Contains("location_name"))
                    {
                        columnState = i;
                    }
                    if (dgvDataList.Columns[i].Name.Trim().ToLower().Contains("_id"))
                    {
                        columnID = i;
                    }
                }
                if (LanguageOld.IsSMATChina && columnState != -1 && columnCounty != -1)
                {
                    for (int i = 0; i < dgvDataList.Rows.Count; i++)
                    {
                        string location, station;
                        DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                        if (Convert.ToBoolean(checkCell.Value) == true)
                        {
                            x = (double)i;
                            location = dgvDataList.Rows[i].Cells[columnState].Value.ToString();
                            station = dgvDataList.Rows[i].Cells[columnCounty].Value.ToString();
                            //xLables[j] = (location.Length > 3 ? location.Substring(0, 3) : location) + " " + (station.Length > 3 ? station.Substring(0, 3) : station);
                            xLables[j] = location + " " + (station.Substring(0, station.IndexOf('.')));
                            arrayY[j] = Convert.ToDouble(dgvDataList.Rows[i].Cells[columnNum].Value);
                            pointPairList.Add(x, arrayY[j]);
                            if (columnID != -1)
                            {
                                lstReceptors.Add(dgvDataList.Rows[i].Cells[columnID].Value.ToString() + "_" + xLables[j]);
                            }
                            j++;
                        }
                    }
                }
                else if ((!LanguageOld.IsSMATChina) && columnCounty != -1)
                {
                    for (int i = 0; i < dgvDataList.Rows.Count; i++)
                    {
                        DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                        if (Convert.ToBoolean(checkCell.Value) == true)
                        {
                            x = (double)i;
                            xLables[j] = dgvDataList.Rows[i].Cells[columnCounty].Value.ToString();
                            arrayY[j] = Convert.ToDouble(dgvDataList.Rows[i].Cells[columnNum].Value);
                            pointPairList.Add(x, arrayY[j]);
                            if (columnID != -1)
                            {
                                string item = dgvDataList.Rows[i].Cells[columnID].Value.ToString() + "_" + xLables[j];
                                //针对daily数据，显示ID+时间
                                if (dgvDataList.Columns.Contains("day"))
                                {
                                    item = item + ", day=" + dgvDataList.Rows[i].Cells["day"].Value.ToString();
                                }
                                lstReceptors.Add(item);
                            }

                            j++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < dgvDataList.Rows.Count; i++)
                    {
                        DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                        if (Convert.ToBoolean(checkCell.Value) == true)
                        {
                            x = (double)i;
                            arrayY[j] = Convert.ToDouble(dgvDataList.Rows[i].Cells[columnNum].Value);
                            pointPairList.Add(x, arrayY[j]);
                            if (columnID != -1)
                            {
                                string item = dgvDataList.Rows[i].Cells[columnID].Value.ToString();
                                //针对模型数据，显示ID+时间
                                if (dgvDataList.Columns.Contains("date"))
                                {
                                    item = item + ", date=" + dgvDataList.Rows[i].Cells["date"].Value.ToString();
                                }
                                else if (dgvDataList.Columns.Contains("quarter"))
                                {
                                    item = item + ", quarter=" + dgvDataList.Rows[i].Cells["quarter"].Value.ToString();
                                }
                                lstReceptors.Add(item);
                            }
                            else//针对BenMAP-ready file
                            {
                                string item = "";
                                //针对模型数据，显示ID+时间
                                if (dgvDataList.Columns.Contains("Column"))
                                {
                                    item = item + "col=" + dgvDataList.Rows[i].Cells["Column"].Value.ToString() + ",";
                                }
                                if (dgvDataList.Columns.Contains("Row"))
                                {
                                    item = item + " row=" + dgvDataList.Rows[i].Cells["Row"].Value.ToString();
                                }
                                item = item.TrimEnd(',');
                                lstReceptors.Add(item);
                            }

                            j++;
                        }
                    }
                }
                string customTitle = "";
                string customYAxis = "";
                //set the legend
                if (dicTitleAndLegend.ContainsKey(cboType.Text))
                {
                    if (dicTitleAndLegend[cboType.Text].CustomLegend != null)
                    {
                        stringValue = dicTitleAndLegend[cboType.Text].CustomLegend.First();
                    }
                    if (dicTitleAndLegend[cboType.Text].CustomTitle != "")
                    {
                        customTitle = dicTitleAndLegend[cboType.Text].CustomTitle;
                    }
                    if (dicTitleAndLegend[cboType.Text].CustomYaxis != "")
                    {
                        customYAxis = dicTitleAndLegend[cboType.Text].CustomYaxis;
                    }
                }

                BarItem myCurve = myPane.AddBar(stringValue, pointPairList, Color.Blue);

                // Set the Titles
                if (customTitle == "")
                {
                    myPane.Title.Text = cboType.Text;
                }
                else
                {
                    myPane.Title.Text = customTitle;
                }
                //set the Yaxis
                if (customYAxis == "")
                {
                    if (LanguageOld.IsSMATChina)
                        myPane.YAxis.Title.Text = "ug/m3";
                    else
                        myPane.YAxis.Title.Text = "Results";
                }
                else
                {
                    myPane.YAxis.Title.Text = customYAxis;
                }

                if (xLables[0] == null)
                    myPane.XAxis.Title.Text = "Regions";
                //myPane.Title.Text = cboType.Text;
                myPane.Title.FontSpec.Size = 16;
                //if (xLables[0] == null)
                //    myPane.XAxis.Title.Text = "Regions";
                //if (Language.IsSMATChina)
                //    myPane.YAxis.Title.Text = "ug/m3";
                //else
                //    myPane.YAxis.Title.Text = "Results";

                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);
                myPane.XAxis.Scale.TextLabels = xLables.ToArray();
                myPane.XAxis.Type = AxisType.Text;
                myPane.XAxis.Scale.FontSpec.Angle = 65;
                myPane.XAxis.Scale.FontSpec.IsBold = true;
                myPane.XAxis.Scale.FontSpec.Size = 11;
                myPane.YAxis.Scale.FontSpec.Size = 11;
                BarItem.CreateBarLabels(myPane, false, "f3", "Calibri", 12, Color.Black, true, false, false);
                myPane.IsFontsScaled = false;//不随着缩放而放大
                zgcChart.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
                SetTitleAndAxis(myPane, _configureSymbol);//设置图例,by sclong，20180419
                zgcChart.AxisChange();
                zgcChart.Refresh();
                GC.Collect();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// Set Title and Axis as well as Legend
        /// </summary>
        /// <param name="myPane"></param>
        /// <param name="cs"></param>       
        /// <param name="chartType">图表类型</param>  
        private void SetTitleAndAxis(GraphPane myPane, ConfigureSymbol cs, string chartType = null)
        {
            try
            {
                if (cs == null)
                {
                    // set the title and axis labels   
                    if (chartType == "Distribution")
                    {
                        myPane.Title.Text = "Source 1";
                        myPane.XAxis.Title.Text = "Cell";
                        myPane.YAxis.Title.Text = LanguageOld.IsSMATChina ? "ug/m3" : "Results";
                    }
                    else if (chartType == "Frequency")
                    {
                        myPane.Title.Text = "ecdf(y)";
                        myPane.XAxis.Title.Text = "Predicted Change";
                        myPane.YAxis.Title.Text = "Fn(x)";
                    }
                    else
                    {
                        myPane.Title.Text = cboType.Text;
                        myPane.XAxis.Title.Text = "Regions";
                        myPane.YAxis.Title.Text = LanguageOld.IsSMATChina ? "ug/m3" : "Results";
                    }

                    //legend
                    myPane.Legend.Position = LegendPos.Top;
                    myPane.Legend.IsVisible = true;
                    myPane.Legend.Gap = Default.Gap;
                    myPane.Legend.FontSpec = new FontSpec(Default.FontFamily, Default.FontSize,
                    Default.FontColor, Default.FontBold,
                    Default.FontItalic, Default.FontUnderline,
                    Default.FontFillColor, Default.FontFillBrush,
                    Default.FontFillType);
                    myPane.Legend.FontSpec.Border.IsVisible = false;
                    myPane.Title.IsVisible = true;
                    myPane.XAxis.Title.IsVisible = true;
                    myPane.YAxis.Title.IsVisible = true;
                    return;
                }

                //1.fill text symbol
                foreach (var item in cs.lstTextSymbol)
                {
                    FontSpec fontSpec = CommonClass.ToFontSpec(item.FontName);
                    fontSpec.FontColor = item.ColorName;
                    switch (item.TypeName)
                    {
                        case "Title":
                            myPane.Title.IsVisible = item.IsShow;
                            myPane.Title.Text = item.TitleName;
                            myPane.Title.FontSpec = fontSpec;
                            break;
                        case "Xaxis":
                            myPane.XAxis.Title.IsVisible = item.IsShow;
                            myPane.XAxis.Title.Text = item.TitleName;
                            myPane.XAxis.Title.FontSpec = fontSpec;
                            break;
                        case "Yaxis":
                            myPane.YAxis.Title.IsVisible = item.IsShow;
                            myPane.YAxis.Title.Text = item.TitleName;
                            myPane.YAxis.Title.FontSpec = fontSpec;
                            break;
                        case "Unit":
                            break;
                        default:
                            break;
                    }
                }
                // 2.set legend
                myPane.Legend.Position = cs.ChartLegend.Position;
                myPane.Legend.IsVisible = cs.ChartLegend.IsVisible;
                myPane.Legend.Gap = cs.ChartLegend.Gap;
                myPane.Legend.FontSpec = cs.ChartLegend.FontSpec;
                myPane.Legend.IsHStack = cs.ChartLegend.IsHStack;//horizontal stacking
                myPane.IsFontsScaled = false;//不随着缩放而放大
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void createZedGraphTwoBars(ZedGraphControl zdControl, string stringValue, int n)
        {
            try
            {
                lstReceptors = new List<string>();
                //----------画图------------
                zdControl.GraphPane = new GraphPane(new Rectangle(0, 0, zdControl.Width, zdControl.Height), "", "", "");
                GraphPane myPane = this.zgcChart.GraphPane;
                List<string> lstPane = new List<string>();
                myPane.CurveList.Clear();
                //----清空图中添加的文本----------
                myPane.GraphObjList.Clear();
                myPane.Title.Text = "";
                myPane.XAxis.Title.Text = "";
                myPane.YAxis.Title.Text = "";
                myPane.XAxis.Scale.TextLabels = null;
                myPane.YAxis.Scale.TextLabels = null;
                int count = 0;
                for (int i = 0; i < dgvDataList.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                    //if (Convert.ToBoolean(checkCell.EditedFormattedValue) == true)
                    if (Convert.ToBoolean(checkCell.Value) == true)
                        count++;
                }
                if (count == 0)
                {
                    WaitClose();
                    MessageBox.Show(Language.Localization.GetValue("Please select data!"));
                    myPane.Title.Text = "";
                    myPane.XAxis.Title.Text = "";
                    myPane.YAxis.Title.Text = "";
                    myPane.XAxis.Scale.TextLabels = null;
                    myPane.YAxis.Scale.TextLabels = null;
                    zgcChart.AxisChange();
                    zgcChart.Refresh();
                    return;
                }

                PointPairList listBaseline = new PointPairList();
                PointPairList listFuture = new PointPairList();

                string[] xLables = new string[count];
                string[] xStateName = new string[count];
                double[] arrayYbaseline = new double[count];
                double[] arrayYfuture = new double[count];
                double x = 0;
                int j = 0;
                int columnNum = -1, columnCounty = -1;
                int columnState = -1;
                int columnID = -1;
                //, columnBase = -1, columnFuture = -1
                for (int i = 0; i < dgvDataList.Columns.Count; i++)
                {
                    if (stringValue == dgvDataList.Columns[i].Name)
                    {
                        if (n == -1)
                            columnNum = i + n;
                        else
                            columnNum = i;
                    }
                    if (dgvDataList.Columns[i].Name.Trim().ToLower().Contains("county") || dgvDataList.Columns[i].Name.Trim().ToLower().Contains("station_name"))
                    {
                        columnCounty = i;
                    }
                    if (dgvDataList.Columns[i].Name.Trim().ToLower().Contains("location_name"))
                    {
                        columnState = i;
                    }
                    if (dgvDataList.Columns[i].Name.Trim().ToLower().Contains("_id"))
                    {
                        columnID = i;
                    }
                }

                for (int i = 0; i < dgvDataList.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                    if (Convert.ToBoolean(checkCell.Value) == true)
                    {
                        x = (double)i;
                        if (LanguageOld.IsSMATChina)
                        {
                            if (columnCounty != -1 && columnState != -1)
                            {
                                string location = dgvDataList.Rows[i].Cells[columnState].Value.ToString();
                                string station = dgvDataList.Rows[i].Cells[columnCounty].Value.ToString();

                                //xLables[j] = (location.Length > 3 ? location.Substring(0, 3) : location) + " " + (station.Length > 3 ? station.Substring(0, 3) : station);
                                if (station.IndexOf('.') > 0)
                                {
                                    xLables[j] = (location + " " + station.Substring(0, station.IndexOf('.')));
                                }
                                else
                                {
                                    xLables[j] = station;
                                }
                            }
                        }
                        else
                        {
                            if (columnCounty != -1)
                                xLables[j] = dgvDataList.Rows[i].Cells[columnCounty].Value.ToString();
                        }
                        arrayYbaseline[j] = Convert.ToDouble(dgvDataList.Rows[i].Cells[columnNum].Value);
                        //if(columnNum>0)
                        arrayYfuture[j] = Convert.ToDouble(dgvDataList.Rows[i].Cells[columnNum + 1].Value);
                        if (columnID != -1)
                        {
                            string item = dgvDataList.Rows[i].Cells[columnID].Value.ToString();

                            if (!string.IsNullOrEmpty(xLables[j]))
                            {
                                item = item + "_" + xLables[j];
                            }
                            //针对daily数据，显示ID+时间
                            if (dgvDataList.Columns.Contains("day"))
                            {
                                item = item + ", day=" + dgvDataList.Rows[i].Cells["day"].Value.ToString();
                            }

                            lstReceptors.Add(item);
                        }
                        listBaseline.Add(x, arrayYbaseline[j]);
                        listFuture.Add(x, arrayYfuture[j]);
                        j++;
                    }
                }



                string customTitle = "";
                string customYAxis = "";
                string[] customLegend = null;
                //set the legend
                if (dicTitleAndLegend.ContainsKey(cboType.Text))
                {
                    if (dicTitleAndLegend[cboType.Text].CustomLegend != null)
                    {
                        customLegend = dicTitleAndLegend[cboType.Text].CustomLegend;
                    }
                    if (dicTitleAndLegend[cboType.Text].CustomTitle != "")
                    {
                        customTitle = dicTitleAndLegend[cboType.Text].CustomTitle;
                    }
                    if (dicTitleAndLegend[cboType.Text].CustomYaxis != "")
                    {
                        customYAxis = dicTitleAndLegend[cboType.Text].CustomYaxis;
                    }

                }
                //set the legend
                if (customLegend == null)
                {
                    customLegend = new string[] { dgvDataList.Columns[columnNum].Name, dgvDataList.Columns[columnNum + 1].Name };
                }
                BarItem myCurve = myPane.AddBar(customLegend.First(), listBaseline, Color.Blue);
                BarItem myCurve2 = myPane.AddBar(customLegend.Last(), listFuture, Color.Red);

                // Set the Titles
                if (customTitle == "")
                {
                    myPane.Title.Text = dgvDataList.Columns[columnNum].Name + " & " + dgvDataList.Columns[columnNum + 1].Name;
                }
                else
                {
                    myPane.Title.Text = customTitle;
                }
                //set the Yaxis
                if (customYAxis == "")
                {
                    if (LanguageOld.IsSMATChina)
                        myPane.YAxis.Title.Text = "ug/m3";
                    else
                        myPane.YAxis.Title.Text = "Results";
                }
                else
                {
                    myPane.YAxis.Title.Text = customYAxis;
                }


                //myPane.Title.Text = dgvDataList.Columns[columnNum].Name + " & " + dgvDataList.Columns[columnNum + 1].Name;
                //if (Language.IsSMATChina)
                //    myPane.YAxis.Title.Text = "ug/m3";
                //else
                //    myPane.YAxis.Title.Text = "Results";

                if (xLables[0] == null)
                    myPane.XAxis.Title.Text = "Regions";

                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);
                myPane.XAxis.Scale.TextLabels = xLables.ToArray();
                myPane.XAxis.Type = AxisType.Text;
                myPane.XAxis.Scale.FontSpec.Angle = 65;
                myPane.XAxis.Scale.FontSpec.IsBold = true;
                myPane.XAxis.Scale.FontSpec.Size = 12;
                BarItem.CreateBarLabels(myPane, false, "f3", "Calibri", 12, Color.Black, true, false, false);
                myPane.IsFontsScaled = false;//不随着缩放而放大

                zgcChart.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
                SetTitleAndAxis(myPane, _configureSymbol);//设置图例,by sclong，20180419
                zgcChart.AxisChange();
                zgcChart.Refresh();
                GC.Collect();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// 画图
        /// </summary>
        /// <param name="dt">datatable，保存图层信息</param>
        /// <param name="legendText">文件名称，显示在legend上</param>
        private void drawMap(DataTable dt, string legendText, bool drawGIS)
        {
            try
            {
                if (dt == null)
                {
                    //MessageBox.Show("Data format is not correct!");
                    return;
                }
                Extent exLast = mainMap.ViewExtents.Clone() as Extent;
                int count = 0;
                //记录经纬度,pm的索引值
                int iLat = 0, iLong = 0, iValue = 0, iPM = -1;
                mainMap.ProjectionModeReproject = ActionMode.Never;
                mainMap.ProjectionModeDefine = ActionMode.Never;

                IFeatureSet addToMapSet = new FeatureSet();
                bool canSelectSpecies = false;
                isPolygon = false;
                isPolygon = IsPolygon(legendText);//判断是不是polygon

                #region cboSpeciesTypeGIS
                //if file is "annual PM2.5 point" - base, future, delta
                if (CommonClass.CurrentBaseScenario == null) return;
                if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration)
                {
                    if (legendText == "Annual PM25 Point" || legendText.Contains("Annual PM25 Point"))
                    {
                        dt.Columns.Add("Δpm25_ann_DV", typeof(double));
                        dt.Columns.Add("Δpm25_ann_DV(%)", typeof(double));
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (Convert.ToDouble(dr["b_pm25_ann_DV"]) < 0 || Convert.ToDouble(dr["f_pm25_ann_DV"]) < 0)
                            {
                                dr["Δpm25_ann_DV"] = 0;
                                dr["Δpm25_ann_DV(%)"] = 0;
                            }
                            else
                            {
                                dr["Δpm25_ann_DV"] = Convert.ToDouble(dr["b_pm25_ann_DV"]) - Convert.ToDouble(dr["f_pm25_ann_DV"]);
                                dr["Δpm25_ann_DV(%)"] = (Convert.ToDouble(dr["b_pm25_ann_DV"]) - Convert.ToDouble(dr["f_pm25_ann_DV"])) / Convert.ToDouble(dr["b_pm25_ann_DV"]) * 100;
                            }
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("f_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV(%)");
                        canSelectSpecies = true;
                    }
                    else if (legendText == "Quarterly PM25 Point")
                    {
                        for (int i = 1; i < 5; i++)
                        {
                            dt.Columns.Add("Δpm25_ann_q_DV_q" + i, typeof(double));
                            dt.Columns.Add("Δpm25_ann_q_DV_q" + i + "(%)", typeof(double));
                        }

                        foreach (DataRow dr in dt.Rows)
                        {
                            for (int i = 1; i < 5; i++)
                            {
                                if (Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) < 0 || Convert.ToDouble(dr["f_pm25_ann_q_DV_q" + i]) < 0)
                                {
                                    dr["Δpm25_ann_q_DV_q" + i] = 0;
                                    dr["Δpm25_ann_q_DV_q" + i + "(%)"] = 0;
                                }
                                else
                                {
                                    dr["Δpm25_ann_q_DV_q" + i] = Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) - Convert.ToDouble(dr["f_pm25_ann_q_DV_q" + i]);
                                    dr["Δpm25_ann_q_DV_q" + i + "(%)"] = (Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) - Convert.ToDouble(dr["f_pm25_ann_q_DV_q" + i])) / Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) * 100;
                                }
                            }
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        for (int i = 1; i < 5; i++)
                        {
                            cboSpeciesTypeGIS.Items.Add("b_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("f_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i + "(%)");
                        }
                        canSelectSpecies = true;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is DailyPMAnalysisConfiguration)//if file is "daily PM2.5 point" - base, future, delta
                {
                    if (legendText == "Daily PM25 Point")
                    {
                        dt.Columns.Add("Δpm25_d_DV", typeof(double));
                        dt.Columns.Add("Δpm25_d_DV(%)", typeof(double));

                        foreach (DataRow dr in dt.Rows)
                        {
                            if (Convert.ToDouble(dr["b_pm25_d_DV"]) < 0 || Convert.ToDouble(dr["f_pm25_d_DV"]) < 0)
                            {
                                dr["Δpm25_d_DV"] = 0;
                                dr["Δpm25_d_DV(%)"] = 0;
                            }
                            else
                            {
                                dr["Δpm25_d_DV"] = Convert.ToDouble(dr["b_pm25_d_DV"]) - Convert.ToDouble(dr["f_pm25_d_DV"]);
                                dr["Δpm25_d_DV(%)"] = (Convert.ToDouble(dr["b_pm25_d_DV"]) - Convert.ToDouble(dr["f_pm25_d_DV"])) / Convert.ToDouble(dr["b_pm25_d_DV"]) * 100;
                            }
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_pm25_d_DV");
                        cboSpeciesTypeGIS.Items.Add("f_pm25_d_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_d_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_d_DV(%)");
                        canSelectSpecies = true;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisConfiguration)//if file is "ozone monitor" - base, future, delta
                {
                    if (legendText.Contains("Ozone Monitors -- monitor data, temporally adjusted") || legendText.Contains("Ozone Monitors -- county high monitoring sites, temporally adjusted"))
                    {
                        dt.Columns.Add("Δo3_DV", typeof(double));

                        foreach (DataRow dr in dt.Rows)
                        {
                            if (Convert.ToDouble(dr["b_o3_DV"]) < 0 || Convert.ToDouble(dr["f_o3_DV"]) < 0)
                                dr["Δo3_DV"] = 0;
                            else
                                dr["Δo3_DV"] = Convert.ToDouble(dr["b_o3_DV"]) - Convert.ToDouble(dr["f_o3_DV"]);
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("f_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("Δo3_DV");
                        cboSpeciesTypeGIS.Items.Add("rrf");
                        canSelectSpecies = true;
                    }
                    if (legendText.Contains("Monitors_Max -- temporally adjusted"))
                    {
                        dt.Columns.Add("Δo3_DV_Max", typeof(double));

                        foreach (DataRow dr in dt.Rows)
                        {
                            if (Convert.ToDouble(dr["b_o3_DV_Max"]) < 0 || Convert.ToDouble(dr["f_o3_DV_Max"]) < 0)
                                dr["Δo3_DV_Max"] = 0;
                            else
                                dr["Δo3_DV_Max"] = Convert.ToDouble(dr["b_o3_DV_Max"]) - Convert.ToDouble(dr["f_o3_DV_Max"]);
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_o3_DV_Max");
                        cboSpeciesTypeGIS.Items.Add("f_o3_DV_Max");
                        cboSpeciesTypeGIS.Items.Add("Δo3_DV_Max");
                        cboSpeciesTypeGIS.Items.Add("rrf");
                        canSelectSpecies = true;
                    }
                    if (legendText.Contains("Spatial Field --"))
                    {
                        cboSpeciesTypeGIS.Items.Clear();

                        if (dt.Columns.Contains("i_b_o3(eVNA)")) cboSpeciesTypeGIS.Items.Add("i_b_o3(eVNA)");
                        if (dt.Columns.Contains("i_f_o3(eVNA)")) cboSpeciesTypeGIS.Items.Add("i_f_o3(eVNA)");
                        if (dt.Columns.Contains("i_b_o3(VNA)")) cboSpeciesTypeGIS.Items.Add("i_b_o3(VNA)");
                        if (dt.Columns.Contains("i_f_o3(VNA)")) cboSpeciesTypeGIS.Items.Add("i_f_o3(VNA)");
                        if (dt.Columns.Contains("i_b_o3(Downscaler)")) cboSpeciesTypeGIS.Items.Add("i_b_o3(Downscaler)");
                        if (dt.Columns.Contains("i_f_o3(Downscaler)")) cboSpeciesTypeGIS.Items.Add("i_f_o3(Downscaler)");

                        //DS-eVNA
                        if (dt.Columns.Contains("i_b_o3(eVNA)") && dt.Columns.Contains("i_b_o3(Downscaler)"))
                        { dt.Columns.Add("Δb_o3(DS-eVNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δb_o3(DS-eVNA)"); }
                        if (dt.Columns.Contains("i_f_o3(eVNA)") && dt.Columns.Contains("i_f_o3(Downscaler)"))
                        { dt.Columns.Add("Δf_o3(DS-eVNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δf_o3(DS-eVNA)"); }
                        //DS-VNA
                        if (dt.Columns.Contains("i_b_o3(VNA)") && dt.Columns.Contains("i_b_o3(Downscaler)"))
                        { dt.Columns.Add("Δb_o3(DS-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δb_o3(DS-VNA)"); }
                        if (dt.Columns.Contains("i_f_o3(VNA)") && dt.Columns.Contains("i_f_o3(Downscaler)"))
                        { dt.Columns.Add("Δf_o3(DS-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δf_o3(DS-VNA)"); }
                        //DS-model
                        if (dt.Columns.Contains("i_b_o3(Downscaler)") && dt.Columns.Contains("b_o3_model"))
                        { dt.Columns.Add("Δb_o3(DS-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δb_o3(DS-model)"); }
                        if (dt.Columns.Contains("i_f_o3(Downscaler)") && dt.Columns.Contains("f_o3_model"))
                        { dt.Columns.Add("Δf_o3(DS-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δf_o3(DS-model)"); }
                        //eVNA-VNA
                        if (dt.Columns.Contains("i_b_o3(eVNA)") && dt.Columns.Contains("i_b_o3(VNA)"))
                        { dt.Columns.Add("Δb_o3(eVNA-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δb_o3(eVNA-VNA)"); }
                        if (dt.Columns.Contains("i_f_o3(eVNA)") && dt.Columns.Contains("i_f_o3(VNA)"))
                        { dt.Columns.Add("Δf_o3(eVNA-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δf_o3(eVNA-VNA)"); }
                        //eVNA-model
                        if (dt.Columns.Contains("i_b_o3(eVNA)") && dt.Columns.Contains("b_o3_model"))
                        { dt.Columns.Add("Δb_o3(eVNA-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δb_o3(eVNA-model)"); }
                        if (dt.Columns.Contains("i_f_o3(eVNA)") && dt.Columns.Contains("f_o3_model"))
                        { dt.Columns.Add("Δf_o3(eVNA-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("Δf_o3(eVNA-model)"); }


                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dt.Columns.Contains("Δb_o3(DS-eVNA)"))
                                dr["Δb_o3(DS-eVNA)"] = Convert.ToDouble(dr["i_b_o3(Downscaler)"]) - Convert.ToDouble(dr["i_b_o3(eVNA)"]);
                            if (dt.Columns.Contains("Δf_o3(DS-eVNA)"))
                                dr["Δf_o3(DS-eVNA)"] = Convert.ToDouble(dr["i_f_o3(Downscaler)"]) - Convert.ToDouble(dr["i_f_o3(eVNA)"]);
                            if (dt.Columns.Contains("Δb_o3(DS-VNA)"))
                                dr["Δb_o3(DS-VNA)"] = Convert.ToDouble(dr["i_b_o3(Downscaler)"]) - Convert.ToDouble(dr["i_b_o3(VNA)"]);
                            if (dt.Columns.Contains("Δf_o3(DS-VNA)"))
                                dr["Δf_o3(DS-VNA)"] = Convert.ToDouble(dr["i_f_o3(Downscaler)"]) - Convert.ToDouble(dr["i_f_o3(VNA)"]);
                            if (dt.Columns.Contains("Δb_o3(DS-model)"))
                                dr["Δb_o3(DS-model)"] = Convert.ToDouble(dr["i_b_o3(Downscaler)"]) - Convert.ToDouble(dr["b_o3_model"]);
                            if (dt.Columns.Contains("Δf_o3(DS-model)"))
                                dr["Δf_o3(DS-model)"] = Convert.ToDouble(dr["i_f_o3(Downscaler)"]) - Convert.ToDouble(dr["f_o3_model"]);
                            if (dt.Columns.Contains("Δb_o3(eVNA-VNA)"))
                                dr["Δb_o3(eVNA-VNA)"] = Convert.ToDouble(dr["i_b_o3(eVNA)"]) - Convert.ToDouble(dr["i_b_o3(VNA)"]);
                            if (dt.Columns.Contains("Δf_o3(eVNA-VNA)"))
                                dr["Δf_o3(eVNA-VNA)"] = Convert.ToDouble(dr["i_f_o3(eVNA)"]) - Convert.ToDouble(dr["i_f_o3(VNA)"]);
                            if (dt.Columns.Contains("Δb_o3(eVNA-model)"))
                                dr["Δb_o3(eVNA-model)"] = Convert.ToDouble(dr["i_b_o3(eVNA)"]) - Convert.ToDouble(dr["b_o3_model"]);
                            if (dt.Columns.Contains("Δf_o3(eVNA-model)"))
                                dr["Δf_o3(eVNA-model)"] = Convert.ToDouble(dr["i_f_o3(eVNA)"]) - Convert.ToDouble(dr["f_o3_model"]);
                        }
                        canSelectSpecies = true;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                {
                    if (drawGIS)
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("gridcell") && !dt.Columns[i].ColumnName.ToLower().Contains("long") && !dt.Columns[i].ColumnName.ToLower().Contains("state")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.ToLower().Contains("lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type") && !dt.Columns[i].ColumnName.ToLower().Contains("county")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.ToLower().Contains("pollutant") && !dt.Columns[i].ColumnName.ToLower().Contains("name"))
                                cboSpeciesTypeGIS.Items.Add(dt.Columns[i].ColumnName);

                            //if (dt.Columns.Contains("i_b_o3(eVNA)")) cboSpeciesTypeGIS.Items.Add("i_b_o3(eVNA)");
                            //if (dt.Columns.Contains("i_f_o3(eVNA)")) cboSpeciesTypeGIS.Items.Add("i_f_o3(eVNA)");
                            //if (dt.Columns.Contains("i_b_o3(VNA)")) cboSpeciesTypeGIS.Items.Add("i_b_o3(VNA)");
                            //if (dt.Columns.Contains("i_f_o3(VNA)")) cboSpeciesTypeGIS.Items.Add("i_f_o3(VNA)");
                            //if (dt.Columns.Contains("i_b_o3(DS)")) cboSpeciesTypeGIS.Items.Add("i_b_o3(DS)");
                            //if (dt.Columns.Contains("i_f_o3(DS)")) cboSpeciesTypeGIS.Items.Add("i_f_o3(DS)");
                        }
                        //DS-eVNA
                        if (dt.Columns.Contains("O3 (BG_eVNA)") && dt.Columns.Contains("O3 (BG_DS)"))
                        { dt.Columns.Add("ΔO3(DS-eVNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔO3(DS-eVNA)"); }
                        if (dt.Columns.Contains("Alt_O3 (BG_eVNA)") && dt.Columns.Contains("Alt_O3 (BG_DS)"))
                        { dt.Columns.Add("ΔAlt_O3(DS-eVNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔAlt_O3(DS-eVNA)"); }
                        //DS-VNA
                        if (dt.Columns.Contains("O3 (BG_VNA)") && dt.Columns.Contains("O3 (BG_DS)"))
                        { dt.Columns.Add("ΔO3(DS-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔO3(DS-VNA)"); }
                        if (dt.Columns.Contains("Alt_O3 (BG_VNA)") && dt.Columns.Contains("Alt_O3 (BG_DS)"))
                        { dt.Columns.Add("ΔAlt_O3(DS-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔAlt_O3(DS-VNA)"); }
                        //DS-model
                        if (dt.Columns.Contains("O3 (BG_DS)") && dt.Columns.Contains("Base_O3"))
                        { dt.Columns.Add("ΔO3(DS-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔO3(DS-model)"); }
                        if (dt.Columns.Contains("Alt_O3 (BG_DS)") && dt.Columns.Contains("Alt_O3"))
                        { dt.Columns.Add("ΔAlt_O3(DS-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔAlt_O3(DS-model)"); }
                        //eVNA-VNA
                        if (dt.Columns.Contains("O3 (BG_eVNA)") && dt.Columns.Contains("O3 (BG_VNA)"))
                        { dt.Columns.Add("ΔO3(eVNA-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔO3(eVNA-VNA)"); }
                        if (dt.Columns.Contains("Alt_O3 (BG_eVNA)") && dt.Columns.Contains("Alt_O3 (BG_VNA)"))
                        { dt.Columns.Add("ΔAlt_O3(eVNA-VNA)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔAlt_O3(eVNA-VNA)"); }
                        //eVNA-model
                        if (dt.Columns.Contains("O3 (BG_eVNA)") && dt.Columns.Contains("Base_O3"))
                        { dt.Columns.Add("ΔO3(eVNA-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔO3(eVNA-model)"); }
                        if (dt.Columns.Contains("Alt_O3 (BG_eVNA)") && dt.Columns.Contains("Alt_O3"))
                        { dt.Columns.Add("ΔAlt_O3(eVNA-model)", typeof(double)); cboSpeciesTypeGIS.Items.Add("ΔAlt_O3(eVNA-model)"); }

                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dt.Columns.Contains("ΔO3(DS-eVNA)"))
                                dr["ΔO3(DS-eVNA)"] = Convert.ToDouble(dr["O3 (BG_DS)"]) - Convert.ToDouble(dr["O3 (BG_eVNA)"]);
                            if (dt.Columns.Contains("ΔAlt_O3(DS-eVNA)"))
                                dr["ΔAlt_O3(DS-eVNA)"] = Convert.ToDouble(dr["Alt_O3 (BG_DS)"]) - Convert.ToDouble(dr["Alt_O3 (BG_eVNA)"]);
                            if (dt.Columns.Contains("ΔO3(DS-VNA)"))
                                dr["ΔO3(DS-VNA)"] = Convert.ToDouble(dr["O3 (BG_DS)"]) - Convert.ToDouble(dr["O3 (BG_VNA)"]);
                            if (dt.Columns.Contains("ΔAlt_O3(DS-VNA)"))
                                dr["ΔAlt_O3(DS-VNA)"] = Convert.ToDouble(dr["Alt_O3 (BG_DS)"]) - Convert.ToDouble(dr["Alt_O3 (BG_VNA)"]);
                            if (dt.Columns.Contains("ΔO3(DS-model)"))
                                dr["ΔO3(DS-model)"] = Convert.ToDouble(dr["O3 (BG_DS)"]) - Convert.ToDouble(dr["Base_O3"]);
                            if (dt.Columns.Contains("ΔAlt_O3(DS-model)"))
                                dr["ΔAlt_O3(DS-model)"] = Convert.ToDouble(dr["Alt_O3 (BG_DS)"]) - Convert.ToDouble(dr["Alt_O3"]);
                            if (dt.Columns.Contains("ΔO3(eVNA-VNA)"))
                                dr["ΔO3(eVNA-VNA)"] = Convert.ToDouble(dr["O3 (BG_eVNA)"]) - Convert.ToDouble(dr["O3 (BG_VNA)"]);
                            if (dt.Columns.Contains("ΔAlt_O3(eVNA-VNA)"))
                                dr["ΔAlt_O3(eVNA-VNA)"] = Convert.ToDouble(dr["Alt_O3 (BG_eVNA)"]) - Convert.ToDouble(dr["Alt_O3 (BG_VNA)"]);
                            if (dt.Columns.Contains("ΔO3(eVNA-model)"))
                                dr["ΔO3(eVNA-model)"] = Convert.ToDouble(dr["O3 (BG_eVNA)"]) - Convert.ToDouble(dr["Base_O3"]);
                            if (dt.Columns.Contains("ΔAlt_O3(eVNA-model)"))
                                dr["ΔAlt_O3(eVNA-model)"] = Convert.ToDouble(dr["Alt_O3 (BG_eVNA)"]) - Convert.ToDouble(dr["Alt_O3"]);
                        }


                        canSelectSpecies = true;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisChinaConfiguration)
                {
                    if (legendText == "Annual PM25 Point" || legendText.Contains("Annual PM25 Point"))
                    {
                        dt.Columns.Add("Δpm25_ann_DV", typeof(double));
                        dt.Columns.Add("Δpm25_ann_DV(%)", typeof(double));

                        foreach (DataRow dr in dt.Rows)
                        {
                            if (Convert.ToDouble(dr["b_pm25_ann_DV"]) < 0 || Convert.ToDouble(dr["f_pm25_ann_DV"]) < 0)
                            {
                                dr["Δpm25_ann_DV"] = 0;
                                dr["Δpm25_ann_DV(%)"] = 0;
                            }
                            else
                            {
                                dr["Δpm25_ann_DV"] = Convert.ToDouble(dr["b_pm25_ann_DV"]) - Convert.ToDouble(dr["f_pm25_ann_DV"]);
                                dr["Δpm25_ann_DV(%)"] = (Convert.ToDouble(dr["b_pm25_ann_DV"]) - Convert.ToDouble(dr["f_pm25_ann_DV"])) / Convert.ToDouble(dr["b_pm25_ann_DV"]) * 100;
                            }
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("f_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV(%)");
                        canSelectSpecies = true;
                    }
                    else if (legendText == "Quarterly PM25 Point")
                    {
                        for (int i = 1; i < 5; i++)
                        {
                            dt.Columns.Add("Δpm25_ann_q_DV_q" + i, typeof(double));
                            dt.Columns.Add("Δpm25_ann_q_DV_q" + i + "(%)", typeof(double));
                        }

                        foreach (DataRow dr in dt.Rows)
                        {
                            for (int i = 1; i < 5; i++)
                            {
                                if (Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) < 0 || Convert.ToDouble(dr["f_pm25_ann_q_DV_q" + i]) < 0)
                                {
                                    dr["Δpm25_ann_q_DV_q" + i] = 0;
                                    dr["Δpm25_ann_q_DV_q" + i + "(%)"] = 0;
                                }
                                else
                                {
                                    dr["Δpm25_ann_q_DV_q" + i] = Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) - Convert.ToDouble(dr["f_pm25_ann_q_DV_q" + i]);
                                    dr["Δpm25_ann_q_DV_q" + i + "(%)"] = (Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) - Convert.ToDouble(dr["f_pm25_ann_q_DV_q" + i])) / Convert.ToDouble(dr["b_pm25_ann_q_DV_q" + i]) * 100;
                                }
                            }
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        for (int i = 1; i < 5; i++)
                        {
                            cboSpeciesTypeGIS.Items.Add("b_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("f_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i + "(%)");
                        }
                        canSelectSpecies = true;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisChinaConfiguration)
                {
                    if (legendText.Contains("Monitors -- temporally adjusted"))
                    {
                        dt.Columns.Add("Δo3_DV", typeof(double));

                        foreach (DataRow dr in dt.Rows)
                        {
                            if (Convert.ToDouble(dr["b_o3_DV"]) < 0 || Convert.ToDouble(dr["f_o3_DV"]) < 0)
                                dr["Δo3_DV"] = 0;
                            else
                                dr["Δo3_DV"] = Convert.ToDouble(dr["b_o3_DV"]) - Convert.ToDouble(dr["f_o3_DV"]);
                        }

                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("f_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("Δo3_DV");
                        canSelectSpecies = true;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration && legendText.ToLower().Contains("forecasted visibility"))
                {
                    cboSpeciesTypeGIS.Items.Clear();
                    cboSpeciesTypeGIS.Items.Add("dv_best_b");//dv_best
                    cboSpeciesTypeGIS.Items.Add("dv_best_f");//dv_worst
                    cboSpeciesTypeGIS.Items.Add("dv_worst_b");//base_best
                    cboSpeciesTypeGIS.Items.Add("dv_worst_f");//base_worst
                    canSelectSpecies = true;
                }

                //change the drop down width of cboSpeciesTypeGIS
                if (cboSpeciesTypeGIS.Items.Count > 0)
                {
                    string str = "";
                    foreach (string s in cboSpeciesTypeGIS.Items)
                    {
                        str = s.Length > str.Length ? s : str;
                    }

                    using (Graphics g0 = this.CreateGraphics())
                    {
                        SizeF string_size = g0.MeasureString(str, cboSpeciesTypeGIS.Font);
                        cboSpeciesTypeGIS.DropDownWidth = (int)string_size.Width;
                    }
                }
                #endregion

                if (mainMap.Layers.Count > 0 && (!isPolygon || (drawGIS && isPolygon)))
                {
                    if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region")
                    //if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "npsClassI")
                    {
                        mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                        mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                    }
                    else
                    {
                        mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                    }
                }

                #region add column
                if (CommonClass.CurrentBaseScenario != null && CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                {
                    if (tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Used Model Reference Cells"))
                    {
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            if (dt.Columns[i].ColumnName.ToLower().Contains("lat"))
                                iLat = i;
                            if (dt.Columns[i].ColumnName.ToLower().Contains("long"))
                                iLong = i;
                            if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("long")
                                 && !dt.Columns[i].ColumnName.ToLower().Contains("lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank"))
                            {
                                if (dt.Columns[i].ColumnName.ToLower().Contains("dv_best"))
                                {
                                    if (iPM == -1)
                                        iPM = i;
                                }
                                iValue = i;
                                count++;
                            }
                            if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("long")
                                 && !dt.Columns[i].ColumnName.ToLower().Contains("lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank"))
                            {
                                addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName, typeof(double));
                            }
                            else
                                addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName);
                        }
                    }
                    else if (tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Class 1 Area and IMPROVE Monitors Identifiers and Locations"))
                    {
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            if (dt.Columns[i].ColumnName.ToLower().Contains("class_i_lat"))
                                iLat = i;
                            if (dt.Columns[i].ColumnName.ToLower().Contains("class_i_long"))
                                iLong = i;
                            if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_long")
                                 && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_state")
                                && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_name"))
                            {
                                if (dt.Columns[i].ColumnName.ToLower().Contains("dv_best"))
                                {
                                    if (iPM == -1)
                                        iPM = i;
                                }
                                iValue = i;
                                count++;
                            }
                            if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_long")
                                 && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_state")
                                && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_name"))
                            {
                                addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName, typeof(double));
                            }
                            else
                                addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName);
                        }
                    }
                    else
                    {
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellAtMonitor)
                        {
                            for (int i = 0; i < dt.Columns.Count; i++)
                            {
                                if (dt.Columns[i].ColumnName.ToLower().Contains("monitor_lat"))
                                    iLat = i;
                                if (dt.Columns[i].ColumnName.ToLower().Contains("monitor_long"))
                                    iLong = i;
                                if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("monitor_long")
                                     && !dt.Columns[i].ColumnName.ToLower().Contains("monitor_lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("name")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("state"))
                                {
                                    if (dt.Columns[i].ColumnName.ToLower().Contains("dv_best"))
                                    {
                                        if (iPM == -1)
                                            iPM = i;
                                    }
                                    iValue = i;
                                    count++;
                                }
                                if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("monitor_long")
                                     && !dt.Columns[i].ColumnName.ToLower().Contains("monitor_lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("name")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("state"))
                                {
                                    addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName, typeof(double));
                                }
                                else
                                    addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName);
                            }
                        }
                        else if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellatClassIAreaCentroid)
                        {
                            for (int i = 0; i < dt.Columns.Count; i++)
                            {
                                if (dt.Columns[i].ColumnName.ToLower().Contains("class_i_lat"))
                                    iLat = i;
                                if (dt.Columns[i].ColumnName.ToLower().Contains("class_i_long"))
                                    iLong = i;
                                if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_long")
                                     && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("name")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("state"))
                                {
                                    if (dt.Columns[i].ColumnName.ToLower().Contains("dv_best"))
                                    {
                                        if (iPM == -1)
                                            iPM = i;
                                    }
                                    iValue = i;
                                    count++;
                                }
                                if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_long")
                                     && !dt.Columns[i].ColumnName.ToLower().Contains("class_i_lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("name")
                                    && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("state"))
                                {
                                    addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName, typeof(double));
                                }
                                else
                                    addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        if (dt.Columns[i].ColumnName.ToLower().Contains("lat"))
                            iLat = i;
                        if (dt.Columns[i].ColumnName.ToLower().Contains("long"))
                            iLong = i;
                        if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("gridcell") && !dt.Columns[i].ColumnName.ToLower().Contains("long") && !dt.Columns[i].ColumnName.ToLower().Contains("state")
                            && !dt.Columns[i].ColumnName.ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.ToLower().Contains("lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type") && !dt.Columns[i].ColumnName.ToLower().Contains("county")
                            && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.ToLower().Contains("pollutant") && !dt.Columns[i].ColumnName.ToLower().Contains("name")
                            && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("col") && !dt.Columns[i].ColumnName.ToLower().Contains("row") && !dt.Columns[i].ColumnName.ToLower().Contains("metric") && !dt.Columns[i].ColumnName.ToLower().Contains("statistic"))
                        {
                            if (dt.Columns[i].ColumnName.ToLower().Contains("pm"))
                            {
                                if (iPM == -1)
                                    iPM = i;
                            }
                            iValue = i;
                            count++;
                        }
                        if (!dt.Columns[i].ColumnName.ToLower().Contains("id") && !dt.Columns[i].ColumnName.ToLower().Contains("gridcell") && !dt.Columns[i].ColumnName.ToLower().Contains("long") && !dt.Columns[i].ColumnName.ToLower().Contains("state")
                            && !dt.Columns[i].ColumnName.ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.ToLower().Contains("lat") && !dt.Columns[i].ColumnName.ToLower().Contains("type") && !dt.Columns[i].ColumnName.ToLower().Contains("county")
                            && !dt.Columns[i].ColumnName.ToLower().Contains("date") && !dt.Columns[i].ColumnName.ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.ToLower().Contains("pollutant") && !dt.Columns[i].ColumnName.ToLower().Contains("name")
                            && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("col") && !dt.Columns[i].ColumnName.ToLower().Contains("row") && !dt.Columns[i].ColumnName.ToLower().Contains("metric") && !dt.Columns[i].ColumnName.ToLower().Contains("statistic"))
                        {
                            addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName, typeof(double));
                        }
                        else
                            addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName);
                    }
                }
                #endregion
                DotSpatial.Topology.Point point;
                Feature feature = null;

                //if (dt.Rows.Count > 0 && dt != null)
                //{
                //    for (int i = 0; i < dt.Rows.Count; i++)
                //    {
                //        point = new DotSpatial.Topology.Point(Convert.ToDouble(dt.Rows[i][iLong].ToString()), Convert.ToDouble(dt.Rows[i][iLat].ToString()));
                //        feature = new Feature(point);
                //        addToMapSet.AddFeature(feature);
                //        for (int j = 0; j < dt.Columns.Count; j++)
                //        {
                //            //Regex r = new Regex(@"^[0-9]+");
                //            //if (!r.IsMatch(dt.Rows[i][j].ToString().TrimStart('-')) && typeof(double) == addToMapSet.DataTable.Columns[j].DataType)
                //            //    dt.Rows[i][j] = 0;
                //            addToMapSet.DataTable.Rows[i][j] = dt.Rows[i][j];
                //        }
                //    }

                //    mainMap.Layers.Add(addToMapSet);
                //    mainMap.Layers[mainMap.Layers.Count - 1].LegendText = legendText;
                //}
                if (isPolygon)
                {
                    if (dt.Rows.Count > 0 && dt != null)
                    {
                        if (drawGIS)
                        {
                            //    for (int i = 0; i < dt.Rows.Count; i++)
                            //    {
                            //        DotSpatial.Topology.Polygon env = new DotSpatial.Topology.Polygon(new List<DotSpatial.Topology.Coordinate>{new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) - 0.072, Convert.ToDouble(dt.Rows[i][iLat]) - 0.073)
                            //        ,new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) + 0.072, Convert.ToDouble(dt.Rows[i][iLat]) - 0.073)
                            //    ,new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) + 0.072, Convert.ToDouble(dt.Rows[i][iLat]) + 0.073)
                            //    ,new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) - 0.072, Convert.ToDouble(dt.Rows[i][iLat]) + 0.073)});
                            //        feature = new Feature(env);
                            //        addToMapSet.AddFeature(feature);
                            //        addToMapSet.DataTable.Rows[i].ItemArray = dt.Rows[i].ItemArray;
                            //    }

                            //    //addToMapSet.DataTable = dt.DefaultView.ToTable();//not work

                            //    mainMap.Layers.Add(addToMapSet);
                            //    mainMap.Layers[mainMap.Layers.Count - 1].LegendText = legendText;
                        }
                        else
                        {
                            bool isBenMAPData = false;
                            if (CommonClass.CurrentBaseScenario.configuration is BenMAPAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is BenMAPOzoneAnalysisConfiguration)
                                isBenMAPData = true;
                            else if (
                                (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisConfiguration)
                                && legendText.Contains("BenMAP-ready")
                                )
                            {
                                isBenMAPData = true;
                            }

                            //plotControl1.MinMaxClean();
                            CommonClass.dicBlend["Map"].Clear();

                            lblMAPname.Text = legendText;
                            int[] icolrow = new int[4];
                            if (isBenMAPData)
                            {
                                icolrow[0] = Convert.ToInt32(dt.Rows[0]["Column"].ToString());//col.min
                                icolrow[1] = icolrow[0];//col.max
                                icolrow[2] = Convert.ToInt32(dt.Rows[0]["Row"].ToString());//row.min
                                icolrow[3] = icolrow[2];//row.max
                            }
                            else
                            {
                                icolrow[0] = Convert.ToInt32(dt.Rows[0]["_id"].ToString()) / 1000;//col.min
                                icolrow[1] = icolrow[0];//col.max
                                icolrow[2] = Convert.ToInt32(dt.Rows[0]["_id"].ToString()) % 1000;//row.min
                                icolrow[3] = icolrow[2];//row.max
                            }
                            dicValueMAP = new Dictionary<string, Dictionary<string, double>>();
                            List<int> lstCheck = new List<int>();
                            for (int j = 0; j < dt.Columns.Count; j++)
                            {
                                string columnname = dt.Columns[j].ColumnName.ToLower();
                                if (!columnname.Contains("id") && !columnname.Contains("gridcell") && !columnname.Contains("long") && !columnname.Contains("state")
                        && !columnname.Contains("quarter") && !columnname.Contains("lat") && !columnname.Contains("type") && !columnname.Contains("county")
                        && !columnname.Contains("date") && !columnname.Contains("neighbor") && !columnname.Contains("pollutant") && !columnname.Contains("name")
                        && !columnname.Contains("_visibility_rank") && !columnname.Contains("column") && !columnname.Contains("row") && !columnname.Contains("metric") && !columnname.Contains("statistic"))
                                {
                                    lstCheck.Add(j);
                                }
                            }
                            ssiaDataOption = SSIAmodeloption(legendText);
                            if (ssiaDataOption == 1)
                            {
                                int gridCount = dt.Rows.Count;
                                int dispersionCount = CommonClass.CurrentBaseScenario.dicLatLongLambert.Where(q => q.Key.Contains("utm")).Count();
                                gridCount = gridCount - dispersionCount;
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    if (i < gridCount)
                                    {
                                        icolrow[0] = Math.Min(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) / 1000, icolrow[0]);
                                        icolrow[1] = Math.Max(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) / 1000, icolrow[1]);
                                        icolrow[2] = Math.Min(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) % 1000, icolrow[2]);
                                        icolrow[3] = Math.Max(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) % 1000, icolrow[3]);
                                    }
                                    Dictionary<string, double> dicValue = new Dictionary<string, double>();
                                    foreach (int jCheck in lstCheck)
                                    {
                                        dicValue.Add(dt.Columns[jCheck].ColumnName, Convert.ToDouble(dt.Rows[i][jCheck]));
                                    }
                                    if (!dicValueMAP.ContainsKey(dt.Rows[i][iLat] + "," + dt.Rows[i][iLong]))
                                        dicValueMAP.Add(dt.Rows[i][iLat] + "," + dt.Rows[i][iLong], dicValue);
                                }
                            }
                            else if (ssiaDataOption == 2)
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    Dictionary<string, double> dicValue = new Dictionary<string, double>();
                                    foreach (int jCheck in lstCheck)
                                    {
                                        dicValue.Add(dt.Columns[jCheck].ColumnName, Convert.ToDouble(dt.Rows[i][jCheck]));
                                    }
                                    if (!dicValueMAP.ContainsKey("utm," + dt.Rows[i][iLat] + "," + dt.Rows[i][iLong]))
                                        dicValueMAP.Add("utm," + dt.Rows[i][iLat] + "," + dt.Rows[i][iLong], dicValue);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    if (isBenMAPData)
                                    {
                                        icolrow[0] = Math.Min(Convert.ToInt32(dt.Rows[i]["Column"].ToString()), icolrow[0]);
                                        icolrow[1] = Math.Max(Convert.ToInt32(dt.Rows[i]["Column"].ToString()), icolrow[1]);
                                        icolrow[2] = Math.Min(Convert.ToInt32(dt.Rows[i]["Row"].ToString()), icolrow[2]);
                                        icolrow[3] = Math.Max(Convert.ToInt32(dt.Rows[i]["Row"].ToString()), icolrow[3]);
                                    }
                                    else
                                    {
                                        icolrow[0] = Math.Min(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) / 1000, icolrow[0]);
                                        icolrow[1] = Math.Max(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) / 1000, icolrow[1]);
                                        icolrow[2] = Math.Min(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) % 1000, icolrow[2]);
                                        icolrow[3] = Math.Max(Convert.ToInt32(dt.Rows[i]["_id"].ToString()) % 1000, icolrow[3]);
                                    }
                                    Dictionary<string, double> dicValue = new Dictionary<string, double>();
                                    foreach (int jCheck in lstCheck)
                                    {
                                        try
                                        {

                                            dicValue.Add(dt.Columns[jCheck].ColumnName, Convert.ToDouble(string.IsNullOrEmpty(dt.Rows[i][jCheck].ToString()) ? 0 : dt.Rows[i][jCheck]));
                                        }
                                        catch (Exception)
                                        {

                                        }
                                    }
                                    if (!dicValueMAP.ContainsKey(dt.Rows[i][iLat] + "," + dt.Rows[i][iLong]))
                                        dicValueMAP.Add(dt.Rows[i][iLat] + "," + dt.Rows[i][iLong], dicValue);
                                }
                            }

                            lstSpeciesTypeMap.Items.Clear();
                            int iIndex = 0;
                            foreach (int jCheck in lstCheck)
                            {
                                if (dt.Columns[jCheck].ColumnName.ToLower().Contains("pm"))//show pm25 first
                                {
                                    lstSpeciesTypeMap.Items.Insert(iIndex, dt.Columns[jCheck].ColumnName);
                                    iIndex++;
                                }
                                else
                                    lstSpeciesTypeMap.Items.Add(dt.Columns[jCheck].ColumnName);
                            }

                            //using in draw map with legend
                            strMapNameColRow[0] = "data = " + legendText;
                            strMapNameColRow[1] = lstSpeciesTypeMap.Items[0].ToString();
                            if (ssiaDataOption == 2)
                            {
                                strMapNameColRow[2] = " ";
                                strMapNameColRow[3] = " ";
                                strMapNameColRow[4] = " ";
                                strMapNameColRow[5] = " ";
                                plotControl1.projForMap = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD);
                            }
                            else
                            {
                                strMapNameColRow[2] = icolrow[0].ToString();
                                strMapNameColRow[3] = icolrow[1].ToString();
                                strMapNameColRow[4] = icolrow[2].ToString();
                                strMapNameColRow[5] = icolrow[3].ToString();
                                plotControl1.projForMap = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);
                            }

                            //CommonClass.modelDefinition = new ModelDefinition();
                            //CommonClass.modelDefinition.ActiveGridType = "12km";
                            //CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state.csv");
                            //CommonClass.modelDefinition.ShapeLCCFiles = new Dictionary<string, Dictionary<string, double[,]>>();
                            //CommonClass.modelDefinition.ShapeLCCFiles.Add(CommonClass.modelDefinition.ActiveGridType, CommonClass.ShapeLCC);
                            if (CommonClass.CurrentAnalysis == enumAnalysis.Ozone || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone)
                                colorBlendMap.ValueUnit = "ppb";
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.Visibility)
                                colorBlendMap.ValueUnit = "deciveiw";
                            else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                                colorBlendMap.ValueUnit = "";
                            else
                                colorBlendMap.ValueUnit = "μg/m3";

                            if (ssiaDataOption == 2)
                            {
                                if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("county_utm"))
                                {
                                    CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\county_utm.csv");
                                    CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("county_utm", CommonClass.ShapeLCC);
                                }
                            }
                            else
                            {
                                if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("county"))
                                {
                                    CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\county.csv");
                                    CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("county", CommonClass.ShapeLCC);
                                }
                            }

                            if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                btnChangeBoundary.Text = "State";
                            if (LanguageOld.IsSMATChina)
                                plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("region");
                            else
                            {
                                if (btnChangeBoundary.Text == "State")
                                {
                                    if (ssiaDataOption == 2)
                                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("county_utm");
                                    else
                                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("county");
                                }
                                else
                                {
                                    if (ssiaDataOption == 2)
                                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state_utm");
                                    else
                                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state");
                                }
                            }
                            plotControl1.ColorBlendControl = colorBlendMap;

                            #region map show - default - the small domain - find the lowerleft and upperright point in lambert
                            smallDomianMAP = "";
                            CommonClass.modelDefinition.ParseGridValues(CommonClass.CurrentBaseScenario.dicLatLongLambert, dicValueMAP, lstSpeciesTypeMap.Items[0].ToString(), ssiaDataOption);
                            List<double> y = new List<double>();
                            List<double> x = new List<double>();
                            foreach (string key in CommonClass.modelDefinition.GridValues.Keys)
                            {
                                string skey = key;
                                if (skey.Contains("d"))
                                    skey = skey.Substring(2);
                                string[] s = skey.Split(',');
                                x.Add(Convert.ToDouble(s[0]));
                                y.Add(Convert.ToDouble(s[1]));
                            }
                            smallDomianMAP = x.Min().ToString() + "," + y.Min().ToString() + "," + x.Max().ToString() + "," + y.Max().ToString();
                            #endregion

                            #region write min max value and grid information
                            if (_dMinValue != 0 && _dMaxValue != 0)
                            {
                                lblMinMaxGIS.Text = "Min = " + _dMinValue.ToString("F3") + "   Max = " + _dMaxValue.ToString("F3");
                                lblMinMaxGIS.Visible = true;

                            }

                            //string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                            //lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[1]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[0]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[0]) % 1000 + ")   Max = " + Convert.ToDouble(minmaxGridValue[3]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[2]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[2]) % 1000 + ")";
                            //lblMinMax.Show();

                            if (ssiaDataOption == 0)
                            {
                                string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                                lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[1]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[0]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[0]) % 1000 + ")   Max = " + Convert.ToDouble(minmaxGridValue[3]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[2]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[2]) % 1000 + ")";
                                lblMinMax.Visible = true;
                            }
                            else
                            {
                                string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                                lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[2]).ToString("F3") + " at (" + Math.Round(Convert.ToDouble(minmaxGridValue[0]), 2) + "," + Math.Round(Convert.ToDouble(minmaxGridValue[1]), 2) + ")   Max = " + Convert.ToDouble(minmaxGridValue[5]).ToString("F3") + " at (" + Math.Round(Convert.ToDouble(minmaxGridValue[3]), 2) + "," + Math.Round(Convert.ToDouble(minmaxGridValue[4]), 2) + ")";
                                lblMinMax.Visible = true;
                            }

                            #endregion

                            #region get cell width height
                            CommonClass.modelDefinition.CellWidthHeight = new double[2];
                            //CommonClass.modelDefinition.CellWidthHeight[0] = 0;
                            //CommonClass.modelDefinition.CellWidthHeight[1] = 0;
                            try
                            {
                                if (ssiaDataOption == 1)
                                {
                                    CommonClass.modelDefinition.CellWidthHeight[0] = 4000;
                                    CommonClass.modelDefinition.CellWidthHeight[1] = 4000;
                                    int id1 = Convert.ToInt32(dt.Rows[0]["_id"].ToString());
                                    string latlong1 = CommonClass.CurrentBaseScenario.dicLatLongLambert[dt.Rows[0][iLat].ToString() + "," + dt.Rows[0][iLong].ToString()];
                                    for (int i = 1; i < dt.Rows.Count - 1; i++)
                                    {
                                        int id2 = Convert.ToInt32(dt.Rows[i]["_id"].ToString());
                                        if (((id1 / 1000 - id2 / 1000) != 0) && ((id1 % 1000 - id2 % 1000) != 0))//col row -> different
                                        {
                                            string latlong2 = CommonClass.CurrentBaseScenario.dicLatLongLambert[dt.Rows[i][iLat].ToString() + "," + dt.Rows[i][iLong].ToString()];
                                            if (latlong2.Contains("d")) break;
                                            int dCol = Math.Abs(id2 / 1000 - id1 / 1000);
                                            int dRow = Math.Abs(id2 % 1000 - id1 % 1000);
                                            CommonClass.modelDefinition.CellWidthHeight[0] = Math.Abs(Convert.ToDouble(latlong2.Split(',')[0]) - Convert.ToDouble(latlong1.Split(',')[0])) / dCol * 1.03;
                                            CommonClass.modelDefinition.CellWidthHeight[1] = Math.Abs(Convert.ToDouble(latlong2.Split(',')[1]) - Convert.ToDouble(latlong1.Split(',')[1])) / dRow * 1.03;
                                            CommonClass.modelDefinition.CellWidthHeight[0] = Math.Max(CommonClass.modelDefinition.CellWidthHeight[0], CommonClass.modelDefinition.CellWidthHeight[1]);
                                            CommonClass.modelDefinition.CellWidthHeight[1] = CommonClass.modelDefinition.CellWidthHeight[0];
                                            break;
                                        }
                                    }
                                }
                                else if (ssiaDataOption == 2)
                                {
                                    CommonClass.modelDefinition.CellWidthHeight[0] = 100;
                                    CommonClass.modelDefinition.CellWidthHeight[1] = 100;
                                    List<string> lstStrlonglat = CommonClass.CurrentBaseScenario.dicLatLongLambert.Where(q => q.Key.Contains("utm")).Select(q => q.Value).ToList();
                                    if (lstStrlonglat.Count == 0)
                                        lstStrlonglat = CommonClass.CurrentBaseScenario.dicLatLongLambert.Select(q => q.Value).ToList();
                                    if (lstStrlonglat.Count > 0)
                                    {
                                        List<double[]> lstLongLat = new List<double[]>();
                                        for (int i = 0; i < lstStrlonglat.Count; i++)
                                        {
                                            lstLongLat.Add(new double[2] { Convert.ToDouble(lstStrlonglat[i].Split(',')[0]), Convert.ToDouble(lstStrlonglat[i].Split(',')[1]) });
                                        }

                                        double dLon = 0, dLat = 0;
                                        List<double> lstLat = lstLongLat.Select(q => q[1]).Distinct().ToList();
                                        List<double> lstLon = lstLongLat.Select(q => q[0]).Distinct().ToList();
                                        lstLat.Sort();
                                        lstLon.Sort();
                                        for (int i = 0; i < lstLat.Count - 1; i++)
                                        {
                                            dLat = Math.Max(dLat, lstLat[i + 1] - lstLat[i]);
                                        }
                                        for (int i = 0; i < lstLon.Count - 1; i++)
                                        {
                                            dLon = Math.Max(dLat, lstLon[i + 1] - lstLon[i]);
                                        }
                                        dLat = Math.Max(dLat, dLon) / 5;
                                        if (dLat > 0)
                                        {
                                            CommonClass.modelDefinition.CellWidthHeight[0] = dLat;
                                            CommonClass.modelDefinition.CellWidthHeight[1] = dLat;
                                        }
                                        lstLat.Clear();
                                        lstLon.Clear();
                                        lstStrlonglat.Clear();
                                    }
                                }
                                else
                                {
                                    int id1 = Convert.ToInt32(dt.Rows[0]["_id"].ToString());
                                    string latlong1 = CommonClass.CurrentBaseScenario.dicLatLongLambert[dt.Rows[0][iLat].ToString() + "," + dt.Rows[0][iLong].ToString()];
                                    //int icount = 0;
                                    for (int i = dt.Rows.Count - 1; i > 0; i--)
                                    {
                                        int id2 = Convert.ToInt32(dt.Rows[i]["_id"].ToString());
                                        if (((id1 / 1000 - id2 / 1000) != 0) && ((id1 % 1000 - id2 % 1000) != 0))//col row -> different
                                        {
                                            string latlong2 = CommonClass.CurrentBaseScenario.dicLatLongLambert[dt.Rows[i][iLat].ToString() + "," + dt.Rows[i][iLong].ToString()];
                                            int dCol = Math.Abs(id2 / 1000 - id1 / 1000);
                                            int dRow = Math.Abs(id2 % 1000 - id1 % 1000);
                                            //average is not ok
                                            //CommonClass.modelDefinition.CellWidthHeight[0] += Math.Abs(Convert.ToDouble(latlong2.Split(',')[0]) - Convert.ToDouble(latlong1.Split(',')[0])) / dCol;
                                            //CommonClass.modelDefinition.CellWidthHeight[1] += Math.Abs(Convert.ToDouble(latlong2.Split(',')[1]) - Convert.ToDouble(latlong1.Split(',')[1])) / dRow;
                                            //icount++;
                                            //max is too large
                                            //CommonClass.modelDefinition.CellWidthHeight[0] = Math.Max(Math.Abs(Convert.ToDouble(latlong2.Split(',')[0]) - Convert.ToDouble(latlong1.Split(',')[0])) / dCol, CommonClass.modelDefinition.CellWidthHeight[0]);
                                            //CommonClass.modelDefinition.CellWidthHeight[1] = Math.Max(Math.Abs(Convert.ToDouble(latlong2.Split(',')[1]) - Convert.ToDouble(latlong1.Split(',')[1])) / dRow, CommonClass.modelDefinition.CellWidthHeight[1]);
                                            CommonClass.modelDefinition.CellWidthHeight[0] = Math.Abs(Convert.ToDouble(latlong2.Split(',')[0]) - Convert.ToDouble(latlong1.Split(',')[0])) / dCol * 1.03;
                                            CommonClass.modelDefinition.CellWidthHeight[1] = Math.Abs(Convert.ToDouble(latlong2.Split(',')[1]) - Convert.ToDouble(latlong1.Split(',')[1])) / dRow * 1.03;
                                            CommonClass.modelDefinition.CellWidthHeight[0] = Math.Max(CommonClass.modelDefinition.CellWidthHeight[0], CommonClass.modelDefinition.CellWidthHeight[1]);
                                            CommonClass.modelDefinition.CellWidthHeight[1] = CommonClass.modelDefinition.CellWidthHeight[0];
                                            //if (CommonClass.modelDefinition.CellWidthHeight[0] < CommonClass.modelDefinition.CellWidthHeight[1] / 2)
                                            //    CommonClass.modelDefinition.CellWidthHeight[0] = CommonClass.modelDefinition.CellWidthHeight[1];
                                            //if (CommonClass.modelDefinition.CellWidthHeight[1] < CommonClass.modelDefinition.CellWidthHeight[0] / 2)
                                            //    CommonClass.modelDefinition.CellWidthHeight[1] = CommonClass.modelDefinition.CellWidthHeight[0];
                                            break;
                                        }
                                    }
                                }
                                //CommonClass.modelDefinition.CellWidthHeight[0] = CommonClass.modelDefinition.CellWidthHeight[0] / icount;
                                //CommonClass.modelDefinition.CellWidthHeight[1] = CommonClass.modelDefinition.CellWidthHeight[1] / icount;
                            }
                            catch
                            { }
                            #endregion

                            plotControl1.Mapname = lstSpeciesTypeMap.Items[0].ToString();

                            btnZoomIn_Click(null, null);
                            //btnZoomOut_Click(null, null);
                            lstSpeciesTypeMap.SelectedIndexChanged -= lstSpeciesTypeMap_SelectedIndexChanged;
                            lstSpeciesTypeMap.SelectedIndex = 0;
                            lstSpeciesTypeMap.SelectedIndexChanged += lstSpeciesTypeMap_SelectedIndexChanged;
                            dgvGridInfo.DataSource = null;
                            if (!LanguageOld.IsSMATChina)
                                btnChangeBoundary.Enabled = true;
                            btnSavePic.Enabled = true;
                            tsbtnPlotMonitors.Enabled = true;
                            #region calculate latlong of lambert after double click output
                            //for (int i = 0; i < dt.Rows.Count; i++)
                            //{
                            //    DotSpatial.Topology.Polygon env = new DotSpatial.Topology.Polygon(new List<DotSpatial.Topology.Coordinate>{new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) - 0.072, Convert.ToDouble(dt.Rows[i][iLat]) - 0.073)
                            //    ,new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) + 0.072, Convert.ToDouble(dt.Rows[i][iLat]) - 0.073)
                            //,new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) + 0.072, Convert.ToDouble(dt.Rows[i][iLat]) + 0.073)
                            //,new DotSpatial.Topology.Coordinate( Convert.ToDouble(dt.Rows[i][iLong]) - 0.072, Convert.ToDouble(dt.Rows[i][iLat]) + 0.073)});
                            //    feature = new Feature(env);
                            //    addToMapSet.AddFeature(feature);
                            //    addToMapSet.DataTable.Rows[i].ItemArray = dt.Rows[i].ItemArray;

                            //    Dictionary<string, double> dicValue = new Dictionary<string, double>();
                            //    for (int j = 4; j < dt.Columns.Count; j++)
                            //    {
                            //        dicValue.Add(dt.Columns[j].ColumnName, Convert.ToDouble(dt.Rows[i][j]));
                            //    }
                            //    dicValueMAP.Add(dt.Rows[i][iLat] + "," + dt.Rows[i][iLong], dicValue);
                            //}

                            //mainMap.Layers.Add(addToMapSet);
                            //mainMap.Layers[mainMap.Layers.Count - 1].LegendText = legendText;


                            ////change projection
                            //if (mainMap.Layers[mainMap.Layers.Count - 1].Projection != KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic)
                            //{
                            //    mainMap.Layers[mainMap.Layers.Count - 1].Projection = KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic;
                            //    mainMap.Layers[mainMap.Layers.Count - 1].Projection = KnownCoordinateSystems.Geographic.World.WGS1984;
                            //    mainMap.Layers[mainMap.Layers.Count - 1].Reproject(KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic);
                            //}

                            //IMapPolygonLayer lyr = mainMap.Layers[mainMap.Layers.Count - 1] as IMapPolygonLayer;
                            //diclatlongTOLambert = new Dictionary<string, string>();
                            //foreach (Feature f in lyr.DataSet.Features)
                            //{
                            //    if (f.BasicGeometry is MultiPolygon)
                            //    {
                            //        MultiPolygon mp = (MultiPolygon)f.BasicGeometry;
                            //        int iMax = 0, iCount = 0;
                            //        for (int imp = 0; imp < mp.Geometries.Count(); imp++)
                            //        {
                            //            if (mp.Geometries[imp].Coordinates.Count > iCount)
                            //            {
                            //                iMax = imp;
                            //                iCount = mp.Geometries[imp].Coordinates.Count;
                            //            }
                            //        }
                            //        foreach (Coordinate co in mp.Geometries[iMax].Coordinates)
                            //        {
                            //            if (!diclatlongTOLambert.ContainsKey(f.DataRow[iLat] + "," + f.DataRow[iLong]))
                            //            {
                            //                diclatlongTOLambert.Add(f.DataRow[iLat] + "," + f.DataRow[iLong], co.X + "," + co.Y);
                            //            }
                            //        }
                            //    }
                            //    else
                            //    {
                            //        foreach (Coordinate co in f.Coordinates)
                            //        {
                            //            if (!diclatlongTOLambert.ContainsKey(f.DataRow[iLat] + "," + f.DataRow[iLong]))
                            //            {
                            //                diclatlongTOLambert.Add(f.DataRow[iLat] + "," + f.DataRow[iLong], co.X + "," + co.Y);
                            //            }
                            //        }
                            //    }
                            //}
                            //mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                            #endregion
                            return;
                        }
                    }
                    else
                        return;
                }
                //else
                {
                    if (dt.Rows.Count > 0 && dt != null)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            point = new DotSpatial.Topology.Point(Convert.ToDouble(dt.Rows[i][iLong]), Convert.ToDouble(dt.Rows[i][iLat]));
                            feature = new Feature(point);
                            addToMapSet.AddFeature(feature);
                            try
                            {
                                addToMapSet.DataTable.Rows[i].ItemArray = dt.Rows[i].ItemArray;
                            }
                            catch (Exception)
                            {

                            }


                        }

                        //addToMapSet.DataTable = dt.DefaultView.ToTable();//not work


                        mainMap.Layers.Add(addToMapSet);
                        mainMap.Layers[mainMap.Layers.Count - 1].LegendText = legendText;
                        _currentLayerIndex = mainMap.Layers.Count - 1;

                    }
                }
                if (CommonClass.CurrentAnalysis == enumAnalysis.Ozone || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone)
                    colorBlend.ValueUnit = "ppb";
                else if (CommonClass.CurrentAnalysis == enumAnalysis.Visibility)
                    colorBlend.ValueUnit = "deciveiw";
                else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                    colorBlendMap.ValueUnit = "";
                else
                    colorBlend.ValueUnit = "μg/m3";
                if (iPM != -1)
                {
                    _columnName = addToMapSet.DataTable.Columns[iPM].ColumnName;
                    if (_columnName.Contains("Δ"))
                        _dMinValue = Convert.ToDouble(addToMapSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), ""));
                    else
                        _dMinValue = Convert.ToDouble(addToMapSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), string.Format("[{0}]>=0", _columnName)));
                    _dMaxValue = Convert.ToDouble(addToMapSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), ""));
                    //setMapPoint(null, null);
                }
                else
                {
                    _columnName = addToMapSet.DataTable.Columns[iValue - count + 1].ColumnName;
                    if (_columnName.Contains("Δ"))
                        _dMinValue = Convert.ToDouble(addToMapSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), ""));
                    else
                        _dMinValue = Convert.ToDouble(addToMapSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), string.Format("[{0}]>=0", _columnName)));
                    _dMaxValue = Convert.ToDouble(addToMapSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), ""));
                }
                if (canSelectSpecies)//如果是point,可以选cboSpeciesTypeGIS
                {
                    cboSpeciesTypeGIS.Enabled = true;
                    cboSpeciesTypeGIS.SelectedIndex = 0;
                }
                else
                {
                    cboSpeciesTypeGIS.Enabled = false;
                    setMapPoint(null, null);
                }
                if (LanguageOld.IsSMATChina)
                {
                    ILayer iLayer = mainMap.Layers[mainMap.Layers.Count - 1];
                    iLayer.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
                    mainMap.Projection = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projChina);
                    iLayer.Reproject(mainMap.Projection);
                }
                else
                {
                    ILayer iLayer = mainMap.Layers[mainMap.Layers.Count - 1];
                    iLayer.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
                    if (CommonClass.CurrentBaseScenario != null && ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly) || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)))
                        mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD);
                    else
                        mainMap.Projection = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);
                    iLayer.Reproject(mainMap.Projection);
                }
                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                {
                    if (!cboZoomTo.Items.Contains("Data Domain"))
                        cboZoomTo.Items.Add("Data Domain");
                    cboZoomTo.SelectedIndexChanged -= cboZoomTo_SelectedIndexChanged;
                    cboZoomTo.Text = "Data Domain";
                    cboZoomTo.SelectedIndexChanged += cboZoomTo_SelectedIndexChanged;
                    //int ilat = 0;
                    //int ilon = 0;
                    double[] dlonglat = new double[4];
                    //for (int i = 0; i < dt.Columns.Count; i++)
                    //{
                    //    if (dt.Columns[i].ColumnName.ToLower().Contains("lat"))
                    //        ilat = i;
                    //    if (dt.Columns[i].ColumnName.ToLower().Contains("long"))
                    //        ilon = i;
                    //}
                    //dlonglat[0] = Convert.ToDouble(dt.Rows[0][ilon]);
                    //dlonglat[1] = Convert.ToDouble(dt.Rows[0][ilat]);
                    //dlonglat[2] = Convert.ToDouble(dt.Rows[0][ilon]);
                    //dlonglat[3] = Convert.ToDouble(dt.Rows[0][ilat]);
                    //for (int i = 1; i < dt.Rows.Count; i++)
                    //{
                    //    dlonglat[0] = Math.Min(dlonglat[0], Convert.ToDouble(dt.Rows[i][ilon]));
                    //    dlonglat[1] = Math.Min(dlonglat[1], Convert.ToDouble(dt.Rows[i][ilat]));
                    //    dlonglat[2] = Math.Max(dlonglat[2], Convert.ToDouble(dt.Rows[i][ilon]));
                    //    dlonglat[3] = Math.Max(dlonglat[3], Convert.ToDouble(dt.Rows[i][ilat]));
                    //}
                    //ProjectionInfo proj = new ProjectionInfo();
                    //if (CommonClass.currentProjisLCC())
                    //    proj = ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);
                    //else
                    //    proj = ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD);
                    //DotSpatial.Projections.Reproject.ReprojectPoints(dlonglat, null, DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984, proj, 0, dlonglat.Length / 2);
                    //mainMap.ViewExtents = new Extent
                    //{
                    //    MinX = dlonglat[0],
                    //    MinY = dlonglat[1],
                    //    MaxX = dlonglat[2],
                    //    MaxY = dlonglat[3]
                    //};
                    //mainMap.ViewExtents = mainMap.Layers[mainMap.Layers.Count - 1].Extent;
                    dlonglat[0] = mainMap.Layers[mainMap.Layers.Count - 1].Extent.MinX - 10000;//*0.995
                    dlonglat[1] = mainMap.Layers[mainMap.Layers.Count - 1].Extent.MinY - 10000;
                    dlonglat[2] = mainMap.Layers[mainMap.Layers.Count - 1].Extent.MaxX + 10000;//*1.005
                    dlonglat[3] = mainMap.Layers[mainMap.Layers.Count - 1].Extent.MaxY + 10000;
                    mainMap.ViewExtents = new Extent
                    {
                        MinX = dlonglat[0],
                        MinY = dlonglat[1],
                        MaxX = dlonglat[2],
                        MaxY = dlonglat[3]
                    };
                    if (dataDomainGIS == null)
                    {
                        dataDomainGIS = new double[4];
                        dataDomainGIS[0] = dlonglat[0];
                        dataDomainGIS[1] = dlonglat[1];
                        dataDomainGIS[2] = dlonglat[2];
                        dataDomainGIS[3] = dlonglat[3];
                    }
                    else
                    {
                        if (dlonglat[0] < dataDomainGIS[0])
                            dataDomainGIS[0] = dlonglat[0];
                        if (dlonglat[1] < dataDomainGIS[1])
                            dataDomainGIS[1] = dlonglat[1];
                        if (dlonglat[2] > dataDomainGIS[2])
                            dataDomainGIS[2] = dlonglat[2];
                        if (dlonglat[3] > dataDomainGIS[3])
                            dataDomainGIS[3] = dlonglat[3];
                    }
                }
                else
                    mainMap.ViewExtents = exLast;
                //mainMap.ZoomToMaxExtent();
                //mainMap.ZoomToPrevious();

                if (mainMap.Layers.Count - 2 >= 0 && mainMap.Layers[mainMap.Layers.Count - 2].LegendText == "SSIA Source Location")
                {
                    // Get a list of layers sorted alphabetically by LegendText.
                    //var newLayers = mainMap.Layers.OrderByDescending(l => l.LegendText).ToList();

                    // Suspending events speeds our changes up and prevents redrawing multiple times.
                    // The events will be called only once, when we call ResumeEvents().
                    //mainMap.Layers.SuspendEvents();
                    //var layer = mainMap.Layers[mainMap.Layers.Count - 2];
                    //layer.LockDispose();
                    //mainMap.Layers.RemoveAt(mainMap.Layers.Count - 2);
                    // By default, it appears some part of the layer is disposed when it is removed from the collection.
                    // If we were to use App.Map.Layers.Clear(), we would stlil need to LockDispose on each layer.
                    //while (App.Map.Layers.Any())
                    //{
                    //    var layer = App.Map.Layers[0];
                    //    layer.LockDispose();
                    //    App.Map.Layers.RemoveAt(0);
                    //}


                    var sourceLocationLayers = mainMap.Layers.Where(l => l.LegendText.Contains("SSIA Source Location")).ToList();
                    mainMap.Layers.SuspendEvents();
                    sourceLocationLayers.ForEach(l =>
                    {
                        l.LockDispose();
                        mainMap.Layers.Remove(l);
                    });
                    mainMap.Layers.AddRange(sourceLocationLayers);
                    // As we add each layer back in, in the correct order, we UnlockDispose so that the layer can be disposed
                    // at the appropriate time.
                    //foreach (IMapLayer newLayer in newLayers)
                    //{
                    //    if (newLayer.LegendText == "SSIA Source Location")
                    //    {
                    //        mainMap.Layers.Add(newLayer);
                    //        newLayer.UnlockDispose();
                    //    }
                    //}
                    mainMap.Layers.ResumeEvents();

                    for (int i = mainMap.Layers.Count - 1; i >= 0; i--)
                    {
                        if (mainMap.Layers[i].LegendText == "SSIA Source Location")
                            continue;
                        _currentLayerIndex = i;
                        break;
                    }
                    //_currentLayerIndex = mainMap.Layers.Count - 2;
                }

                #region write min max value and grid information in GIS
                if (CommonClass.modelDefinition.MinmaxValueGrid != "")
                {
                    if (ssiaDataOption == 0)
                    {
                        string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                        lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[1]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[0]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[0]) % 1000 + ")   Max = " + Convert.ToDouble(minmaxGridValue[3]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[2]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[2]) % 1000 + ")";
                        lblMinMax.Visible = true;
                    }
                    else
                    {
                        string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                        lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[2]).ToString("F3") + " at (" + Math.Round(Convert.ToDouble(minmaxGridValue[0]), 2) + "," + Math.Round(Convert.ToDouble(minmaxGridValue[1]), 2) + ")   Max = " + Convert.ToDouble(minmaxGridValue[5]).ToString("F3") + " at (" + Math.Round(Convert.ToDouble(minmaxGridValue[3]), 2) + "," + Math.Round(Convert.ToDouble(minmaxGridValue[4]), 2) + ")";
                        lblMinMax.Visible = true;
                    }
                }
                #endregion

                dt.Dispose();
                GC.Collect();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        public void changeProject(DataTable dt, string setup)
        {
            try
            {
                #region change point project
                double[] dConvertArray = null;
                List<double> lstConvertArray = new List<double>();
                ProjectionInfo p = new ProjectionInfo();
                switch (setup)
                {
                    case "USA":
                        //p = DotSpatial.Projections.KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic;
                        p = ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);
                        break;
                    case "China":
                        p = ProjectionInfo.FromProj4String(CommonClass.projChina);
                        break;
                    case "Other":
                        p = ProjectionInfo.FromProj4String(CommonClass.projOther);
                        break;
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    lstConvertArray.Add(Convert.ToDouble(dt.Rows[i][2]));
                    lstConvertArray.Add(Convert.ToDouble(dt.Rows[i][1]));
                }
                dConvertArray = lstConvertArray.ToArray();
                DotSpatial.Projections.Reproject.ReprojectPoints(dConvertArray, null,
                   DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984, p, 0, dConvertArray.Length / 2);
                CommonClass.CurrentBaseScenario.dicLatLongLambert = new Dictionary<string, string>();
                CommonClass.CurrentBaseScenario.dicLambertLatLong = new Dictionary<string, string>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string data = dConvertArray[2 * i] + "," + dConvertArray[2 * i + 1];
                    if (!CommonClass.CurrentBaseScenario.dicLatLongLambert.ContainsKey(dt.Rows[i][1] + "," + dt.Rows[i][2]))
                    {
                        CommonClass.CurrentBaseScenario.dicLatLongLambert.Add(dt.Rows[i][1] + "," + dt.Rows[i][2], data);
                        if (!CommonClass.CurrentBaseScenario.dicLambertLatLong.ContainsKey(data))
                        {
                            CommonClass.CurrentBaseScenario.dicLambertLatLong.Add(data, dt.Rows[i][0] + "," + dt.Rows[i][1] + "," + dt.Rows[i][2]);
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private int _currentLayerIndex = 1;
        private string _columnName = string.Empty;
        private double _dMinValue = 0.0;//最小值
        private double _dMaxValue = 0.0;// 最大值
        private Color[] _blendColors;

        /// <summary>
        /// 图例改变后的颜色
        /// </summary>
        public Color[] BlendColors
        {
            get { return _blendColors; }
            set { _blendColors = value; }
        }

        /// <summary>
        /// 设置map
        /// </summary>
        /// <param name="nLayer">图层序号</param>
        /// <param name="fieldName">quantifiers</param>
        private void setMapPoint(object sender, EventArgs e)
        {
            try
            {
                double min = _dMinValue;
                double max = _dMaxValue;
                colorBlend.SetValueRange(min, max, true);
                colorBlend._minPlotValue = _dMinValue;
                colorBlend._maxPlotValue = _dMaxValue;

                ResetMapColor(null, null);
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        public void ResetMapColorPolygonLayer(object sender, EventArgs e)
        {
            try
            {
                _blendColors = colorBlend.ColorArray;
                _dMaxValue = colorBlend.MaxValue;
                _dMinValue = colorBlend.MinValue;
                //colorBlend.s
                colorBlend.SetValueRange(_dMinValue, _dMaxValue, false);
                //colorBlend._minPlotValue = _dMinValue;
                //colorBlend._maxPlotValue = _dMaxValue;
                Color[] colors = new Color[_blendColors.Length];
                _blendColors.CopyTo(colors, 0);
                //Quantities+半透明
                PolygonCategoryCollection pcc = new PolygonCategoryCollection();
                int iColor = 0;
                //PolygonScheme pgs = (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbology as PolygonScheme;
                string ColumnName = _columnName;
                PolygonScheme myScheme1 = new PolygonScheme();
                //float fl = (float)0.1;
                //myScheme1.EditorSettings.StartColor = Color.Blue;
                //myScheme1.EditorSettings.StartColor.ToTransparent(fl);
                //myScheme1.EditorSettings.EndColor = Color.Red;
                //myScheme1.EditorSettings.EndColor.ToTransparent(fl);
                float fColor = (float)0.2;
                Color ctemp = new Color();
                myScheme1.EditorSettings.ClassificationType = ClassificationType.Custom;
                //myScheme1.EditorSettings.ClassificationType = ClassificationType.UniqueValues ;
                //myScheme1.EditorSettings.NumBreaks = 5;
                //myScheme1.EditorSettings.FieldName = _columnName;// "Value";
                //myScheme1.EditorSettings.UseGradient = false;
                //myScheme1.CreateCategories((mainMap.Layers[_currentLayerIndex] as IFeatureLayer).DataSet.DataTable);
                //if (myScheme1.Categories.Count == 1)
                //{

                //    //pc.Symbolizer.SetOutlineWidth(0);
                //    PointSymbolizer ps = new PointSymbolizer();
                //    ps.SetFillColor(colors[iColor]);
                //    //ps.SetOutline(Color.Transparent, 0);
                //    ps.SetFillColor(colors[iColor].ToTransparent(fl));
                //    //player.Symbology = myScheme1;

                //    (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbolizer = ps;
                //    return;

                //}
                iColor = 0;
                //foreach (PolygonCategory pc in myScheme1.Categories)
                for (int iBlend = 0; iBlend < 7; iBlend++)
                {
                    //pc.Symbolizer.SetOutlineWidth(0);
                    PolygonCategory pcin = new PolygonCategory();
                    double dnow = 0;// Math.Round(_dMinValue + ((_dMaxValue - _dMinValue) / 6.00) * Convert.ToDouble(iColor), 3);
                    double dnowUp = 0;// Math.Round(_dMinValue + ((_dMaxValue - _dMinValue) / 6.00) * Convert.ToDouble(iColor + 1), 3);
                    //------------实现value--
                    dnow = colorBlend.ValueArray[iBlend];
                    if (iBlend < 6)
                        dnowUp = colorBlend.ValueArray[iBlend + 1];
                    pcin.FilterExpression = string.Format("[{0}]>=" + dnow + " and [{0}] <" + dnowUp, ColumnName);
                    pcin.LegendText = ">=" + dnow.ToString() + " and <" + dnowUp.ToString();// string.Format("[{0}]>=" + dnow.ToString("E2") + " and [{0}] <" + dnowUp.ToString("E2"), ColumnName);
                    if (iBlend == 0)
                    {
                        pcin.FilterExpression = string.Format(" [{0}] <" + dnowUp, ColumnName);
                        //pcin.LegendText = string.Format(" [{0}] <" + dnowUp.ToString("E2"), ColumnName);
                        pcin.LegendText = "<" + dnowUp.ToString();
                    }
                    if (iBlend == 6)
                    {
                        pcin.FilterExpression = string.Format(" [{0}] >=" + dnow, ColumnName);
                        //pcin.LegendText = string.Format(" [{0}] >=" + dnow.ToString("E2"), ColumnName);
                        pcin.LegendText = ">=" + dnow.ToString();
                    }

                    //pcin.LegendText = pcin.FilterExpression;// string.Format("{0} >= " + dnow + " and {0} < " + dnowUp, strValueField);

                    //pcin.Symbolizer.SetOutline(Color.Transparent, 0);
                    //ctemp = pcin.Symbolizer.GetFillColor();
                    //pcin.Symbolizer.SetFillColor(ctemp.ToTransparent(fColor));
                    //ctemp.ToTransparent(fColor);
                    pcin.Symbolizer.SetOutline(Color.Transparent, 0);
                    //ctemp = pcin.Symbolizer.GetFillColor();
                    //pcin.Symbolizer.SetFillColor(ctemp.ToTransparent(fColor));
                    //ctemp.ToTransparent(fColor);
                    pcin.Symbolizer.SetFillColor(colors[iColor]);
                    pcc.Add(pcin);
                    iColor++;
                }
                myScheme1.ClearCategories();
                foreach (PolygonCategory pct in pcc)
                {
                    myScheme1.Categories.Add(pct);
                }
                myScheme1.AppearsInLegend = true;
                myScheme1.LegendText = _columnName;
                //player.Symbology = myScheme1;
                //if (myScheme1.LegendText == "Pooled Inci") myScheme1.LegendText = "Pooled Incidence";
                //if (myScheme1.LegendText == "Pooled Valu") myScheme1.LegendText = "Pooled Valuation";
                myScheme1.EditorSettings.ClassificationType = ClassificationType.Custom;
                (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbology = myScheme1;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        public void ResetMapColor(object sender, EventArgs e)
        {
            try
            {
                string legendText = "";
                for (; _currentLayerIndex >= 0; _currentLayerIndex--)
                {
                    legendText = mainMap.Layers[_currentLayerIndex].LegendText;
                    if (!legendText.Contains("SSIA Source Location"))
                    {
                        break;
                    }
                }
                if (_currentLayerIndex < 0) return;
                _columnName = _columnName == null ? (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbology.LegendText : _columnName;
                isPolygon = false;
                isPolygon = IsPolygon(legendText);//判断是不是polygon

                //if (isPolygon)
                //{
                //    ResetMapColorPolygonLayer(null, null);
                //    return;
                //}
                _blendColors = colorBlend.ColorArray;
                _dMaxValue = colorBlend.MaxValue;
                _dMinValue = colorBlend.MinValue;
                //colorBlend.s
                colorBlend.SetValueRange(_dMinValue, _dMaxValue, false);
                //colorBlend._minPlotValue = _dMinValue;
                //colorBlend._maxPlotValue = _dMaxValue;
                Color[] colors = new Color[_blendColors.Length];
                _blendColors.CopyTo(colors, 0);
                //Quantities+半透明
                PointCategoryCollection pcc = new PointCategoryCollection();
                int iColor = 0;
                //PolygonScheme pgs = (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbology as PolygonScheme;
                string ColumnName = _columnName;
                PointScheme myScheme1 = new PointScheme();
                //float fl = (float)0.1;
                //myScheme1.EditorSettings.StartColor = Color.Blue;
                //myScheme1.EditorSettings.StartColor.ToTransparent(fl);
                //myScheme1.EditorSettings.EndColor = Color.Red;
                //myScheme1.EditorSettings.EndColor.ToTransparent(fl);
                float fColor = (float)0.2;
                Color ctemp = new Color();
                myScheme1.EditorSettings.ClassificationType = ClassificationType.Custom;
                //myScheme1.EditorSettings.ClassificationType = ClassificationType.UniqueValues ;
                //myScheme1.EditorSettings.NumBreaks = 5;
                //myScheme1.EditorSettings.FieldName = _columnName;// "Value";
                //myScheme1.EditorSettings.UseGradient = false;
                //myScheme1.CreateCategories((mainMap.Layers[_currentLayerIndex] as IFeatureLayer).DataSet.DataTable);
                //if (myScheme1.Categories.Count == 1)
                //{

                //    //pc.Symbolizer.SetOutlineWidth(0);
                //    PointSymbolizer ps = new PointSymbolizer();
                //    ps.SetFillColor(colors[iColor]);
                //    //ps.SetOutline(Color.Transparent, 0);
                //    ps.SetFillColor(colors[iColor].ToTransparent(fl));
                //    //player.Symbology = myScheme1;

                //    (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbolizer = ps;
                //    return;

                //}
                iColor = 0;
                //foreach (PolygonCategory pc in myScheme1.Categories)
                for (int iBlend = 0; iBlend < 7; iBlend++)
                {
                    //pc.Symbolizer.SetOutlineWidth(0);
                    PointCategory pcin = new PointCategory(Color.Blue, DotSpatial.Symbology.PointShape.Ellipse, 6);
                    if (!isPolygon)
                    {
                        pcin = new PointCategory(Color.Blue, DotSpatial.Symbology.PointShape.Ellipse, 8);
                        pcin.Symbolizer.SetOutline(Color.Black, 2);
                    }
                    double dnow = 0;// Math.Round(_dMinValue + ((_dMaxValue - _dMinValue) / 6.00) * Convert.ToDouble(iColor), 3);
                    double dnowUp = 0;// Math.Round(_dMinValue + ((_dMaxValue - _dMinValue) / 6.00) * Convert.ToDouble(iColor + 1), 3);
                    //------------实现value--
                    dnow = colorBlend.ValueArray[iBlend];
                    if (iBlend < 6)
                        dnowUp = colorBlend.ValueArray[iBlend + 1];
                    pcin.FilterExpression = string.Format("[{0}]>=" + dnow + " and [{0}] <" + dnowUp, ColumnName);
                    pcin.LegendText = ">=" + dnow.ToString() + " and <" + dnowUp.ToString();// string.Format("[{0}]>=" + dnow.ToString("E2") + " and [{0}] <" + dnowUp.ToString("E2"), ColumnName);
                    if (iBlend == 0)
                    {
                        pcin.FilterExpression = string.Format(" [{0}] <" + dnowUp, ColumnName);
                        //pcin.LegendText = string.Format(" [{0}] <" + dnowUp.ToString("E2"), ColumnName);
                        pcin.LegendText = "<" + dnowUp.ToString();
                    }
                    if (iBlend == 6)
                    {
                        pcin.FilterExpression = string.Format(" [{0}] >=" + dnow, ColumnName);
                        //pcin.LegendText = string.Format(" [{0}] >=" + dnow.ToString("E2"), ColumnName);
                        pcin.LegendText = ">=" + dnow.ToString();
                    }

                    //pcin.LegendText = pcin.FilterExpression;// string.Format("{0} >= " + dnow + " and {0} < " + dnowUp, strValueField);

                    //pcin.Symbolizer.SetOutline(Color.Transparent, 0);
                    //ctemp = pcin.Symbolizer.GetFillColor();
                    //pcin.Symbolizer.SetFillColor(ctemp.ToTransparent(fColor));
                    //ctemp.ToTransparent(fColor);
                    pcin.Symbolizer.SetFillColor(colors[iColor]);

                    pcc.Add(pcin);
                    iColor++;
                }
                myScheme1.ClearCategories();
                foreach (PointCategory pct in pcc)
                {
                    myScheme1.Categories.Add(pct);
                }
                myScheme1.AppearsInLegend = true;
                myScheme1.LegendText = _columnName;
                //player.Symbology = myScheme1;
                //if (myScheme1.LegendText == "Pooled Inci") myScheme1.LegendText = "Pooled Incidence";
                //if (myScheme1.LegendText == "Pooled Valu") myScheme1.LegendText = "Pooled Valuation";
                myScheme1.EditorSettings.ClassificationType = ClassificationType.Custom;
                (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbology = myScheme1;

                if (chkChangeAllColorRange.Checked)
                {
                    #region  Apply the changes of the color blend to all layers by Yangwenwei 20151118
                    foreach (var layer in mainMap.Layers)
                    {
                        if (layer.LegendText.Contains("Source Location") ||
                        layer.LegendText.Contains("Counties") ||
                        layer.LegendText.Contains("States") ||
                        layer.LegendText.Contains("class14_region") ||
                        layer.LegendText.Contains("npsClassI") ||
                        layer.LegendText.Contains("State_epa2") ||
                        layer.LegendText.Contains("China_prov_WGS84_LCC"))
                        { continue; }

                        PointScheme newScheme = (PointScheme)(layer as IFeatureLayer).Symbology.Copy();
                        for (int i = 0; i < newScheme.Categories.Count; i++)
                        {
                            newScheme.Categories[i].FilterExpression = myScheme1.Categories[i].FilterExpression.Replace(myScheme1.LegendText, (layer as IFeatureLayer).Symbology.LegendText);
                        }
                        //foreach (var item in newScheme.Categories)
                        //{
                        //    item.FilterExpression=item.FilterExpression.Replace(myScheme1.LegendText, (layer as IFeatureLayer).Symbology.LegendText);
                        //}
                        (layer as IFeatureLayer).Symbology = newScheme;
                    }
                    #endregion
                }

                ////added by Yangwenwei 2014227
                //if (cboSpeciesTypeGIS.Enabled && dicMaxMinPoint.ContainsKey(legendText + cboSpeciesTypeGIS.Text))
                //{                    
                //    dicMaxMinPoint[legendText + cboSpeciesTypeGIS.Text][0] = _dMinValue;
                //    dicMaxMinPoint[legendText + cboSpeciesTypeGIS.Text][1] = _dMaxValue;
                //}
                //else if (dicMaxMinPoint.ContainsKey(legendText))
                //{
                //    dicMaxMinPoint[legendText][0] = _dMinValue;
                //    dicMaxMinPoint[legendText][1] = _dMaxValue;
                //}
                //else if (legendText != "")
                //{
                //    dicMaxMinPoint.Add(legendText, new double[2] { _dMinValue, _dMaxValue });
                //}

                //added by Yangwenwei 2014.3.24                
                if (cboSpeciesTypeGIS.Enabled && CommonClass.dicBlend["GIS"].Keys.Contains(legendText + cboSpeciesTypeGIS.Text))
                {
                    CommonClass.SaveBlend saveblend = new CommonClass.SaveBlend(colorBlend.ColorArray, colorBlend.ValueArray);
                    saveblend.max = _dMaxValue;
                    saveblend.min = _dMinValue;
                    CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS.Text] = saveblend;
                }
                else if (!CommonClass.dicBlend.Keys.Contains("GIS"))
                {
                    CommonClass.SaveBlend saveblend = new CommonClass.SaveBlend(colorBlend.ColorArray, colorBlend.ValueArray);
                    saveblend.max = _dMaxValue;
                    saveblend.min = _dMinValue;
                    Dictionary<string, CommonClass.SaveBlend> dic = new Dictionary<string, CommonClass.SaveBlend>();
                    dic.Add(legendText, saveblend);
                    CommonClass.dicBlend.Add("GIS", dic);
                }
                else if (CommonClass.dicBlend["GIS"].Keys.Contains(legendText))
                {
                    CommonClass.SaveBlend saveblend = new CommonClass.SaveBlend(colorBlend.ColorArray, colorBlend.ValueArray);
                    saveblend.max = _dMaxValue;
                    saveblend.min = _dMinValue;
                    CommonClass.dicBlend["GIS"][legendText] = saveblend;
                }
                else if (legendText != "")
                {
                    CommonClass.SaveBlend saveblend = new CommonClass.SaveBlend(colorBlend.ColorArray, colorBlend.ValueArray);
                    saveblend.max = _dMaxValue;
                    saveblend.min = _dMinValue;
                    CommonClass.dicBlend["GIS"].Add(legendText, saveblend);
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        public void setStandardMap()
        {
            try
            {
                if (mainMap.Layers.Count > 0 && (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "States"
                    || mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "Counties"
                    || mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region"
                     || mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "npsClassI"
                    || mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "State_epa2"
                    || mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "China_prov_WGS84_LCC"))
                {
                    if (mainMap.Layers.Count == 1)
                        mainMap.Layers.Clear();
                    else
                        return;
                }
                Extent exLast = mainMap.ViewExtents.Clone() as Extent;
                switch (cboStandardLayers.SelectedItem.ToString())
                {
                    case "US States":
                        mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\State_epa2.shp");
                        break;
                    case "US Counties":
                        mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\Counties.shp");
                        break;
                    case "Class I Area":
                        mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\Nation.shp");
                        mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\class14_region.shp");
                        //mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\npsClassI.shp");
                        break;
                    case "Class I Area and States":
                        mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\State_epa2.shp");
                        mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\class14_region.shp");
                        //mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\npsClassI.shp");
                        break;
                    case "Continental US":
                        mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\States.shp");
                        break;
                    case "China":
                        string domainShapeFile = Application.StartupPath + @"\Data\ShapeFiles\China_prov_WGS84_LCC.shp";
                        if (CommonClass.dicExampleConfiguration != null && CommonClass.dicExampleConfiguration["AnnualPM"].ContainsKey("DomainShapeFile"))
                        {
                            domainShapeFile = File.Exists(CommonClass.dicExampleConfiguration["AnnualPM"]["DomainShapeFile"]) ? CommonClass.dicExampleConfiguration["AnnualPM"]["DomainShapeFile"] : domainShapeFile;
                        }
                        mainMap.AddLayer(domainShapeFile);
                       //var  playRegions = mainMap.Layers[mainMap.Layers.Count - 1] as PolygonLayer;                 
                       // playRegions.Reproject(mainMap.Projection);                        
                       // mainMap.AddLayer(Application.StartupPath + @"\Data\ShapeFiles\China_XiAn_WGS84_LCC.shp");
                        break;
                }
                PolygonLayer playRegion = mainMap.Layers[mainMap.Layers.Count - 1] as PolygonLayer;
                playRegion.LegendItemVisible = false;
                Color fillCol = Color.Transparent;
                PolygonSymbolizer TransparentRegion = new PolygonSymbolizer(fillCol);
                //指定outline的颜色，宽度
                double width = 1;
                if (cboStandardLayers.SelectedItem.ToString() == "Class I Area" || cboStandardLayers.SelectedItem.ToString() == "Class I Area and States")
                {
                    //Color.FromArgb(116,247,255)
                    TransparentRegion.OutlineSymbolizer = new LineSymbolizer(Color.FromArgb(49, 186, 232), width);
                }
                else
                {
                    TransparentRegion.OutlineSymbolizer = new LineSymbolizer(Color.DarkBlue, width);
                }
                playRegion.Symbolizer = TransparentRegion;
                IMapFeatureLayer ifLayer = default(IMapFeatureLayer);
                ifLayer = (IMapFeatureLayer)playRegion;
                double fsize = 8.0;
                Color fcolor = Color.Black;
                Font f = new Font("Calibri", (float)fsize);
                if (cboStandardLayers.SelectedItem.ToString() == "US States" || cboStandardLayers.SelectedItem.ToString() == "Continental US")
                    mainMap.AddLabels(ifLayer, "[STATE_NAME]", f, fcolor);
                else if (cboStandardLayers.SelectedItem.ToString() == "US Counties" || cboStandardLayers.SelectedItem.ToString() == "China")
                {
                    string lbl = "Name";
                    if (ifLayer.DataSet.GetColumns().Select(c => c.ColumnName).Contains("Name"))
                        lbl = "Name";
                    else if (ifLayer.DataSet.GetColumns().Select(c => c.ColumnName).Contains("NAME"))
                        lbl = "NAME";
                    mainMap.AddLabels(ifLayer, "[" + lbl + "]", f, fcolor);
                }
                else if (cboStandardLayers.SelectedItem.ToString() == "Class I Area and States" || cboStandardLayers.SelectedItem.ToString() == "Class I Area")
                    mainMap.AddLabels(ifLayer, "[CLASS_NAME]", f, fcolor);

                //added & modified by Yangwenwei
                if (cboStandardLayers.SelectedItem.ToString() == "China")
                    mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projChina);//mainMap.Layers[mainMap.Layers.Count - 1].Projection;//DotSpatial.Projections.KnownCoordinateSystems.Projected.Asia.AsiaLambertConformalConic;
                else
                {
                    playRegion.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
                    if (CommonClass.CurrentBaseScenario != null && ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly) || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)))
                        mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD);
                    else
                        mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);//DotSpatial.Projections.KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic;
                    playRegion.Reproject(mainMap.Projection);
                }

                if (cboStandardLayers.SelectedItem.ToString() == "Class I Area" || cboStandardLayers.SelectedItem.ToString() == "Class I Area and States")
                {
                    playRegion = mainMap.Layers[mainMap.Layers.Count - 2] as PolygonLayer;
                    playRegion.LegendItemVisible = false;
                    fillCol = Color.Transparent;
                    // fillCol = Color.FromArgb(227,221,207);
                    TransparentRegion = new PolygonSymbolizer(fillCol);
                    //指定outline的颜色，宽度
                    TransparentRegion.OutlineSymbolizer = new LineSymbolizer(Color.DarkBlue, width);
                    playRegion.Symbolizer = TransparentRegion;
                    ifLayer = default(IMapFeatureLayer);
                    ifLayer = (IMapFeatureLayer)playRegion;

                    playRegion.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
                    if (CommonClass.CurrentBaseScenario != null && CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                        mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD);
                    else
                        mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);//DotSpatial.Projections.KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic;
                    playRegion.Reproject(mainMap.Projection);
                }

                if (mainMap.Layers.Count == 1 || (mainMap.Layers.Count == 2 && mainMap.Layers[0].LegendText.Contains("SSIA Source Location")))
                {
                    //added by Yangwenwei
                    if (cboStandardLayers.SelectedItem.ToString() == "China")
                    {
                        mainMap.ViewExtents = new Extent()
                        {
                            MaxX = 2114399,
                            MaxY = 2906359,
                            MinX = -3397624,
                            MinY = -2567910
                        };
                    }
                    else
                    {
                        if (!CommonClass.currentProjisLCC())
                        {
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2084597.7,
                                MaxY = 6873065.9,
                                MinX = -2728406.7,
                                MinY = 1935195.9
                            };
                        }
                        else
                        {
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2325850.8,
                                MaxY = 1275319.5,
                                MinX = -2274714.4,
                                MinY = -1604646.2
                            };
                        }
                    }
                    //mainMap.ViewExtents = mainMap.Extent;
                }
                else
                    mainMap.ViewExtents = exLast;
                mainMap.Refresh();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        public void addConfiguration()
        {
            try
            {
                string filePath = "";
                filePath = CommonClass.CurrentBaseScenario.configuration.configurationPath;
                if (!File.Exists(filePath))
                {
                    filePath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                    if (!File.Exists(filePath))
                    {
                        MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                        return;
                    }
                }
                FileStream fs = null;
                StreamReader sr = null;
                ListViewItem item = null;
                string sLine = null;
                if (listViewCFG.Columns.Count == 0)
                    this.listViewCFG.Columns.Add("Configuration", this.listViewCFG.Size.Width);
                foreach (TabPage tp in tbcFunction.TabPages)
                {
                    if (tp.Text == "Configuration & Batch")
                    {
                        this.tbcFunction.SelectedTab = tp;
                        this.listViewCFG.Items.Clear();
                        //fs = new FileStream(Path.GetDirectoryName(CommonClass.FileName) + @"\" + Path.GetFileNameWithoutExtension(CommonClass.FileName) + @"\" + Path.GetFileName(CommonClass.FileName).Replace(".proj", ".cfg"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        // if (this.tlvDataViewer.SelectedItems[0].Name == null)
                        fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        //else
                        //    fs = new FileStream(this.tlvDataViewer.SelectedItems[0].Name.ToString(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        sr = new StreamReader(fs, System.Text.Encoding.UTF8);
                        sLine = sr.ReadLine();
                        if (sLine == null) return;
                        item = new ListViewItem() { Text = sLine };
                        listViewCFG.Items.Add(item);
                        while (sLine != null)
                        {
                            sLine = sr.ReadLine();
                            if (sLine != "")
                            {
                                item = new ListViewItem() { Text = sLine };
                                listViewCFG.Items.Add(item);
                            }
                        }
                        return;
                    }
                }
                tbcFunction.TabPages.Add(tbpConfigurationBatch);
                tbcFunction.SelectedTab = tbpConfigurationBatch;

                //fs = new FileStream(Path.GetDirectoryName(CommonClass.FileName) + @"\" + Path.GetFileNameWithoutExtension(CommonClass.FileName) + @"\" + Path.GetFileName(CommonClass.FileName).Replace(".proj", ".cfg"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                sr = new StreamReader(fs, System.Text.Encoding.UTF8);
                sLine = sr.ReadLine();
                item = new ListViewItem() { Text = sLine };
                listViewCFG.Items.Add(item);
                while (sLine != null)
                {
                    sLine = sr.ReadLine();
                    if (sLine != "")
                    {
                        item = new ListViewItem() { Text = sLine };
                        listViewCFG.Items.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        public void addLog()
        {
            try
            {
                if (CommonClass.CurrentBaseScenario.log.lstLog == null
                    || CommonClass.CurrentBaseScenario.log.lstLog.Count == 0
                    || CommonClass.CurrentBaseScenario.log == null)
                    return;
                tlvLogFile.Sorting = SortOrder.None;
                TreeListViewItem itemName = new TreeListViewItem();
                TreeListViewItem itemLogMessages = new TreeListViewItem();
                foreach (TabPage tp in tbcFunction.TabPages)
                {
                    if (tp.Text == "Run Log")
                    {
                        this.tbcFunction.SelectedTab = tp;
                        tlvLogFile.Items.Clear();
                        itemName = new TreeListViewItem() { Text = CommonClass.CurrentBaseScenario.configuration.configurationName, ImageIndex = 1 };
                        itemName.Expand();
                        itemLogMessages = new TreeListViewItem();
                        for (int i = CommonClass.CurrentBaseScenario.log.lstLog.Count - 1; i >= 0; i--)
                        {
                            if (i == 0)
                                itemName.SubItems.Add(CommonClass.CurrentBaseScenario.log.lstLog[i]);
                            else
                            {
                                itemLogMessages = new TreeListViewItem() { Name = "", Text = "", ImageIndex = 2 };
                                itemName.Items.Add(itemLogMessages);
                                itemLogMessages.SubItems.Add(CommonClass.CurrentBaseScenario.log.lstLog[i]);
                            }
                        }
                        tlvLogFile.Items.Add(itemName);
                        //if (CommonClass.IsFirstLoadProject)
                        return;
                    }
                }
                tbcFunction.TabPages.Add(tbpLog);
                tbcFunction.SelectedTab = tbpLog;
                itemName = new TreeListViewItem() { Text = CommonClass.CurrentBaseScenario.configuration.configurationName };
                itemName.Expand();
                itemLogMessages = new TreeListViewItem();
                for (int i = CommonClass.CurrentBaseScenario.log.lstLog.Count - 1; i >= 0; i--)
                {
                    if (i == 0)
                        itemName.SubItems.Add(CommonClass.CurrentBaseScenario.log.lstLog[i]);
                    else
                    {
                        itemLogMessages = new TreeListViewItem() { };
                        itemName.Items.Add(itemLogMessages);
                        itemLogMessages.SubItems.Add(CommonClass.CurrentBaseScenario.log.lstLog[i]);
                    }
                }
                tlvLogFile.Items.Add(itemName);
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        #endregion

        private void btnUserGuide_Click(object sender, EventArgs e)
        {
            try
            {
                string pathManual = Application.StartupPath + @"\Data\User Manual.chm";
                string keyWord = "";

                if (Language.Localization.CurrentLanguage == "en")
                {
                    pathManual = Application.StartupPath + @"\Data\User Manual.chm";
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                            keyWord = "_6_annual_pm_analysis.htm";//"Overview.htm";
                            break;
                        case enumAnalysis.DailyPM:
                            keyWord = "_7 _daily_pm_analysis.htm";// "Sub_chapter_2_1.htm";
                            break;
                        case enumAnalysis.Ozone:
                            keyWord = "_8_ozone_analysis.htm";//"2_3_Ozone_Analysis.htm";
                            break;
                        case enumAnalysis.Visibility:
                            keyWord = "_9_visibility_analysis.htm";//2_4_Visibility_Analysis.htm";
                            break;
                        case enumAnalysis.SSIAAnnualPM:
                            keyWord = "SSIA_Annual_PM_Analysis.htm";
                            break;
                        case enumAnalysis.SSIADailyPM:
                            keyWord = "3_6_SSIA_Daily_PM_Analysis.htm";
                            break;
                        case enumAnalysis.SSIAOzone:
                            keyWord = "3_7_SSIA_Ozone_Analysis.htm";
                            break;
                    }
                }
                else if (Language.Localization.CurrentLanguage == "zh")
                {
                    pathManual = Application.StartupPath + @"\Data\User Manual_zh.chm";
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPMChina:
                            keyWord = "第7章.html";
                            break;
                        case enumAnalysis.OzoneChina:
                            keyWord = "第8章.html";
                            break;
                    }
                }


                if (keyWord != "")
                    Help.ShowHelp(this, pathManual, keyWord);
                else
                    Help.ShowHelp(this, pathManual);
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnAbout_Click(object sender, EventArgs e)
        {
            try
            {
                About ab = new About();
                ab.ShowDialog();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tbcFunction_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {

            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //---------树的双击事件-------------
        private void trvAnalysis_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                TreeNode currentNode = trvAnalysis.SelectedNode;
                if (currentNode == null) { currentNode = (sender as TreeNode); }
                if (currentNode.Name.ToLower().ToString() == "ssiamonitorinput" && !ssia_useMonitor)
                    return;
                string errorTip = "";
                StringBuilder errorBuilder = new StringBuilder("");
                #region annual
                if (pnlUserControl.Controls[0].Name == "uc_DataInputA")
                {
                    errorTip = checkDataInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region daily
                if (pnlUserControl.Controls[0].Name == "uc_DataInputD")
                {
                    errorTip = checkDataInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region ozone
                if (pnlUserControl.Controls[0].Name == "uc_DataInputOzone")
                {
                    errorTip = checkDataInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region visibility
                if (pnlUserControl.Controls[0].Name == "uc_DataInputV")
                {
                    errorTip = (pnlUserControl.Controls[0] as uc_DataInputV).checkDataInputV();// checkDataInputV();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_ChooseDesiredOutputV")
                {
                    uc_ChooseDesiredOutputV _outputV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                    if (_outputV.rbtnOldIMPROVEAlgorithmVisibility.Checked)
                    {
                        MessageBox.Show(Language.Localization.GetValue("Not currently implemented."));
                        return;
                    }
                }
                #endregion
                #region SSIA Annual
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputA")
                {
                    errorTip = checkSSIAModelInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA")
                {
                    errorTip = checkSSIAMonitorInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Daily added by Yangwenwei
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputD")
                {
                    errorTip = checkSSIAModelInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputD")
                {
                    errorTip = checkSSIAMonitorInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA O3
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputO")
                {
                    errorTip = checkSSIAModelInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputO")
                {
                    errorTip = checkSSIAMonitorInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Deposition added by Lijiabin
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputDep")
                {
                    errorTip = checkSSIAModelInputDep();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                //if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA")
                //{
                //    errorTip = checkSSIAMonitorInputA();
                //    if (errorTip != "" && errorTip.Length > 0)
                //    {
                //        errorNode(trvAnalysis.Nodes[2]);
                //        btnSaveRun.Enabled = false;
                //        MessageBox.Show(errorTip, Language.Translate("Tip"), MessageBoxButtons.OK);
                //        return;
                //    }
                //}
                #endregion
                #region Annual PM China
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataChina")
                {
                    errorTip = checkPMChinaModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataChina")
                {
                    errorTip = checkPMChinaMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_PM25SpeciesOptionChina")
                {
                    errorTip = checkPMChinaSpecies();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region Ozone China
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataOzoneChina")
                {
                    errorTip = checkOzoneChinaModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataOzoneChina")
                {
                    errorTip = checkOzoneChinaMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region BenMAP Annual PM
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_ModelData")
                {
                    errorTip = checkBenMAPAnnualPMModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_MonitorData")
                {
                    errorTip = checkBenMAPAnnualPMMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_SpeciesData")
                {
                    errorTip = checkBenMAPAnnualPMSpeciesInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                {
                    if (!File.Exists(CommonClass.shapefile))
                    {
                        errorNode(trvAnalysis.Nodes[3]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(Language.Localization.GetValue("Grid definition path does not exist!"), Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region BenMap Ozone
                if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_ModelData")
                {
                    errorTip = checkBenMAPOzoneModel();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_MonitorData")
                {
                    errorTip = checkBenMAPOzoneMonitor();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                if (errorTip != null && errorTip.Length > 0)
                {
                    MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                    return;
                }
                TreeNodeLoad();
                ////-------------------For each analysis, the Next button is not enabled when it is the last step.
                //if (pnlUserControl.Controls[0].Name == "uc_ModelDataA" || pnlUserControl.Controls[0].Name == "uc_ModelDataD"
                //    || pnlUserControl.Controls[0].Name == "uc_RRForSpatialGradientOzone" || pnlUserControl.Controls[0].Name == "uc_FilteringV")
                //{
                //btnNext.Enabled = false;
                //btnNext.Image = Resources.Next_gray;
                //}
                //else
                //{
                //    btnNext.Enabled = true;
                //    btnNext.Image = Resources.Next1;
                //}

                //------------For each analysis,the Back button is not enabled when it is the first step.
                if (pnlUserControl.Controls[0].Name == "uc_OutputA" || pnlUserControl.Controls[0].Name == "uc_OutputD"
                    || pnlUserControl.Controls[0].Name == "uc_ChooseDesiredOutputV" || pnlUserControl.Controls[0].Name == "uc_DesiredOutputOzone" || pnlUserControl.Controls[0].Name == "uc_AnalysisOption" || pnlUserControl.Controls[0].Name == "uc_ModelDataChina")
                {
                    btnBack.Enabled = false;
                    btnBack.Image = Resources.Back_gray;
                }
                else
                {
                    btnBack.Enabled = true;
                    btnBack.Image = Resources.Back;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //----------------清除当前UC的设置，恢复到原始值---------------
        private void btnClear_Click(object sender, EventArgs e)
        {
            try
            {
                switch (pnlUserControl.Controls[0].Name)
                {
                    #region annual pm
                    case "uc_OutputA":
                        uc_OutputA _outPutA = (pnlUserControl.Controls[0] as uc_OutputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA = new ChooseDesiredOutputA();
                        _outPutA.txtScenarioName.Text = "";
                        _outPutA.choStandardAnalysisA.Checked = true;
                        _outPutA.choQuarterlyModelDataA.Checked = true;
                        _outPutA.choQuarterlyModelDataUsedA.Checked = true;
                        _outPutA.choSpeciesFractionOutputA.Checked = true;
                        _outPutA.choActionsCompletionA.Checked = true;
                        break;
                    case "uc_OutputAdvancedA":
                        uc_OutputAdvancedA _outputAdvancedA = (pnlUserControl.Controls[0] as uc_OutputAdvancedA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA = new OutputChoiceAdvancedA();
                        _outputAdvancedA.choIFRMSpeA.Checked = false;
                        _outputAdvancedA.choIAdjustedFRMSpeA.Checked = false;
                        _outputAdvancedA.choBaseOnlyVNA.Checked = false;
                        _outputAdvancedA.choFutureOnlyVNA.Checked = false;
                        _outputAdvancedA.choBaseOnlyEvna.Checked = false;
                        _outputAdvancedA.choFutureOnlyEvna.Checked = false;
                        _outputAdvancedA.choQuaPointA.Checked = true;
                        _outputAdvancedA.choQuaSpatialA.Checked = false;
                        _outputAdvancedA.choQuaSpaGraAdjA.Checked = false;
                        _outputAdvancedA.choFileCA.Checked = true;
                        _outputAdvancedA.choSpeSpatialFieldA.Checked = false;
                        _outputAdvancedA.choSpeSpaGraAdjA.Checked = false;
                        _outputAdvancedA.choFileEA.Checked = true;
                        _outputAdvancedA.choDVPeriods.Checked = false;
                        _outputAdvancedA.choNeiPointA.Checked = false;
                        _outputAdvancedA.choNeiSpatialA.Checked = false;

                        _outputAdvancedA.chkDS.Checked = false;
                        _outputAdvancedA.chkDSOnlyBase.Checked = false;
                        _outputAdvancedA.chkDSOnlyFuture.Checked = false;
                        _outputAdvancedA.txtDSBurn.Text = "500";
                        _outputAdvancedA.txtDSCmaqres.Text = "12";
                        _outputAdvancedA.txtDSThin.Text = "1";
                        _outputAdvancedA.txtDSNumit.Text = "2500";
                        _outputAdvancedA.choQuaSpaDSA.Checked = false;
                        _outputAdvancedA.choSpeSpaDSA.Checked = false;
                        break;
                    case "uc_DataInputA":
                        uc_DataInputA _dataInputA = (pnlUserControl.Controls[0] as uc_DataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA = new DataInputA();
                        _dataInputA.rbtnMonitorFileA.Checked = true;
                        CommonClass.speciesMonitorFile = CommonClass.dicExampleConfiguration["AnnualPM"]["speciesMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\SpeciesForFractions2002to2015_v2.csv";//SpeciesForFractions2002to2012.csv;
                        _dataInputA.txtMonitorFileA.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                        _dataInputA.cboPointA.SelectedIndex = 0;
                        _dataInputA.cboSpatialA.SelectedIndex = 0;
                        _dataInputA.txtFractionPointA.Text = "";
                        _dataInputA.txtFractionSpatialA.Text = "";
                        CommonClass.unofficialPMFile = CommonClass.dicExampleConfiguration["AnnualPM"]["unofficialMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\PM25ForFractions2002to2017.csv";//PM25ForFractions2002to2012.csv;
                        _dataInputA.txtUnofficialMonitorA.Text = Path.GetFileName(CommonClass.unofficialPMFile);
                        CommonClass.officialPMFile = CommonClass.dicExampleConfiguration["AnnualPM"]["officialMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\official_annual-PM25_2002thru2017.csv";//official_annual-PM25_allFRM.NID2002thru2015_v2.csv//official_annual-PM25_allFRM 121013.csv";
                        _dataInputA.txtOfficialMonitorA.Text = Path.GetFileName(CommonClass.officialPMFile);
                        _dataInputA.rbtnDailyModelA.Checked = true;
                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["baselineModelDataFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2011eh.camx.grid.csv";//PM_small_USA_12km_2011.csv";
                        _dataInputA.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["forecastModelDataFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2017eh.camx.grid.csv";//PM_small_USA_12km_2018.csv";
                        _dataInputA.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                        break;
                    case "uc_SpeciesFractionsCalculationOptionsA":
                        uc_SpeciesFractionsCalculationOptionsA _speciesA = (pnlUserControl.Controls[0] as uc_SpeciesFractionsCalculationOptionsA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA = new SpeciesFractionOptionsA();
                        if (_speciesA.cboIMPROVEStartYaerA.Items.Count >= 9)
                            _speciesA.cboIMPROVEStartYaerA.SelectedIndex = 8;
                        else
                            _speciesA.cboIMPROVEStartYaerA.SelectedIndex = _speciesA.cboIMPROVEStartYaerA.Items.Count - 1;
                        if (_speciesA.cboIMPROVEEndYaerA.Items.Count >= 11)
                        {
                            _speciesA.cboIMPROVEEndYaerA.SelectedIndex = 10;
                        }
                        else
                        {
                            _speciesA.cboIMPROVEEndYaerA.SelectedIndex = _speciesA.cboIMPROVEEndYaerA.Items.Count - 1;
                        }
                        //_speciesA.cboIMPROVEEndYaerA.SelectedIndex = 0;
                        _speciesA.choIMPROVEEPADeletionsA.Checked = true;
                        _speciesA.choIMPROVEUserDeletionA.Checked = false;
                        _speciesA.nudownIMPROVEMinDaysA.Value = 11;
                        _speciesA.nudownIMPROVEMinYearsA.Value = 1;
                        _speciesA.nudownIMPROVEMinSeasonsA.Value = 1;
                        if (_speciesA.cboPMStartYaerA.Items.Count >= 9)
                            _speciesA.cboPMStartYaerA.SelectedIndex = 8;
                        else
                            _speciesA.cboPMStartYaerA.SelectedIndex = _speciesA.cboPMStartYaerA.Items.Count - 1;
                        if (_speciesA.cboPMEndYaerA.Items.Count >= 11)
                        {
                            _speciesA.cboPMEndYaerA.SelectedIndex = 10;
                        }
                        else
                        {
                            _speciesA.cboPMEndYaerA.SelectedIndex = _speciesA.cboPMEndYaerA.Items.Count - 1;
                        }
                        //_speciesA.cboPMStartYaerA.SelectedIndex = 0;
                        //_speciesA.cboPMEndYaerA.SelectedIndex = 0;
                        _speciesA.choPMEPADeletionsA.Checked = true;
                        _speciesA.choPMUserDeletionA.Checked = false;
                        _speciesA.nudownPMMinDaysA.Value = 11;
                        _speciesA.nudownPMMinYearsA.Value = 1;
                        _speciesA.nudownPMMinPointA.Value = 4;
                        _speciesA.nudownPMMinSpatialA.Value = 1;
                        #region
                        _speciesA.cboItpPM25A.SelectedIndex = 2;
                        _speciesA.cboItpSO4A.SelectedIndex = 2;
                        _speciesA.cboItpNO3A.SelectedIndex = 2;
                        _speciesA.cboItpECA.SelectedIndex = 2;
                        _speciesA.cboItpSaltA.SelectedIndex = 2;
                        _speciesA.cboItpCrustalA.SelectedIndex = 2;
                        _speciesA.cboItpDONA.SelectedIndex = 2;
                        _speciesA.cboItpOCA.SelectedIndex = 2;
                        _speciesA.cboItpNH4A.SelectedIndex = 2;
                        _speciesA.nudownPM25DistanceA.Value = 9000000000;
                        _speciesA.nudownSO4DistanceA.Value = 9000000000;
                        _speciesA.nudownNO3DistanceA.Value = 9000000000;
                        _speciesA.nudownECDistanceA.Value = 9000000000;
                        _speciesA.nudownSaltDistanceA.Value = 9000000000;
                        _speciesA.nudownCrustalDistanceA.Value = 9000000000;
                        _speciesA.nudownDONDistanceA.Value = 9000000000;
                        _speciesA.nudownOCDistanceA.Value = 9000000000;
                        _speciesA.nudownNH4DistanceA.Value = 9000000000;
                        _speciesA.rbtnDONA.Checked = true;
                        _speciesA.nudownNH4PercentageA.Value = 0;
                        _speciesA.nudownDefaultMassA.Value = 0.2M;
                        _speciesA.nudownOCmbFloorA.Value = 1;
                        _speciesA.nudownOCmbCeilingA.Value = 0.8M;
                        #endregion
                        break;
                    case "uc_PM25CalculationOptionsA":
                        uc_PM25CalculationOptionsA _pmCalculationA = (pnlUserControl.Controls[0] as uc_PM25CalculationOptionsA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA = new PM25CalculationOptionsA();
                        if (_pmCalculationA.cboStartYearA.Items.Count >= 8)//12
                            _pmCalculationA.cboStartYearA.SelectedIndex = 7;
                        else
                            _pmCalculationA.cboStartYearA.SelectedIndex = _pmCalculationA.cboStartYearA.Items.Count - 1;
                        if (_pmCalculationA.cboEndYearA.Items.Count >= 12)//14
                        {
                            _pmCalculationA.cboEndYearA.SelectedIndex = 11;
                        }
                        else
                        {
                            _pmCalculationA.cboEndYearA.SelectedIndex = _pmCalculationA.cboEndYearA.Items.Count - 1;
                        }
                        //_pmCalculationA.cboStartYearA.SelectedIndex = 0;
                        //_pmCalculationA.cboEndYearA.SelectedIndex = 0;
                        _pmCalculationA.rbtnOfficialA.Checked = true;
                        _pmCalculationA.nudownMinDaysA.Value = 11;
                        _pmCalculationA.nudownMinQuarterA.Value = 12;
                        _pmCalculationA.nudownMinNumDV.Value = 1;
                        _pmCalculationA.txtRequiredA.Text = "None selected";
                        _pmCalculationA.rbtnNH4DONA.Checked = true;
                        break;
                    case "uc_ModelDataA":
                        uc_ModelDataA _modelA = (pnlUserControl.Controls[0] as uc_ModelDataA);
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA == null)
                            (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA = new ModelDataOptionsA();
                        _modelA.cboPointGridA.SelectedIndex = 1;
                        _modelA.cboSpatialGridA.SelectedIndex = 0;
                        break;
                    #endregion
                    #region daily added by dian
                    case "uc_OutputD":
                        uc_OutputD _outputD = (pnlUserControl.Controls[0] as uc_OutputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD == null)
                        { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD = new ChooseDesiredOutputD(); }
                        _outputD.txtScenarioNameDily.Text = "";
                        _outputD.choStandardAnalysisD.Checked = true;
                        _outputD.choQuarterlyPeakModelDataD.Checked = true;
                        _outputD.choSpeciesFractionsFileD.Checked = true;
                        _outputD.choActionsExtractAllD.Checked = true;
                        break;
                    case "uc_OutputAdvancedD":
                        uc_OutputAdvancedD _outputAdvancedD = (pnlUserControl.Controls[0] as uc_OutputAdvancedD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD == null)
                            (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD = new OutputChoiceAdvancedD();
                        _outputAdvancedD.choQuarterlyAvgFilePointD.Checked = true;
                        _outputAdvancedD.choFileCD.Checked = true;
                        _outputAdvancedD.choFileED.Checked = true;
                        _outputAdvancedD.choDVPeriodsD.Checked = false;
                        _outputAdvancedD.choNeighborFilePointD.Checked = false;
                        break;
                    case "uc_DataInputD":
                        uc_DataInputD _dataInputD = (pnlUserControl.Controls[0] as uc_DataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD == null)
                        { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD = new DataInputD(); }
                        _dataInputD.rbtnSpeciesMonitorD.Checked = true;
                        _dataInputD.rbtnSpeciesFractionD.Checked = false;
                        CommonClass.speciesMonitorFile = CommonClass.dicExampleConfiguration["DailyPM"]["speciesMonitorDataFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\SpeciesForFractions2002to2015_v2.csv";//SpeciesForFractions2002to2012.csv;
                        _dataInputD.txtSpeciesMonitorFileD.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                        _dataInputD.cboSpeciesFractionsPointD.SelectedIndex = 0;
                        _dataInputD.cboSpeciesFractionsSpatialD.SelectedIndex = 0;
                        CommonClass.speciesFractionFilePoint = CommonClass.dicExampleConfiguration["DailyPM"]["unofficialMonitorFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\PM25ForFractions2002to2015_v2.csv";//PM25ForFractions2002to2012.csv;
                        _dataInputD.txtUnofficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.speciesFractionFilePoint);
                        CommonClass.speciesFractionFileSpatial = CommonClass.dicExampleConfiguration["DailyPM"]["officialMonitorFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\official_24-hr-PM25.NID2002thru2015_v2.csv";
                        _dataInputD.txtOfficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.speciesFractionFileSpatial);
                        _dataInputD.rbtnDailyModelDataD.Checked = true;
                        _dataInputD.rbtnQuarterlyPeakModelDataD.Checked = false;
                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["DailyPM"]["baselineModelFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2011eh.camx.grid.csv";//PM_small_USA_12km_2011.csv";
                        _dataInputD.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["DailyPM"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2017eh.camx.grid.csv";//PM_small_USA_12km_2018.csv";
                        _dataInputD.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                        break;
                    case "uc_SpeciesFrctionD":
                        uc_SpeciesFrctionD _speciesFrctionD = (pnlUserControl.Controls[0] as uc_SpeciesFrctionD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD == null)
                        { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD = new SpeciesFractionOptionsD(); }
                        if (_speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Items.Count >= 9)
                            _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.SelectedIndex = 8;
                        else
                            _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.SelectedIndex = _speciesFrctionD.cboIMPROVEMonitorStartYearDaily.Items.Count - 1;
                        if (_speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Items.Count >= 11)
                            _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.SelectedIndex = 10;
                        else
                            _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.SelectedIndex = _speciesFrctionD.cboIMPROVEMonitorEndYearDaily.Items.Count - 1;
                        if (_speciesFrctionD.cboPMMonitorStartYearDaily.Items.Count >= 9)
                            _speciesFrctionD.cboPMMonitorStartYearDaily.SelectedIndex = 8;
                        else
                            _speciesFrctionD.cboPMMonitorStartYearDaily.SelectedIndex = _speciesFrctionD.cboPMMonitorStartYearDaily.Items.Count - 1;
                        if (_speciesFrctionD.cboPMMonitorEndYearDaily.Items.Count >= 11)
                            _speciesFrctionD.cboPMMonitorEndYearDaily.SelectedIndex = 10;
                        else
                            _speciesFrctionD.cboPMMonitorEndYearDaily.SelectedIndex = _speciesFrctionD.cboPMMonitorEndYearDaily.Items.Count - 1;
                        //_speciesFrctionD.cboIMPROVEMonitorStartYearDaily.SelectedIndex = 0;
                        //_speciesFrctionD.cboIMPROVEMonitorEndYearDaily.SelectedIndex = 0;
                        //_speciesFrctionD.cboPMMonitorStartYearDaily.SelectedIndex = 0;
                        //_speciesFrctionD.cboPMMonitorEndYearDaily.SelectedIndex = 0;
                        _speciesFrctionD.choEPASpecifiedIMPROVEDaily.Checked = true;
                        _speciesFrctionD.choEPASpecifiedPMDaily.Checked = true;
                        _speciesFrctionD.choUserSpecifiedIMPROVEDaily.Checked = false;
                        _speciesFrctionD.choUserSpecifiedPMDaily.Checked = false;
                        _speciesFrctionD.nudownMinDaysIMPROVEDaily.Value = 11;
                        _speciesFrctionD.nudownMinQuartersIMPROVEDaily.Value = 1;
                        _speciesFrctionD.nudownMinYearsIMPROVEDaily.Value = 1;
                        _speciesFrctionD.nudownMinDaysPMDaily.Value = 11;
                        _speciesFrctionD.nudownMinQuartersPMDaily.Value = 4;
                        _speciesFrctionD.nudownMinYearsPMDaily.Value = 1;
                        #region
                        _speciesFrctionD.rbtnTopPercMonitorIMPROVEDaily.Checked = true;
                        _speciesFrctionD.rbtnTopPercMonitorPMDaily.Checked = true;
                        _speciesFrctionD.nudownTopPercMonitorIMPROVEDaily.Value = 10;
                        _speciesFrctionD.nudownAllMonitorGreaterIMPROVEDaily.Value = 0;
                        _speciesFrctionD.nudownMinNumAboveIMPROVEDaily.Value = 1;
                        _speciesFrctionD.nudownTopNumMonitorIMPROVEDaily.Value = 25;
                        _speciesFrctionD.nudownTopPercMonitorPMDaily.Value = 10;
                        _speciesFrctionD.nudownAllMonitorGreaterPMDaily.Value = 0;
                        _speciesFrctionD.nudownMinNumAbovePMDaily.Value = 1;
                        _speciesFrctionD.nudownTopNumMonitorPMDaily.Value = 25;
                        _speciesFrctionD.cboPM25InterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboSO4InterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboNO3InterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboECInterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboSaltInterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboCrastalInterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboDONInterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboOCInterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.cboNH4InterpolationDaily.SelectedIndex = 2;
                        _speciesFrctionD.nudownPM25DistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownSO4DistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownNO3DistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownECDistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownSaltDistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownCrustalDistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownDONDistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownOCDistanceDaily.Value = 9000000000;
                        _speciesFrctionD.nudownNH4DistanceDaily.Value = 9000000000;
                        _speciesFrctionD.cboPM25InterpolationDaily.Enabled = false;
                        _speciesFrctionD.nudownPM25DistanceDaily.Enabled = false;
                        _speciesFrctionD.cboNH4InterpolationDaily.Enabled = false;
                        _speciesFrctionD.nudownNH4DistanceDaily.Enabled = false;
                        _speciesFrctionD.rbtnDONValueDaily.Checked = true;
                        _speciesFrctionD.nudownNH4PercDaily.Enabled = false;
                        _speciesFrctionD.nudownDefaultBMDaily.Value = (decimal)0.2;
                        _speciesFrctionD.nudownOCmbFloorDaily.Value = 1;
                        _speciesFrctionD.nudownOCmbCeilingDaily.Value = (decimal)0.8;
                        #endregion
                        break;
                    case "uc_PM25CalculationD":
                        uc_PM25CalculationD _pmCalculationD = (pnlUserControl.Controls[0] as uc_PM25CalculationD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD == null)
                        { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD = new PM25CalculationOptionsD(); }
                        if (_pmCalculationD.cboStartYearD.Items.Count > 8)
                            _pmCalculationD.cboStartYearD.SelectedIndex = 7;
                        else
                            _pmCalculationD.cboStartYearD.SelectedIndex = _pmCalculationD.cboStartYearD.Items.Count - 1;
                        if (_pmCalculationD.cboEndYearD.Items.Count > 12)
                            _pmCalculationD.cboEndYearD.SelectedIndex = 11;
                        else
                            _pmCalculationD.cboEndYearD.SelectedIndex = _pmCalculationD.cboEndYearD.Items.Count - 1;
                        //_pmCalculationD.cboStartYearD.SelectedIndex = 0;
                        //_pmCalculationD.cboEndYearD.SelectedIndex = 0;
                        _pmCalculationD.nudownMinNumDVD.Value = 1;
                        _pmCalculationD.txtRequiredDVD.Text = "None selected";
                        _pmCalculationD.rbtnCalculateNH4byDON.Checked = true;
                        break;
                    case "uc_ModelDataD":
                        uc_ModelDataD _modelDataD = (pnlUserControl.Controls[0] as uc_ModelDataD);
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD == null)
                        { (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD = new ModelDataOptionsD(); }
                        _modelDataD.cboGridPointModelOptionDaily.SelectedIndex = 0;
                        _modelDataD.cboStatisticMethodDaily.SelectedIndex = 0;
                        _modelDataD.choGridforSpatialForecast.SelectedIndex = 0;
                        _modelDataD.rbtnTopPerceRRFDaily.Checked = true;
                        _modelDataD.nudownTopPerceRRFDaily.Value = 10;
                        _modelDataD.nudownAllDailyGreaterRRFDaily.Value = 0;
                        _modelDataD.nudownMinNumDaysGreaterRRFDaily.Value = 1;
                        _modelDataD.nudownTopNumRRFDaily.Value = 25;
                        break;
                    #endregion
                    #region Ozone added by sclong 20120916
                    case "uc_DesiredOutputOzone":
                        uc_DesiredOutputOzone _desiredOutputOzone = (pnlUserControl.Controls[0] as uc_DesiredOutputOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO = new ChooseDesiredOutputO();
                        _desiredOutputOzone.txtScenarioOzone.Text = "";
                        _desiredOutputOzone.choPointForecastOzone.Checked = true;
                        _desiredOutputOzone.choQuarterlyModelData.Checked = true;
                        _desiredOutputOzone.choSpatialOzone.Checked = false;
                        _desiredOutputOzone.choSpatialGradAdjOzone.Checked = false;
                        _desiredOutputOzone.choBaseOnlyVNAOzone.Checked = false;
                        _desiredOutputOzone.choFutureOnlyVNAOzone.Checked = false;
                        _desiredOutputOzone.chkDS.Checked = false;
                        _desiredOutputOzone.txtDSBurn.Text = "500";
                        _desiredOutputOzone.txtDSCmaqres.Text = "12";
                        _desiredOutputOzone.txtDSNumit.Text = "2500";
                        _desiredOutputOzone.txtDSThin.Text = "1";

                        _desiredOutputOzone.choBaseOnlyEvnaOzone.Checked = false;
                        _desiredOutputOzone.choFutureOnlyEvnaOzone.Checked = false;
                        //_desiredOutputOzone.choSpatialForecastOzone.Checked = false;
                        //_desiredOutputOzone.choSpatialGradAdjForecastOzone.Checked = false;
                        _desiredOutputOzone.choNeighborFileSpatial.Checked = false;
                        _desiredOutputOzone.choExtractAllOzone.Checked = true;
                        _desiredOutputOzone.choDVPeriods.Checked = false;
                        break;
                    case "uc_DataInputOzone":
                        uc_DataInputOzone _dataInputOzone = (pnlUserControl.Controls[0] as uc_DataInputOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO = new DataInputO();
                        CommonClass.ozoneMonitorFile = CommonClass.dicExampleConfiguration["Ozone"]["ozoneMonitorDataFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\SMAT_OZONE_MAX4DV_STD70_2002_2015.CSV";//MATS_OZONE_DV_2012_V2_off.csv";
                        _dataInputOzone.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                        _dataInputOzone.cboCMAQOzone.Checked = false;
                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["Ozone"]["baselineModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2011.csv";
                        _dataInputOzone.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["Ozone"]["forecastModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2018.csv";
                        _dataInputOzone.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        _dataInputOzone.cboGridOzone.SelectedIndex = 1;//1 x 1
                        _dataInputOzone.cboStatisticOzone.SelectedIndex = 2;//Maximum-paired in space
                        break;
                    case "uc_FilteringorInterpolationOzone":
                        uc_FilteringorInterpolationOzone _filteringorInterpolationOzone = (pnlUserControl.Controls[0] as uc_FilteringorInterpolationOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO = new FilteringInterpolationO();
                        if (_filteringorInterpolationOzone.cboStartYearOzone.Items.Count >= 10)
                            _filteringorInterpolationOzone.cboStartYearOzone.SelectedIndex = 9;
                        else
                            _filteringorInterpolationOzone.cboStartYearOzone.SelectedIndex = _filteringorInterpolationOzone.cboStartYearOzone.Items.Count - 1;
                        if (_filteringorInterpolationOzone.cboEndYearOzone.Items.Count >= 12)
                            _filteringorInterpolationOzone.cboEndYearOzone.SelectedIndex = 11;
                        else
                            _filteringorInterpolationOzone.cboEndYearOzone.SelectedIndex = _filteringorInterpolationOzone.cboEndYearOzone.Items.Count - 1;
                        //_filteringorInterpolationOzone.cboStartYearOzone.SelectedIndex = 0;
                        //_filteringorInterpolationOzone.cboEndYearOzone.SelectedIndex = 0;
                        _filteringorInterpolationOzone.nudownMinNumDVO.Value = 1;
                        _filteringorInterpolationOzone.txtRequiredDVOzone.Text = "None selected";
                        _filteringorInterpolationOzone.cboDefaultItpOzone.SelectedIndex = 1;
                        _filteringorInterpolationOzone.choMaxItpDistanceOzone.Checked = false;
                        _filteringorInterpolationOzone.nudownMaxItpDistanceOzone.Value = 100;
                        break;
                    case "uc_RRForSpatialGradientOzone":
                        uc_RRForSpatialGradientOzone _rrforSpatialGradientOzone = (pnlUserControl.Controls[0] as uc_RRForSpatialGradientOzone);
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO == null)
                            (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO = new RRFSpatialGradientO();
                        _rrforSpatialGradientOzone.rbtnInitial.Checked = false;
                        _rrforSpatialGradientOzone.rbtnTopX.Checked = true;
                        _rrforSpatialGradientOzone.txtInitialValueOzone.Text = "85";
                        _rrforSpatialGradientOzone.txtAboveThresholdOzone.Text = "10";
                        _rrforSpatialGradientOzone.txtTopX.Text = "10";
                        _rrforSpatialGradientOzone.txtAllowableValueOzone.Text = "60";
                        _rrforSpatialGradientOzone.txtAboveAllowableThresholdOzone.Text = "5";
                        _rrforSpatialGradientOzone.choEnableBackstopOzone.Checked = false;
                        _rrforSpatialGradientOzone.txtBackstopMinOzone.Text = "0";
                        _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Value = 1;
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays > 0)
                        {
                            _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                            _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                            _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO.maxOzoneModelDays;
                        }
                        else
                        {
                            _rrforSpatialGradientOzone.nudownSubrangeFirstOzone.Maximum = 366;
                            _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Maximum = 366;
                            _rrforSpatialGradientOzone.nudownSubrangeLastOzone.Value = 366;
                        }
                        _rrforSpatialGradientOzone.choPairDaysOzone.Checked = false;
                        _rrforSpatialGradientOzone.txtStartValueOzone.Text = "1";
                        _rrforSpatialGradientOzone.txtEndValueOzone.Text = "5";
                        break;
                    #endregion
                    #region Visibility added by sclong 20120916
                    case "uc_ChooseDesiredOutputV":
                        #region uc_ChooseDesiredOutputV
                        uc_ChooseDesiredOutputV _outPutV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV == null)
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV = new ChooseDesiredOutputV();
                        _outPutV.txtScenarioNameVisibility.Text = "";
                        _outPutV.choVisibilityLevels.Checked = true;
                        _outPutV.rbtnOldIMPROVEAlgorithmVisibility.Checked = false;
                        _outPutV.rbtnNewIMPROVEAlgorithmVisibility.Checked = true;
                        _outPutV.rbtnModelGridCellatMonitorVisi.Checked = true;
                        _outPutV.rbtnModelGridCellatClass1Visi.Checked = false;
                        _outPutV.choExtractAllVisibility.Checked = true;
                        #endregion
                        break;
                    case "uc_DataInputV":
                        #region uc_DataInputV
                        uc_DataInputV _dataInputV = (pnlUserControl.Controls[0] as uc_DataInputV);
                        _dataInputV.InitializeControl();
                        #endregion
                        break;
                    case "uc_FilteringV":
                        #region uc_FilteringV
                        uc_FilteringV _filteringV = (pnlUserControl.Controls[0] as uc_FilteringV);
                        //_filteringV.cboStartYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorData.Distinct().ToList();
                        //_filteringV.cboEndYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorData.Distinct().ToList();
                        //_filteringV.cboBaseYearVisibility.DataSource = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV.lstMonitorData.Distinct().ToList();
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV == null)
                            (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV = new FilteringV();
                        if (_filteringV.cboStartYearVisibility.Items.Count > 11)
                            _filteringV.cboStartYearVisibility.SelectedIndex = 10;
                        else
                            _filteringV.cboStartYearVisibility.SelectedIndex = _filteringV.cboStartYearVisibility.Items.Count - 1;
                        if (_filteringV.cboEndYearVisibility.Items.Count > 13)
                            _filteringV.cboEndYearVisibility.SelectedIndex = 12;
                        else
                            _filteringV.cboEndYearVisibility.SelectedIndex = _filteringV.cboEndYearVisibility.Items.Count - 1;
                        if (_filteringV.cboBaseYearVisibility.Items.Count > 12)
                            _filteringV.cboBaseYearVisibility.SelectedIndex = 11;
                        else
                            _filteringV.cboBaseYearVisibility.SelectedIndex = _filteringV.cboBaseYearVisibility.Items.Count - 1;
                        //_filteringV.cboStartYearVisibility.SelectedIndex = 0;
                        //_filteringV.cboEndYearVisibility.SelectedIndex = 0;
                        //_filteringV.cboBaseYearVisibility.SelectedIndex = 0;
                        _filteringV.txtMinYearVisibility.Text = "3";
                        #endregion
                        break;
                    #endregion
                    #region SSIA
                    case "uc_AnalysisOption":
                        if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                        {
                            uc_AnalysisOption _optionA = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA = new SSIAAnalysisOption();
                            _optionA.choUseModelFRMData.Checked = true;
                            _optionA.rbtnGridOnly.Checked = true;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                        {
                            uc_AnalysisOption _optionA = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD = new SSIAAnalysisOption();
                            _optionA.choUseModelFRMData.Checked = true;
                            _optionA.rbtnGridOnly.Checked = true;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                        {
                            uc_AnalysisOption _optionA = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO = new SSIAAnalysisOption();
                            _optionA.choUseModelFRMData.Checked = true;
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)    //added by Lijiabin
                        {
                            uc_AnalysisOption _optionA = (pnlUserControl.Controls[0] as uc_AnalysisOption);
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep = new SSIAAnalysisOption();
                            _optionA.choUseModelFRMData.Checked = false;
                            _optionA.txtScenarioName.Text = "";
                            //_optionA.rbtnGridOnly.Checked = true;
                        }
                        break;
                    case "uc_ModelDataInputA":
                        uc_ModelDataInputA _modelDataA = (pnlUserControl.Controls[0] as uc_ModelDataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA = new SSIAModelDataInputA();
                        if (!(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly)
                        {
                            _modelDataA.rbtnDailyModelA.Checked = true;
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["baselineModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                            _modelDataA.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["forecastModelFile"]; //Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                            _modelDataA.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        if (!(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly)
                        {
                            CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["dispersionModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                            _modelDataA.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                        }
                        CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["sourceCoordinatesFile"]; //Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                        _modelDataA.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        break;
                    case "uc_ModelDataInputD":
                        uc_ModelDataInputD _modelDataSSIAd = (pnlUserControl.Controls[0] as uc_ModelDataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD = new SSIAModelDataInputD();
                        if (!(CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)
                        {
                            _modelDataSSIAd.rbtnDailyModelDataD.Checked = true;
                            CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["baselineModelFile"]; // Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_BASE.csv";
                            _modelDataSSIAd.txtBaselineFileD.Text = Path.GetFileName(CommonClass.baseModelFile);
                            CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["forecastModelFile"]; // Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.PM.4ATL1.2007ee_07f_ALT.csv";
                            _modelDataSSIAd.txtForecastFileD.Text = Path.GetFileName(CommonClass.futureModelFile);
                        }
                        if (!(CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useGridOnly)
                        {
                            CommonClass.dispersionModelFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["dispersionModelFile"]; // Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\DAILY_SOURCE.PST";
                            _modelDataSSIAd.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                        }
                        _modelDataSSIAd.cboGridPointModelOptionDaily.SelectedIndex = 0;
                        //_modelDataSSIAd.cboGridforSpatialForecast.SelectedIndex = 0;
                        _modelDataSSIAd.cboStatisticMethodDaily.SelectedIndex = 0;
                        _modelDataSSIAd.rbtnTopPerceRRFDaily.Checked = true;
                        _modelDataSSIAd.nudownTopPerceRRFDaily.Value = 10;
                        _modelDataSSIAd.nudownAllDailyGreaterRRFDaily.Value = 0;
                        _modelDataSSIAd.nudownMinNumDaysGreaterRRFDaily.Value = 1;
                        _modelDataSSIAd.nudownTopNumRRFDaily.Value = 25;
                        CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["sourceCoordinatesFile"]; // Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                        _modelDataSSIAd.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        break;
                    case "uc_ModelDataInputO":
                        uc_ModelDataInputO _modelDataSSIAo = (pnlUserControl.Controls[0] as uc_ModelDataInputO);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).modelInputO = new SSIAModelDataInputO();
                        _modelDataSSIAo.choCMAQOzone.Checked = false;
                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["baselineModelFile"]; //  Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.O3.4ATL1.2007ee_07f_BASE.csv";
                        _modelDataSSIAo.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["forecastModelFile"]; // Application.StartupPath + @"\Data\SampleData\SSIA\Grid\mats.O3.4ATL1.2007ee_07f_ALT.csv";
                        _modelDataSSIAo.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIAOzone"]["sourceCoordinatesFile"]; //  Application.StartupPath + @"\Data\SampleData\SSIA\Source Coordinate.csv";
                        _modelDataSSIAo.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        break;
                    case "uc_ModelDataInputDep":                                                                          //added by Lijiabin
                        uc_ModelDataInputDep _modelDataDep = (pnlUserControl.Controls[0] as uc_ModelDataInputDep);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).modelInputDep = new SSIAModelDataInputDep();
                        //if (!(CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionA.useDispersionOnly)
                        //{
                        _modelDataDep.rbtnDailyModelDataDep.Checked = true;
                        _modelDataDep.rbtnQuarterlyModelDataDep.Checked = false;
                        _modelDataDep.rbtnQuarterlyModelDataDep.Enabled = false;
                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["SSIADeposition"]["baselineModelFile"];//Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_baseline.csv";
                        _modelDataDep.txtBaselineDep.Text = Path.GetFileName(CommonClass.baseModelFile);
                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["SSIADeposition"]["forecastModelFile"];// Application.StartupPath + @"\Data\SampleData\SSIA\Deposition\mats.TDEP.12WUS1.2011eh_v6_11g+25fake3000_13.csv";
                        _modelDataDep.txtForecastDep.Text = Path.GetFileName(CommonClass.futureModelFile);
                        //}
                        //if (!(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useGridOnly)
                        //{
                        //    CommonClass.dispersionModelFile = Application.StartupPath + @"\Data\SampleData\SSIA\Dispersion\SOURCE_ANNUAL.PLT";
                        //    _modelDataA.txtDispersion.Text = Path.GetFileName(CommonClass.dispersionModelFile);
                        //}
                        CommonClass.ssiasourcefile = CommonClass.dicExampleConfiguration["SSIADeposition"]["sourceCoordinatesFile"];// Application.StartupPath + @"\Data\SampleData\Deposition\mats.sourcecoords.12WUS1.tag013.csv";
                        _modelDataDep.txtSourceFile.Text = Path.GetFileName(CommonClass.ssiasourcefile);
                        break;
                    case "uc_MonitorDataInputA":
                        uc_MonitorDataInputA _monitorDataA = (pnlUserControl.Controls[0] as uc_MonitorDataInputA);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA = new SSIAMonitorDataInputA();
                        CommonClass.officialPMFile = CommonClass.dicExampleConfiguration["SSIAAnnualPM"]["officialMonitorFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\official_annual-PM25_2002thru2017.csv";//official_annual-PM25_allFRM.NID2002thru2015_v2.csv//official_annual-PM25_allFRM 121013.csv";
                        _monitorDataA.cboStartYearA.DataSource = null;
                        _monitorDataA.cboEndYearA.DataSource = null;
                        CommonClass.getmonitorYear("");
                        _monitorDataA.txtOfficialMonitorA.Text = Path.GetFileName(CommonClass.officialPMFile);
                        _monitorDataA.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        _monitorDataA.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        if (_monitorDataA.cboStartYearA.Items.Count > 7)
                            _monitorDataA.cboStartYearA.SelectedIndex = 6;
                        else
                            _monitorDataA.cboStartYearA.SelectedIndex = _monitorDataA.cboStartYearA.Items.Count - 1;
                        if (_monitorDataA.cboEndYearA.Items.Count > 11)
                        {
                            _monitorDataA.cboEndYearA.SelectedIndex = 10;
                        }
                        else
                        {
                            _monitorDataA.cboEndYearA.SelectedIndex = _monitorDataA.cboEndYearA.Items.Count - 1;
                        }
                        if (_monitorDataA.choVNA.Enabled)
                            _monitorDataA.choVNA.Checked = true;
                        if (_monitorDataA.choEVNA.Enabled)
                            _monitorDataA.choEVNA.Checked = true;
                        break;
                    case "uc_MonitorDataInputD":
                        uc_MonitorDataInputD _monitorDataD = (pnlUserControl.Controls[0] as uc_MonitorDataInputD);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD = new SSIAMonitorDataInputD();
                        CommonClass.officialPMFile = CommonClass.dicExampleConfiguration["SSIADailyPM"]["officialMonitorFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\official_24-hr-PM25.NID2002thru2015_v2.csv";
                        _monitorDataD.cboStartYearD.DataSource = null;
                        _monitorDataD.cboEndYearD.DataSource = null;
                        CommonClass.getmonitorYear("");
                        _monitorDataD.txtOfficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.officialPMFile);
                        _monitorDataD.txtOfficialMonitorDataFileD.Text = Path.GetFileName(CommonClass.officialPMFile);
                        _monitorDataD.cboStartYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        _monitorDataD.cboEndYearD.DataSource = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.lstPMCalculationMonitorDataYears.Distinct().ToList();
                        if (_monitorDataD.cboStartYearD.Items.Count > 7)
                            _monitorDataD.cboStartYearD.SelectedIndex = 6;
                        else
                            _monitorDataD.cboStartYearD.SelectedIndex = _monitorDataD.cboStartYearD.Items.Count - 1;
                        if (_monitorDataD.cboEndYearD.Items.Count > 11)
                        {
                            _monitorDataD.cboEndYearD.SelectedIndex = 10;
                        }
                        else
                        {
                            _monitorDataD.cboEndYearD.SelectedIndex = _monitorDataD.cboEndYearD.Items.Count - 1;
                        }
                        _monitorDataD.choVNA.Checked = true;
                        _monitorDataD.choEVNA.Checked = true;
                        break;
                    case "uc_MonitorDataInputO":
                        uc_MonitorDataInputO _monitorDataO = (pnlUserControl.Controls[0] as uc_MonitorDataInputO);
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO == null)
                            (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO = new SSIAMonitorDataInputO();
                        CommonClass.ozoneMonitorFile = CommonClass.dicExampleConfiguration["SSIAOzone"]["officialMonitorFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\SMAT_OZONE_MAX4DV_STD70_2002_2015.CSV";//MATS_OZONE_DV_2012_V2_off.csv";
                        _monitorDataO.cboStartYearOzone.Items.Clear();
                        _monitorDataO.cboEndYearOzone.Items.Clear();
                        CommonClass.getmonitorYear("");
                        _monitorDataO.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);

                        (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData.Sort();
                        List<string> year = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.lstOzoneMonitorData;
                        for (int i = 0; i < year.Count; i++)
                        {
                            _monitorDataO.cboStartYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                            _monitorDataO.cboEndYearOzone.Items.Add((Convert.ToInt32(year[i]) - 2).ToString() + "-" + year[i]);
                        }

                        if (_monitorDataO.cboStartYearOzone.Items.Count >= 5)
                            _monitorDataO.cboStartYearOzone.SelectedIndex = 4;
                        else
                            _monitorDataO.cboStartYearOzone.SelectedIndex = _monitorDataO.cboStartYearOzone.Items.Count - 1;
                        if (_monitorDataO.cboEndYearOzone.Items.Count >= 7)
                            _monitorDataO.cboEndYearOzone.SelectedIndex = 6;
                        else
                            _monitorDataO.cboEndYearOzone.SelectedIndex = _monitorDataO.cboEndYearOzone.Items.Count - 1;
                        _monitorDataO.choVNA.Checked = true;
                        _monitorDataO.choEVNA.Checked = true;
                        _monitorDataO.cboGridOzone.SelectedIndex = 1;
                        _monitorDataO.cboStatisticOzone.SelectedIndex = 2;

                        _monitorDataO.chkDS.Checked = false;
                        _monitorDataO.txtDSThin.Text = "1";
                        _monitorDataO.txtDSNumit.Text = "2500";
                        _monitorDataO.txtDSCmaqres.Text = "12";
                        _monitorDataO.txtDSBurn.Text = "500";
                        break;
                    case "uc_CalculationOption":
                        uc_CalculationOption _cal = (pnlUserControl.Controls[0] as uc_CalculationOption);
                        if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                            _cal.txtNAAQS.Text = "12";
                            _cal.txtThreshold.Text = "1";
                            _cal.nupdStartPercentage.Value = 0;
                            _cal.nupdEndPercentage.Value = 100;
                            _cal.lblNAAQS_Unit.Text = "(μg/m3) ";
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                            _cal.txtNAAQS.Text = "12";
                            _cal.txtThreshold.Text = "1";
                            _cal.nupdStartPercentage.Value = 95;
                            _cal.nupdEndPercentage.Value = 98;
                            _cal.lblNAAQS_Unit.Text = "(μg/m3) ";
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption = new SSIACalculationOption();
                            _cal.txtNAAQS.Text = "70";
                            _cal.txtThreshold.Text = "1";
                            _cal.nupdStartPercentage.Value = 100;
                            _cal.nupdEndPercentage.Value = 100;
                            _cal.lblNAAQS_Unit.Text = "(ppb) ";
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)         //addede by Lijiabin
                        {
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption == null)
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption = new SSIACalculationOption();
                            _cal.txtNAAQS.Text = "0";
                            _cal.txtThreshold.Text = "0";
                            //_cal.nupdStartPercentage.Value = 0;
                            //_cal.nupdEndPercentage.Value = 100;;
                            _cal.lblNAAQS_Unit.Text = "";
                        }
                        break;
                    #endregion
                    #region Annual PM China added by Yangwenwei
                    case "uc_ModelDataChina":
                        uc_ModelDataChina modeldatachina = (pnlUserControl.Controls[0] as uc_ModelDataChina);
                        //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina == null)
                        //    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina = new ModelDataInputChina();
                        modeldatachina.InitializeControl();
                        //modeldatachina.rbtnQuarterlyAverageDataChina.Checked = true;
                        //modeldatachina.rbtnDailyAvertageDatalChina.Checked = false;
                        //modeldatachina.rbtnCMAQChina.Checked = false;
                        //CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_Base_Quarterly.csv";
                        //CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\XiAn_Model_L_R_0.5_0.5_Quarterly.csv";
                        //modeldatachina.txtControlChina.Text = Path.GetFileName(CommonClass.futureModelFile);
                        //modeldatachina.txtBaselineChina.Text = Path.GetFileName(CommonClass.baseModelFile);
                        //modeldatachina.txtScenarioName.Text = "";
                        break;
                    case "uc_MonitorDataChina":
                        uc_MonitorDataChina monitordatachina = (pnlUserControl.Controls[0] as uc_MonitorDataChina);
                        //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina == null)
                        //    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina = new MonitorDataInputChina();
                        monitordatachina.InitializeControl();
                        //monitordatachina.rbtnQuarterlyMonitorChina.Checked = true;
                        //monitordatachina.rbtnDailyMonitorChina.Checked = false;
                        //monitordatachina.choIAdjustedFRMChina.Checked = false;
                        //monitordatachina.choIFRMChina.Checked = false;
                        //monitordatachina.chkwVNA.Checked = false;
                        //monitordatachina.chkwVNAAdvance.Checked = false;
                        //monitordatachina.chkNS.Checked = false;
                        //CommonClass.monitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\陕西省PM25测点季度均值.csv";
                        //monitordatachina.txtOfficialMonitorChina.Text = Path.GetFileName(CommonClass.monitorFile);
                        //monitordatachina.cboEndYearChina.Items.Clear();
                        //monitordatachina.cboStartYearChina.Items.Clear();
                        //CommonClass.getmonitorYear("");
                        //for (int i = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear); i <= Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear); i++)
                        //{
                        //    monitordatachina.cboEndYearChina.Items.Add(i);
                        //    monitordatachina.cboStartYearChina.Items.Add(i);
                        //}
                        //monitordatachina.cboStartYearChina.SelectedIndex = 0;
                        //monitordatachina.cboEndYearChina.SelectedIndex = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataEndYear) - Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina.MonitorDataStartYear);
                        break;
                    case "uc_PM25SpeciesOptionChina":
                        uc_PM25SpeciesOptionChina speciesoptionchina = (pnlUserControl.Controls[0] as uc_PM25SpeciesOptionChina);
                        speciesoptionchina.InitializeControl();//
                        //if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina == null)
                        //    (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina = new PM25SpeciesOptionChina();
                        //speciesoptionchina.chkSpeciesFractionDataChina.Checked = true;
                        //CommonClass.speciesMonitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\PM25_Species_Fraction_Quarterly_2013_YRD.csv";
                        //speciesoptionchina.txtSpeciesDataChina.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                        break;
                    #endregion
                    #region Ozone China added by Yangwenwei
                    case "uc_ModelDataOzoneChina":
                        uc_ModelDataOzoneChina modeldataozonechina = (pnlUserControl.Controls[0] as uc_ModelDataOzoneChina);
                        modeldataozonechina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina == null)
                        //    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina = new ModelDataOzoneChina();
                        //modeldataozonechina.cboCMAQOzone.Checked = false;
                        //CommonClass.baseModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2013_YRD.csv";
                        //CommonClass.futureModelFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Model_O3_Seasonal_2017_YRD.csv";
                        //modeldataozonechina.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        //modeldataozonechina.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile); ;
                        //modeldataozonechina.txtScenarioName.Text = "";
                        break;
                    case "uc_MonitorDataOzoneChina":
                        uc_MonitorDataOzoneChina monitordataozonechina = (pnlUserControl.Controls[0] as uc_MonitorDataOzoneChina);
                        monitordataozonechina.InitializeControl();
                        //if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina == null)
                        //    (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina = new MonitorDataOzoneChina();
                        //monitordataozonechina.choIAdjustedFRMChina.Checked = false;
                        //monitordataozonechina.choIFRMChina.Checked = false;
                        //monitordataozonechina.chkwVNA.Checked = false;
                        //monitordataozonechina.chkwVNAAdvance.Checked = false;
                        //monitordataozonechina.chkNS.Checked = false;
                        //CommonClass.ozoneMonitorFile = Application.StartupPath + @"\Data\SampleData\SMAT-China\Ozone_Data_Seasonal_2013_YRD.csv";
                        //monitordataozonechina.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);
                        //monitordataozonechina.cboEndYearOzone.Items.Clear();
                        //monitordataozonechina.cboStartYearOzone.Items.Clear();
                        //CommonClass.getmonitorYear("");
                        //for (int i = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear); i <= Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear); i++)
                        //{
                        //    monitordataozonechina.cboEndYearOzone.Items.Add(i);
                        //    monitordataozonechina.cboStartYearOzone.Items.Add(i);
                        //}
                        //monitordataozonechina.cboStartYearOzone.SelectedIndex = 0;
                        //monitordataozonechina.cboEndYearOzone.SelectedIndex = Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneEndYear) - Convert.ToInt16((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina.ozoneStartYear);
                        break;
                    #endregion
                    #region BenMAP annual pm
                    case "uc_BenMAP_AnnualPM_ModelData":
                        uc_BenMAP_AnnualPM_ModelData benMapAnnualModel = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput = new BenMAPAnnualPMModel();

                        benMapAnnualModel.rbtnDailyModelA.Checked = true;
                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["baselineModelDataFile"];//   Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2011eh.camx.grid.csv";//PM_small_USA_12km_2011.csv";
                        benMapAnnualModel.txtBaselineA.Text = Path.GetFileName(CommonClass.baseModelFile);
                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["AnnualPM"]["forecastModelDataFile"];// Application.StartupPath + @"\Data\SampleData\Model_data\SMAT.PM.Large.12.SE_US2.2017eh.camx.grid.csv";//PM_small_USA_12km_2018.csv";
                        benMapAnnualModel.txtForecastA.Text = Path.GetFileName(CommonClass.futureModelFile);
                        benMapAnnualModel.cboSpatialGridA.SelectedIndex = 0;
                        break;
                    case "uc_BenMAP_AnnualPM_MonitorData":
                        uc_BenMAP_AnnualPM_MonitorData benMapAnnualMonitor = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput = new BenMAPAnnualPMMonitor();

                        CommonClass.unofficialPMFile = CommonClass.dicExampleConfiguration["AnnualPM"]["unofficialMonitorDataFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\PM25ForFractions2002to2017.csv";//PM25ForFractions2002to2012.csv;
                        benMapAnnualMonitor.txtUnofficialMonitorA.Text = Path.GetFileName(CommonClass.unofficialPMFile);
                        CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_MonitorData");
                        benMapAnnualMonitor.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                        benMapAnnualMonitor.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).monitorInput.lstUnofficialYear.Distinct().ToList();
                        if (benMapAnnualMonitor.cboStartYearA.Items.Count >= 9)
                            benMapAnnualMonitor.cboStartYearA.SelectedIndex = 8;
                        else
                            benMapAnnualMonitor.cboStartYearA.SelectedIndex = benMapAnnualMonitor.cboStartYearA.Items.Count - 1;
                        if (benMapAnnualMonitor.cboEndYearA.Items.Count >= 11)
                        {
                            benMapAnnualMonitor.cboEndYearA.SelectedIndex = 10;
                        }
                        else
                        {
                            benMapAnnualMonitor.cboEndYearA.SelectedIndex = benMapAnnualMonitor.cboEndYearA.Items.Count - 1;
                        }
                        benMapAnnualMonitor.choIFRMSpeA.Checked = true;
                        benMapAnnualMonitor.choIAdjustedFRMSpeA.Checked = true;


                        benMapAnnualMonitor.chkDS.Checked = false;
                        benMapAnnualMonitor.txtDSBurn.Text = "500";
                        benMapAnnualMonitor.txtDSCmaqres.Text = "12";
                        benMapAnnualMonitor.txtDSThin.Text = "1";
                        benMapAnnualMonitor.txtDSNumit.Text = "2500";
                        break;
                    case "uc_BenMAP_AnnualPM_SpeciesData":
                        uc_BenMAP_AnnualPM_SpeciesData benMapAnnualSpecies = (pnlUserControl.Controls[0] as uc_BenMAP_AnnualPM_SpeciesData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput = new BenMAPAnnualPMSpecies();

                        benMapAnnualSpecies.rbtnMonitorFileA.Checked = true;
                        CommonClass.speciesMonitorFile = CommonClass.dicExampleConfiguration["AnnualPM"]["speciesMonitorDataFile"];// Application.StartupPath + @"\Data\SampleData\Monitor_data\SpeciesForFractions2002to2015_v2.csv";//SpeciesForFractions2002to2012.csv;
                        benMapAnnualSpecies.txtMonitorFileA.Text = Path.GetFileName(CommonClass.speciesMonitorFile);
                        CommonClass.getmonitorYear("uc_BenMAP_AnnualPM_SpeciesData");
                        benMapAnnualSpecies.cboStartYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                        benMapAnnualSpecies.cboEndYearA.DataSource = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).speciesMonitorInput.lstSpeciesYear.Distinct().ToList();
                        if (benMapAnnualSpecies.cboStartYearA.Items.Count >= 9)
                            benMapAnnualSpecies.cboStartYearA.SelectedIndex = 8;
                        else
                            benMapAnnualSpecies.cboStartYearA.SelectedIndex = benMapAnnualSpecies.cboStartYearA.Items.Count - 1;
                        if (benMapAnnualSpecies.cboEndYearA.Items.Count >= 11)
                        {
                            benMapAnnualSpecies.cboEndYearA.SelectedIndex = 10;
                        }
                        else
                        {
                            benMapAnnualSpecies.cboEndYearA.SelectedIndex = benMapAnnualSpecies.cboEndYearA.Items.Count - 1;
                        }
                        break;
                    case "uc_BenMAP_GridDefinition":
                        uc_BenMAP_GridDefinition gridDefintion = (pnlUserControl.Controls[0] as uc_BenMAP_GridDefinition);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).gridDefinitionFile == null)
                        {
                            CommonClass.shapefile = Application.StartupPath + @"\Data\ShapeFiles\CMAQ_12km_Nation.shp";
                            gridDefintion.txtGridDefinition.Text = Path.GetFileName(CommonClass.shapefile);
                        }
                        break;
                    #endregion
                    #region BenMap Ozone
                    case "uc_BenMap_Ozone_ModelData":
                        uc_BenMap_Ozone_ModelData benMapOzoneModel = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_ModelData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput = new BenMAPOzoneModel();
                        benMapOzoneModel.choCMAQOzone.Checked = false;
                        CommonClass.baseModelFile = CommonClass.dicExampleConfiguration["Ozone"]["baselineModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2011.csv";
                        benMapOzoneModel.txtBaselineOzone.Text = Path.GetFileName(CommonClass.baseModelFile);
                        CommonClass.futureModelFile = CommonClass.dicExampleConfiguration["Ozone"]["forecastModelDataFile"];//  Application.StartupPath + @"\Data\SampleData\Model_data\O3_small_USA_12km_2018.csv";
                        benMapOzoneModel.txtForecastOzone.Text = Path.GetFileName(CommonClass.futureModelFile);
                        break;
                    case "uc_BenMap_Ozone_MonitorData":
                        uc_BenMap_Ozone_MonitorData benMapOzoneMonitor = (pnlUserControl.Controls[0] as uc_BenMap_Ozone_MonitorData);
                        if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput == null)
                            (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput = new BenMapOzoneMonitor();
                        CommonClass.ozoneMonitorFile = CommonClass.dicExampleConfiguration["Ozone"]["ozoneMonitorDataFile"];//  Application.StartupPath + @"\Data\SampleData\Monitor_data\SMAT_OZONE_MAX4DV_STD70_2002_2015.CSV";//MATS_OZONE_DV_2012_V2_off.csv";
                        benMapOzoneMonitor.cboEndYearOzone.Items.Clear();
                        benMapOzoneMonitor.cboStartYearOzone.Items.Clear();
                        CommonClass.getmonitorYear("uc_BenMap_Ozone_MonitorData");
                        benMapOzoneMonitor.txtOzoneData.Text = Path.GetFileName(CommonClass.ozoneMonitorFile);

                        (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData.Sort();
                        List<string> yearO = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).monitorInput.lstOzoneMonitorData;
                        for (int i = 0; i < yearO.Count; i++)
                        {
                            benMapOzoneMonitor.cboStartYearOzone.Items.Add((Convert.ToInt32(yearO[i]) - 2).ToString() + "-" + yearO[i]);
                            benMapOzoneMonitor.cboEndYearOzone.Items.Add((Convert.ToInt32(yearO[i]) - 2).ToString() + "-" + yearO[i]);
                        }

                        if (benMapOzoneMonitor.cboStartYearOzone.Items.Count >= 9)
                            benMapOzoneMonitor.cboStartYearOzone.SelectedIndex = 8;
                        else
                            benMapOzoneMonitor.cboStartYearOzone.SelectedIndex = benMapOzoneMonitor.cboStartYearOzone.Items.Count - 1;
                        if (benMapOzoneMonitor.cboEndYearOzone.Items.Count >= 10)
                            benMapOzoneMonitor.cboEndYearOzone.SelectedIndex = 9;
                        else
                            benMapOzoneMonitor.cboEndYearOzone.SelectedIndex = benMapOzoneMonitor.cboEndYearOzone.Items.Count - 1;
                        benMapOzoneMonitor.choVNA.Checked = true;
                        benMapOzoneMonitor.choEVNA.Checked = true;
                        benMapOzoneMonitor.cboGridOzone.SelectedIndex = 1;
                        benMapOzoneMonitor.cboStatisticOzone.SelectedIndex = 2;

                        benMapOzoneMonitor.chkDS.Checked = false;
                        benMapOzoneMonitor.txtDSBurn.Text = "500";
                        benMapOzoneMonitor.txtDSCmaqres.Text = "12";
                        benMapOzoneMonitor.txtDSNumit.Text = "2500";
                        benMapOzoneMonitor.txtDSThin.Text = "1";
                        break;
                        #endregion
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }



        //---------保存当前的scenario------
        public void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string errorTips = "";
                #region annual
                if (pnlUserControl.Controls[0].Name == "uc_DataInputA")
                {
                    errorTips = checkDataInputA();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region daily
                if (pnlUserControl.Controls[0].Name == "uc_DataInputD")
                {
                    errorTips = checkDataInputD();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region ozone
                if (pnlUserControl.Controls[0].Name == "uc_DataInputOzone")
                {
                    errorTips = checkDataInputO();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region visibility
                if (pnlUserControl.Controls[0].Name == "uc_DataInputV")
                {
                    errorTips = (pnlUserControl.Controls[0] as uc_DataInputV).checkDataInputV();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Annual
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputA")
                {
                    errorTips = checkSSIAModelInputA();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA")
                {
                    errorTips = checkSSIAMonitorInputA();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Daily added by Yangwenwei
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputD")
                {
                    errorTips = checkSSIAModelInputD();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputD")
                {
                    errorTips = checkSSIAMonitorInputD();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA O3
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputO")
                {
                    errorTips = checkSSIAModelInputO();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputO")
                {
                    errorTips = checkSSIAMonitorInputO();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Deposition added by Lijiabin
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputDep")
                {
                    errorTips = checkSSIAModelInputDep();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region PM China
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataChina")
                {
                    errorTips = checkPMChinaModelInput();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataChina")
                {
                    errorTips = checkPMChinaMonitorInput();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_PM25SpeciesOptionChina")
                {
                    errorTips = checkPMChinaSpecies();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region Ozone China
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataOzoneChina")
                {
                    errorTips = checkOzoneChinaModelInput();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataOzoneChina")
                {
                    errorTips = checkOzoneChinaMonitorInput();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region BenMAP Annual PM
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_ModelData")
                {
                    errorTips = checkBenMAPAnnualPMModelInput();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_MonitorData")
                {
                    errorTips = checkBenMAPAnnualPMMonitorInput();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_SpeciesData")
                {
                    errorTips = checkBenMAPAnnualPMSpeciesInput();
                    if (errorTips != "" && errorTips.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                {
                    if (!File.Exists(CommonClass.shapefile))
                    {
                        errorNode(trvAnalysis.Nodes[3]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(Language.Localization.GetValue("Grid definition path does not exist!"), Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion

                errorTips = "";
                errorTips = SaveCurrentUCConfiguration();
                if (errorTips != null && errorTips.Length > 0)
                {
                    MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                    return;
                }
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        errorTips = CommonClass.checkAnnualPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.DailyPM:
                        errorTips = CommonClass.checkDailyPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.Ozone:
                        errorTips = CommonClass.checkOzoneUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.Visibility:
                        errorTips = CommonClass.checkVisibilityUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.SSIAAnnualPM:
                        errorTips = CommonClass.checkSSIAAnnualPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.SSIADailyPM:
                        errorTips = CommonClass.checkSSIADailyPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.SSIAOzone:
                        errorTips = CommonClass.checkSSIAOzoneUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.AnnualPMChina:
                        errorTips = CommonClass.checkAnnualPMChina(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.OzoneChina:
                        errorTips = CommonClass.checkOzoneChina(CommonClass.CurrentBaseScenario);
                        break;
                }
                if (errorTips != null && errorTips.Length > 0)
                {
                    MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                    return;
                }

                SaveFileDialog savefile = new SaveFileDialog();
                savefile.Title = Language.Localization.GetValue("Save project...");
                savefile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Project";
                savefile.Filter = Language.Localization.GetValue("Project files(*.proj)|*.proj");
                savefile.RestoreDirectory = true;
                #region
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                        }
                        break;
                    case enumAnalysis.DailyPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                        }
                        break;
                    case enumAnalysis.Ozone:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                        }
                        break;
                    case enumAnalysis.Visibility:
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                        }
                        break;
                    case enumAnalysis.SSIAAnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                        }
                        break;
                    case enumAnalysis.SSIAOzone:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                        }
                        break;
                    case enumAnalysis.SSIADeposition:                          //added by Lijiabin
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                        }
                        break;
                    case enumAnalysis.AnnualPMChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                        }
                        break;
                    case enumAnalysis.OzoneChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName.Length != 0)
                        {
                            savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                            CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                        }
                        break;
                }
                #endregion
                #region
                if (savefile.ShowDialog() == DialogResult.OK)
                {
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                            }
                            //errorTips = CommonClass.checkAnnualPMUC(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.DailyPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName);
                            }
                            //errorTips = CommonClass.checkDailyPMUC(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.Ozone:
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                            }
                            //errorTips = CommonClass.checkOzoneUC(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.Visibility:
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                            }
                            //errorTips = CommonClass.checkVisibilityUC(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.SSIAAnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                            }
                            //errorTips = CommonClass.checkSSIAAnnualPMUC(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.SSIADailyPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIAOzone:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                            }
                            //errorTips = CommonClass.checkSSIAOzoneUC(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.SSIADeposition:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                            }
                            //errorTips = CommonClass.checkSSIAAnnualPMUC(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.AnnualPMChina:
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            }
                            //errorTips = CommonClass.checkAnnualPMChina(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.OzoneChina:
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName = Path.GetFileNameWithoutExtension(savefile.FileName);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                            }
                            //errorTips = CommonClass.checkOzoneChina(CommonClass.CurrentBaseScenario);
                            break;
                    }
                    //if (errorTips != null && errorTips.Length > 0)
                    //{
                    //    MessageBox.Show(errorTips, "Tip", MessageBoxButtons.OK);
                    //}

                    //将cfg文件保存到/Result/CFG目录下
                    //BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, Application.StartupPath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                    CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                    CommonClass.SaveScenario(CommonClass.CurrentBaseScenario, savefile.FileName);
                    CommonClass.ProjectName = savefile.FileName;

                    if (btnSaveRun.Enabled)
                        BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");

                    MessageBox.Show(Language.Localization.GetValue("Save project successfully!"));
                    trvAnalysis.Nodes[trvAnalysis.Nodes.Count - 1].ImageKey = _saveImageKey;
                    trvAnalysis.Nodes[trvAnalysis.Nodes.Count - 1].SelectedImageKey = _saveImageKey;
                }
                #endregion
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        public void UpdateTreelisview(TreeListViewItem item, string message)
        {
            try
            {
                TreeListViewItem itemA = new TreeListViewItem() { };
                item.Items.Add(itemA);
                itemA.SubItems.Add("Completed loading/creating baseline/future model data. " + CommonClass.TotalTime + " s");
                tlvRunning.Refresh();
                tlvRunning.ExpandAll();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        public void RunProject()
        {
            try
            {
                //----------------开始Run project-----------------------------------------------------
                //----------判断是否Batch--------------
                bool isBatch = false;
                if (CommonClass.InputParams != null && CommonClass.InputParams.Count() > 0 && CommonClass.InputParams[0].ToLower().Contains(".cfg"))
                {
                    isBatch = true;
                }

            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        //------保存结果文件路径----------------
        private string _resultFilePath = "";
        private string _resultOutputFiles = "";
        //------------保存当前scenario并运行--------------
        public void btnSaveRun_Click(object sender, EventArgs e)
        {
            try
            {
                //----------------开始Run project-----------------------------------------------------
                //----------判断是否Batch--------------
                CommonClass.IsBatch = false;
                if (CommonClass.InputParams != null && CommonClass.InputParams.Count() > 0 && CommonClass.InputParams[0].ToLower().Contains(".cfg"))
                {
                    CommonClass.IsBatch = true;
                }
                //-----------保存运行之前check files---------
                //---------对于每种analysis，若没有选择任何output options，则不run
                #region
                bool nooutputoption = false;
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        AnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration;
                        if (!annualPMAnalysisConfiguration.chooseDesiredOutputA.doStandardAnalysis && !annualPMAnalysisConfiguration.chooseDesiredOutputA.doQuarterlyModelData
                            && !annualPMAnalysisConfiguration.chooseDesiredOutputA.doUsedQuarterlyAvgModelData && !annualPMAnalysisConfiguration.chooseDesiredOutputA.doSpeciesFraction
                            && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doInterpolatedSFETempAdj && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doBaseOnlyVNA && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doFutureOnlyVNA
                            && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doInterpolatedSFETempAdj_GradAdj && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doBaseOnlyEvna && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doFutureOnlyEvna
                            && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgFilePoint && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgFileSpatial
                            && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_GraAdj && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgSpeciatedMonitors
                            && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doSpeciesFractionSpatial && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doSpeciesFractionSpatial_GraAdj
                            && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doNeighborFilePoint && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doNeighborFileSpatial
                            && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doHighCountySites && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doDesignValuePeriods)
                        {
                            nooutputoption = true;
                            return;
                        }
                        break;
                    case enumAnalysis.DailyPM:
                        DailyPMAnalysisConfiguration dailyPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration;
                        if (!dailyPMAnalysisConfiguration.chooseDesiredOutputD.doStandardAnalysis && !dailyPMAnalysisConfiguration.chooseDesiredOutputD.doSpeciesFraction && !dailyPMAnalysisConfiguration.chooseDesiredOutputD.doQuarterlyPeakModelData
                            && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doDesignValuePeriods && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doHighCountySites && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doNeighborFilePoint
                            && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doQuarterlyPeakFilesPoint && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doQuarterlyPeakSpeciatedMonitors)
                        {
                            nooutputoption = true;
                            return;
                        }
                        break;
                    case enumAnalysis.Ozone:
                        OzoneAnalysisConfiguration ozoneAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration;
                        if (!ozoneAnalysisConfiguration.chooseDesiredOutputO.doDesignValuePeriods && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doMaxDesignValuePeriods && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doNeighborFileSpatial && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doPointEstimatesForecast
                            && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doQuarterlyModelData && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doSpatialFieldEstimates && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj
                            && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doBaseOnlyVNA && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doFutureOnlyVNA && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doBaseOnlyEVNA && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doFutureOnlyEVNA)
                        {
                            nooutputoption = true;
                            return;
                        }
                        break;
                    case enumAnalysis.Visibility:
                        VisibilityAnalysisConfiguration visibilityAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration;
                        if (!visibilityAnalysisConfiguration.chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast)
                        {
                            nooutputoption = true;
                            return;
                        }
                        break;
                }
                if (nooutputoption)
                {
                    if (CommonClass.IsBatch)
                    {
                        BatchCommonClass.WriteBatchLogFile("Wrong Batch : Please choose output options!", CommonClass.InputParams[0] + ".log");
                    }
                    else
                        MessageBox.Show(Language.Localization.GetValue("Please choose output options!"));
                    return;
                }
                #endregion
                string errorTips = "";
                if (!CommonClass.IsBatch)
                    SaveCurrentUCConfiguration();
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        errorTips = CommonClass.checkAnnualPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.DailyPM:
                        errorTips = CommonClass.checkDailyPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.Ozone:
                        errorTips = CommonClass.checkOzoneUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.Visibility:
                        errorTips = CommonClass.checkVisibilityUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.SSIAAnnualPM:
                        errorTips = CommonClass.checkSSIAAnnualPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.SSIADailyPM:
                        errorTips = CommonClass.checkSSIADailyPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.SSIAOzone:
                        errorTips = CommonClass.checkSSIAOzoneUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.SSIADeposition:                                                  //added by Lijiabin
                        errorTips = CommonClass.checkSSIADepositionUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.AnnualPMChina:
                        errorTips = CommonClass.checkAnnualPMChina(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.AnnualPMOther:
                        errorTips = CommonClass.checkAnnualPMChina(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.OzoneOther:
                        errorTips = CommonClass.checkOzoneChina(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.OzoneChina:
                        errorTips = CommonClass.checkOzoneChina(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.BenMAPAnnualPM:
                        errorTips = CommonClass.checkBenMAPAnnualPMUC(CommonClass.CurrentBaseScenario);
                        break;
                    case enumAnalysis.BenMAPSeasonalOzone:
                        errorTips = CommonClass.checkBenMAPOzoneUC(CommonClass.CurrentBaseScenario);
                        break;
                }
                if (errorTips != null && errorTips.Length > 0)
                {
                    if (CommonClass.IsBatch)
                    {
                        BatchCommonClass.WriteBatchLogFile("Wrong Batch :" + errorTips, CommonClass.InputParams[0] + ".log");
                    }
                    else
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                    return;
                }
                CommonClass.CurrentBaseScenario.log = new BaseLog();
                CommonClass.CurrentBaseScenario.log.lstLog = new List<string>();
                CommonClass.CurrentBaseScenario.lstOutput = new List<BaseOutput>();
                if (!CommonClass.IsBatch)
                {
                    #region add by Amy 2012-10-12
                    errorTips = SaveCurrentUCConfiguration();
                    if (errorTips != null && errorTips.Length > 0)
                    {
                        MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                    #endregion
                    SaveFileDialog savefile = new SaveFileDialog();
                    savefile.Title = Language.Localization.GetValue("Save project...");
                    savefile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Project";
                    savefile.Filter = Language.Localization.GetValue("Project files(*.proj)|*.proj");
                    savefile.RestoreDirectory = true;
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                            }
                            break;
                        case enumAnalysis.DailyPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                            }
                            break;
                        case enumAnalysis.Ozone:
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                            }
                            break;
                        case enumAnalysis.Visibility:
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIAAnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIADailyPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIAOzone:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIADeposition:                               //added by Lijiabin
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                            }
                            break;
                        case enumAnalysis.AnnualPMChina:
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            }
                            break;
                        case enumAnalysis.OzoneChina:
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                            }
                            break;
                        case enumAnalysis.BenMAPAnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName;
                            }
                            break;
                        case enumAnalysis.BenMAPSeasonalOzone:
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName.Length != 0)
                            {
                                savefile.FileName = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName;
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName;
                            }
                            break;
                    }
                    if (savefile.ShowDialog() != DialogResult.OK) return;
                    //-----OK则将文件名赋值给configuration name------------
                    //---------保存project的路径------------
                    _resultFilePath = savefile.FileName;
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                            }
                            break;
                        case enumAnalysis.DailyPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName);
                            }
                            break;
                        case enumAnalysis.Ozone:
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                            }
                            break;
                        case enumAnalysis.Visibility:
                            if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIAAnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIADailyPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIAOzone:
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                            }
                            break;
                        case enumAnalysis.SSIADeposition:                         //added by Lijiabin
                            if ((CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                            }
                            break;
                        case enumAnalysis.AnnualPMChina:
                            if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            }
                            break;
                        case enumAnalysis.OzoneChina:
                            if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                            }
                            break;
                        case enumAnalysis.BenMAPAnnualPM:
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName;
                            }
                            break;
                        case enumAnalysis.BenMAPSeasonalOzone:
                            if ((CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName != Path.GetFileNameWithoutExtension(_resultFilePath))
                            {
                                (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName = Path.GetFileNameWithoutExtension(_resultFilePath);
                                CommonClass.CurrentBaseScenario.configuration.configurationName = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName;
                            }
                            break;
                    }
                }
                else
                {
                    //_resultFilePath = Application.StartupPath + @"\Result\Batchjob\" + Path.GetFileNameWithoutExtension(CommonClass.InputParams[0]) + @"\" + Path.GetFileNameWithoutExtension(CommonClass.InputParams[0]); //Path.GetFileNameWithoutExtension(CommonClass.InputParams[0]) may be different from scenarioName
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.scenarioName;
                            break;
                        case enumAnalysis.DailyPM:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.scenarioName;
                            break;
                        case enumAnalysis.Ozone:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.scenarioName;
                            break;
                        case enumAnalysis.Visibility:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.scenarioName;
                            break;
                        case enumAnalysis.SSIAAnnualPM:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.scenarioName;
                            break;
                        case enumAnalysis.SSIADailyPM:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.scenarioName;
                            break;
                        case enumAnalysis.SSIAOzone:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).analysisOptionO.scenarioName;
                            break;
                        case enumAnalysis.SSIADeposition:                   //added by Lijiabin
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).analysisOptionDep.scenarioName;
                            break;
                        case enumAnalysis.AnnualPMChina:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            break;
                        case enumAnalysis.AnnualPMOther:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina.scenarioName;
                            break;
                        case enumAnalysis.OzoneOther:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                            break;
                        case enumAnalysis.OzoneChina:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina.scenarioName;
                            break;
                        case enumAnalysis.BenMAPAnnualPM:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration).modelInput.scenarioName;
                            break;
                        case enumAnalysis.BenMAPSeasonalOzone:
                            _resultFilePath = (CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration).modelInput.scenarioName;
                            break;
                    }
                    //_resultFilePath = CommonClass.ResultFilePath + @"\" + _resultFilePath + @"\" + _resultFilePath;
                }
                //---------记录SMAT_CE运行的开始时间
                CommonClass.CurrentBaseScenario.log.start = DateTime.Now;
                if (LanguageOld.IsSMATChina)
                    CommonClass.CurrentLog = "Start SMAT-China " + CommonClass.versionSMATChina + " run            " + CommonClass.CurrentBaseScenario.log.start;
                else
                {
                    CommonClass.CurrentLog = "Start SMAT-CE " + CommonClass.VersionNumber + " run            " + CommonClass.CurrentBaseScenario.log.start;
                }
                CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                //----点击OK之后，首先改变图标为运行，然后根据用户所选的output choice进行运算-------------
                bool isOK = true;
                if (!CommonClass.IsBatch)
                {
                    trvAnalysis.Nodes[trvAnalysis.Nodes.Count - 1].ImageKey = _yibuImageKey;
                    trvAnalysis.Nodes[trvAnalysis.Nodes.Count - 1].SelectedImageKey = _yibuImageKey;
                    trvAnalysis.Refresh();
                    tlvRunning.Sorting = SortOrder.None;
                    WaitShow(Language.Localization.GetValue("Project running...\r\nPlease wait!"));
                    //-------判断用户是否更改文件名;若修改则将scenario name同时修改------------
                    CommonClass.ProjectName = _resultFilePath;
                    if (CommonClass.CurrentBaseScenario.lstOutput == null)
                        CommonClass.CurrentBaseScenario.lstOutput = new List<BaseOutput>();
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Set up model data for calculating RRF: " + (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.forecastModelDataFile + "...");
                            //CommonClass.CurrentLog = "Set up model data for calculating RRF: " + (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.forecastModelDataFile + "...";
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Set Reduction Factors for " + (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.forecastModelDataFile + "...");
                            CommonClass.CurrentLog = "Starting Annual PM Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            isOK = AnnualPMCommonClass.AnnualPMAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.DailyPM:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentLog = "Starting Daily PM Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Set up model data: " + (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.forecastModelFile + "...");
                            //CommonClass.CurrentLog = "Set up model data: " + (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.forecastModelFile + "...";
                            isOK = DailyPMCommonClass.DailyAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.Ozone:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Setting up run structure...");
                            //CommonClass.CurrentLog = "Setting up run structure...";
                            CommonClass.CurrentLog = "Starting Ozone Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            isOK = OzoneCommonClass.OzoneAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.Visibility:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Visibility Analysis...");
                            CommonClass.CurrentLog = "Starting Visibility Analysis...";
                            isOK = VisibilityCommonClass.VisibilityAnalysis(CommonClass.CurrentBaseScenario);
                            #endregion
                            break;
                        case enumAnalysis.SSIAAnnualPM:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Annual PM Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Annual PM Analysis...";
                            isOK = SSIACommonClass.AnnualPMAnalysisSSIA(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.SSIADailyPM:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Daily PM Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Daily PM Analysis...";
                            isOK = SSIADailyPMCommonClass.DailyAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.SSIAOzone:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Ozone Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Ozone Analysis...";
                            isOK = SSIACommonClass.OzoneAnalysisSSIA(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.SSIADeposition:             //added by Lijiabin
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Deposition Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Deposition Analysis...";
                            isOK = SSIADepositionCommonClass.DepositonAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.AnnualPMChina:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Annual PM Analysis...");
                            CommonClass.CurrentLog = "Starting Annual PM Analysis...";
                            isOK = AnnualPMCommonClassChina.AnnualPMAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.OzoneChina:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Ozone Analysis...");
                            CommonClass.CurrentLog = "Starting Ozone Analysis...";
                            isOK = OzoneChinaCommonClass.OzoneChinaAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.BenMAPAnnualPM:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentLog = "Starting BenMAP - Annual PM Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            isOK = BenMAPAnnualPMCommonClass.AnnualPMAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.BenMAPSeasonalOzone:
                            #region
                            BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg");
                            CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\Result\CFG\" + CommonClass.CurrentBaseScenario.configuration.configurationName + ".cfg";
                            CommonClass.CurrentLog = "Starting BenMAP - Ozone Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            isOK = BenMAPOzoneCommonClass.BenMapOzoneAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                    }
                    _resultOutputFiles = CommonClass.ResultFilePath + @"\Result\Output\" + CommonClass.CurrentBaseScenario.configuration.configurationName + @"\";
                }
                else
                {

                    if (!Directory.Exists(CommonClass.ResultFilePath))// + @"\" + Path.GetFileNameWithoutExtension(_resultFilePath)))//@"\Result\Batchjob\"
                    {
                        System.IO.Directory.CreateDirectory(CommonClass.ResultFilePath);// + @"\" + Path.GetFileNameWithoutExtension(_resultFilePath));
                    }

                    CommonClass.ProjectName = Path.GetFileNameWithoutExtension(_resultFilePath) + ".proj";
                    string cfgPath = Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"\My SMAT-CE Files\Result\CFG\";
                    if (!File.Exists(cfgPath + _resultFilePath + ".cfg"))
                    {
                        BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, cfgPath + _resultFilePath + ".cfg");
                    }
                    //if (!File.Exists(CommonClass.ResultFilePath + @"\" + _resultFilePath + ".cfg"))
                    //{
                    //    BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, CommonClass.ResultFilePath + @"\" + _resultFilePath + ".cfg");
                    //}                  
                    //CommonClass.CurrentBaseScenario.configuration.configurationPath = CommonClass.ResultFilePath + @"\" + _resultFilePath + ".cfg";
                    if (CommonClass.CurrentBaseScenario.lstOutput == null)
                        CommonClass.CurrentBaseScenario.lstOutput = new List<BaseOutput>();
                    //---------Run Batch-------------
                    #region
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                            #region
                            CommonClass.CurrentLog = "Starting Annual PM Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Loading/creating baseline/future model data.");
                            //CommonClass.CurrentLog = "Set up model data for calculating RRF: " + (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.forecastModelDataFile + "...";
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Set up model data for calculating RRF: " + (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA.forecastModelDataFile + "...");
                            isOK = AnnualPMCommonClass.AnnualPMAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                        case enumAnalysis.DailyPM:
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Set up model data: " + (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.forecastModelFile + "...");
                            //CommonClass.CurrentLog = "Set up model data: " + (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD.forecastModelFile + "...";
                            CommonClass.CurrentLog = "Starting Daily PM Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            isOK = DailyPMCommonClass.DailyAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.Ozone:
                            //CommonClass.CurrentBaseScenario.log.lstLog.Add("Setting up run structure...");
                            //CommonClass.CurrentLog = "Setting up run structure...";
                            CommonClass.CurrentLog = "Starting Ozone Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            isOK = OzoneCommonClass.OzoneAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.Visibility:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Visibility Analysis...");
                            CommonClass.CurrentLog = "Starting Visibility Analysis...";
                            isOK = VisibilityCommonClass.VisibilityAnalysis(CommonClass.CurrentBaseScenario);
                            break;
                        case enumAnalysis.SSIAAnnualPM:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Annual PM Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Annual PM Analysis...";
                            isOK = SSIACommonClass.AnnualPMAnalysisSSIA(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.SSIADailyPM:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Daily PM Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Daily PM Analysis...";
                            isOK = SSIADailyPMCommonClass.DailyAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.SSIAOzone:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Ozone Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Ozone Analysis...";
                            isOK = SSIACommonClass.OzoneAnalysisSSIA(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.SSIADeposition:                                                            //added by Lijiabin
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting SSIA Deposition Analysis...");
                            CommonClass.CurrentLog = "Starting SSIA Deposition Analysis...";
                            isOK = SSIADepositionCommonClass.DepositonAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.AnnualPMChina:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Annual PM Analysis...");
                            CommonClass.CurrentLog = "Starting Annual PM Analysis...";
                            isOK = AnnualPMCommonClassChina.AnnualPMAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.AnnualPMOther:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Annual PM Analysis...");
                            CommonClass.CurrentLog = "Starting Annual PM Analysis...";
                            isOK = AnnualPMCommonClassChina.AnnualPMAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.OzoneOther:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Ozone Analysis...");
                            CommonClass.CurrentLog = "Starting Ozone Analysis...";
                            isOK = OzoneChinaCommonClass.OzoneChinaAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.OzoneChina:
                            CommonClass.CurrentBaseScenario.log.lstLog.Add("Starting Ozone Analysis...");
                            CommonClass.CurrentLog = "Starting Ozone Analysis...";
                            isOK = OzoneChinaCommonClass.OzoneChinaAnalysis(CommonClass.CurrentBaseScenario, this);
                            break;
                        case enumAnalysis.BenMAPAnnualPM:
                            #region
                            CommonClass.CurrentLog = "Starting BenMAP - Annual PM Analysis...";
                            CommonClass.CurrentBaseScenario.log.lstLog.Add(CommonClass.CurrentLog);
                            isOK = BenMAPAnnualPMCommonClass.AnnualPMAnalysis(CommonClass.CurrentBaseScenario, this);
                            #endregion
                            break;
                    }
                    #endregion
                }
                CommonClass.CurrentBaseScenario.log.end = DateTime.Now;
                CommonClass.TotalTime = Math.Round(CommonClass.CurrentBaseScenario.log.end.Subtract(CommonClass.CurrentBaseScenario.log.start).TotalSeconds, 3);
                if (!isOK)
                {
                    CommonClass.CurrentBaseScenario.log.lstLog.Add("SMAT-CE terminates. Total SMAT-CE run time: " + CommonClass.TotalTime + " s.");
                }
                else
                {
                    CommonClass.CurrentBaseScenario.log.lstLog.Add("Total SMAT-CE run time: " + CommonClass.TotalTime + " s.");
                }
                CommonClass.CurrentBaseScenario.log.lstLog.Add("Finish SMAT-CE" + " run            " + CommonClass.CurrentBaseScenario.log.end);
                if (!CommonClass.IsBatch)
                {
                    CommonClass.SaveScenario(CommonClass.CurrentBaseScenario, _resultFilePath);
                    WaitClose();
                    ChangeNodeImage(trvAnalysis.Nodes[trvAnalysis.Nodes.Count - 1]);
                    //运行完之后自动打开结果文件夹
                    if (isOK && ((CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doAutomaticallyExtract)
                        || (CommonClass.CurrentBaseScenario.configuration is DailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doAutomaticallyExtract)
                        || (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doAutomaticallyExtract)
                        || (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doAutomaticallyExtract)
                        || CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisChinaConfiguration || CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisChinaConfiguration) || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration
                        || CommonClass.CurrentBaseScenario.configuration is BenMAPAnnualPMAnalysisConfiguration
                        || CommonClass.CurrentBaseScenario.configuration is BenMAPOzoneAnalysisConfiguration)
                    {
                        System.Diagnostics.Process.Start(_resultOutputFiles);
                    }
                    //运行完之后加载当前的scenario
                    CommonClass.OutputNavigator = true;
                    CommonClass.LoadProjectFromStartPageOrAnalysisPage = false;
                    CommonClass.IsFirstLoadProject = true;
                    CommonClass.IsDataViewerState = false;
                    initForm();
                    setStandardMap();
                    CommonClass.FileName = _resultFilePath;
                    CommonClass.CurrentBaseScenario = CommonClass.LoadScenario(_resultFilePath);
                    addTreeListView(_resultFilePath);
                    lblProjectName.Text = CommonClass.CurrentBaseScenario.configuration.configurationName;
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.AnnualPM:
                        case enumAnalysis.AnnualPMChina: lblAnalysis2.Text = Language.Localization.GetValue("Annual PM Analysis"); break;
                        case enumAnalysis.DailyPM: lblAnalysis2.Text = Language.Localization.GetValue("Daily PM Analysis"); break;
                        case enumAnalysis.OzoneChina:
                        case enumAnalysis.Ozone: lblAnalysis2.Text = Language.Localization.GetValue("Ozone Analysis"); break;
                        case enumAnalysis.Visibility: lblAnalysis2.Text = Language.Localization.GetValue("Visibility Analysis"); break;
                        case enumAnalysis.SSIAAnnualPM: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Annual PM Analysis"); break;
                        case enumAnalysis.SSIADailyPM: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Daily PM Analysis"); break;
                        case enumAnalysis.SSIAOzone: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Ozone Analysis"); break;
                        case enumAnalysis.SSIADeposition: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Deposition Analysis"); break;      //added by Lijiabin
                        case enumAnalysis.BenMAPAnnualPM: lblAnalysis2.Text = Language.Localization.GetValue("BenMAP - Annual PM Analysis"); break;
                        case enumAnalysis.BenMAPSeasonalOzone: lblAnalysis2.Text = Language.Localization.GetValue("BenMAP - Ozone Analysis"); break;
                    }

                    if (tlvDataViewer.Items.Count > 1)
                        labelTips.Visible = true;
                    addConfiguration();
                    addLog();
                    btnEdit.Enabled = true;
                    btnExportCFG.Enabled = true;
                    //---------若tlvDataViewer有数据，则下面的按钮能用----
                    btnExtractSelected.Enabled = true;
                    btnExtractAll.Enabled = true;

                    //btnLinkTo.Enabled = true;
                    //btnOutputFor.Enabled = true;
                    //}
                }
                else
                {
                    string projPath = Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"\My SMAT-CE Files\Result\Project\";

                    CommonClass.SaveScenario(CommonClass.CurrentBaseScenario, projPath + _resultFilePath + ".proj");
                    //CommonClass.SaveScenario(CommonClass.CurrentBaseScenario, CommonClass.ResultFilePath + @"\" + _resultFilePath + ".proj");
                }
                string logPath = Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"\My SMAT-CE Files\Result\LOG\";
                if (!Directory.Exists(logPath))
                {
                    Directory.CreateDirectory(logPath);
                }
                CommonClass.SaveLog(CommonClass.CurrentBaseScenario.log, logPath + CommonClass.CurrentBaseScenario.configuration.configurationName + ".log", false);
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            try
            {
                isNext = true;
                string errorTip = "";
                StringBuilder errorBuilder = new StringBuilder("");
                #region
                #region annual
                if (pnlUserControl.Controls[0].Name == "uc_DataInputA")
                {
                    errorTip = checkDataInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region daily
                if (pnlUserControl.Controls[0].Name == "uc_DataInputD")
                {
                    errorTip = checkDataInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region ozone
                if (pnlUserControl.Controls[0].Name == "uc_DataInputOzone")
                {
                    errorTip = checkDataInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region visibility
                if (pnlUserControl.Controls[0].Name == "uc_DataInputV")
                {
                    errorTip = (pnlUserControl.Controls[0] as uc_DataInputV).checkDataInputV();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_ChooseDesiredOutputV")
                {
                    uc_ChooseDesiredOutputV _outputV = (pnlUserControl.Controls[0] as uc_ChooseDesiredOutputV);
                    if (_outputV.rbtnOldIMPROVEAlgorithmVisibility.Checked)
                    {
                        MessageBox.Show(Language.Localization.GetValue("Not currently implemented."));
                        return;
                    }
                }
                #endregion
                #region SSIA Annual
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputA")
                {
                    errorTip = checkSSIAModelInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA")
                {
                    errorTip = checkSSIAMonitorInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Daily added by Yangwenwei
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputD")
                {
                    errorTip = checkSSIAModelInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputD")
                {
                    errorTip = checkSSIAMonitorInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA O3
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputO")
                {
                    errorTip = checkSSIAModelInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputO")
                {
                    errorTip = checkSSIAMonitorInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Deposition added by Lijiabin
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputDep")
                {
                    errorTip = checkSSIAModelInputDep();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region Annual PM China
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataChina")
                {
                    errorTip = checkPMChinaModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataChina")
                {
                    errorTip = checkPMChinaMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_PM25SpeciesOptionChina")
                {
                    errorTip = checkPMChinaSpecies();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region Ozone
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataOzoneChina")
                {
                    errorTip = checkOzoneChinaModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataOzoneChina")
                {
                    errorTip = checkOzoneChinaMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region BenMAP Annual PM
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_ModelData")
                {
                    errorTip = checkBenMAPAnnualPMModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_MonitorData")
                {
                    errorTip = checkBenMAPAnnualPMMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_SpeciesData")
                {
                    errorTip = checkBenMAPAnnualPMSpeciesInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPAnnualPM && pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                {
                    if (!File.Exists(CommonClass.shapefile))
                    {
                        errorNode(trvAnalysis.Nodes[3]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(Language.Localization.GetValue("Grid definition path does not exist!"), Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region BenMAP Ozone

                if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_ModelData")
                {
                    errorTip = checkBenMAPOzoneModel();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_MonitorData")
                {
                    errorTip = checkBenMAPOzoneMonitor();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone && pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                {
                    if (!File.Exists(CommonClass.shapefile))
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(Language.Localization.GetValue("Grid definition path does not exist!"), Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }

                #endregion
                #endregion
                if ((pnlUserControl.Controls[0].Name == "uc_ModelDataA"
                    || pnlUserControl.Controls[0].Name == "uc_ModelDataD"
                    || pnlUserControl.Controls[0].Name == "uc_ModelDataDep"    //added by Lijiabin
                    || pnlUserControl.Controls[0].Name == "uc_RRForSpatialGradientOzone"
                    || pnlUserControl.Controls[0].Name == "uc_FilteringV"
                    //|| pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA"
                    //|| pnlUserControl.Controls[0].Name == "uc_MonitorDataInputD"
                    || pnlUserControl.Controls[0].Name == "uc_CalculationOption")
                    //|| (!ssia_useMonitor && pnlUserControl.Controls[0].Name == "uc_ModelDataInputA")
                    //|| (!ssia_useMonitor && pnlUserControl.Controls[0].Name == "uc_ModelDataInputD")
                    //|| (!ssia_useMonitor && pnlUserControl.Controls[0].Name == "uc_ModelDataInputO")
                    || pnlUserControl.Controls[0].Name == "uc_PM25SpeciesOptionChina"//added by Yangwenwei
                    || pnlUserControl.Controls[0].Name == "uc_MonitorDataOzoneChina"
                    || pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")//added by Yangwenwei
                {
                    errorTip = "";
                    errorTip = SaveCurrentUCConfiguration();
                    if (errorTip != null && errorTip.Length > 0)
                    {
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }

                    SaveOrRunProject frm = new SaveOrRunProject();
                    if (frm.ShowDialog() != DialogResult.OK)
                        return;
                    switch (CommonClass.IsSaveOrRun)
                    {
                        case enumSaveProjectOrRun.SaveProject:
                            btnSave_Click(sender, e);
                            break;
                        case enumSaveProjectOrRun.SaveRunProject:
                            #region
                            //----选择save and run时，先判断是否有错误,若有错误则不能往下走------------
                            //首先check是否设置正确，然后在提示用户save or run
                            #region
                            //-----------保存运行之前check files---------
                            //---------对于每种analysis，若没有选择任何output options，则不run
                            #region
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    AnnualPMAnalysisConfiguration annualPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration;
                                    if (!annualPMAnalysisConfiguration.chooseDesiredOutputA.doStandardAnalysis && !annualPMAnalysisConfiguration.chooseDesiredOutputA.doQuarterlyModelData
                                        && !annualPMAnalysisConfiguration.chooseDesiredOutputA.doUsedQuarterlyAvgModelData && !annualPMAnalysisConfiguration.chooseDesiredOutputA.doSpeciesFraction
                                        && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doInterpolatedSFETempAdj && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doBaseOnlyVNA && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doFutureOnlyVNA
                                        && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doInterpolatedSFETempAdj_GradAdj && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doBaseOnlyEvna && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doFutureOnlyEvna
                                        && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgFilePoint && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgFileSpatial
                                        && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgFileSpatial_GraAdj && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doQuarterlyAvgSpeciatedMonitors
                                        && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doSpeciesFractionSpatial && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doSpeciesFractionSpatial_GraAdj
                                        && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doNeighborFilePoint && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doNeighborFileSpatial
                                        && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doHighCountySites && !annualPMAnalysisConfiguration.outputChoiceAdvancedA.doDesignValuePeriods)
                                    {
                                        MessageBox.Show(Language.Localization.GetValue("Please choose output options!"));
                                        return;
                                    }
                                    break;
                                case enumAnalysis.DailyPM:
                                    DailyPMAnalysisConfiguration dailyPMAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration;
                                    if (!dailyPMAnalysisConfiguration.chooseDesiredOutputD.doStandardAnalysis && !dailyPMAnalysisConfiguration.chooseDesiredOutputD.doSpeciesFraction && !dailyPMAnalysisConfiguration.chooseDesiredOutputD.doQuarterlyPeakModelData
                                        && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doDesignValuePeriods && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doHighCountySites && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doNeighborFilePoint
                                        && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doQuarterlyPeakFilesPoint && !dailyPMAnalysisConfiguration.outputChoiceAdvancedD.doQuarterlyPeakSpeciatedMonitors)
                                    {
                                        MessageBox.Show(Language.Localization.GetValue("Please choose output options!"));
                                        return;
                                    }
                                    break;
                                case enumAnalysis.Ozone:
                                    OzoneAnalysisConfiguration ozoneAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration;
                                    if (!ozoneAnalysisConfiguration.chooseDesiredOutputO.doDesignValuePeriods && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doMaxDesignValuePeriods && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doNeighborFileSpatial && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doPointEstimatesForecast
                                        && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doQuarterlyModelData && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doSpatialFieldEstimates && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj
                                        && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doBaseOnlyVNA && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doFutureOnlyVNA && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doBaseOnlyEVNA && !ozoneAnalysisConfiguration.chooseDesiredOutputO.doFutureOnlyEVNA)
                                    {
                                        MessageBox.Show(Language.Localization.GetValue("Please choose output options!"));
                                        return;
                                    }
                                    break;
                                case enumAnalysis.Visibility:
                                    VisibilityAnalysisConfiguration visibilityAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration;
                                    if (!visibilityAnalysisConfiguration.chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast)
                                    {
                                        MessageBox.Show(Language.Localization.GetValue("Please choose output options!"));
                                        return;
                                    }
                                    break;
                            }
                            #endregion
                            string errorTips = "";
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    errorTips = CommonClass.checkAnnualPMUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.DailyPM:
                                    errorTips = CommonClass.checkDailyPMUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.Ozone:
                                    errorTips = CommonClass.checkOzoneUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.Visibility:
                                    errorTips = CommonClass.checkVisibilityUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.SSIAAnnualPM:
                                    errorTips = CommonClass.checkSSIAAnnualPMUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.SSIADailyPM:
                                    errorTips = CommonClass.checkSSIADailyPMUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.SSIAOzone:
                                    errorTips = CommonClass.checkSSIAOzoneUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.SSIADeposition:                                                     //added by Lijiabin
                                    errorTips = CommonClass.checkSSIADepositionUC(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.AnnualPMChina:
                                    errorTips = CommonClass.checkAnnualPMChina(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.OzoneChina:
                                    errorTips = CommonClass.checkOzoneChina(CommonClass.CurrentBaseScenario);
                                    break;
                                case enumAnalysis.BenMAPAnnualPM:
                                    errorTips = CommonClass.checkBenMAPAnnualPMUC(CommonClass.CurrentBaseScenario);
                                    break;
                            }
                            if (errorTips != null && errorTips.Length > 0)
                            {
                                MessageBox.Show(errorTips, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                                return;
                            }
                            #endregion
                            #endregion
                            btnSaveRun_Click(sender, e);
                            break;
                    }
                    return;
                }
                NextBackOperation();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            try
            {
                isNext = false;
                string errorTip = "";
                StringBuilder errorBuilder = new StringBuilder("");
                #region
                switch (pnlUserControl.Controls[0].Name)
                {
                    case "uc_DataInputA":
                        errorTip = checkDataInputA();
                        if (errorTip != "" && errorTip.Length > 0)
                        {
                            errorNode(trvAnalysis.Nodes[2]);
                            btnSaveRun.Enabled = false;
                            MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                            return;
                        }
                        break;
                    case "uc_ModelDataA":
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select Official Quarterly Averge FRM Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "uc_DataInputD":
                        errorTip = checkDataInputD();
                        if (errorTip != "" && errorTip.Length > 0)
                        {
                            errorNode(trvAnalysis.Nodes[2]);
                            btnSaveRun.Enabled = false;
                            MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                            return;
                        }
                        break;
                    case "uc_ModelDataD":
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select Official Quarterly Averge FRM Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "uc_DataInputOzone":
                        errorTip = checkDataInputO();
                        if (errorTip != "" && errorTip.Length > 0)
                        {
                            errorNode(trvAnalysis.Nodes[1]);
                            btnSaveRun.Enabled = false;
                            MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                            return;
                        }
                        break;
                    case "uc_RRForSpatialGradientOzone":
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO == null)
                        {
                            MessageBox.Show(Language.Localization.GetValue("Please select Ozone Data File in Data Input!"));
                            return;
                        }
                        break;
                    case "uc_DataInputV":
                        errorTip = (pnlUserControl.Controls[0] as uc_DataInputV).checkDataInputV();
                        if (errorTip != "" && errorTip.Length > 0)
                        {
                            errorNode(trvAnalysis.Nodes[1]);
                            btnSaveRun.Enabled = false;
                            MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                            return;
                        }
                        break;
                }
                #endregion
                #region
                //if (pnlUserControl.Controls[0].Name == "uc_DataInputA")
                //{
                //    errorTip = checkDataInputA();
                //    if (errorTip != "" && errorTip.Length > 0)
                //    {
                //        errorNode(trvAnalysis.Nodes[2]);
                //        btnSaveRun.Enabled = false;
                //        MessageBox.Show(errorTip, "Tip", MessageBoxButtons.OK);
                //        return;
                //    }
                //}
                #endregion
                #region daily
                //if (pnlUserControl.Controls[0].Name == "uc_DataInputD")
                //{
                //    errorTip = checkDataInputD();
                //    if (errorTip != "" && errorTip.Length > 0)
                //    {
                //        errorNode(trvAnalysis.Nodes[2]);
                //        btnSaveRun.Enabled = false;
                //        MessageBox.Show(errorTip, "Tip", MessageBoxButtons.OK);
                //        return;
                //    }
                //}
                #endregion
                #region ozone
                //if (pnlUserControl.Controls[0].Name == "uc_DataInputOzone")
                //{
                //    errorTip = checkDataInputO();
                //    if (errorTip != "" && errorTip.Length > 0)
                //    {
                //        errorNode(trvAnalysis.Nodes[1]);
                //        btnSaveRun.Enabled = false;
                //        MessageBox.Show(errorTip, "Tip", MessageBoxButtons.OK);
                //        return;
                //    }
                //}
                #endregion
                #region visibility
                //if (pnlUserControl.Controls[0].Name == "uc_DataInputV")
                //{
                //    errorTip = checkDataInputV();
                //    if (errorTip != "" && errorTip.Length > 0)
                //    {
                //        errorNode(trvAnalysis.Nodes[1]);
                //        btnSaveRun.Enabled = false;
                //        MessageBox.Show(errorTip, "Tip", MessageBoxButtons.OK);
                //        return;
                //    }
                //}
                #endregion
                #region SSIA Annual
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputA")
                {
                    errorTip = checkSSIAModelInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputA")
                {
                    errorTip = checkSSIAMonitorInputA();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Daily added by Yangwenwei
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputD")
                {
                    errorTip = checkSSIAModelInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputD")
                {
                    errorTip = checkSSIAMonitorInputD();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA O3
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputO")
                {
                    errorTip = checkSSIAModelInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataInputO")
                {
                    errorTip = checkSSIAMonitorInputO();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region SSIA Deposition added by Lijiabin
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataInputDep")
                {
                    errorTip = checkSSIAModelInputDep();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region Annual PM China
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataChina")
                {
                    errorTip = checkPMChinaModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataChina")
                {
                    errorTip = checkPMChinaMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_PM25SpeciesOptionChina")
                {
                    errorTip = checkPMChinaSpecies();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region Ozone
                if (pnlUserControl.Controls[0].Name == "uc_ModelDataOzoneChina")
                {
                    errorTip = checkOzoneChinaModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_MonitorDataOzoneChina")
                {
                    errorTip = checkOzoneChinaMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region BenMAP Annual PM
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_ModelData")
                {
                    errorTip = checkBenMAPAnnualPMModelInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_MonitorData")
                {
                    errorTip = checkBenMAPAnnualPMMonitorInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMAP_AnnualPM_SpeciesData")
                {
                    errorTip = checkBenMAPAnnualPMSpeciesInput();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPAnnualPM && pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                {
                    if (!File.Exists(CommonClass.shapefile))
                    {
                        errorNode(trvAnalysis.Nodes[3]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(Language.Localization.GetValue("Grid definition path does not exist!"), Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                #endregion
                #region BenMAP Ozone

                if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_ModelData")
                {
                    errorTip = checkBenMAPOzoneModel();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[0]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (pnlUserControl.Controls[0].Name == "uc_BenMap_Ozone_MonitorData")
                {
                    errorTip = checkBenMAPOzoneMonitor();
                    if (errorTip != "" && errorTip.Length > 0)
                    {
                        errorNode(trvAnalysis.Nodes[1]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }
                if (CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone && pnlUserControl.Controls[0].Name == "uc_BenMAP_GridDefinition")
                {
                    if (!File.Exists(CommonClass.shapefile))
                    {
                        errorNode(trvAnalysis.Nodes[2]);
                        btnSaveRun.Enabled = false;
                        MessageBox.Show(Language.Localization.GetValue("Grid definition path does not exist!"), Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                        return;
                    }
                }

                #endregion
                if (errorTip != "" && errorTip.Length > 0)
                {
                    MessageBox.Show(errorTip, Language.Localization.GetValue("Tip"), MessageBoxButtons.OK);
                    return;
                }
                NextBackOperation();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //--------------Timer
        private void timerLoad_Tick(object sender, EventArgs e)
        {
            try
            {
                ChangeNodeImage(trvAnalysis.Nodes[trvAnalysis.Nodes.Count - 1]);
                timerLoad.Enabled = false;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //---------DataViewer界面中，Link to BenMAP按钮
        private void btnLinkTo_Click(object sender, EventArgs e)
        {
            try
            {
                //SetUpforBenMAP frm = new SetUpforBenMAP();
                //frm.Show();
                string setup = "United States";
                string gridType = "CMAQ 12km Nation";
                string pollutant = "";
                string baseFile = "";
                string controlFile = "";
                if (CommonClass.CurrentBaseScenario.configuration is BenMAPAnnualPMAnalysisConfiguration)
                {
                    pollutant = "PM2.5";
                    BenMAPAnnualPMAnalysisConfiguration annualPMSSIAAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as BenMAPAnnualPMAnalysisConfiguration;
                    List<BaseOutput> bo = new List<BaseOutput>();
                    if (rbtnVNA.Checked)
                    {
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(annualPMSSIAAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Annual PM25 Spatial Field Base").ToList();
                        if (bo.Count == 0) return;
                        baseFile = bo.First().outputFilePath;
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(annualPMSSIAAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Annual PM25 Spatial Field Future").ToList();
                        if (bo.Count == 0) return;
                        controlFile = bo.First().outputFilePath;
                    }
                    else
                    {
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(annualPMSSIAAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Grad Adj Annual PM25 Spatial Field Base").ToList();
                        if (bo.Count == 0) return;
                        baseFile = bo.First().outputFilePath;
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(annualPMSSIAAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Grad Adj Annual PM25 Spatial Field Future").ToList();
                        if (bo.Count == 0) return;
                        controlFile = bo.First().outputFilePath;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is BenMAPOzoneAnalysisConfiguration)
                {
                    pollutant = "Ozone";
                    BenMAPOzoneAnalysisConfiguration OzoneAnalysisConfiguration = CommonClass.CurrentBaseScenario.configuration as BenMAPOzoneAnalysisConfiguration;
                    List<BaseOutput> bo = new List<BaseOutput>();
                    if (rbtnVNA.Checked)
                    {
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(OzoneAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Ozone Spatial Field Base").ToList();
                        if (bo.Count == 0) return;
                        baseFile = bo.First().outputFilePath;
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(OzoneAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Ozone Spatial Field Future").ToList();
                        if (bo.Count == 0) return;
                        controlFile = bo.First().outputFilePath;
                    }
                    else
                    {
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(OzoneAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Grad Adj Ozone Spatial Field Base").ToList();
                        if (bo.Count == 0) return;
                        baseFile = bo.First().outputFilePath;
                        bo = CommonClass.CurrentBaseScenario.lstOutput.Where(q => q.outputName.Replace(OzoneAnalysisConfiguration.modelInput.scenarioName, "").Trim() == "Grad Adj Ozone Spatial Field Future").ToList();
                        if (bo.Count == 0) return;
                        controlFile = bo.First().outputFilePath;
                    }
                }

                string installLocation = "";
                string strPath = CommonClass.ResultFilePath + @"\SMAT.exe.config";
                XmlDocument doc = new XmlDocument();
                doc.Load(strPath);//Application.ExecutablePath + ".config");
                XmlNode node = doc.SelectSingleNode(@"//add[@key='BenMAP-CEpath']");
                XmlElement ele = (XmlElement)node;

                if (ele != null && ele.GetAttribute("value") != "")
                {
                    installLocation = ele.GetAttribute("value");
                }

                if (!File.Exists(installLocation))
                {
                    installLocation = Application.ExecutablePath.Replace("SMAT", "BenMAP");
                }

                if (!File.Exists(installLocation))
                {
                    installLocation = checkInstall();
                }

                if (!File.Exists(installLocation))
                {
                    SelectBenMAPexePath frm = new SelectBenMAPexePath();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        installLocation = frm.filePath;
                    }
                    else
                        return;
                }
                //声明一个程序信息类
                System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
                //设置外部程序名
                Info.FileName = "BenMAP.exe";
                //设置外部程序的启动参数（命令行参数）
                Info.Arguments = "SMAT*" + setup + "*" + gridType + "*" + pollutant + "*" + baseFile + "*" + controlFile;
                //设置外部程序工作目录
                Info.WorkingDirectory = Path.GetDirectoryName(installLocation);
                //声明一个程序类
                System.Diagnostics.Process Proc;

                try
                {
                    //启动外部程序
                    Proc = System.Diagnostics.Process.Start(Info);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Language.Localization.GetValue("BenMAP-CE may not be intalled successfully."));
                    CommonClass.LogError(ex);
                    return;
                }
                //System.Diagnostics.Process.Start(@"D:\软件项目\BenMAP\trunk\Code\BenMAP\bin\Debug\BenMAP.exe", "SMAT*" + pollutant + "*" + baseFile + "*" + controlFile);//test
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        virtual public int PlateFormRunMode
        {
            get
            {
                if (IntPtr.Size == 8)
                {
                    return 64;
                }
                return 32;
            }
        }
        private string checkInstall()
        {
            try
            {
                string str = "";
                if (PlateFormRunMode == 64)
                    str = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
                else
                    str = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

                Microsoft.Win32.RegistryKey uninstallNode = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(str);
                foreach (string subKeyName in uninstallNode.GetSubKeyNames())
                {
                    Microsoft.Win32.RegistryKey subKey = uninstallNode.OpenSubKey(subKeyName);
                    object displayName = subKey.GetValue("DisplayName");
                    if (displayName != null)
                    {
                        if (displayName.ToString().Contains("BenMAP-CE"))
                        {
                            string installLocation = subKey.GetValue("InstallLocation", "").ToString();//获取安装路径
                            return installLocation + @"BenMAP-CE\BenMAP.exe";
                        }
                    }
                }
                return "";
            }
            catch
            { return ""; }
        }

        //-----------DataViewer界面中，Output for BenMAP按钮
        private void btnOutputFor_Click(object sender, EventArgs e)
        {
            try
            {
                SaveAs frm = new SaveAs();
                frm.Show();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //---------Analysis界面中，新建scenario,默认的与currentAnalysis一致---------------
        private void pboCreateCFG_Click(object sender, EventArgs e)
        {
            try
            {
                bool isSave = false;
                DialogResult rtn = DialogResult.No;
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null || ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doQuarterlyModelData
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doSpeciesFraction || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doStandardAnalysis
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doUsedQuarterlyAvgModelData))
                            isSave = true;
                        break;
                    case enumAnalysis.DailyPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null
                            || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null
                            || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null
                            || ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doQuarterlyPeakModelData
                            || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doSpeciesFraction || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doStandardAnalysis))
                            isSave = true;
                        break;
                    case enumAnalysis.Ozone:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null
                            || ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDesignValuePeriods || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doMaxDesignValuePeriods
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doNeighborFileSpatial || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doPointEstimatesForecast
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doQuarterlyModelData || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj))
                            isSave = true;
                        break;
                    case enumAnalysis.Visibility:
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null
                            || ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast
                            || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellatClassIAreaCentroid || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellAtMonitor
                            || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseNewVersionforIMPROVEAlgorithm || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm))
                            isSave = true;
                        break;
                    case enumAnalysis.SSIAAnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null
                            || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null)
                            isSave = true;
                        break;
                    case enumAnalysis.AnnualPMChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                            isSave = true;
                        break;
                    case enumAnalysis.OzoneChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                            isSave = true;
                        break;
                }
                if (isSave)
                    rtn = MessageBox.Show(Language.Localization.GetValue("Save project?"), Language.Localization.GetValue("Tip"), MessageBoxButtons.YesNo);
                //DialogResult rtn = MessageBox.Show("Save project?", "Tip", MessageBoxButtons.YesNo);
                if (rtn == DialogResult.Yes)
                {
                    SaveFileDialog saveFile = new SaveFileDialog();
                    saveFile.Title = "";
                    saveFile.Title = Language.Localization.GetValue("Save project...");
                    saveFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Project";
                    saveFile.Filter = Language.Localization.GetValue("Project files(*.proj)|*.proj");
                    saveFile.RestoreDirectory = true;
                    if (saveFile.ShowDialog() == DialogResult.OK)
                    {
                        CommonClass.SaveScenario(CommonClass.CurrentBaseScenario, saveFile.FileName);
                    }
                    else
                        return;
                }
                CommonClass.OpenScenario = false;
                CommonClass.OutputNavigator = false;
                CommonClass.IsDataViewerState = false;
                initForm();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //---------Analysis界面中，打开一个project,default view to "data viewer"
        private void pboOpenCFG_Click(object sender, EventArgs e)
        {
            try
            {
                bool isSave = false;
                DialogResult rtn = DialogResult.No;
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).outputChoiceAdvancedA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).dataInputA != null
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).speciesFractionOptionsA != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).pm25CalculationOptionsA != null
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).modelDataOptionsA != null || ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doQuarterlyModelData
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doSpeciesFraction || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doStandardAnalysis
                            || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisConfiguration).chooseDesiredOutputA.doUsedQuarterlyAvgModelData))
                            isSave = true;
                        break;
                    case enumAnalysis.DailyPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).outputChoiceAdvancedD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).dataInputD != null
                            || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).speciesFractionOptionsD != null || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).pm25CalculationOptionsD != null
                            || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).modelDataOptionsD != null
                            || ((CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doQuarterlyPeakModelData
                            || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doSpeciesFraction || (CommonClass.CurrentBaseScenario.configuration as DailyPMAnalysisConfiguration).chooseDesiredOutputD.doStandardAnalysis))
                            isSave = true;
                        break;
                    case enumAnalysis.Ozone:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).dataInputO != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).filteringInterpolationO != null
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).rrfSpatialGradientO != null
                            || ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyEVNA
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doBaseOnlyVNA || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doDesignValuePeriods || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doMaxDesignValuePeriods
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyEVNA || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doFutureOnlyVNA
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doNeighborFileSpatial || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doPointEstimatesForecast
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doQuarterlyModelData || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimates
                            || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisConfiguration).chooseDesiredOutputO.doSpatialFieldEstimatesGradAdj))
                            isSave = true;
                        break;
                    case enumAnalysis.Visibility:
                        if ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).dataInputV != null || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).filteringV != null
                            || ((CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doAutomaticallyExtract || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.doTemporallyAdjVisibilityLevelsForecast
                            || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellatClassIAreaCentroid || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseModelGridCellAtMonitor
                            || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseNewVersionforIMPROVEAlgorithm || (CommonClass.CurrentBaseScenario.configuration as VisibilityAnalysisConfiguration).chooseDesiredOutputV.choiceUseOldVersionforIMPROVEAlgorithm))
                            isSave = true;
                        break;
                    case enumAnalysis.SSIAAnnualPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).modelInputA != null
                            || (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null)
                            isSave = true;
                        break;
                    case enumAnalysis.SSIADailyPM:
                        if ((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).modelInputD != null
                            || (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null)
                            isSave = true;
                        break;
                    case enumAnalysis.AnnualPMChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).modelDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).monitorDataInputChina != null || (CommonClass.CurrentBaseScenario.configuration as AnnualPMAnalysisChinaConfiguration).pm25SpeciesOptionChina != null)
                            isSave = true;
                        break;
                    case enumAnalysis.OzoneChina:
                        if ((CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).modelDataOzoneChina != null || (CommonClass.CurrentBaseScenario.configuration as OzoneAnalysisChinaConfiguration).monitorDataOzoneChina != null)
                            isSave = true;
                        break;
                }
                if (isSave)
                    rtn = MessageBox.Show(Language.Localization.GetValue("Save project?"), Language.Localization.GetValue("Tip"), MessageBoxButtons.YesNo);
                //DialogResult rtn = MessageBox.Show("Save project?", "Tip", MessageBoxButtons.YesNo);
                if (rtn == DialogResult.Yes)
                {
                    SaveFileDialog saveFile = new SaveFileDialog();
                    saveFile.Title = "";
                    saveFile.Title = Language.Localization.GetValue("Save project...");
                    saveFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Project";
                    saveFile.Filter = Language.Localization.GetValue("Project files(*.proj)|*.proj");
                    saveFile.RestoreDirectory = true;
                    if (saveFile.ShowDialog() == DialogResult.OK)
                    {
                        CommonClass.SaveScenario(CommonClass.CurrentBaseScenario, saveFile.FileName);
                    }
                    else
                        return;
                }
                OpenFileDialog openfile = new OpenFileDialog();
                openfile.Title = Language.Localization.GetValue("Select a project");
                openfile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Project";
                openfile.Filter = Language.Localization.GetValue("Project files(*.proj)|*.proj");
                openfile.RestoreDirectory = true;
                if (openfile.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                //CommonClass.OpenScenario = true;
                //CommonClass.OutputNavigator = false;
                //CommonClass.IsDataViewerState = false;
                //CommonClass.CurrentBaseScenario = CommonClass.LoadScenario(openfile.FileName);
                //CommonClass.FileName = openfile.FileName;
                CommonClass.OpenScenario = false;
                CommonClass.OutputNavigator = true;
                CommonClass.LoadProjectFromStartPageOrAnalysisPage = true;
                CommonClass.IsDataViewerState = false;
                //CommonClass.CurrentBaseScenario = CommonClass.LoadScenario(openfile.FileName);
                CommonClass.FileName = openfile.FileName;
                initForm();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //----------Data tab中，导出当前数据--------------
        private void btnExport_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvDataView.Rows.Count == 0)
                    return;
                SaveFileDialog savefile = new SaveFileDialog();
                savefile.Title = Language.Localization.GetValue("Save files...");
                savefile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\CSV";
                savefile.Filter = Language.Localization.GetValue("CSV files(*.csv)|*.csv");
                savefile.RestoreDirectory = true;
                if (savefile.ShowDialog() == DialogResult.Cancel)
                    return;
                CommonClass.SaveCSV(_dtSelectOutput, savefile.FileName, _dataType);
                MessageBox.Show(Language.Localization.GetValue("Save as CSV successfully!"));
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //-----------Data Viewer界面中，导出选择的文件
        private void btnExtractSelected_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.tlvDataViewer.SelectedItems.Count == 0) return;
                if (this.tlvDataViewer.SelectedItems[0].Tag.ToString() != "cfg"
                    && this.tlvDataViewer.SelectedItems[0].Tag.ToString() != "logfile" && this.tlvDataViewer.SelectedItems[0].Tag.ToString() != "outputfiles")
                    return;
                SaveFileDialog savefile = new SaveFileDialog();
                savefile.Title = Language.Localization.GetValue("Save files...");
                switch (this.tlvDataViewer.SelectedItems[0].Tag.ToString())
                {
                    case "cfg":
                        savefile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\CFG";
                        savefile.Filter = Language.Localization.GetValue("CFG files(*.cfg)|*.cfg");
                        savefile.RestoreDirectory = true;
                        if (savefile.ShowDialog() != DialogResult.OK)
                            return;
                        CommonClass.ProjectName = CommonClass.FileName;
                        BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, savefile.FileName);
                        if (CommonClass.CurrentBaseScenario.configuration.configurationName != Path.GetFileNameWithoutExtension(savefile.FileName))
                            CommonClass.CurrentBaseScenario.configuration.configurationName = Path.GetFileNameWithoutExtension(savefile.FileName);
                        CommonClass.CurrentBaseScenario.configuration.configurationPath = savefile.FileName;
                        break;
                    case "logfile":
                        savefile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\LOG";
                        savefile.Filter = Language.Localization.GetValue("log file(*.log)|*.log");
                        savefile.RestoreDirectory = true;
                        if (savefile.ShowDialog() != DialogResult.OK)
                            return;
                        CommonClass.SaveLog(CommonClass.CurrentBaseScenario.log, savefile.FileName, true);
                        break;
                    case "outputfiles":
                        savefile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\CSV";
                        savefile.Filter = Language.Localization.GetValue("CSV files(*.csv)|*.csv");
                        savefile.RestoreDirectory = true;
                        if (savefile.ShowDialog() != DialogResult.OK)
                            return;
                        string originFile = this.tlvDataViewer.SelectedItems[0].Name.ToString();
                        string newFile = savefile.FileName;
                        // BenMAP-ready导出文件不包含经纬度2列 ty
                        if (originFile.Contains("BenMAP-ready"))
                        {
                            //tsmiExportOutputs_Click(null, null);
                            string dataType = "";
                            DataTable dt = null;
                            bool errorOccur = false;
                            dt = CommonClass.getDataSetFromCSVAndFirstLine(originFile, ref dataType, ref errorOccur, true);
                            CommonClass.SaveCSV(dt, savefile.FileName, dataType);
                        }
                        //
                        else
                        {
                            File.Copy(originFile, newFile, true);
                        }
                        //string dataType = "";
                        //DataTable dt = null;
                        //dt = CommonClass.getDataSetFromCSVAndFirstLine(this.tlvDataViewer.SelectedItems[0].Name.ToString(), ref dataType);
                        //CommonClass.SaveCSV(dt, savefile.FileName, dataType);
                        break;
                }
                MessageBox.Show(Language.Localization.GetValue("Save file successfully!"));
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //----------Data Viewer界面中， 导出所有文件，包括Log,configuration和Ouptutfiles
        private void btnExtractAll_Click(object sender, EventArgs e)
        {
            try
            {
                SaveAs frm = new SaveAs();
                frm.ShowDialog();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //----------Data Viewer界面中，加载ASRX文件，显示文件列表
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openfile = new OpenFileDialog();
                openfile.Title = Language.Localization.GetValue("Select project...");
                openfile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Project";
                openfile.RestoreDirectory = true;
                openfile.Filter = Language.Localization.GetValue("Project files(*.proj)|*.proj");
                if (openfile.ShowDialog() != DialogResult.OK)
                    return;
                LoadProject(openfile.FileName);
                cboSpeciesTypeGIS.Items.Clear();
                CommonClass.dicBlend.Clear();
                CommonClass.dicLayerValueRange.Clear();
                lstSpeciesTypeMap.Items.Clear();
                dgvGridInfo.DataSource = null;
                lblMAPname.Text = "";
                if (CommonClass.modelDefinition == null)
                {
                    CommonClass.modelDefinition = new ModelDefinition();
                    CommonClass.modelDefinition.ActiveGridType = "12km";
                    bool ok = CommonClass.modelDefinition.ParseModelDef("", !CommonClass.currentProjisLCC());
                    if (!ok)
                    {
                        return;
                    }
                }

                if (CommonClass.modelDefinition.ShapeLCCFiles == null)
                    CommonClass.modelDefinition.ShapeLCCFiles = new Dictionary<string, Dictionary<string, double[,]>>();
                if (!CommonClass.modelDefinition.ShapeLCCFiles.ContainsKey(CommonClass.modelDefinition.ActiveGridType))
                    CommonClass.modelDefinition.ShapeLCCFiles.Add(CommonClass.modelDefinition.ActiveGridType, new Dictionary<string, double[,]>());
                //SMAT-China Map added by Yangwenwei
                if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("region") && LanguageOld.IsSMATChina)
                {
                    CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\China_Region.csv");
                    CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("region", CommonClass.ShapeLCC);
                }
                if (!CommonClass.currentProjisLCC())
                {
                    if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("state_utm"))
                    {
                        CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state_utm.csv");
                        CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("state_utm", CommonClass.ShapeLCC);
                    }
                }
                else
                {
                    if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("state"))
                    {
                        CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state.csv");
                        CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("state", CommonClass.ShapeLCC);
                    }
                }
                //if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("county"))
                //{
                //    CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\county.csv");
                //    CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("county", CommonClass.ShapeLCC);
                //}
                CommonClass.modelDefinition.ParseModelDef("", !CommonClass.currentProjisLCC());
                plotControl1.modelDef = CommonClass.modelDefinition.modelDef;
                if (LanguageOld.IsSMATChina)
                    plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("region");
                else if (!CommonClass.currentProjisLCC())
                    plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state_utm");
                else
                    plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state");
                plotControl1.ColorBlendControl = colorBlendMap;
                colorBlendMap.ValueUnit = CommonClass.modelDefinition.modelDef.ValueUnit;
                CommonClass.modelDefinition.GridValues = new Dictionary<string, double>();
                plotControl1.UseInterpolation = true;
                Dictionary<string, double> dic = new Dictionary<string, double>();
                dic.Add("0,0", 0);
                plotControl1.NewGridValues = dic;
                plotControl1.UseInterpolation = false;

                cboSpeciesTypeGIS.Items.Clear();
                cboSpeciesTypeGIS.Enabled = false;
                btnZoomIn.Enabled = false;
                btnZoomOut.Enabled = false;
                btnChangeBoundary.Enabled = false;
                tsbtnPlotMonitors.Enabled = false; this.plotControl1.IsDrawMonitors = false; plotControl1.isMarkSelectedPoint = false;
                btnSavePic.Enabled = false;
                btnBar.Visible = false;
                btnDistribution.Visible = false;
                btnFrequency.Visible = false;
                lblNote.Visible = false;
                clboQuantifiers.ItemCheck -= new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                dataDomainGIS = null;
                //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 18);
                //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 7);
                //added by Yangwenwei
                if ((!LanguageOld.IsSMATChina))// && groupBox3.Left == 6)
                {
                    gbxQuantifiers.Visible = true;
                    splitContainerData.Panel1MinSize = 25;
                    splitContainerData.SplitterDistance = 214;
                    //groupBox3.Width -= 220;
                    //groupBox3.Left = 226;
                }
                else if (LanguageOld.IsSMATChina)// && groupBox3.Left == 226)
                {
                    gbxQuantifiers.Visible = false;
                    splitContainerData.Panel1MinSize = 0;
                    splitContainerData.SplitterDistance = 0;
                    //groupBox3.Width += 220;
                    //groupBox3.Left = 6;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        public void LoadProject(string filePath)
        {
            try
            {
                //bool LoadChinaProject = false;
                LanguageOld.IsSMATChina = false;
                CommonClass.CurrentBaseScenario = CommonClass.LoadScenario(filePath);
                if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration)
                    CommonClass.CurrentAnalysis = enumAnalysis.AnnualPM;
                else if (CommonClass.CurrentBaseScenario.configuration is DailyPMAnalysisConfiguration)
                    CommonClass.CurrentAnalysis = enumAnalysis.DailyPM;
                else if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisConfiguration)
                    CommonClass.CurrentAnalysis = enumAnalysis.Ozone;
                else if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                    CommonClass.CurrentAnalysis = enumAnalysis.Visibility;
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                {
                    #region UpdateConfig Set ShowSSIA to T
                    XmlDocument doc = new XmlDocument();
                    doc.Load(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    XmlNode node = doc.SelectSingleNode(@"//add[@key='ShowSSIA']");
                    XmlElement ele = (XmlElement)node;
                    ele.SetAttribute("value", "T");
                    doc.Save(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    System.Configuration.ConfigurationManager.RefreshSection("appSettings");
                    #endregion
                    CommonClass.CurrentAnalysis = enumAnalysis.SSIAAnnualPM;
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                {
                    #region UpdateConfig Set ShowSSIA to T
                    XmlDocument doc = new XmlDocument();
                    doc.Load(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    XmlNode node = doc.SelectSingleNode(@"//add[@key='ShowSSIA']");
                    XmlElement ele = (XmlElement)node;
                    ele.SetAttribute("value", "T");
                    doc.Save(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    System.Configuration.ConfigurationManager.RefreshSection("appSettings");
                    #endregion
                    CommonClass.CurrentAnalysis = enumAnalysis.SSIAOzone;
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                {
                    #region UpdateConfig Set ShowSSIA to T
                    XmlDocument doc = new XmlDocument();
                    doc.Load(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    XmlNode node = doc.SelectSingleNode(@"//add[@key='ShowSSIA']");
                    XmlElement ele = (XmlElement)node;
                    ele.SetAttribute("value", "T");
                    doc.Save(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    System.Configuration.ConfigurationManager.RefreshSection("appSettings");
                    #endregion
                    CommonClass.CurrentAnalysis = enumAnalysis.SSIADailyPM;
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                {
                    #region UpdateConfig Set ShowSSIA to T
                    XmlDocument doc = new XmlDocument();
                    doc.Load(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    XmlNode node = doc.SelectSingleNode(@"//add[@key='ShowSSIA']");
                    XmlElement ele = (XmlElement)node;
                    ele.SetAttribute("value", "T");
                    doc.Save(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    System.Configuration.ConfigurationManager.RefreshSection("appSettings");
                    #endregion
                    CommonClass.CurrentAnalysis = enumAnalysis.SSIADeposition;
                }
                else if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisChinaConfiguration)
                {
                    CommonClass.CurrentAnalysis = enumAnalysis.AnnualPMChina;
                    LanguageOld.IsSMATChina = true;
                }
                else if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisChinaConfiguration)
                {
                    CommonClass.CurrentAnalysis = enumAnalysis.OzoneChina;
                    LanguageOld.IsSMATChina = true;
                }
                else if (CommonClass.CurrentBaseScenario.configuration is BenMAPAnnualPMAnalysisConfiguration)
                    CommonClass.CurrentAnalysis = enumAnalysis.BenMAPAnnualPM;
                else if (CommonClass.CurrentBaseScenario.configuration is BenMAPOzoneAnalysisConfiguration)
                    CommonClass.CurrentAnalysis = enumAnalysis.BenMAPSeasonalOzone;
                string isShowSSIA = "";
                //added by Yangwenwei
                if (LanguageOld.IsSMATChina)
                {
                    #region UpdateConfig Set IncludeChina to T
                    XmlDocument doc = new XmlDocument();
                    doc.Load(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    XmlNode node = doc.SelectSingleNode(@"//add[@key='IncludeChina']");
                    XmlElement ele = (XmlElement)node;
                    ele.SetAttribute("value", "T");
                    doc.Save(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    System.Configuration.ConfigurationManager.RefreshSection("appSettings");
                    #endregion
                    (this.ParentForm as Main).tsbtnLanguage.Visible = true;
                    (this.ParentForm as Main).tsmiVisibility.Visible = false;
                    (this.ParentForm as Main).tsmiDailyPM.Visible = false;
                    (this.ParentForm as Main).tsbtnSingleAssessment.Visible = false;
                    (this.ParentForm as Main).tsbtnLanguage.Text = "China";
                }
                if (!LanguageOld.IsSMATChina)
                {
                    #region Set SSIA Visible/Unvisible
                    XmlDocument doc = new XmlDocument();
                    doc.Load(CommonClass.ResultFilePath + @"\SMAT.exe.config");//Application.ExecutablePath + ".config");
                    XmlNode node = doc.SelectSingleNode(@"//add[@key='ShowSSIA']");
                    if (node != null)
                    {
                        XmlElement ele = (XmlElement)node;
                        ele = (XmlElement)node;
                        isShowSSIA = ele.GetAttribute("value");
                        //BetaVersion，需要隐藏SSIA module
                        (this.ParentForm as Main).tsbtnSingleAssessment.Visible = !CommonClass.BetaVersion && isShowSSIA == "T" ? true : false;
                    }
                    #endregion
                    (this.ParentForm as Main).tsmiDailyPM.Visible = true;
                    (this.ParentForm as Main).tsmiVisibility.Visible = true;
                    (this.ParentForm as Main).tsbtnLanguage.Text = "USA";
                }
                CommonClass.FileName = filePath;
                addTreeListView(filePath);
                lblProjectName.Text = CommonClass.CurrentBaseScenario.configuration.configurationName;
                switch (CommonClass.CurrentAnalysis)
                {
                    case enumAnalysis.AnnualPM:
                    case enumAnalysis.AnnualPMChina: lblAnalysis2.Text = Language.Localization.GetValue("Annual PM Analysis"); break;
                    case enumAnalysis.DailyPM: lblAnalysis2.Text = Language.Localization.GetValue("Daily PM Analysis"); break;
                    case enumAnalysis.OzoneChina:
                    case enumAnalysis.Ozone: lblAnalysis2.Text = Language.Localization.GetValue("Ozone Analysis"); break;
                    case enumAnalysis.Visibility: lblAnalysis2.Text = Language.Localization.GetValue("Visibility Analysis"); break;
                    case enumAnalysis.SSIAAnnualPM: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Annual PM Analysis"); break;
                    case enumAnalysis.SSIADailyPM: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Daily PM Analysis"); break;
                    case enumAnalysis.SSIAOzone: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Ozone Analysis"); break;
                    case enumAnalysis.SSIADeposition: lblAnalysis2.Text = Language.Localization.GetValue("SSIA - Deposition Analysis"); break;
                    case enumAnalysis.BenMAPAnnualPM: lblAnalysis2.Text = Language.Localization.GetValue("BenMAP - Annual PM Analysis"); break;
                    case enumAnalysis.BenMAPSeasonalOzone: lblAnalysis2.Text = Language.Localization.GetValue("BenMAP - Ozone Analysis"); break;
                }
                if (tlvLogFile.Items.Count > 0)
                    tlvLogFile.Items.Clear();
                if (listViewCFG.Items.Count > 0)
                    listViewCFG.Items.Clear();
                if (CommonClass.CurrentBaseScenario.log != null)
                {
                    addLog();
                    addConfiguration();
                }
                if (CommonClass.IsFirstLoadProject)
                    this.tbcFunction.SelectedTab = tbpLog;
                else
                    this.tbcFunction.SelectedTab = tbpGIS;
                if (listViewCFG.Items.Count > 0)
                {
                    btnClose.Enabled = true;
                    btnEdit.Enabled = true;
                    btnExportCFG.Enabled = true;
                    picCloseCFG.Visible = true;
                }
                //----------清空原有的数据：data,chart,map---------
                if (dgvDataView.Columns.Count > 0)
                    dgvDataView.Columns.Clear();
                dgvDataView.DataSource = null;
                dgvDataView.Refresh();
                if (clboQuantifiers.Items.Count > 0)
                    clboQuantifiers.Items.Clear();
                if (dgvDataList.Columns.Count > 0)
                    dgvDataList.Columns.Clear();
                dgvDataList.DataSource = null;
                dgvDataList.Refresh();
                _dtChangeDigit = null;
                this.numericUpDownResult.Value = 4;
                if (cboFilter.Items.Count > 0)
                    cboFilter.Items.Clear();
                if (cboType.Items.Count > 0)
                    cboType.Items.Clear();
                //清空ZedGraph
                GraphPane myPane = this.zgcChart.GraphPane;
                myPane.CurveList.Clear();
                myPane.GraphObjList.Clear();
                myPane.Title.Text = "";
                myPane.XAxis.Title.Text = "";
                myPane.YAxis.Title.Text = "";
                myPane.XAxis.Scale.TextLabels = null;
                myPane.Chart.Fill = new Fill();

                if (dgvDataList.Columns.Count == 0)
                {
                    //btnApply.Enabled = false;
                }
                if (dgvDataView.Columns.Count == 0)
                {
                    btnShowAll.Enabled = false;
                    btnExport.Enabled = false;
                    btnApplyData.Enabled = false;
                    numericUpDownResult.Enabled = false;
                    txtDistance.Enabled = false;
                    txtThreshold.Enabled = false;
                }


                if (listViewCFG.Items.Count == 0)
                {
                    btnClose.Enabled = false;
                    btnEdit.Enabled = false;
                    btnExportCFG.Enabled = false;
                    picCloseCFG.Visible = false;
                }
                if (tlvLogFile.Items.Count == 0)
                    picCloseLog.Visible = false;
                else
                    picCloseLog.Visible = true;

                if (tlvDataViewer.Items.Count > 1)
                    labelTips.Visible = true;

                lblFileName.Text = "";

                //if (mainMap.Layers.Count > 1)//utm<->lcc
                {
                    mainMap.Layers.Clear();
                    setStandardMap();
                }

                //mainMap.Layers.Clear();
                labelTips.Visible = true;
                //---------若tlvDataViewer有数据，则下面的按钮能用----
                //tlvDataViewer.ShowItemToolTips = true;
                if (CommonClass.CurrentBaseScenario.lstOutput != null)
                {
                    btnExtractSelected.Enabled = true;
                    btnExtractAll.Enabled = true;
                    //btnLinkTo.Enabled = true;
                    //btnOutputFor.Enabled = true;
                    if (CommonClass.CurrentBaseScenario.configuration != null && (CommonClass.CurrentBaseScenario.configuration is BenMAPAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is BenMAPOzoneAnalysisConfiguration))
                    {
                        rbtnVNA.Enabled = true;
                        rbtnEVNA.Enabled = true;
                        btnLinkTo.Enabled = true;
                    }
                    else
                    {
                        rbtnVNA.Enabled = false;
                        rbtnEVNA.Enabled = false;
                        btnLinkTo.Enabled = false;
                    }
                }
                else
                {
                    btnExtractSelected.Enabled = false;
                    btnExtractAll.Enabled = false;
                    //btnLinkTo.Enabled = false;
                    //btnOutputFor.Enabled = false;
                }
                if (LanguageOld.IsSMATChina && cboZoomTo.Items[0].ToString() != "China")
                {
                    cboStandardLayers.Items.Clear();
                    cboStandardLayers.Items.Add("China");
                    cboStandardLayers.SelectedIndex = 0;
                    cboZoomTo.Items.Clear();
                    cboZoomTo.Items.Add("China");
                    cboZoomTo.Items.Add("YRD");
                    cboZoomTo.Items.Add("PRD");
                    cboZoomTo.Items.Add("JJJ");
                    cboZoomTo.SelectedIndex = 0;
                    tsmiTexas.Visible = false;
                    tsmiSouthernCalifornia.Visible = false;
                    tsmiContinentalUS.Visible = false;
                    tsmiMaryland.Visible = false;
                    tsmiWashingtonDC.Visible = false;
                    tsmiNewEngland.Visible = false;
                    tsmiChina.Visible = true;
                    tsmiYRD.Visible = true;
                    tsmiPRD.Visible = true;
                    tsmiJJJ.Visible = true;
                    (this.ParentForm as Main).tsbtnLanguage.Text = "China";
                    (this.ParentForm as Main).tsbtnSingleAssessment.Visible = false;
                    (this.ParentForm as Main).tsmiDailyPM.Visible = false;
                    (this.ParentForm as Main).tsmiVisibility.Visible = false;
                }
                if (!LanguageOld.IsSMATChina && cboZoomTo.Items[0].ToString() == "China")
                {
                    cboZoomTo.Items.Clear();
                    cboZoomTo.Items.Add("Continental US");
                    cboZoomTo.Items.Add("Maryland");
                    cboZoomTo.Items.Add("New England");
                    cboZoomTo.Items.Add("Southern California");
                    cboZoomTo.Items.Add("Texas");
                    cboZoomTo.Items.Add("Washington DC");
                    cboStandardLayers.Items.Clear();
                    cboStandardLayers.Items.Add("US States");
                    cboStandardLayers.Items.Add("US Counties");
                    cboStandardLayers.Items.Add("Class I Area");
                    cboStandardLayers.Items.Add("Class I Area and States");
                    cboStandardLayers.Items.Add("Continental US");
                    cboStandardLayers.SelectedIndex = 0;
                    cboZoomTo.SelectedIndex = 0;
                    tsmiTexas.Visible = true;
                    tsmiSouthernCalifornia.Visible = true;
                    tsmiContinentalUS.Visible = true;
                    tsmiMaryland.Visible = true;
                    tsmiWashingtonDC.Visible = true;
                    tsmiNewEngland.Visible = true;
                    tsmiChina.Visible = false;
                    tsmiYRD.Visible = false;
                    tsmiPRD.Visible = false;
                    tsmiJJJ.Visible = false;
                    (this.ParentForm as Main).tsbtnLanguage.Text = "USA";
                    //BetaVersion，需要隐藏SSIA module
                    (this.ParentForm as Main).tsbtnSingleAssessment.Visible = !CommonClass.BetaVersion && isShowSSIA == "T" ? true : false;
                    (this.ParentForm as Main).tsmiDailyPM.Visible = true;
                    (this.ParentForm as Main).tsmiVisibility.Visible = true;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        //--------双击查看dataviewer中显示的文件----------
        private DataTable _dtChangeDigit = null;
        private void tlvDataViewer_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (tlvDataViewer.SelectedItems.Count == 0)
                    return;
                else if (tlvDataViewer.SelectedItems[0].Text == "No data loaded")
                    return;
                string filePath = "";
                string fileName = "";

                switch (this.tlvDataViewer.SelectedItems[0].Tag.ToString())
                {
                    case "proj":
                        filePath = this.tlvDataViewer.SelectedItems[0].Name;
                        if (!File.Exists(filePath))
                        {
                            filePath = CommonClass.ResultFilePath + @"\Result\Project\" + Path.GetFileName(this.tlvDataViewer.SelectedItems[0].Name);
                            if (!File.Exists(filePath))
                            {
                                MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                                return;
                            }
                        }
                        CommonClass.OpenScenario = true;
                        CommonClass.OutputNavigator = false;
                        CommonClass.IsDataViewerState = true;
                        CommonClass.CurrentBaseScenario = CommonClass.LoadScenario(filePath);
                        CommonClass.FileName = this.tlvDataViewer.SelectedItems[0].Name;
                        initForm();
                        break;
                    case "cfg":
                        addConfiguration();
                        btnClose.Enabled = true;
                        btnEdit.Enabled = true;
                        btnExportCFG.Enabled = true;
                        picCloseCFG.Visible = true;
                        break;
                    case "logfile":
                        addLog();
                        picCloseLog.Visible = true;
                        break;
                    case "outputfiles":
                        fileName = this.tlvDataViewer.SelectedItems[0].Text.ToString();
                        filePath = this.tlvDataViewer.SelectedItems[0].Name.ToString();
                        if (!File.Exists(filePath))
                        {
                            filePath = CommonClass.ResultFilePath + @"\Result\Output\" + CommonClass.CurrentBaseScenario.configuration.configurationName + @"\" + Path.GetFileName(this.tlvDataViewer.SelectedItems[0].Name.ToString());
                            if (!File.Exists(filePath))
                            {
                                MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                                return;
                            }
                        }
                        if (fileName.Contains("Neighbor File"))
                        {
                            MessageBox.Show(Language.Localization.GetValue("File is too large and only top 1000 records are displayed. You can extract it to read in another program."));
                        }
                        DataTable dt = null;

                        #region If double click the "SSIA Source Location" node, set the SelectedTab=GIS
                        // added by ty 2015-10-16
                        if (filePath.Contains("SSIA Source Location"))
                        {
                            Action<TabPage> handler = delegate (TabPage tab)
                            {
                                this.tbcFunction.SelectedTab = tab;
                                this.tbcFunction.Update();
                            };
                            this.tbcFunction.Invoke(handler, new object[] { tbpGIS });
                        }
                        #endregion

                        if ((this.tbcFunction.SelectedTab.Text == "Map" || this.tbcFunction.SelectedTab.Text == "GIS") && !fileName.Contains("Neighbor File"))
                        {
                            WaitShow(Language.Localization.GetValue("Drawing Data"));
                            //added by Yangwenwei 20131218
                            //plotControl1.MinMaxClean();

                            //if (fileName.Contains("Neighbor File"))
                            //{
                            //    dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, 1000);
                            //}
                            //else
                            {
                                #region
                                //string dataType = "";
                                FileStream fs = null;
                                fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
                                string[] sMatchArray = sr.ReadLine().Split(new char[] { ',' });
                                _dataType = sMatchArray[0];
                                fs.Dispose();
                                sr.Dispose();
                                sr.Close();
                                GC.Collect();
                                #endregion
                                #region
                                bool errorOccur = false;
                                if (_dataType.Trim().ToLower() == "quarter")
                                {
                                    if (fileName.Contains("Daily All Years All Days PM25 Point"))
                                    {
                                        dt = CommonClass.getDataTableForMapDaily(filePath, CommonClass.CurrentBaseScenario);
                                    }
                                    else if (fileName.Contains("Daily All Years High Days PM25 Point"))
                                    {
                                        dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                                    }
                                    else
                                        dt = CommonClass.getDataTableForMap(filePath);
                                }
                                else if (filePath.Contains("SSIA Source Location"))//SSIA
                                {
                                    dt = CommonClass.getDataSetFromCSV(filePath).Tables[0];
                                }
                                else
                                {
                                    dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                                }
                                #endregion
                            }
                            if (dt == null)
                            {
                                WaitClose();
                                MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                                return;
                            }
                            if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                            {
                                if (!IsPolygon(fileName))
                                {
                                    if (filePath.Contains("SSIA Source Location"))
                                    {
                                        #region Add the SSIA Source Coordinates into GIS
                                        if (dt.Rows.Count > 0 && dt != null)
                                        {
                                            mainMap.ProjectionModeReproject = ActionMode.Never;
                                            mainMap.ProjectionModeDefine = ActionMode.Never;
                                            //删除底图
                                            if (mainMap.Layers.Count > 0)
                                            {
                                                if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region")
                                                //if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "npsClassI")
                                                {
                                                    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                                                    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                                                }
                                                else
                                                {
                                                    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                                                }
                                            }
                                            //读取坐标点的数据
                                            IFeatureSet addToMapSet = new FeatureSet();
                                            for (int i = 0; i < dt.Columns.Count; i++)//获取列名
                                            {
                                                addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName, dt.Columns[i].DataType);
                                            }
                                            DotSpatial.Topology.Point point;
                                            Feature feature;
                                            for (int i = 0; i < dt.Rows.Count; i++)//获取每一行的数据
                                            {
                                                point = new DotSpatial.Topology.Point(Convert.ToDouble(dt.Rows[i][2]), Convert.ToDouble(dt.Rows[i][1]));
                                                feature = new Feature(point);

                                                addToMapSet.AddFeature(feature);
                                                addToMapSet.DataTable.Rows[i].ItemArray = dt.Rows[i].ItemArray;
                                            }
                                            //add a new layer
                                            mainMap.Layers.Add(addToMapSet);
                                            mainMap.Layers[mainMap.Layers.Count - 1].LegendText = fileName;

                                            DotSpatial.Symbology.PictureSymbol s = new PictureSymbol();
                                            s.Image = Properties.Resources.sourceX;
                                            s.Scale(4);


                                            //sym.OutlineWidth = 4;
                                            PointSymbolizer psb = new PointSymbolizer(s);
                                            (mainMap.Layers[mainMap.Layers.Count - 1] as PointLayer).Symbolizer = psb;

                                            //Change the Projection 
                                            mainMap.Layers[mainMap.Layers.Count - 1].Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
                                            if (CommonClass.CurrentBaseScenario != null && ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly) || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)))
                                                mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD);
                                            else
                                                mainMap.Projection = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);
                                            mainMap.Layers[mainMap.Layers.Count - 1].Reproject(mainMap.Projection);
                                            for (int i = mainMap.Layers.Count - 1; i >= 0; i--)
                                            {
                                                if (mainMap.Layers[i].LegendText == "SSIA Source Location")
                                                    continue;
                                                _currentLayerIndex = i;
                                                break;
                                            }
                                            //_currentLayerIndex = mainMap.Layers.Count - 1 - 1;
                                            cboStandardLayers.SelectedIndexChanged -= cboStandardLayers_SelectedIndexChanged;
                                            cboStandardLayers.Text = "US Counties";
                                            cboStandardLayers.SelectedIndexChanged += cboStandardLayers_SelectedIndexChanged;
                                            setStandardMap();
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        //Add the SSIA results into GIS
                                        drawMap(dt, fileName, true);
                                        cboStandardLayers.SelectedIndexChanged -= cboStandardLayers_SelectedIndexChanged;
                                        cboStandardLayers.Text = "US Counties";
                                        cboStandardLayers.SelectedIndexChanged += cboStandardLayers_SelectedIndexChanged;
                                        setStandardMap();
                                        tbcFunction.SelectedTab = tbpGIS;
                                    }
                                }
                                else
                                {
                                    tbcFunction.SelectedTab = tbpGIS;
                                    drawMap(dt, fileName, tbcFunction.SelectedTab == tbpGIS);
                                    cboStandardLayers.SelectedIndexChanged -= cboStandardLayers_SelectedIndexChanged;
                                    cboStandardLayers.Text = "US Counties";
                                    cboStandardLayers.SelectedIndexChanged += cboStandardLayers_SelectedIndexChanged;
                                    drawMap(dt, fileName, tbcFunction.SelectedTab == tbpMap);
                                    #region Load tbpData & tbpChart
                                    iStateName = -1;
                                    _ChartFilter = "";
                                    if (dtchartTemp != null)
                                    {
                                        dtchartTemp.Clear();
                                        GC.Collect();
                                    }
                                    dtchartTemp = null;

                                    _dtChangeDigit = null;
                                    WaitShow(Language.Localization.GetValue("Loading data"));
                                    bool errorOccur1 = false;
                                    if (!fileName.Contains("Neighbor File"))
                                    {
                                        if (fileName.Contains("Quarterly Avg PM2.5 Monitors")
                                            || fileName.Contains("Quarterly Peak PM2.5 Monitors")
                                            || fileName.Contains("Quarterly Peak Spec Frac Point"))
                                        {
                                            dt = CommonClass.getDataTableForQuarterlyMonitors(filePath, ref _dataType);
                                        }
                                        else if (filePath.Contains("SSIA Source Location"))//SSIA
                                        {
                                            dt = CommonClass.getDataSetFromCSV(filePath).Tables[0];
                                        }
                                        else
                                        {
                                            dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur1);
                                        }
                                    }

                                    else
                                    {
                                        dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, 1000);
                                    }
                                    if (dt == null)
                                    {
                                        WaitClose();
                                        MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                                        return;
                                    }

                                    //either vna or evna can be choosen
                                    if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                    {
                                        gbxQuantifiers.Text = "";
                                        if ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useEVNA) || (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useEVNA) || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useEVNA))
                                        //if (this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia annual pm data") || this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia ozone data"))
                                        {
                                            lblNote.Visible = true;
                                            clboQuantifiers.ItemCheck += new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                        }
                                        else
                                        {
                                            lblNote.Visible = false;
                                            clboQuantifiers.ItemCheck -= new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                        }
                                    }
                                    else
                                    {
                                        lblNote.Visible = false;
                                        gbxQuantifiers.Text = "Quantifiers that must be >= 0";
                                    }

                                    //if is ssia grid data - enable the btn (bar, distribution, frequency) in Chart and save the datatable
                                    bool showDistribution = false;
                                    if ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && !this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("point")) || this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia ozone data") || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && !this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("point")))
                                    {
                                        dtchartTemp = dt;
                                        btnBar.Visible = true;
                                        btnDistribution.Visible = true;
                                        btnFrequency.Visible = true;
                                        ichartType = 1;
                                        showDistribution = true;
                                        //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 51);
                                        //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 40);
                                    }
                                    else
                                    {
                                        btnBar.Visible = false;
                                        btnDistribution.Visible = false;
                                        btnFrequency.Visible = false;
                                        ichartType = 0;
                                        //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 18);
                                        //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 7);
                                    }
                                    //tclFiltering.Enabled = true;
                                    #region
                                    if (dgvDataView.Columns.Count > 0)
                                        dgvDataView.Columns.Clear();
                                    if (dgvDataView.Rows.Count > 0)
                                        dgvDataView.Rows.Clear();
                                    if (dgvDataList.Columns.Count > 0)
                                        dgvDataList.Columns.Clear();
                                    if (dgvDataList.Rows.Count > 0)
                                        dgvDataList.Rows.Clear();
                                    if (clboQuantifiers.Items.Count > 0)
                                        clboQuantifiers.Items.Clear();
                                    if (cboType.Items.Count > 0)
                                        cboType.Items.Clear();
                                    if (cboFilter.Items.Count > 0)
                                    {
                                        cboFilter.Items.Clear();
                                    }
                                    for (int i = 0; i < dt.Columns.Count; i++)
                                    {
                                        if (dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") || dt.Columns[i].ColumnName.Trim().ToLower().Contains("location"))
                                            iStateName = i;
                                    }
                                    _dtOutput = dt;
                                    _dtSelectOutput = dt;
                                    _dtChangeDigit = dt;

                                    //----------data部分-----------添加选择的文件名，为checklistbox添加items，datalistview添加列名及datasource----------
                                    #region
                                    lblFileName.Text = fileName.TrimStart('-');
                                    if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("_visibility_rank")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name"))
                                                clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataView.Columns.Add(col);
                                        }
                                    }
                                    else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                    {
                                        if (fileName.ToLower().Contains("quarterly"))
                                        {
                                            List<string> lstQ = new List<string>();
                                            for (int i = 0; i < dt.Columns.Count; i++)
                                            {
                                                string columnname = dt.Columns[i].ColumnName;
                                                lstQ.Add(columnname);
                                                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                                //added by Yangwenwei 20131220
                                                if (col.HeaderText.Contains("Δ"))
                                                {
                                                    col.Width = 120;
                                                }
                                                dgvDataView.Columns.Add(col);

                                            }
                                            for (int j = 1; j < 5; j++)
                                            {
                                                foreach (string s in lstQ)
                                                {
                                                    if (s.Contains("Δ"))
                                                        clboQuantifiers.Items.Add(s + "_q" + j.ToString() + " >= Threshold");
                                                    if (s.Contains("Alt") && (s.Contains("VNA") || s.Contains("eVNA")))
                                                        clboQuantifiers.Items.Add(s + "_q" + j.ToString() + " >= NAAQS");
                                                }
                                            }

                                        }
                                        else
                                        {
                                            if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                            {
                                                label7.Text = "Threshold (kg/ha):";
                                            }
                                            for (int i = 0; i < dt.Columns.Count; i++)
                                            {
                                                string columnname = dt.Columns[i].ColumnName;
                                                if (columnname.Contains("Δ"))
                                                    clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= Threshold");
                                                if (columnname.Contains("Alt") && (columnname.Contains("VNA") || columnname.Contains("eVNA")))
                                                    clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= NAAQS");
                                                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                                //added by Yangwenwei 20131220
                                                if (col.HeaderText.Contains("Δ"))
                                                {
                                                    col.Width = 120;
                                                }
                                                dgvDataView.Columns.Add(col);
                                            }
                                        }
                                        if (fileName.ToLower().Contains("data") || fileName.ToLower().Contains("receptor"))//max distance from source
                                        {
                                            clboQuantifiers.Items.Add("Receptor <= max distance from source");
                                        }
                                        switch (CommonClass.CurrentAnalysis)
                                        {
                                            case enumAnalysis.SSIAAnnualPM:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                            case enumAnalysis.SSIADailyPM:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                            case enumAnalysis.SSIAOzone:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                            case enumAnalysis.SSIADeposition:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.threshold.ToString(); break;
                                        }

                                    }
                                    else
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("county")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("pollutant")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("day") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("year") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("98th_percent_rank")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name") && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("col") && !dt.Columns[i].ColumnName.ToLower().Contains("row") && !dt.Columns[i].ColumnName.ToLower().Contains("metric") && !dt.Columns[i].ColumnName.ToLower().Contains("statistic"))
                                                clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                //col.Width = dt.Columns[i].ColumnName.Length * 12;
                                                //col.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                                                col.Width = 120;
                                            }
                                            dgvDataView.Columns.Add(col);
                                        }
                                    }
                                    //if (fileName.Contains("Quarterly Avg PM2.5 Monitors"))
                                    //{
                                    //    numericUpDownResult_ValueChanged(sender, e);
                                    //}
                                    //else
                                    //    dgvDataView.DataSource = dt;
                                    numericUpDownResult_ValueChanged(sender, e);
                                    //dgvDataView.Rows[0].Selected = false;
                                    //numericUpDownResult.Value = 4;
                                    #endregion
                                    dt.Dispose();
                                    GC.Collect();
                                    //----------chart部分--------
                                    //----------获取filter，并为cbofilter添加items，若没有则为空
                                    #region
                                    List<string> lstStateNames = CommonClass.getStateListFromCSV(dt);
                                    if (lstStateNames == null)
                                        cboFilter.Text = "";
                                    else
                                    {
                                        foreach (string item in lstStateNames)
                                        {
                                            cboFilter.Items.Add(item);
                                        }
                                        cboFilter.Items.Insert(0, "");
                                    }
                                    cboFilter.Text = "";

                                    //----------为objectlistview添加列名-----------
                                    int iPMOrO3 = -1, iValue = -1;
                                    if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            string columnname = dt.Columns[i].ColumnName.Trim().ToLower();
                                            if (!columnname.Contains("id") && !columnname.Contains("type")
                                                && !columnname.Contains("lat") && !columnname.Contains("long")
                                                 && !columnname.Contains("date") && !columnname.Contains("state")
                                                 && !columnname.Contains("name"))
                                            {
                                                cboType.Items.Add(dt.Columns[i].ColumnName);
                                                if (iValue == -1) iValue = i;
                                            }

                                            if (columnname.Contains("pm") || (columnname.Contains("o3") && !columnname.Contains("no3"))
                                                || columnname.Contains("dv") || columnname.Contains("base"))
                                            {
                                                if (iPMOrO3 == -1)
                                                    iPMOrO3 = i;
                                            }
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName, ReadOnly = true };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataList.Columns.Add(col);
                                        }
                                    }
                                    else
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {

                                            string columnname = dt.Columns[i].ColumnName.Trim().ToLower();
                                            if (!columnname.Contains("id") && !columnname.Contains("type")
                                                && !columnname.Contains("lat") && !columnname.Contains("long")
                                                && !columnname.Contains("quarter") && !columnname.Contains("date")
                                                && !columnname.Contains("98th_percent_rank")
                                                && !columnname.Contains("county") && !columnname.Contains("state")
                                                && !columnname.Contains("neighbor") && !columnname.Contains("day")
                                                && !columnname.Contains("year") && !columnname.Contains("pollutant")
                                                && !columnname.Contains("name") && !columnname.Contains("_visibility_rank")
                                                && !columnname.Contains("col") && !columnname.Contains("row") && !columnname.Contains("metric") && !columnname.Contains("statistic"))
                                            {
                                                cboType.Items.Add(dt.Columns[i].ColumnName);
                                                if (iValue == -1) iValue = i;
                                            }

                                            if (columnname.Contains("pm") || (columnname.Contains("o3") && !columnname.Contains("no3"))
                                                || columnname.Contains("dv") || columnname.Contains("base"))
                                            {
                                                if (iPMOrO3 == -1)
                                                    iPMOrO3 = i;
                                            }

                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName, ReadOnly = true };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataList.Columns.Add(col);
                                        }
                                    }
                                    if (iPMOrO3 != -1)
                                    {
                                        iPMOrO3 = iPMOrO3 - iValue;
                                        cboType.SelectedIndex = iPMOrO3;
                                    }
                                    else
                                        if (cboType.Items.Count == 0)
                                        cboType.Text = "";
                                    else
                                        cboType.SelectedIndex = 0;
                                    DataGridViewCheckBoxColumn checkBoxCol = new DataGridViewCheckBoxColumn() { Width = 30 };
                                    dgvDataList.Columns.Insert(0, checkBoxCol);
                                    dgvDataList.DataSource = dt;
                                    dgvDataList.Rows[0].Selected = false;
                                    dt.Dispose();
                                    GC.Collect();
                                    //--------最开始默认为前5个------------如果不够5个
                                    int count = 5;
                                    if (dgvDataList.Rows.Count < count) count = dgvDataList.Rows.Count;
                                    for (int i = 0; i < count; i++)
                                    {
                                        DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                                        checkCell.Value = true;
                                    }
                                    //--------画柱状图-----------
                                    //对于pm25和o3，当为point时则同时展示baseline和future value。
                                    if (showDistribution)//show distribution first
                                    {
                                        ChangecboType(1);
                                        cboType.SelectedIndex = 0;
                                        plotLine = true;
                                        changeColor = true;
                                        btnDistribution_Click(null, null);
                                    }
                                    else
                                    {
                                        cboFilter.Enabled = true;
                                        if (iPMOrO3 != -1)
                                        {
                                            if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                            {
                                                if (dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("worst"))
                                                {
                                                    createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                                }
                                                else
                                                {
                                                    createGraph(zgcChart, cboType.Text);
                                                }
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else
                                            {
                                                if (dt.Columns.Count > iPMOrO3 + iValue + 1 && dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("f")
                                                    && dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Replace("f", "") == dt.Columns[iPMOrO3 + iValue].ColumnName.Replace("b", ""))
                                                {
                                                    createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                                }
                                                else
                                                {
                                                    createGraph(zgcChart, cboType.Text);
                                                }
                                            }
                                        }
                                        else
                                            createGraph(zgcChart, cboType.Text);
                                    }
                                    #endregion
                                    //if (this.tbcFunction.SelectedTab.Text != "Chart" && this.tbcFunction.SelectedTab.Text != "Data")
                                    //{
                                    tbcFunction.SelectedTab = tbpGIS;
                                    //}
                                    //btnApply.Enabled = true;
                                    btnExport.Enabled = true;
                                    btnShowAll.Enabled = true;
                                    btnApplyData.Enabled = true;
                                    numericUpDownResult.Enabled = true;
                                    if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                                    {
                                        if (Path.GetFileName(filePath).ToLower().Contains("data") || Path.GetFileName(filePath).ToLower().Contains("receptor"))
                                        {
                                            txtDistance.Enabled = true;
                                        }
                                        else
                                        {
                                            txtDistance.Enabled = false;
                                        }
                                        txtThreshold.Enabled = true;
                                    }
                                    #endregion

                                    #endregion
                                    setStandardMap();
                                }
                                //tbcFunction.SelectedTab = tbpGIS;
                            }
                            else
                            {
                                drawMap(dt, fileName, false);
                                if (isPolygon)
                                {
                                    tbcFunction.SelectedTab = tbpMap;
                                    //added by Yangwenwei lstSpeciesTypeMap_SelectedIndexChanged(sender, e);
                                    //plotControl1.Mapname = lstSpeciesTypeMap.SelectedItem.ToString();
                                }
                                else
                                {
                                    setStandardMap();
                                    tbcFunction.SelectedTab = tbpGIS;
                                }
                            }
                        }
                        else
                        {
                            if ((CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                                && (this.tbcFunction.SelectedTab.Text == "Data" || this.tbcFunction.SelectedTab.Text == "Chart" || this.tbcFunction.SelectedTab.Text == "Running" || this.tbcFunction.SelectedTab.Text == "Run Log" || this.tbcFunction.SelectedTab.Text == "Configuration & Batch") && !fileName.Contains("Neighbor File"))
                            {
                                {
                                    #region
                                    //string dataType = "";
                                    FileStream fs = null;
                                    fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                                    StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
                                    string[] sMatchArray = sr.ReadLine().Split(new char[] { ',' });
                                    _dataType = sMatchArray[0];
                                    fs.Dispose();
                                    sr.Dispose();
                                    sr.Close();
                                    GC.Collect();
                                    #endregion
                                    #region
                                    bool errorOccur = false;
                                    if (_dataType.Trim().ToLower() == "quarter")
                                    {
                                        if (fileName.Contains("Daily All Years All Days PM25 Point"))
                                        {
                                            dt = CommonClass.getDataTableForMapDaily(filePath, CommonClass.CurrentBaseScenario);
                                        }
                                        else if (fileName.Contains("Daily All Years High Days PM25 Point"))
                                        {
                                            dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                                        }
                                        else
                                            dt = CommonClass.getDataTableForMap(filePath);
                                    }
                                    else if (filePath.Contains("SSIA Source Location"))//SSIA
                                    {
                                        dt = CommonClass.getDataSetFromCSV(filePath).Tables[0];
                                    }
                                    else
                                    {
                                        dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                                    }
                                    #endregion
                                }
                                if (dt == null)
                                {
                                    WaitClose();
                                    MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                                    return;
                                }
                                if (!IsPolygon(fileName))
                                {
                                    if (filePath.Contains("SSIA Source Location"))
                                    {
                                        #region Add the SSIA Source Coordinates into GIS
                                        if (dt.Rows.Count > 0 && dt != null)
                                        {
                                            mainMap.ProjectionModeReproject = ActionMode.Never;
                                            mainMap.ProjectionModeDefine = ActionMode.Never;
                                            //删除底图
                                            if (mainMap.Layers.Count > 0)
                                            {
                                                if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region")
                                                //if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "npsClassI")
                                                {
                                                    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                                                    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                                                }
                                                else
                                                {
                                                    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                                                }
                                            }
                                            //读取坐标点的数据
                                            IFeatureSet addToMapSet = new FeatureSet();
                                            for (int i = 0; i < dt.Columns.Count; i++)//获取列名
                                            {
                                                addToMapSet.DataTable.Columns.Add(dt.Columns[i].ColumnName, dt.Columns[i].DataType);
                                            }
                                            DotSpatial.Topology.Point point;
                                            Feature feature;
                                            for (int i = 0; i < dt.Rows.Count; i++)//获取每一行的数据
                                            {
                                                point = new DotSpatial.Topology.Point(Convert.ToDouble(dt.Rows[i][2]), Convert.ToDouble(dt.Rows[i][1]));
                                                feature = new Feature(point);

                                                addToMapSet.AddFeature(feature);
                                                addToMapSet.DataTable.Rows[i].ItemArray = dt.Rows[i].ItemArray;
                                            }
                                            //add a new layer
                                            mainMap.Layers.Add(addToMapSet);
                                            mainMap.Layers[mainMap.Layers.Count - 1].LegendText = fileName;

                                            DotSpatial.Symbology.PictureSymbol s = new PictureSymbol();
                                            s.Image = Properties.Resources.sourceX;
                                            s.Scale(4);


                                            //sym.OutlineWidth = 4;
                                            PointSymbolizer psb = new PointSymbolizer(s);
                                            (mainMap.Layers[mainMap.Layers.Count - 1] as PointLayer).Symbolizer = psb;

                                            //Change the Projection 
                                            mainMap.Layers[mainMap.Layers.Count - 1].Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
                                            if (CommonClass.CurrentBaseScenario != null && ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).analysisOptionA.useDispersionOnly) || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).analysisOptionD.useDispersionOnly)))
                                                mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD);
                                            else
                                                mainMap.Projection = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);
                                            mainMap.Layers[mainMap.Layers.Count - 1].Reproject(mainMap.Projection);
                                            for (int i = mainMap.Layers.Count - 1; i >= 0; i--)
                                            {
                                                if (mainMap.Layers[i].LegendText == "SSIA Source Location")
                                                    continue;
                                                _currentLayerIndex = i;
                                                break;
                                            }
                                            //_currentLayerIndex = mainMap.Layers.Count - 1 - 1;
                                            cboStandardLayers.SelectedIndexChanged -= cboStandardLayers_SelectedIndexChanged;
                                            cboStandardLayers.Text = "US Counties";
                                            cboStandardLayers.SelectedIndexChanged += cboStandardLayers_SelectedIndexChanged;
                                            setStandardMap();
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        //Add the SSIA results into GIS
                                        drawMap(dt, fileName, true);
                                        cboStandardLayers.SelectedIndexChanged -= cboStandardLayers_SelectedIndexChanged;
                                        cboStandardLayers.Text = "US Counties";
                                        cboStandardLayers.SelectedIndexChanged += cboStandardLayers_SelectedIndexChanged;
                                        setStandardMap();
                                        tbcFunction.SelectedTab = tbpGIS;
                                    }
                                }
                                else
                                {
                                    tbcFunction.SelectedTab = tbpGIS;
                                    drawMap(dt, fileName, tbcFunction.SelectedTab == tbpGIS);
                                    cboStandardLayers.SelectedIndexChanged -= cboStandardLayers_SelectedIndexChanged;
                                    cboStandardLayers.Text = "US Counties";
                                    cboStandardLayers.SelectedIndexChanged += cboStandardLayers_SelectedIndexChanged;
                                    drawMap(dt, fileName, tbcFunction.SelectedTab == tbpMap);
                                    #region Load tbpData & tbpChart
                                    iStateName = -1;
                                    _ChartFilter = "";
                                    if (dtchartTemp != null)
                                    {
                                        dtchartTemp.Clear();
                                        GC.Collect();
                                    }
                                    dtchartTemp = null;

                                    _dtChangeDigit = null;
                                    WaitShow(Language.Localization.GetValue("Loading data")); ;
                                    bool errorOccur1 = false;
                                    if (!fileName.Contains("Neighbor File"))
                                    {
                                        if (fileName.Contains("Quarterly Avg PM2.5 Monitors")
                                            || fileName.Contains("Quarterly Peak PM2.5 Monitors")
                                            || fileName.Contains("Quarterly Peak Spec Frac Point"))
                                        {
                                            dt = CommonClass.getDataTableForQuarterlyMonitors(filePath, ref _dataType);
                                        }
                                        else if (filePath.Contains("SSIA Source Location"))//SSIA
                                        {
                                            dt = CommonClass.getDataSetFromCSV(filePath).Tables[0];
                                        }
                                        else
                                        {
                                            dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur1);
                                        }
                                    }

                                    else
                                    {
                                        dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, 1000);
                                    }
                                    if (dt == null)
                                    {
                                        WaitClose();
                                        MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                                        return;
                                    }

                                    //either vna or evna can be choosen
                                    if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                    {
                                        gbxQuantifiers.Text = "";
                                        if ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useEVNA) || (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useEVNA) || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useEVNA))
                                        //if (this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia annual pm data") || this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia ozone data"))
                                        {
                                            lblNote.Visible = true;
                                            clboQuantifiers.ItemCheck += new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                        }
                                        else
                                        {
                                            lblNote.Visible = false;
                                            clboQuantifiers.ItemCheck -= new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                        }
                                    }
                                    else
                                    {
                                        lblNote.Visible = false;
                                        gbxQuantifiers.Text = "Quantifiers that must be >= 0";
                                    }

                                    //if is ssia grid data - enable the btn (bar, distribution, frequency) in Chart and save the datatable
                                    bool showDistribution = false;
                                    if ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && !this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("point")) || this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia ozone data") || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && !this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("point")))
                                    {
                                        dtchartTemp = dt;
                                        btnBar.Visible = true;
                                        btnDistribution.Visible = true;
                                        btnFrequency.Visible = true;
                                        ichartType = 1;
                                        showDistribution = true;
                                        //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 51);
                                        //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 40);
                                    }
                                    else
                                    {
                                        btnBar.Visible = false;
                                        btnDistribution.Visible = false;
                                        btnFrequency.Visible = false;
                                        ichartType = 0;
                                        //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 18);
                                        //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 7);
                                    }
                                    //tclFiltering.Enabled = true;
                                    #region
                                    if (dgvDataView.Columns.Count > 0)
                                        dgvDataView.Columns.Clear();
                                    if (dgvDataView.Rows.Count > 0)
                                        dgvDataView.Rows.Clear();
                                    if (dgvDataList.Columns.Count > 0)
                                        dgvDataList.Columns.Clear();
                                    if (dgvDataList.Rows.Count > 0)
                                        dgvDataList.Rows.Clear();
                                    if (clboQuantifiers.Items.Count > 0)
                                        clboQuantifiers.Items.Clear();
                                    if (cboType.Items.Count > 0)
                                        cboType.Items.Clear();
                                    if (cboFilter.Items.Count > 0)
                                    {
                                        cboFilter.Items.Clear();
                                    }
                                    for (int i = 0; i < dt.Columns.Count; i++)
                                    {
                                        if (dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") || dt.Columns[i].ColumnName.Trim().ToLower().Contains("location"))
                                            iStateName = i;
                                    }
                                    _dtOutput = dt;
                                    _dtSelectOutput = dt;
                                    _dtChangeDigit = dt;

                                    //----------data部分-----------添加选择的文件名，为checklistbox添加items，datalistview添加列名及datasource----------
                                    #region
                                    lblFileName.Text = fileName.TrimStart('-');
                                    if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("_visibility_rank")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name"))
                                                clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataView.Columns.Add(col);
                                        }
                                    }
                                    else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                    {
                                        if (fileName.ToLower().Contains("quarterly"))
                                        {
                                            List<string> lstQ = new List<string>();
                                            for (int i = 0; i < dt.Columns.Count; i++)
                                            {
                                                string columnname = dt.Columns[i].ColumnName;
                                                lstQ.Add(columnname);
                                                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                                //added by Yangwenwei 20131220
                                                if (col.HeaderText.Contains("Δ"))
                                                {
                                                    col.Width = 120;
                                                }
                                                dgvDataView.Columns.Add(col);

                                            }
                                            for (int j = 1; j < 5; j++)
                                            {
                                                foreach (string s in lstQ)
                                                {
                                                    if (s.Contains("Δ"))
                                                        clboQuantifiers.Items.Add(s + "_q" + j.ToString() + " >= Threshold");
                                                    if (s.Contains("Alt") && (s.Contains("VNA") || s.Contains("eVNA")))
                                                        clboQuantifiers.Items.Add(s + "_q" + j.ToString() + " >= NAAQS");
                                                }
                                            }

                                        }
                                        else
                                        {
                                            if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                            {
                                                label7.Text = "Threshold (kg/ha):";
                                            }
                                            for (int i = 0; i < dt.Columns.Count; i++)
                                            {
                                                string columnname = dt.Columns[i].ColumnName;
                                                if (columnname.Contains("Δ"))
                                                    clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= Threshold");
                                                if (columnname.Contains("Alt") && (columnname.Contains("VNA") || columnname.Contains("eVNA")))
                                                    clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= NAAQS");
                                                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                                //added by Yangwenwei 20131220
                                                if (col.HeaderText.Contains("Δ"))
                                                {
                                                    col.Width = 120;
                                                }
                                                dgvDataView.Columns.Add(col);
                                            }
                                        }
                                        if (fileName.ToLower().Contains("data") || fileName.ToLower().Contains("receptor"))//max distance from source
                                        {
                                            clboQuantifiers.Items.Add("Receptor <= max distance from source");
                                        }
                                        switch (CommonClass.CurrentAnalysis)
                                        {
                                            case enumAnalysis.SSIAAnnualPM:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                            case enumAnalysis.SSIADailyPM:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                            case enumAnalysis.SSIAOzone:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                            case enumAnalysis.SSIADeposition:
                                                txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.threshold.ToString(); break;
                                        }

                                    }
                                    else
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("county")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("pollutant")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("day") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("year") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("98th_percent_rank")
                                                && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name") && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("col") && !dt.Columns[i].ColumnName.ToLower().Contains("row") && !dt.Columns[i].ColumnName.ToLower().Contains("metric") && !dt.Columns[i].ColumnName.ToLower().Contains("statistic"))
                                                clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                //col.Width = dt.Columns[i].ColumnName.Length * 12;
                                                //col.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                                                col.Width = 120;
                                            }
                                            dgvDataView.Columns.Add(col);
                                        }
                                    }
                                    //if (fileName.Contains("Quarterly Avg PM2.5 Monitors"))
                                    //{
                                    //    numericUpDownResult_ValueChanged(sender, e);
                                    //}
                                    //else
                                    //    dgvDataView.DataSource = dt;
                                    numericUpDownResult_ValueChanged(sender, e);
                                    //dgvDataView.Rows[0].Selected = false;
                                    //numericUpDownResult.Value = 4;
                                    #endregion
                                    dt.Dispose();
                                    GC.Collect();
                                    //----------chart部分--------
                                    //----------获取filter，并为cbofilter添加items，若没有则为空
                                    #region
                                    List<string> lstStateNames = CommonClass.getStateListFromCSV(dt);
                                    if (lstStateNames == null)
                                        cboFilter.Text = "";
                                    else
                                    {
                                        foreach (string item in lstStateNames)
                                        {
                                            cboFilter.Items.Add(item);
                                        }
                                        cboFilter.Items.Insert(0, "");
                                    }
                                    cboFilter.Text = "";

                                    //----------为objectlistview添加列名-----------
                                    int iPMOrO3 = -1, iValue = -1;
                                    if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            string columnname = dt.Columns[i].ColumnName.Trim().ToLower();
                                            if (!columnname.Contains("id") && !columnname.Contains("type")
                                                && !columnname.Contains("lat") && !columnname.Contains("long")
                                                 && !columnname.Contains("date") && !columnname.Contains("state")
                                                 && !columnname.Contains("name"))
                                            {
                                                cboType.Items.Add(dt.Columns[i].ColumnName);
                                                if (iValue == -1) iValue = i;
                                            }

                                            if (columnname.Contains("pm") || (columnname.Contains("o3") && !columnname.Contains("no3"))
                                                || columnname.Contains("dv") || columnname.Contains("base"))
                                            {
                                                if (iPMOrO3 == -1)
                                                    iPMOrO3 = i;
                                            }
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName, ReadOnly = true };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataList.Columns.Add(col);
                                        }
                                    }
                                    else
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {

                                            string columnname = dt.Columns[i].ColumnName.Trim().ToLower();
                                            if (!columnname.Contains("id") && !columnname.Contains("type")
                                                && !columnname.Contains("lat") && !columnname.Contains("long")
                                                && !columnname.Contains("quarter") && !columnname.Contains("date")
                                                && !columnname.Contains("98th_percent_rank")
                                                && !columnname.Contains("county") && !columnname.Contains("state")
                                                && !columnname.Contains("neighbor") && !columnname.Contains("day")
                                                && !columnname.Contains("year") && !columnname.Contains("pollutant")
                                                && !columnname.Contains("name") && !columnname.Contains("_visibility_rank")
                                                && !columnname.Contains("col") && !columnname.Contains("row") && !columnname.Contains("metric") && !columnname.Contains("statistic"))
                                            {
                                                cboType.Items.Add(dt.Columns[i].ColumnName);
                                                if (iValue == -1) iValue = i;
                                            }

                                            if (columnname.Contains("pm") || (columnname.Contains("o3") && !columnname.Contains("no3"))
                                                || columnname.Contains("dv") || columnname.Contains("base"))
                                            {
                                                if (iPMOrO3 == -1)
                                                    iPMOrO3 = i;
                                            }

                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName, ReadOnly = true };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataList.Columns.Add(col);
                                        }
                                    }
                                    if (iPMOrO3 != -1)
                                    {
                                        iPMOrO3 = iPMOrO3 - iValue;
                                        cboType.SelectedIndex = iPMOrO3;
                                    }
                                    else
                                        if (cboType.Items.Count == 0)
                                        cboType.Text = "";
                                    else
                                        cboType.SelectedIndex = 0;
                                    DataGridViewCheckBoxColumn checkBoxCol = new DataGridViewCheckBoxColumn() { Width = 30 };
                                    dgvDataList.Columns.Insert(0, checkBoxCol);
                                    dgvDataList.DataSource = dt;
                                    dgvDataList.Rows[0].Selected = false;
                                    dt.Dispose();
                                    GC.Collect();
                                    //--------最开始默认为前5个------------如果不够5个
                                    int count = 5;
                                    if (dgvDataList.Rows.Count < count) count = dgvDataList.Rows.Count;
                                    for (int i = 0; i < count; i++)
                                    {
                                        DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                                        checkCell.Value = true;
                                    }
                                    //--------画柱状图-----------
                                    //对于pm25和o3，当为point时则同时展示baseline和future value。
                                    if (showDistribution)//show distribution first
                                    {
                                        ChangecboType(1);
                                        cboType.SelectedIndex = 0;
                                        plotLine = true;
                                        changeColor = true;
                                        btnDistribution_Click(null, null);
                                    }
                                    else
                                    {
                                        cboFilter.Enabled = true;
                                        if (iPMOrO3 != -1)
                                        {
                                            if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                            {
                                                if (dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("worst"))
                                                {
                                                    createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                                }
                                                else
                                                {
                                                    createGraph(zgcChart, cboType.Text);
                                                }
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else
                                            {
                                                if (dt.Columns.Count > iPMOrO3 + iValue + 1 && dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("f")
                                                    && dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Replace("f", "") == dt.Columns[iPMOrO3 + iValue].ColumnName.Replace("b", ""))
                                                {
                                                    createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                                }
                                                else
                                                {
                                                    createGraph(zgcChart, cboType.Text);
                                                }
                                            }
                                        }
                                        else
                                            createGraph(zgcChart, cboType.Text);
                                    }
                                    #endregion
                                    //if (this.tbcFunction.SelectedTab.Text != "Chart" && this.tbcFunction.SelectedTab.Text != "Data")
                                    //{
                                    tbcFunction.SelectedTab = tbpGIS;
                                    //}
                                    //btnApply.Enabled = true;
                                    btnExport.Enabled = true;
                                    btnShowAll.Enabled = true;
                                    btnApplyData.Enabled = true;
                                    numericUpDownResult.Enabled = true;
                                    if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                                    {
                                        if (Path.GetFileName(filePath).ToLower().Contains("data") || Path.GetFileName(filePath).ToLower().Contains("receptor"))
                                        {
                                            txtDistance.Enabled = true;
                                        }
                                        else
                                        {
                                            txtDistance.Enabled = false;
                                        }
                                        txtThreshold.Enabled = true;
                                    }
                                    #endregion

                                    #endregion
                                    setStandardMap();
                                }
                            }
                            else
                            {

                                #region Load tbpData & tbpChart
                                iStateName = -1;
                                _ChartFilter = "";
                                if (dtchartTemp != null)
                                {
                                    dtchartTemp.Clear();
                                    GC.Collect();
                                }
                                dtchartTemp = null;

                                _dtChangeDigit = null;
                                WaitShow(Language.Localization.GetValue("Loading data")); ;
                                bool errorOccur1 = false;
                                if (!fileName.Contains("Neighbor File"))
                                {
                                    if (fileName.Contains("Quarterly Avg PM2.5 Monitors")
                                        || fileName.Contains("Quarterly Peak PM2.5 Monitors")
                                        || fileName.Contains("Quarterly Peak Spec Frac Point"))
                                    {
                                        dt = CommonClass.getDataTableForQuarterlyMonitors(filePath, ref _dataType);
                                    }
                                    else if (filePath.Contains("SSIA Source Location"))//SSIA
                                    {
                                        dt = CommonClass.getDataSetFromCSV(filePath).Tables[0];
                                    }
                                    else
                                    {
                                        dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur1);
                                    }
                                }

                                else
                                {
                                    dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, 1000);
                                }
                                if (dt == null)
                                {
                                    WaitClose();
                                    MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                                    return;
                                }

                                //either vna or evna can be choosen
                                if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                {
                                    gbxQuantifiers.Text = "";
                                    if ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA != null && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA.useEVNA) || (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO != null && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).monitorInputO.useEVNA) || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD != null && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useVNA && (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD.useEVNA))
                                    //if (this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia annual pm data") || this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia ozone data"))
                                    {
                                        lblNote.Visible = true;
                                        clboQuantifiers.ItemCheck += new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                    }
                                    else
                                    {
                                        lblNote.Visible = false;
                                        clboQuantifiers.ItemCheck -= new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                    }
                                }
                                else
                                {
                                    lblNote.Visible = false;
                                    gbxQuantifiers.Text = "Quantifiers that must be >= 0";
                                }

                                //if is ssia grid data - enable the btn (bar, distribution, frequency) in Chart and save the datatable
                                bool showDistribution = false;
                                if ((CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration && !this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("point")) || this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("ssia ozone data") || (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration && !this.tlvDataViewer.SelectedItems[0].Text.ToLower().Contains("point")))
                                {
                                    dtchartTemp = dt;
                                    btnBar.Visible = true;
                                    btnDistribution.Visible = true;
                                    btnFrequency.Visible = true;
                                    ichartType = 1;
                                    showDistribution = true;
                                    //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 51);
                                    //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 40);
                                }
                                else
                                {
                                    btnBar.Visible = false;
                                    btnDistribution.Visible = false;
                                    btnFrequency.Visible = false;
                                    ichartType = 0;
                                    //zgcChart.Size = new Size(zgcChart.Size.Width, tbpChart.Size.Height - 18);
                                    //zgcChart.Location = new System.Drawing.Point(zgcChart.Location.X, 7);
                                }
                                //tclFiltering.Enabled = true;
                                #region
                                if (dgvDataView.Columns.Count > 0)
                                    dgvDataView.Columns.Clear();
                                if (dgvDataView.Rows.Count > 0)
                                    dgvDataView.Rows.Clear();
                                if (dgvDataList.Columns.Count > 0)
                                    dgvDataList.Columns.Clear();
                                if (dgvDataList.Rows.Count > 0)
                                    dgvDataList.Rows.Clear();
                                if (clboQuantifiers.Items.Count > 0)
                                    clboQuantifiers.Items.Clear();
                                if (cboType.Items.Count > 0)
                                    cboType.Items.Clear();
                                if (cboFilter.Items.Count > 0)
                                {
                                    cboFilter.Items.Clear();
                                }
                                for (int i = 0; i < dt.Columns.Count; i++)
                                {
                                    if (dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") || dt.Columns[i].ColumnName.Trim().ToLower().Contains("location"))
                                        iStateName = i;
                                }
                                _dtOutput = dt;
                                _dtSelectOutput = dt;
                                _dtChangeDigit = dt;

                                //----------data部分-----------添加选择的文件名，为checklistbox添加items，datalistview添加列名及datasource----------
                                #region
                                lblFileName.Text = fileName.TrimStart('-');
                                if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                {
                                    for (int i = 0; i < dt.Columns.Count; i++)
                                    {
                                        if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat")
                                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("_visibility_rank")
                                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name"))
                                            clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                        //added by Yangwenwei 20131220
                                        if (col.HeaderText.Contains("Δ"))
                                        {
                                            col.Width = 120;
                                        }
                                        dgvDataView.Columns.Add(col);
                                    }
                                }
                                else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                {
                                    if (fileName.ToLower().Contains("quarterly"))
                                    {
                                        List<string> lstQ = new List<string>();
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            string columnname = dt.Columns[i].ColumnName;
                                            lstQ.Add(columnname);
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataView.Columns.Add(col);

                                        }
                                        for (int j = 1; j < 5; j++)
                                        {
                                            foreach (string s in lstQ)
                                            {
                                                if (s.Contains("Δ"))
                                                    clboQuantifiers.Items.Add(s + "_q" + j.ToString() + " >= Threshold");
                                                if (s.Contains("Alt") && (s.Contains("VNA") || s.Contains("eVNA")))
                                                    clboQuantifiers.Items.Add(s + "_q" + j.ToString() + " >= NAAQS");
                                            }
                                        }

                                    }
                                    else
                                    {
                                        for (int i = 0; i < dt.Columns.Count; i++)
                                        {
                                            string columnname = dt.Columns[i].ColumnName;
                                            if (columnname.Contains("Δ"))
                                                clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= Threshold");
                                            if (columnname.Contains("Alt") && (columnname.Contains("VNA") || columnname.Contains("eVNA")))
                                                clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= NAAQS");
                                            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                            //added by Yangwenwei 20131220
                                            if (col.HeaderText.Contains("Δ"))
                                            {
                                                col.Width = 120;
                                            }
                                            dgvDataView.Columns.Add(col);
                                        }
                                    }
                                    if (fileName.ToLower().Contains("data") || fileName.ToLower().Contains("receptor"))//max distance from source
                                    {
                                        clboQuantifiers.Items.Add("Receptor <= max distance from source");
                                    }
                                    switch (CommonClass.CurrentAnalysis)
                                    {
                                        case enumAnalysis.SSIAAnnualPM:
                                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                        case enumAnalysis.SSIADailyPM:
                                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                        case enumAnalysis.SSIAOzone:
                                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                                        case enumAnalysis.SSIADeposition:
                                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.threshold.ToString(); break;
                                    }

                                }
                                else
                                {
                                    for (int i = 0; i < dt.Columns.Count; i++)
                                    {
                                        if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long")
                                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("county")
                                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("pollutant")
                                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("day") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("year") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("98th_percent_rank")
                                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name") && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank") && !dt.Columns[i].ColumnName.ToLower().Contains("col") && !dt.Columns[i].ColumnName.ToLower().Contains("row") && !dt.Columns[i].ColumnName.ToLower().Contains("metric") && !dt.Columns[i].ColumnName.ToLower().Contains("statistic"))
                                            clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                                        if (col.HeaderText.Contains("Δ"))
                                        {
                                            //col.Width = dt.Columns[i].ColumnName.Length * 12;
                                            //col.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                                            col.Width = 120;
                                        }
                                        dgvDataView.Columns.Add(col);
                                    }
                                }
                                //if (fileName.Contains("Quarterly Avg PM2.5 Monitors"))
                                //{
                                //    numericUpDownResult_ValueChanged(sender, e);
                                //}
                                //else
                                //    dgvDataView.DataSource = dt;
                                numericUpDownResult_ValueChanged(sender, e);
                                //dgvDataView.Rows[0].Selected = false;
                                //numericUpDownResult.Value = 4;
                                #endregion
                                dt.Dispose();
                                GC.Collect();
                                //----------chart部分--------
                                //----------获取filter，并为cbofilter添加items，若没有则为空
                                #region
                                List<string> lstStateNames = CommonClass.getStateListFromCSV(dt);
                                if (lstStateNames == null)
                                    cboFilter.Text = "";
                                else
                                {
                                    foreach (string item in lstStateNames)
                                    {
                                        cboFilter.Items.Add(item);
                                    }
                                    cboFilter.Items.Insert(0, "");
                                }
                                cboFilter.Text = "";

                                //----------为objectlistview添加列名-----------
                                int iPMOrO3 = -1, iValue = -1;
                                if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                {
                                    for (int i = 0; i < dt.Columns.Count; i++)
                                    {
                                        string columnname = dt.Columns[i].ColumnName.Trim().ToLower();
                                        if (!columnname.Contains("id") && !columnname.Contains("type")
                                            && !columnname.Contains("lat") && !columnname.Contains("long")
                                             && !columnname.Contains("date") && !columnname.Contains("state")
                                             && !columnname.Contains("name"))
                                        {
                                            cboType.Items.Add(dt.Columns[i].ColumnName);
                                            if (iValue == -1) iValue = i;
                                        }

                                        if (columnname.Contains("pm") || (columnname.Contains("o3") && !columnname.Contains("no3"))
                                            || columnname.Contains("dv") || columnname.Contains("base"))
                                        {
                                            if (iPMOrO3 == -1)
                                                iPMOrO3 = i;
                                        }
                                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName, ReadOnly = true };
                                        //added by Yangwenwei 20131220
                                        if (col.HeaderText.Contains("Δ"))
                                        {
                                            col.Width = 120;
                                        }
                                        dgvDataList.Columns.Add(col);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < dt.Columns.Count; i++)
                                    {

                                        string columnname = dt.Columns[i].ColumnName.Trim().ToLower();
                                        if (!columnname.Contains("id") && !columnname.Contains("type")
                                            && !columnname.Contains("lat") && !columnname.Contains("long")
                                            && !columnname.Contains("quarter") && !columnname.Contains("date")
                                            && !columnname.Contains("98th_percent_rank")
                                            && !columnname.Contains("county") && !columnname.Contains("state")
                                            && !columnname.Contains("neighbor") && !columnname.Contains("day")
                                            && !columnname.Contains("year") && !columnname.Contains("pollutant")
                                            && !columnname.Contains("name") && !columnname.Contains("_visibility_rank")
                                            && !columnname.Contains("col") && !columnname.Contains("row") && !columnname.Contains("metric") && !columnname.Contains("statistic"))
                                        {
                                            cboType.Items.Add(dt.Columns[i].ColumnName);
                                            if (iValue == -1) iValue = i;
                                        }

                                        if (columnname.Contains("pm") || (columnname.Contains("o3") && !columnname.Contains("no3"))
                                            || columnname.Contains("dv") || columnname.Contains("base"))
                                        {
                                            if (iPMOrO3 == -1)
                                                iPMOrO3 = i;
                                        }

                                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName, ReadOnly = true };
                                        //added by Yangwenwei 20131220
                                        if (col.HeaderText.Contains("Δ"))
                                        {
                                            col.Width = 120;
                                        }
                                        dgvDataList.Columns.Add(col);
                                    }
                                }
                                if (iPMOrO3 != -1)
                                {
                                    iPMOrO3 = iPMOrO3 - iValue;
                                    cboType.SelectedIndex = iPMOrO3;
                                }
                                else
                                    if (cboType.Items.Count == 0)
                                    cboType.Text = "";
                                else
                                    cboType.SelectedIndex = 0;
                                DataGridViewCheckBoxColumn checkBoxCol = new DataGridViewCheckBoxColumn() { Width = 30 };
                                dgvDataList.Columns.Insert(0, checkBoxCol);
                                dgvDataList.DataSource = dt;
                                dgvDataList.Rows[0].Selected = false;
                                dt.Dispose();
                                GC.Collect();
                                //--------最开始默认为前5个------------如果不够5个
                                int count = 5;
                                if (dgvDataList.Rows.Count < count) count = dgvDataList.Rows.Count;
                                for (int i = 0; i < count; i++)
                                {
                                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                                    checkCell.Value = true;
                                }
                                //--------画柱状图-----------
                                //对于pm25和o3，当为point时则同时展示baseline和future value。
                                if (showDistribution)//show distribution first
                                {
                                    ChangecboType(1);
                                    cboType.SelectedIndex = 0;
                                    plotLine = true;
                                    changeColor = true;
                                    btnDistribution_Click(null, null);
                                }
                                else
                                {
                                    cboFilter.Enabled = true;
                                    if (iPMOrO3 != -1)
                                    {
                                        if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                                        {
                                            if (dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("worst") || dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("best"))
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else
                                            {
                                                createGraph(zgcChart, cboType.Text);
                                            }
                                        }
                                        else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                                        {
                                            createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                        }
                                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                                        {
                                            createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                        }
                                        else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                        {
                                            createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                        }
                                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                        {
                                            createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                        }
                                        else
                                        {
                                            if (dt.Columns.Count > iPMOrO3 + iValue + 1 && dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("f")
                                                && dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Replace("f", "") == dt.Columns[iPMOrO3 + iValue].ColumnName.Replace("b", ""))
                                            {
                                                createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                                            }
                                            else
                                            {
                                                createGraph(zgcChart, cboType.Text);
                                            }
                                        }
                                    }
                                    else
                                        createGraph(zgcChart, cboType.Text);
                                }
                                #endregion
                                if (this.tbcFunction.SelectedTab.Text != "Chart" && this.tbcFunction.SelectedTab.Text != "Data")
                                {
                                    tbcFunction.SelectedTab = tbpData;
                                }
                                //btnApply.Enabled = true;
                                btnExport.Enabled = true;
                                btnShowAll.Enabled = true;
                                btnApplyData.Enabled = true;
                                numericUpDownResult.Enabled = true;
                                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                                {
                                    if (Path.GetFileName(filePath).ToLower().Contains("data") || Path.GetFileName(filePath).ToLower().Contains("receptor"))
                                    {
                                        txtDistance.Enabled = true;
                                    }
                                    else
                                    {
                                        txtDistance.Enabled = false;
                                    }
                                    txtThreshold.Enabled = true;
                                }
                                #endregion

                                #endregion

                            }

                        }
                        WaitClose();
                        dt.Dispose();
                        GC.Collect();
                        break;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        void clboQuantifiers_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            try
            {
                string str = clboQuantifiers.SelectedItem.ToString();
                if (str.Contains("_VNA"))
                {
                    str = str.Replace("_VNA", "_eVNA");
                    if (clboQuantifiers.GetItemCheckState(clboQuantifiers.SelectedIndex) == CheckState.Unchecked)
                    {
                        for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                        {
                            if (clboQuantifiers.GetItemCheckState(i) == CheckState.Checked && clboQuantifiers.Items[i].ToString() == str)
                            {
                                clboQuantifiers.ItemCheck -= new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                clboQuantifiers.SetItemChecked(i, false);
                                clboQuantifiers.ItemCheck += new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                break;
                            }
                        }
                    }
                }
                else if (str.Contains("_eVNA"))
                {
                    str = str.Replace("_eVNA", "_VNA");
                    if (clboQuantifiers.GetItemCheckState(clboQuantifiers.SelectedIndex) == CheckState.Unchecked)
                    {
                        for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                        {
                            if (clboQuantifiers.GetItemCheckState(i) == CheckState.Checked && clboQuantifiers.Items[i].ToString() == str)
                            {
                                clboQuantifiers.ItemCheck -= new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                clboQuantifiers.SetItemChecked(i, false);
                                clboQuantifiers.ItemCheck += new ItemCheckEventHandler(clboQuantifiers_ItemCheck);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        #region 为每个步骤添加help
        //-----------------Show Help with HyperLink---------------
        private void lblSteps_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                string keyWord = "";
                string stepName = lblSteps.Text;
                if (stepName == "Desired Output")
                {
                    stepName = "Choose Desired Output";
                }//for Ozone annalysis


                string pathManual = Application.StartupPath + @"\Data\User Manual.chm";
                if (Language.Localization.CurrentLanguage == "en")
                {
                    pathManual = Application.StartupPath + @"\Data\User Manual.chm";
                    switch (stepName)
                    {
                        case ("Choose Desired Output"):
                        case ("选择输出文件"):
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    //keyWord = "2_1_1_choose_desired_output.htm";
                                    keyWord = "_6_1_choose_desired_output.htm";
                                    break;
                                case enumAnalysis.DailyPM:
                                    // keyWord = "2_2_1_choose_desired_output.htm";
                                    keyWord = "_7_1_choose_desired_output.htm";
                                    break;
                                case enumAnalysis.Ozone:
                                    // keyWord = "2_3_1_desired_output.htm";
                                    keyWord = "_8_1_desired_output.htm";
                                    break;
                                case enumAnalysis.Visibility:
                                    // keyWord = "2_4_1_choose_desired_output.htm";
                                    keyWord = "_9_1_choose_desired_output.htm";
                                    break;
                                default:
                                    break;
                            }
                            break;
                        case "Output Choices-Advanced":
                        case ("选择高级输出文件"):
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    // keyWord = "2_1_2output_choices-advanced.htm";
                                    keyWord = "_6_2_output_choices-advanced.htm";
                                    break;
                                case enumAnalysis.DailyPM:
                                    // keyWord = "2_2_2_output_choices-advanced.htm";
                                    keyWord = "_7_2_output_choices-advanced.htm";
                                    break;
                            }
                            break;
                        case "Data Input":
                        case ("选择输入数据"):
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    // keyWord = "2_1_3_data_input.htm";
                                    keyWord = "_6_3_data_input.htm";
                                    break;
                                case enumAnalysis.DailyPM:
                                    // keyWord = "2_2_3_data_input.htm";
                                    keyWord = "_7_3_data_input.htm";
                                    break;
                                case enumAnalysis.Ozone:
                                    // keyWord = "2_3_2_data_input.htm";
                                    keyWord = "_8_2_data_input.htm";
                                    break;
                                case enumAnalysis.Visibility:
                                    // keyWord = "2_4_2_data_input.htm";
                                    keyWord = "_9_2_data_input.htm";
                                    break;
                            }
                            break;
                        case "Species Fraction Options":
                        case ("设置成分比例计算参数"):
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    //keyWord = "2_1_4_species_fraction_options.htm";
                                    keyWord = "_6_4_species_fraction_options.htm";
                                    break;
                                case enumAnalysis.DailyPM:
                                    // keyWord = "2_2_4_species_fraction_options.htm";
                                    keyWord = "_7_4_species_fraction_options.htm";
                                    break;
                            }
                            break;
                        //case "Species Fraction-Advanced":
                        //    switch (CommonClass.CurrentAnalysis)
                        //    {
                        //        case enumAnalysis.AnnualPM:
                        //            keyWord = "2_1_5_species_fraction_advance.htm";
                        //            break;
                        //        case enumAnalysis.DailyPM:
                        //            keyWord = "2_2_5_species_fraction_advance.htm";
                        //            break;
                        ////    }
                        //    break;
                        case "PM2.5 Calculation Options":
                        case ("设置PM2.5计算参数"):
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    //keyWord = "2_1_6_pm2_5_calculation_option.htm";
                                    keyWord = "_6_5_pm_2_5_calculation_options.htm";
                                    break;
                                case enumAnalysis.DailyPM:
                                    // keyWord = "2_2_6_pm2_5_calculation_option.htm";
                                    //keyWord = "_7_4_1_pm2_5_calculation_options.htm";
                                    keyWord = "_7_4_1_pm_2_5_calculation_options.htm";
                                    break;
                            }
                            break;
                        case "Model Data Options":
                        case ("设置模型数据参数"):
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPM:
                                    // keyWord = "2_1_7_model_data_options.htm";
                                    keyWord = "_6_5_1_model_data_options.htm";
                                    break;
                                case enumAnalysis.DailyPM:
                                    // keyWord = "2_2_7_model_data_options.htm";
                                    keyWord = "_7_5_model_data_options.htm";
                                    break;
                            }
                            break;
                        case "Filtering/Interpolation":
                        case "筛选与插值设置":
                            // keyWord = "2_3_3_filtering_interpolation.htm";
                            keyWord = "_8_3_filtering_interpolation.htm";
                            break;
                        case "RRF/Spatial Gradient":
                        case "//中文译文":
                            // keyWord = "2_3_4_rrf_spatial_gradient.htm";
                            keyWord = "_8_4_rrf_spatial_gradient.htm";
                            break;
                        case "Filtering":
                        case "设置筛选":
                            //keyWord = "2_4_3_filtering.htm";
                            keyWord = "_9_3_filtering.htm";
                            break;
                        case "Single Source Impact Analysis Option":
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.SSIAAnnualPM:
                                    keyWord = "3_5_1_Single_Source_Impact_Analysis_.htm";
                                    break;
                                case enumAnalysis.SSIADailyPM:
                                    keyWord = "3_6_1_Single_Source_Impact_Ana.htm";
                                    break;
                                case enumAnalysis.SSIAOzone:
                                    keyWord = "3_7_1Single_Source_Impact_Anal.htm";
                                    break;
                            }
                            break;
                        case "Model Data Input && Option":
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.SSIAAnnualPM:
                                    keyWord = "3_5_2_Model_Data_Input__Option.htm";
                                    break;
                                case enumAnalysis.SSIADailyPM:
                                    keyWord = "3_6_2_Model_Data_Input__Option.htm";
                                    break;
                                case enumAnalysis.SSIAOzone:
                                    keyWord = "3_7_2Model_Data_Input__Option.htm";
                                    break;
                            }
                            break;
                        case "Monitor Data Input && Option":
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.SSIAAnnualPM:
                                    keyWord = "3_5_3_Monitor_Data_Input__Opti.htm";
                                    break;
                                case enumAnalysis.SSIADailyPM:
                                    keyWord = "3_6_3_Monitor_Data_Input__Opti.htm";
                                    break;
                                case enumAnalysis.SSIAOzone:
                                    keyWord = "3_7_3Monitor_Data_Input__Optio.htm";
                                    break;
                            }
                            break;
                        case "PM Calculation Option":
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.SSIAAnnualPM:
                                    keyWord = "3_5_4_PM_Calculation_Option.htm";
                                    break;
                                case enumAnalysis.SSIADailyPM:
                                    keyWord = "3_6_4_PM_Calculation_Option.htm";
                                    break;
                            }
                            break;
                        case "Ozone Calculation Option":
                            keyWord = "3_7_4Ozone_Calculation_Option.htm";
                            break;
                    }
                }
                else if (Language.Localization.CurrentLanguage == "zh")
                {
                    pathManual = Application.StartupPath + @"\Data\User Manual_zh.chm";

                    switch (stepName)
                    {
                        case "模型数据输入":
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPMChina:
                                    keyWord = "7_1.html";
                                    break;
                                case enumAnalysis.OzoneChina:
                                    keyWord = "8_1.html";
                                    break;
                            }
                            break;
                        case "监测数据输入":
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPMChina:
                                    keyWord = "7_2.html";
                                    break;
                                case enumAnalysis.OzoneChina:
                                    keyWord = "8_2.html";
                                    break;
                            }
                            break;
                        case "PM2.5成分数据选项":
                            switch (CommonClass.CurrentAnalysis)
                            {
                                case enumAnalysis.AnnualPMChina:
                                    keyWord = "7_3.html";
                                    break;
                            }
                            break;
                    }
                }

                Help.ShowHelp(this, pathManual, keyWord);
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        #endregion

        //---------------close Log tab------------
        private void picCloseLog_Click(object sender, EventArgs e)
        {
            try
            {
                if (tlvLogFile.Items.Count > 0)
                {
                    this.tbcFunction.TabPages.Remove(tbpLog);
                    tlvLogFile.Items.Clear();
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        //----------Close Running Log tab-----------
        private void picCloseRunning_Click(object sender, EventArgs e)
        {
            try
            {
                if (tlvRunning.Items.Count > 0)
                {
                    this.tbcFunction.TabPages.Remove(tbpRunning);
                    tlvRunning.Items.Clear();
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        #region DotSpatial
        private void tsmiFullExtent_Click(object sender, EventArgs e)
        {
            try
            {
                mainMap.ZoomToMaxExtent();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        #region zoom to
        private void tsmiContinentalUS_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiContinentalUS.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiMaryland_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiMaryland.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiNewEngland_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiNewEngland.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiSouthernCalifornia_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiSouthernCalifornia.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiTexas_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiTexas.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiWashingtonDC_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiWashingtonDC.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiEditFrames_Click(object sender, EventArgs e)
        {
            try
            {
                MessageBox.Show(Language.Localization.GetValue("Not currently implemented! "));
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiAdd_Click(object sender, EventArgs e)
        {
            try
            {
                MessageBox.Show(Language.Localization.GetValue("Not currently implemented! "));
                //AddFrame addFrameForm = new AddFrame();
                //if (addFrameForm.ShowDialog() == DialogResult.OK)
                //{
                //    ToolStripMenuItem menuItem = new ToolStripMenuItem();
                //    menuItem.Text = CommonClass.FrameName;
                //    tsbtnZoomTo.DropDownItems.Insert(tsbtnZoomTo.DropDownItems.Count - 3, menuItem);
                //}
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        #endregion
        private void tsbtnZoomIn_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    mainMap.FunctionMode = FunctionMode.ZoomIn;
                }
                catch (Exception ex)
                {
                    CommonClass.LogError(ex);
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnZoomOut_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    mainMap.FunctionMode = FunctionMode.ZoomOut;
                }
                catch (Exception ex)
                {
                    CommonClass.LogError(ex);
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnPan_Click(object sender, EventArgs e)
        {
            try
            {
                mainMap.FunctionMode = FunctionMode.Pan;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnFullExtent_Click(object sender, EventArgs e)
        {
            try
            {
                mainMap.ZoomToMaxExtent();
                mainMap.FunctionMode = FunctionMode.None;
                cboZoomTo.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }

        }

        private void tsbtnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                mainMap.FunctionMode = FunctionMode.Select;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnIdentify_Click(object sender, EventArgs e)
        {
            try
            {
                mainMap.FunctionMode = FunctionMode.Info;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnSavePicture_Click(object sender, EventArgs e)
        {
            try
            {
                Image imageMap = new Bitmap(mainMap.Width, mainMap.Height);
                Graphics gMap = Graphics.FromImage(imageMap);
                gMap.CopyFromScreen(this.PointToScreen(new System.Drawing.Point(stcMain.Width - stcGIS.Panel2.Width - 6, scrRight.Location.Y + tbcFunction.Location.Y + 148)), new System.Drawing.Point(0, 0), new Size(this.Width, this.Height));

                SaveFileDialog savePicture = new SaveFileDialog();
                savePicture.Filter = "BMP(*.bmp)|*.bmp|JPG(*.jpg)|*.jpg|PNG(*.png)|*.png|GIF(*.gif)|*.gif";
                savePicture.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Picture";
                savePicture.Title = Language.Localization.GetValue("Save image to...");
                if (savePicture.ShowDialog() == DialogResult.Cancel) return;
                string fileName = savePicture.FileName;
                //Thread.Sleep(300);
                //if (this.stcMap.Panel1MinSize < 180)

                imageMap.Save(fileName);
                MessageBox.Show(Language.Localization.GetValue("Save map image successfully!"));
                gMap.Dispose();

            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnSaveSHP_Click(object sender, EventArgs e)
        {
            try
            {
                if (mainMap.Layers.Count == 0)
                    return;
                SaveFileDialog saveShapeFile = new SaveFileDialog();
                saveShapeFile.Filter = "SHP(*.shp)|*.shp";
                saveShapeFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\SHP";
                saveShapeFile.Title = Language.Localization.GetValue("Save map...");
                if (saveShapeFile.ShowDialog() == DialogResult.Cancel)
                { return; }
                string shapeFileName = saveShapeFile.FileName;
                //FeatureLayer f1 = mainMap.Layers[mainMap.Layers.Count - 1] as FeatureLayer;
                FeatureLayer f1 = mainMap.Layers[0] as FeatureLayer;
                f1.DataSet.SaveAs(shapeFileName, true);
                MessageBox.Show(Language.Localization.GetValue("Save map file successfully!"));
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnOpenFile_Click(object sender, EventArgs e)
        {
            try
            {
                string firstLine = "";
                OpenFileDialog openFile = new OpenFileDialog();
                openFile.Title = Language.Localization.GetValue("Open Monitor Network");
                openFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Output";
                openFile.Filter = Language.Localization.GetValue("Monitor Network(*.csv)|*.csv");
                openFile.RestoreDirectory = true;
                if (openFile.ShowDialog() != DialogResult.OK)
                    return;
                WaitShow(Language.Localization.GetValue("Drawing Map"));
                DataTable dt = null;
                bool errorOccur = false;
                if (Path.GetFileNameWithoutExtension(openFile.FileName).Contains("Quarterly Avg PM2.5 Monitors")
                    || Path.GetFileNameWithoutExtension(openFile.FileName).Contains("Quarterly Peak PM2.5 Monitors")
                    || Path.GetFileNameWithoutExtension(openFile.FileName).Contains("Quarterly Peak Spec Frac Point"))
                    dt = CommonClass.getDataTableForQuarterlyMonitors(openFile.FileName, ref firstLine);
                else
                    dt = CommonClass.getDataSetFromCSVAndFirstLine(openFile.FileName, ref firstLine, ref errorOccur);
                if (dt == null)
                {
                    MessageBox.Show(Language.Localization.GetValue("Fail to read the file."));
                    return;
                }
                drawMap(dt, Path.GetFileNameWithoutExtension(openFile.FileName), false);
                //drawMap(dt, this.tlvDataViewer.SelectedItems[0].Text.ToString(), false);
                setStandardMap();

            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
            WaitClose();
        }

        private void tsbtnAddLayers_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFile = new OpenFileDialog();
                openFile.Title = Language.Localization.GetValue("Add Layer...");
                openFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\SHP";
                openFile.Filter = "SHP(*.shp)|*.shp";
                openFile.RestoreDirectory = true;
                if (openFile.ShowDialog() != DialogResult.OK) return;
                mainMap.ProjectionModeReproject = ActionMode.Never;
                mainMap.ProjectionModeDefine = ActionMode.Never;
                //if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region")
                //{
                //    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                //    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                //}
                //else
                //{
                //    mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                //}
                mainMap.AddLayer(openFile.FileName);
                //mainMap.AddLayer();
                //if (mainMap.Projection != ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ))//DotSpatial.Projections.KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic)
                //{
                //    mainMap.Projection = ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ);//DotSpatial.Projections.KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic;
                //}
                ILayer iLayer = mainMap.Layers[mainMap.Layers.Count - 1];
                iLayer.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
                iLayer.Reproject(mainMap.Projection);
                //setStandardMap();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnShowLegend_Click(object sender, EventArgs e)
        {
            try
            {
                Extent exLast = new Extent();
                if (mainMap.ViewExtents.MinX < mainMap.Extent.MinX
                   && mainMap.ViewExtents.MinY < mainMap.Extent.MinY
                   && mainMap.ViewExtents.MaxX > mainMap.Extent.MaxX
                   && mainMap.ViewExtents.MaxY > mainMap.Extent.MaxY)
                {
                    mainMap.ZoomToMaxExtent();
                }
                exLast = mainMap.ViewExtents.Clone() as Extent;
                if (isShowLegend)
                {
                    this.stcGIS.Panel1MinSize = 185;
                    this.stcGIS.SplitterWidth = 1;
                    this.stcGIS.FixedPanel = FixedPanel.Panel1;
                    this.stcGIS.BorderStyle = BorderStyle.FixedSingle;
                    mainMap.ViewExtents = exLast;
                    //mainMap.ZoomToPrevious();
                    isShowLegend = false;
                }
                else
                {
                    this.stcGIS.Panel1MinSize = 24;
                    this.stcGIS.SplitterDistance = 0;
                    this.stcGIS.BorderStyle = BorderStyle.None;
                    mainMap.ViewExtents = exLast;
                    //mainMap.ZoomToPrevious();
                    isShowLegend = true;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        #endregion

        private void cboStandardLayers_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                mainMap.ProjectionModeReproject = ActionMode.Never;
                mainMap.ProjectionModeDefine = ActionMode.Never;
                if (mainMap.Layers.Count >= 1)
                {
                    if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region")
                    //if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "npsClassI")
                    {
                        mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                        mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                    }
                    else
                        mainMap.Layers.RemoveAt(mainMap.Layers.Count - 1);
                }
                setStandardMap();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnShowAll_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < clboQuantifiers.Items.Count; i++)
                {
                    clboQuantifiers.SetItemChecked(i, false);
                }
                if (_dtChangeDigit.Rows.Count != _dtOutput.Rows.Count)
                    numericUpDownResult_ValueChanged(null, null);
                dgvDataView.DataSource = _dtChangeDigit;
                _dtSelectOutput = _dtChangeDigit;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void choCheckAll_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                if (!choCheckAll.Checked)
                {
                    for (int i = 0; i < mainMap.Layers.Count - 1; i++)
                    {
                        ILayer iLayer = mainMap.Layers[i];
                        iLayer.ClearSelection();
                        iLayer.Checked = false;
                    }
                    mainMap.Refresh();
                    Lengend.RefreshNodes();
                }
                else
                {
                    for (int i = 0; i < mainMap.Layers.Count - 1; i++)
                    {
                        ILayer iLayer = mainMap.Layers[i];
                        iLayer.Checked = true;
                    }
                    mainMap.Refresh();
                    Lengend.RefreshNodes();
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            chartApply();
            zgcChart.Refresh();
        }

        private void chartApply()
        {
            try
            {
                //--------- added by Yangwenwei

                if (cboFilter.Text == "")
                {
                    if (_ChartFilter != cboFilter.Text)
                    {
                        dgvDataList.DataSource = _dtOutput;
                        int count = 5;
                        if (_dtOutput.Rows.Count < count)
                            count = _dtOutput.Rows.Count;
                        for (int i = 0; i < count; i++)
                        {
                            dgvDataList.Rows[i].Cells[0].Value = true;
                        }
                    }
                }
                else
                {
                    if (_ChartFilter == cboFilter.Text)
                    {
                        //dt = _dtStateDataTable;
                    }
                    else
                    {
                        _ChartFilter = cboFilter.Text;
                        DataRow[] drArray = _dtOutput.Select(string.Format("{0}='{1}'", _dtOutput.Columns[iStateName].ColumnName, cboFilter.Text));
                        DataTable dt = new DataTable();
                        dt = _dtOutput.Clone();
                        for (int i = 0; i < drArray.Length; i++)
                        {
                            dt.ImportRow(drArray[i]);
                        }
                        dgvDataList.DataSource = dt;
                        //_dtStateDataTable = dt;
                        for (int i = 0; i < dgvDataList.Rows.Count; i++)
                        {
                            DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                            checkCell.Value = true;
                        }
                    }
                }

                if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                {
                    string SIAname = cboType.Text;
                    switch (ichartType)
                    {
                        case 1:
                            //distribution
                            DataTable dtTmp = new DataTable();
                            dtTmp.Columns.Add("_id");
                            dtTmp.Columns.Add(SIAname, typeof(double));
                            for (int i = 0; i < dgvDataList.Rows.Count; i++)
                            {
                                if (Convert.ToBoolean(dgvDataList.Rows[i].Cells[0].Value))
                                {
                                    DataRow dr = dtTmp.NewRow();
                                    dr[0] = dgvDataList.Rows[i].Cells["_id"].Value;
                                    dr[1] = dgvDataList.Rows[i].Cells[SIAname].Value;
                                    dtTmp.Rows.Add(dr);
                                }
                            }
                            string unit = "(μg/m3)";
                            if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                unit = "(ppb)";
                            if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                unit = "";
                            if (SIAname.Contains("Δ"))
                                unit = "Predicted Change " + unit;
                            else
                                unit = "Concentration " + unit;
                            createDistribution(zgcChart, dtTmp, unit);
                            dtTmp.Clear();
                            dgvDataList.Rows[0].Selected = false;
                            return;
                        case 2:
                            //frequency
                            List<double> lstDelta = new List<double>();
                            for (int i = 0; i < dgvDataList.Rows.Count; i++)
                            {
                                if (Convert.ToBoolean(dgvDataList.Rows[i].Cells[0].Value))
                                {
                                    lstDelta.Add(Convert.ToDouble(dgvDataList.Rows[i].Cells[SIAname].Value));
                                }
                            }
                            unit = "μg/m3";
                            if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                                unit = "ppb";
                            if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                                unit = "";
                            createFrequency(zgcChart, lstDelta, unit);
                            lstDelta.Clear();
                            dgvDataList.Rows[0].Selected = false;
                            return;
                    }
                }

                if (cboType.Text.ToLower().Contains("pm") || (cboType.Text.ToLower().Contains("o3") && !cboType.Text.Contains("no3")) || cboType.Text.Contains("dv"))
                {
                    if (cboType.Items.Count > cboType.SelectedIndex + 1 && (cboType.Items[cboType.SelectedIndex + 1].ToString().Contains("f") || cboType.Items[cboType.SelectedIndex + 1].ToString().Contains("worst"))
                        && (cboType.Items[cboType.SelectedIndex + 1].ToString().Replace("f", "") == cboType.Items[cboType.SelectedIndex].ToString().Replace("b", "").Replace("est", "best") || cboType.Items[cboType.SelectedIndex + 1].ToString().Replace("worst", "") == cboType.Items[cboType.SelectedIndex].ToString().Replace("best", "")) || cboType.Text == "Base_PM25" || cboType.Text == "PM25 (FRM)" || cboType.Text == "Base_O3" || cboType.Text == "O3 (Obs)")
                    {
                        int iColumnNumText = -1, iColumnNumNext = -1;
                        for (int i = 0; i < dgvDataList.Columns.Count; i++)
                        {
                            if (dgvDataList.Columns[i].Name == cboType.Items[cboType.SelectedIndex].ToString())
                                iColumnNumText = i;
                            if (dgvDataList.Columns[i].Name == cboType.Items[cboType.SelectedIndex + 1].ToString())
                                iColumnNumNext = i;
                        }
                        if (iColumnNumNext - iColumnNumText == 1)
                            createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                        else
                            createGraph(zgcChart, cboType.Text);
                    }
                    else
                    {
                        if (cboType.SelectedIndex > 0 && (cboType.Items[cboType.SelectedIndex - 1].ToString().Contains("b") || cboType.Items[cboType.SelectedIndex - 1].ToString().Contains("best"))
                               && (cboType.Items[cboType.SelectedIndex - 1].ToString().Replace("b", "").Replace("est", "best") == cboType.Items[cboType.SelectedIndex].ToString().Replace("f", "")
                               || cboType.Items[cboType.SelectedIndex].ToString().Replace("worst", "") == cboType.Items[cboType.SelectedIndex - 1].ToString().Replace("best", "")) || cboType.Text == "Alt_PM25" || cboType.Text == "Alt_O3")
                        {
                            int iColumnNumText = -1, iColumnNumNext = -1;
                            for (int i = 0; i < dgvDataList.Columns.Count; i++)
                            {
                                if (dgvDataList.Columns[i].Name == cboType.Items[cboType.SelectedIndex].ToString())
                                    iColumnNumText = i;
                                if (dgvDataList.Columns[i].Name == cboType.Items[cboType.SelectedIndex - 1].ToString())
                                    iColumnNumNext = i;
                            }
                            if (iColumnNumText - iColumnNumNext == 1)
                                createZedGraphTwoBars(zgcChart, cboType.Text, -1);
                            else
                                createGraph(zgcChart, cboType.Text);
                        }
                        else
                        {
                            createGraph(zgcChart, cboType.Text);
                        }
                    }
                }
                else
                {
                    createGraph(zgcChart, cboType.Text);
                }
                dgvDataList.Rows[0].Selected = false;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tlvDataViewer_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                if (this.tlvDataViewer.SelectedItems.Count <= 0 && tlvDataViewer.Items.ToString() == "No data loaded" || tlvDataViewer.Items.Count == 1)
                {
                    this.ctmsOutputs.Hide();
                    this.ctmsLogConfig.Hide();
                }
                else
                {
                    if (e.Button == MouseButtons.Right && (this.tlvDataViewer.SelectedItems[0].Tag.ToString() == "cfg" || this.tlvDataViewer.SelectedItems[0].Tag.ToString() == "logfile"))
                        this.ctmsLogConfig.Show(MousePosition);
                    else if (e.Button == MouseButtons.Right && this.tlvDataViewer.SelectedItems[0].Tag.ToString() == "outputfiles")
                    {
                        if (IsPolygon(this.tlvDataViewer.SelectedItems[0].Text))
                        {
                            this.tsmiAddToMAP.Visible = true;
                            this.ctmsOutputs.Show(MousePosition);
                        }
                        else
                        {
                            this.tsmiAddToMAP.Visible = false;
                            this.ctmsOutputs.Show(MousePosition);
                        }

                        if (
                            (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM
                            || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition
                            || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM
                            || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone
                            ) &&
                            this.tlvDataViewer.SelectedItems[0].Text.Contains("SSIA Source Location"))
                        {
                            this.tsmiOverlayLocation.Visible = true;
                        }
                        else
                        {
                            //this.tsmiOverlayLocation.Checked = false;
                            this.tsmiOverlayLocation.Visible = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiViewLogConfig_Click(object sender, EventArgs e)
        {
            try
            {
                switch (this.tlvDataViewer.SelectedItems[0].Tag.ToString())
                {
                    case "cfg":
                        addConfiguration();
                        if (this.tbcFunction.SelectedTab != tbpConfigurationBatch)
                            this.tbcFunction.SelectedTab = tbpConfigurationBatch;
                        btnExportCFG.Enabled = true;
                        //btnClose.Enabled = true;
                        btnEdit.Enabled = true;
                        picCloseCFG.Visible = true;
                        break;
                    case "logfile":
                        addLog();
                        if (this.tbcFunction.SelectedTab != tbpLog)
                            this.tbcFunction.SelectedTab = tbpLog;
                        picCloseLog.Visible = true;
                        break;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiExportLogConfig_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog saveFile = new SaveFileDialog();
                saveFile.Title = Language.Localization.GetValue("Extracting...");
                switch (this.tlvDataViewer.SelectedItems[0].Tag.ToString())
                {
                    case "cfg":
                        saveFile.FileName = "Configuration";
                        saveFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\CFG";
                        saveFile.Filter = "CFG files(*.cfg)|*.cfg";
                        saveFile.RestoreDirectory = true;
                        if (saveFile.ShowDialog() == DialogResult.Cancel)
                            return;
                        CommonClass.ProjectName = CommonClass.FileName;
                        BatchCommonClass.OutPutBaseConfiguration(CommonClass.CurrentBaseScenario.configuration, saveFile.FileName);
                        if (CommonClass.CurrentBaseScenario.configuration.configurationName != Path.GetFileNameWithoutExtension(saveFile.FileName))
                            CommonClass.CurrentBaseScenario.configuration.configurationName = Path.GetFileNameWithoutExtension(saveFile.FileName);
                        CommonClass.CurrentBaseScenario.configuration.configurationPath = saveFile.FileName;
                        //CommonClass.SaveCFG(CommonClass.CurrentBaseScenario.configuration, saveFile.FileName);
                        break;
                    case "logfile":
                        saveFile.FileName = "Log File";
                        saveFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\LOG";
                        saveFile.Filter = "log file(*.log)|*.log";
                        saveFile.RestoreDirectory = true;
                        if (saveFile.ShowDialog() == DialogResult.Cancel)
                            return;
                        CommonClass.SaveLog(CommonClass.CurrentBaseScenario.log, saveFile.FileName, true);
                        break;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiAddToMAP_Click(object sender, EventArgs e)
        {
            try
            {
                string filePath = this.tlvDataViewer.SelectedItems[0].Name.ToString();
                if (!File.Exists(filePath))
                {
                    filePath = CommonClass.ResultFilePath + @"\Result\Output\" + CommonClass.CurrentBaseScenario.configuration.configurationName + @"\" + Path.GetFileName(this.tlvDataViewer.SelectedItems[0].Name.ToString());
                    if (!File.Exists(filePath))
                    {
                        MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                        return;
                    }
                }
                if (this.tlvDataViewer.SelectedItems[0].Text.Contains("Neighbor File"))
                {
                    MessageBox.Show(Language.Localization.GetValue("File is too large and only top 1000 records are displayed. You can extract it to read in another program."));
                }
                WaitShow(Language.Localization.GetValue("Drawing Map"));
                DataTable dtMap = null;
                if (this.tlvDataViewer.SelectedItems[0].Text.Contains("Neighbor File"))
                {
                    dtMap = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, 1000);
                }
                else
                {
                    //-------首先确定是frequency为quarterly还是其他---------
                    #region
                    //string dataType = "";
                    FileStream fs = null;
                    fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
                    string[] sMatchArray = sr.ReadLine().Split(new char[] { ',' });
                    _dataType = sMatchArray[0];
                    fs.Dispose();
                    sr.Dispose();
                    sr.Close();
                    #endregion
                    bool errorOccur = false;
                    if (_dataType.Trim().ToLower() == "quarter")
                    {
                        if (this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Daily All Years All Days PM25 Point"))
                        {
                            dtMap = CommonClass.getDataTableForMapDaily(filePath, CommonClass.CurrentBaseScenario);
                        }
                        else if (this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Daily All Years High Days PM25 Point"))
                        {
                            dtMap = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                            //drawMap(dtMap, Path.GetFileNameWithoutExtension(tlvDataViewer.SelectedItems[0].Name.ToString()));
                        }
                        else
                            dtMap = CommonClass.getDataTableForMap(filePath);
                    }
                    else
                    {
                        dtMap = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                    }
                }
                if (dtMap == null)
                {
                    WaitClose();
                    MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                    return;
                }
                drawMap(dtMap, this.tlvDataViewer.SelectedItems[0].Text.ToString(), false);
                WaitClose();
                if (this.tbcFunction.SelectedTab != tbpMap)
                    tbcFunction.SelectedTab = tbpMap;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiAddToGIS_Click(object sender, EventArgs e)
        {
            try
            {
                string filePath = this.tlvDataViewer.SelectedItems[0].Name.ToString();
                if (!File.Exists(filePath))
                {
                    filePath = CommonClass.ResultFilePath + @"\Result\Output\" + CommonClass.CurrentBaseScenario.configuration.configurationName + @"\" + Path.GetFileName(this.tlvDataViewer.SelectedItems[0].Name.ToString());
                    if (!File.Exists(filePath))
                    {
                        MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                        return;
                    }
                }
                if (this.tlvDataViewer.SelectedItems[0].Text.Contains("Neighbor File"))
                {
                    MessageBox.Show(Language.Localization.GetValue("File is too large and only top 1000 records are displayed. You can extract it to read in another program."));
                }
                WaitShow(Language.Localization.GetValue("Drawing Map"));
                DataTable dtMap = null;
                if (this.tlvDataViewer.SelectedItems[0].Text.Contains("Neighbor File"))
                {
                    dtMap = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, 1000);
                }
                else
                {
                    //-------首先确定是frequency为quarterly还是其他---------
                    #region
                    //string dataType = "";
                    FileStream fs = null;
                    fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
                    string[] sMatchArray = sr.ReadLine().Split(new char[] { ',' });
                    _dataType = sMatchArray[0];
                    fs.Dispose();
                    sr.Dispose();
                    sr.Close();
                    #endregion
                    bool errorOccur = false;
                    if (_dataType.Trim().ToLower() == "quarter")
                    {
                        if (this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Daily All Years All Days PM25 Point"))
                        {
                            dtMap = CommonClass.getDataTableForMapDaily(filePath, CommonClass.CurrentBaseScenario);
                        }
                        else if (this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Daily All Years High Days PM25 Point"))
                        {
                            dtMap = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                            //drawMap(dtMap, Path.GetFileNameWithoutExtension(tlvDataViewer.SelectedItems[0].Name.ToString()));
                        }
                        else
                            dtMap = CommonClass.getDataTableForMap(filePath);
                    }
                    else
                    {
                        dtMap = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                    }
                }
                if (dtMap == null)
                {
                    WaitClose();
                    MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                    return;
                }
                drawMap(dtMap, this.tlvDataViewer.SelectedItems[0].Text.ToString(), true);
                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                {
                    cboStandardLayers.SelectedIndexChanged -= cboStandardLayers_SelectedIndexChanged;
                    cboStandardLayers.Text = "US Counties";
                    cboStandardLayers.SelectedIndexChanged += cboStandardLayers_SelectedIndexChanged;
                }
                setStandardMap();
                WaitClose();
                if (this.tbcFunction.SelectedTab != tbpGIS)
                    tbcFunction.SelectedTab = tbpGIS;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiViewOutputs_Click(object sender, EventArgs e)
        {
            try
            {
                string filePath = this.tlvDataViewer.SelectedItems[0].Name.ToString();
                if (!File.Exists(filePath))
                {
                    filePath = CommonClass.ResultFilePath + @"\Result\Output\" + CommonClass.CurrentBaseScenario.configuration.configurationName + @"\" + Path.GetFileName(this.tlvDataViewer.SelectedItems[0].Name.ToString());
                    if (!File.Exists(filePath))
                    {
                        MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                        return;
                    }
                }
                iStateName = -1;
                if (this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Neighbor File"))
                {
                    MessageBox.Show(Language.Localization.GetValue("File is too large and only top 1000 records are displayed. You can extract it to read in another program."));
                }
                WaitShow(Language.Localization.GetValue("Loading Data"));
                //string dataType = "";
                if (dgvDataView.Columns.Count > 0)
                    dgvDataView.Columns.Clear();
                if (clboQuantifiers.Items.Count > 0)
                    clboQuantifiers.Items.Clear();
                if (cboFilter.Items.Count > 0)
                    cboFilter.Items.Clear();
                if (cboType.Items.Count > 0)
                    cboType.Items.Clear();
                if (dgvDataList.Columns.Count > 0)
                    dgvDataList.Columns.Clear();
                DataTable dt = null;
                bool errorOccur = false;
                if (!this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Neighbor File"))
                {
                    if (this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Quarterly Avg PM2.5 Monitors")
                        || this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Quarterly Peak PM2.5 Monitors")
                        || this.tlvDataViewer.SelectedItems[0].Text.ToString().Contains("Quarterly Peak Spec Frac Point"))
                        dt = CommonClass.getDataTableForQuarterlyMonitors(filePath, ref _dataType);
                    else
                        dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                }
                else
                {
                    dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, 1000);
                }
                //dt = CommonClass.getDataSetFromCSVAndFirstLine(this.tlvDataViewer.SelectedItems[0].Name.ToString(), ref dataType);
                if (dt == null)
                {
                    WaitClose();
                    MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                    return;
                }
                #region
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    if (dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") || dt.Columns[i].ColumnName.Trim().ToLower().Contains("location"))
                        iStateName = i;
                }
                //_dataType = dataType;
                _dtOutput = dt;
                _dtSelectOutput = dt;
                _dtChangeDigit = dt;
                lblFileName.Text = Path.GetFileNameWithoutExtension(this.tlvDataViewer.SelectedItems[0].Text.ToString());
                if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                {
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("_visibility_rank")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name"))
                            clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                        //added by Yangwenwei 20131220
                        if (col.HeaderText.Contains("Δ"))
                        {
                            col.Width = 120;
                        }
                        dgvDataView.Columns.Add(col);
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                {
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        string columnname = dt.Columns[i].ColumnName;
                        if (columnname.Contains("Δ"))
                            clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= Threshold");
                        if (columnname.Contains("Alt") && (columnname.Contains("VNA") || columnname.Contains("eVNA")))
                            clboQuantifiers.Items.Add(dt.Columns[i].ColumnName + " >= NAAQS");
                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { Name = dt.Columns[i].ColumnName, HeaderText = dt.Columns[i].ColumnName.Trim('_'), DataPropertyName = dt.Columns[i].ColumnName };
                        //added by Yangwenwei 20131220
                        if (col.HeaderText.Contains("Δ"))
                        {
                            col.Width = 120;
                        }
                        dgvDataView.Columns.Add(col);
                    }

                    if (Path.GetFileName(filePath).ToLower().Contains("data") || Path.GetFileName(filePath).ToLower().Contains("receptor"))//max distance from source
                    {
                        clboQuantifiers.Items.Add("Receptor <= max distance from source");
                    }
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.SSIAAnnualPM:
                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                        case enumAnalysis.SSIADailyPM:
                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                        case enumAnalysis.SSIAOzone:
                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold.ToString(); break;
                        case enumAnalysis.SSIADeposition:
                            txtThreshold.Text = (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).calculationOption.threshold.ToString(); break;
                    }

                }
                else
                {
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("gridcell") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("county")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("pollutant")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name") && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank"))
                            clboQuantifiers.Items.Add(dt.Columns[i].ColumnName);
                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName, Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName };
                        //added by Yangwenwei 20131220
                        if (col.HeaderText.Contains("Δ"))
                        {
                            col.Width = 120;
                        }
                        dgvDataView.Columns.Add(col);
                    }
                }
                numericUpDownResult_ValueChanged(sender, e);
                dgvDataView.Rows[0].Selected = false;
                //dgvDataView.DataSource = dt;
                dt.Dispose();
                #endregion
                //--------Chart部分-----------
                //--------获取filter，并为cbofilter添加items，若没有则为空
                #region
                List<string> lstStateNames = null;
                //lstStateNames = CommonClass.getStateListFromCSV(this.tlvDataViewer.SelectedItems[0].Name.ToString());
                lstStateNames = CommonClass.getStateListFromCSV(dt);
                if (lstStateNames == null)
                    cboFilter.Text = "";
                else
                {
                    foreach (string item in lstStateNames)
                    {
                        cboFilter.Items.Add(item);
                    }
                    cboFilter.Items.Insert(0, "");
                }
                cboFilter.Text = "";

                //----------为objectlistview添加列名-----------
                int iPMOrO3 = -1, iValue = -1;
                if (CommonClass.CurrentBaseScenario.configuration is VisibilityAnalysisConfiguration)
                {
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {

                        if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long")
                             && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state")
                             && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name"))
                        {
                            cboType.Items.Add(dt.Columns[i].ColumnName);
                            if (iValue == -1) iValue = i;
                        }

                        if (dt.Columns[i].ColumnName.Contains("pm") || (dt.Columns[i].ColumnName.Contains("o3") && !dt.Columns[i].ColumnName.Contains("no3"))
                            || dt.Columns[i].ColumnName.Contains("dv") || dt.Columns[i].ColumnName.Contains("base"))
                        {
                            if (iPMOrO3 == -1)
                                iPMOrO3 = i;
                        }

                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName, ReadOnly = true };
                        //added by Yangwenwei 20131220
                        if (col.HeaderText.Contains("Δ"))
                        {
                            col.Width = 120;
                        }
                        dgvDataList.Columns.Add(col);
                    }
                }
                else
                {
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name")
                                  && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("gridcell") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("county")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("neighbor") && !dt.Columns[i].ColumnName.ToLower().Contains("_visibility_rank"))
                        {
                            cboType.Items.Add(dt.Columns[i].ColumnName);
                            if (iValue == -1) iValue = i;
                        }

                        if (dt.Columns[i].ColumnName.Contains("pm") || (dt.Columns[i].ColumnName.Contains("o3") && !dt.Columns[i].ColumnName.Contains("no3")) || dt.Columns[i].ColumnName.Contains("dv"))
                        {
                            if (iPMOrO3 == -1)
                                iPMOrO3 = i;
                        }

                        DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = dt.Columns[i].ColumnName.Trim('_'), Name = dt.Columns[i].ColumnName, DataPropertyName = dt.Columns[i].ColumnName };
                        //added by Yangwenwei 20131220
                        if (col.HeaderText.Contains("Δ"))
                        {
                            col.Width = 120;
                        }
                        dgvDataList.Columns.Add(col);
                    }
                }

                if (iPMOrO3 != -1)
                {
                    iPMOrO3 = iPMOrO3 - iValue;
                    cboType.SelectedIndex = iPMOrO3;
                }
                else
                    if (cboType.Items.Count == 0)
                {
                    cboType.Text = "";
                }
                else
                    cboType.SelectedIndex = 0;


                DataGridViewCheckBoxColumn checkBoxCol = new DataGridViewCheckBoxColumn() { Width = 30 };
                dgvDataList.Columns.Insert(0, checkBoxCol);
                dgvDataList.DataSource = dt;
                //cboType.SelectedIndex = 0;
                dt.Dispose();

                //--------最开始默认为前5个------------
                for (int i = 0; i < 5; i++)
                {
                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                    checkCell.Value = true;
                }
                //--------画柱状图-----------
                //对于pm25和o3，当为point时则同时展示baseline和future value。
                if (iPMOrO3 != -1)
                {
                    if (dt.Columns.Count > iPMOrO3 + iValue + 1 && (dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("f") || dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Contains("worst"))
                        && (dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Replace("f", "") == dt.Columns[iPMOrO3 + iValue].ColumnName.Replace("b", "") || dt.Columns[iPMOrO3 + iValue + 1].ColumnName.Replace("worst", "") == dt.Columns[iPMOrO3 + iValue].ColumnName.Replace("best", "")))
                    {
                        createZedGraphTwoBars(zgcChart, cboType.Text, 1);
                    }
                    else
                    {
                        createGraph(zgcChart, cboType.Text);
                    }
                }
                else
                {
                    createGraph(zgcChart, cboType.Text);
                }
                #endregion
                //createGraph(zgcChart, cboType.Text, dt);
                if (this.tbcFunction.SelectedTab != tbpChart && this.tbcFunction.SelectedTab != tbpData)
                {
                    this.tbcFunction.SelectedTab = tbpData;
                }
                WaitClose();
                //btnApply.Enabled = true;
                btnExport.Enabled = true;
                btnShowAll.Enabled = true;
                btnApplyData.Enabled = true;
                numericUpDownResult.Enabled = true;
                if (CommonClass.CurrentAnalysis == enumAnalysis.SSIAAnnualPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIADailyPM || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                {
                    if (Path.GetFileName(filePath).ToLower().Contains("data") || Path.GetFileName(filePath).ToLower().Contains("receptor"))
                    {
                        txtDistance.Enabled = true;
                    }
                    else
                    {
                        txtDistance.Enabled = false;
                    }
                    txtThreshold.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                WaitClose();
                CommonClass.LogError(ex);
            }
        }

        private void tsmiExportOutputs_Click(object sender, EventArgs e)
        {
            try
            {
                string filePath = this.tlvDataViewer.SelectedItems[0].Name.ToString();
                if (!File.Exists(filePath))
                {
                    filePath = CommonClass.ResultFilePath + @"\Result\Output\" + CommonClass.CurrentBaseScenario.configuration.configurationName + @"\" + Path.GetFileName(this.tlvDataViewer.SelectedItems[0].Name.ToString());
                    if (!File.Exists(filePath))
                    {
                        MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                        return;
                    }
                }
                SaveFileDialog savefile = new SaveFileDialog();
                savefile.Title = Language.Localization.GetValue("Extracting...");
                savefile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\CSV";
                savefile.Filter = Language.Localization.GetValue("CSV files(*.csv)|*.csv");
                savefile.RestoreDirectory = true;
                if (savefile.ShowDialog() == DialogResult.Cancel)
                    return;
                string dataType = "";
                DataTable dt = null;
                bool errorOccur = false;
                dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref dataType, ref errorOccur, true);
                CommonClass.SaveCSV(dt, savefile.FileName, dataType);
                MessageBox.Show(Language.Localization.GetValue("Save as CSV successfully!"));
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        #region 等待窗口
        TipGIF waitMess = new TipGIF();//等待窗体
        bool sFlog = true;
        //--显示等待窗体 
        private void ShowWaitMess()
        {
            try
            {
                if (!waitMess.IsDisposed)
                {
                    waitMess.ShowDialog();
                }
            }
            catch (System.Threading.ThreadAbortException Err)
            {
                MessageBox.Show(Err.Message);
            }
        }

        //--新开辟一个线程调用 
        public void WaitShow(string msg)
        {
            try
            {
                if (sFlog == true)
                {
                    sFlog = false;
                    waitMess.Msg = msg;
                    waitMess.Title = Language.Localization.GetValue("Tip");
                    //ShowWaitMess();
                    System.Threading.Thread upgradeThread = null;
                    upgradeThread = new System.Threading.Thread(new System.Threading.ThreadStart(ShowWaitMess));
                    upgradeThread.Start();
                    //upgradeThread.IsBackground = true;
                }
            }
            catch (System.Threading.ThreadAbortException Err)
            {
                MessageBox.Show(Err.Message);
            }
        }
        private delegate void CloseFormDelegate();
        private delegate void ChangeDelegate(string msg);
        //--关闭等待窗体 
        public void WaitClose()
        {
            //同步到主线程上
            if (waitMess.InvokeRequired)
                waitMess.Invoke(new CloseFormDelegate(DoCloseJob));
            else
                DoCloseJob();
        }

        public void WaitChangeMsg(string msg)
        {
            try
            {
                if (waitMess.InvokeRequired)
                    waitMess.Invoke(new ChangeDelegate(DoChange), msg);
            }
            catch (System.Threading.ThreadAbortException Err)
            {
                MessageBox.Show(Err.Message);
            }
        }
        private void DoChange(string msg)
        {
            try
            {
                if (!waitMess.IsDisposed)
                {
                    if (waitMess.Created)
                    {
                        //sFlog = true;
                        waitMess.Msg = msg;
                        waitMess.Title = Language.Localization.GetValue("Tip");
                    }
                }
            }
            catch (System.Threading.ThreadAbortException Err)
            {
                MessageBox.Show(Err.Message);
            }
        }
        private void DoCloseJob()
        {
            try
            {
                if (!waitMess.IsDisposed)
                {
                    if (waitMess.Created)
                    {
                        sFlog = true;
                        waitMess.Close();
                    }
                }
            }
            catch (System.Threading.ThreadAbortException Err)
            {
                MessageBox.Show(Err.Message);
            }
        }
        #endregion 等待窗口

        private void choDeleteChecked_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                if (choDeleteChecked.Checked)
                {
                    if (mainMap.Layers.Count - 1 == 0 || (mainMap.Layers.Count == 2 && mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region"))
                    //if (mainMap.Layers.Count - 1 == 0 || (mainMap.Layers.Count == 2 && mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "npsClassI"))//只有底图npsClassI
                    {
                        choDeleteChecked.Checked = false;
                        CommonClass.dicBlend["GIS"].Clear();//added by Yangwenwei
                        return;
                    }
                    int n = mainMap.Layers.Count - 1;
                    if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region")
                    {
                        for (int i = n - 2; i >= 0; i--)
                        {
                            ILayer iLayer = mainMap.Layers[i];
                            if (iLayer.Checked)
                            {
                                mainMap.Layers.RemoveAt(i);
                            }
                        }
                    }
                    else
                    {
                        //int n = mainMap.Layers.Count - 1;
                        for (int i = n - 1; i >= 0; i--)
                        {
                            ILayer iLayer = mainMap.Layers[i];
                            if (iLayer.Checked)
                            {
                                mainMap.Layers.RemoveAt(i);
                            }
                        }
                    }
                    mainMap.Refresh();
                    Lengend.RefreshNodes();
                    Lengend.Refresh();
                    //if (mainMap.Layers.Count - 1 == 0 || (mainMap.Layers.Count == 2 && mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region"))
                    choDeleteChecked.Checked = false;

                    //如果当前不是point就不能选cboSpeciesTypeGIS
                    for (int i = mainMap.Layers.Count - 1; i >= 0; i--)
                    {
                        string lt = mainMap.Layers[i].LegendText;
                        if (lt != "States"
                            && lt != "Counties"
                            && lt != "class14_region"
                            && lt != "npsClassI"
                            && lt != "State_epa2"
                            && lt != "China_prov_WGS84_LCC"
                            && lt != "SSIA Source Location")
                        {
                            _currentLayerIndex = i;
                            break;
                        }
                        _currentLayerIndex = -1;
                    }

                    //if (mainMap.Layers[mainMap.Layers.Count - 1].LegendText == "class14_region")
                    //    _currentLayerIndex = mainMap.Layers.Count - 3;
                    //else
                    //    _currentLayerIndex = mainMap.Layers.Count - 2;
                    if (_currentLayerIndex < 0)
                    {
                        colorBlend.SetValueRange(0, 0, true);
                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Enabled = false;
                        CommonClass.dicBlend["GIS"].Clear();
                        dataDomainGIS = null;
                        cboZoomTo.Items.Remove("Data Domain");
                        return;
                    }
                    else
                    {
                        if (cboZoomTo.Items.Contains("Data Domain"))
                        {
                            if (dataDomainGIS == null)
                                dataDomainGIS = new double[4];
                            dataDomainGIS[0] = mainMap.Layers[_currentLayerIndex].Extent.MinX - 10000;
                            dataDomainGIS[1] = mainMap.Layers[_currentLayerIndex].Extent.MinY - 10000;
                            dataDomainGIS[2] = mainMap.Layers[_currentLayerIndex].Extent.MaxX + 10000;
                            dataDomainGIS[3] = mainMap.Layers[_currentLayerIndex].Extent.MaxY + 10000;
                            for (int i = _currentLayerIndex - 1; i >= 0; i--)
                            {
                                if (mainMap.Layers[i].Extent.MinX - 10000 < dataDomainGIS[0])
                                    dataDomainGIS[0] = mainMap.Layers[i].Extent.MinX - 10000;
                                if (mainMap.Layers[i].Extent.MinY - 10000 < dataDomainGIS[1])
                                    dataDomainGIS[1] = mainMap.Layers[i].Extent.MinY - 10000;
                                if (mainMap.Layers[i].Extent.MaxX + 10000 > dataDomainGIS[2])
                                    dataDomainGIS[2] = mainMap.Layers[i].Extent.MaxX + 10000;
                                if (mainMap.Layers[i].Extent.MaxY + 10000 > dataDomainGIS[3])
                                    dataDomainGIS[3] = mainMap.Layers[i].Extent.MaxY + 10000;
                            }
                        }
                    }
                    string legendText = mainMap.Layers[_currentLayerIndex].LegendText;
                    ShowSpecies(legendText);

                    //Remove Min&Max in dicMaxMin.  added by Yangwenwei
                    List<KeyValuePair<string, CommonClass.SaveBlend>> lst = new List<KeyValuePair<string, CommonClass.SaveBlend>>();
                    for (int i = 0; i < mainMap.Layers.Count; i++)
                    {
                        lst.AddRange(CommonClass.dicBlend["GIS"].Where(p => p.Key.StartsWith(mainMap.Layers[i].LegendText)).ToList());
                    }
                    CommonClass.dicBlend["GIS"].Clear();
                    CommonClass.dicBlend["GIS"] = lst.Distinct().ToDictionary(p => p.Key, p => p.Value);

                    isPolygon = IsPolygon(legendText);//判断是不是polygon
                    _columnName = (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbology.LegendText;
                    //_columnName = mainMap.Layers[_currentLayerIndex].LegendItems.ToArray().First().LegendText;
                    //if (isPolygon)
                    //{
                    //    MapPolygonLayer mLayer = default(MapPolygonLayer);
                    //    mLayer = (MapPolygonLayer)mainMap.Layers[_currentLayerIndex];
                    //    _dMinValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), ""));
                    //    _dMaxValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), ""));
                    //}
                    //else
                    {
                        //get min&max from dic.
                        if (CommonClass.dicBlend["GIS"].ContainsKey(mainMap.Layers[_currentLayerIndex].LegendText))
                        {
                            SetValueRange frm = new SetValueRange();
                            frm.MinValue = CommonClass.dicBlend["GIS"][legendText].min;
                            frm.MaxValue = CommonClass.dicBlend["GIS"][legendText].max;
                            frm.ColorArray = CommonClass.dicBlend["GIS"][legendText].colorarray;
                            frm.ValueArray = CommonClass.dicBlend["GIS"][legendText].value;
                            _dMinValue = frm.MinValue;
                            _dMaxValue = frm.MaxValue;
                            colorBlend.SetValueRangeAndBundaryColor(frm, false);
                        }
                        else if (CommonClass.dicBlend["GIS"].ContainsKey(mainMap.Layers[_currentLayerIndex].LegendText + cboSpeciesTypeGIS.Text))
                        {
                            SetValueRange frm = new SetValueRange();
                            frm.MinValue = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS.Text].min;
                            frm.MaxValue = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS.Text].max;
                            frm.ColorArray = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS.Text].colorarray;
                            frm.ValueArray = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS.Text].value;
                            _dMinValue = frm.MinValue;
                            _dMaxValue = frm.MaxValue;
                            colorBlend.SetValueRangeAndBundaryColor(frm, false);
                        }
                        else
                        {
                            MapPointLayer mLayer = default(MapPointLayer);
                            mLayer = (MapPointLayer)mainMap.Layers[_currentLayerIndex];
                            _dMinValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), ""));
                            _dMaxValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), ""));
                            colorBlend.SetValueRange(_dMinValue, _dMaxValue, true);
                        }
                    }
                    colorBlend._maxPlotValue = _dMaxValue;
                    colorBlend._minPlotValue = _dMinValue;
                    if (cboSpeciesTypeGIS.Enabled && cboSpeciesTypeGIS.Text != _columnName)//加了两个point 第一个显示base, 第二个显示future，删掉第二个 cboSpeciesTypeGIS应该显示base
                    {
                        cboSpeciesTypeGIS.Text = _columnName;
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                //Application.DoEvents();
                //if (proBarRunning.Value == 100)
                //{
                //    proBarRunning.Value = 0;
                //}
                //else
                //    proBarRunning.Value += proBarRunning.Step;//让进度条增加一次
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void cboZoomTo_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (cboZoomTo.Text == "Data Domain")
                {
                    mainMap.ViewExtents = new Extent
                    {
                        MinX = dataDomainGIS[0],
                        MinY = dataDomainGIS[1],
                        MaxX = dataDomainGIS[2],
                        MaxY = dataDomainGIS[3]
                    };
                    return;
                }

                if (!CommonClass.currentProjisLCC())//utm
                {
                    switch (cboZoomTo.SelectedItem.ToString())
                    {
                        case "Continental US":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2084597.7,
                                MaxY = 6873065.9,
                                MinX = -2728406.7,
                                MinY = 1935195.9
                            };
                            break;
                        case "Maryland":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 1602159.6,
                                MaxY = 4539772.7,
                                MinX = 1122481.0,
                                MinY = 4047649.6
                            };
                            break;
                        case "New England":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2135576.5,
                                MaxY = 5480951.9,
                                MinX = 1249393.2,
                                MinY = 4571778.0
                            };
                            break;
                        case "Southern California":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = -1872220.1,
                                MaxY = 4722846.5,
                                MinX = -2744327.0,
                                MinY = 3828114.2
                            };
                            break;
                        case "Texas":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 17356.9,
                                MaxY = 4296601.0,
                                MinX = -1478155.4,
                                MinY = 2762290.1
                            };
                            break;
                        case "Washington DC":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 1378816.2,
                                MaxY = 4366071.1,
                                MinX = 1352391.1,
                                MinY = 4338960.5
                            };
                            break;
                    }
                }
                else
                {
                    switch (cboZoomTo.SelectedItem.ToString())
                    {
                        case "Continental US":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2325850.8,
                                MaxY = 1275319.5,
                                MinX = -2274714.4,
                                MinY = -1604646.2
                            };
                            break;
                        case "Maryland":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 1899617.2,
                                MaxY = 264631.1,
                                MinX = 1463805.0,
                                MinY = -182487.6
                            };
                            break;
                        case "New England":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2457662.9,
                                MaxY = 1218889.5,
                                MinX = 1530830.6,
                                MinY = 268012.0
                            };
                            break;
                        case "Southern California":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = -1506672.6,
                                MaxY = 9251.0,
                                MinX = -2231023.7,
                                MinY = -733892.2
                            };
                            break;
                        case "Texas":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 442023.0,
                                MaxY = -270952.7,
                                MinX = -972119.2,
                                MinY = -1721782.6
                            };
                            break;
                        case "Washington DC":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 1717635.8,
                                MaxY = 78567.2,
                                MinX = 1691918.0,
                                MinY = 52182.2
                            };
                            break;
                        case "China":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 2114399,
                                MaxY = 2906359,
                                MinX = -3397624,
                                MinY = -2567910
                            };
                            break;
                        case "YRD":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 1296541.7,
                                MaxY = 167147.3,
                                MinX = 480211.2,
                                MinY = -670361.6
                            };
                            break;
                        case "PRD":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 515471.7,
                                MaxY = -1012336.1,
                                MinX = 187920.4,
                                MinY = -1348385.3
                            };
                            break;
                        case "JJJ":
                            mainMap.ViewExtents = new Extent()
                            {
                                MaxX = 924299.2,
                                MaxY = 985611.5,
                                MinX = 178642.7,
                                MinY = 220610.2
                            };
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// 关闭configuration的标签页,同时清空listview中的items
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClose_Click(object sender, EventArgs e)
        {
            try
            {
                this.tbcFunction.TabPages.Remove(tbpConfigurationBatch);
                listViewCFG.Items.Clear();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        /// <summary>
        /// 将编辑后的configuration导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExportCFG_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog saveFile = new SaveFileDialog();
                saveFile.Title = Language.Localization.GetValue("Extracting...");
                saveFile.FileName = Path.GetFileNameWithoutExtension(CommonClass.FileName);
                saveFile.InitialDirectory = CommonClass.ResultFilePath + @"\Result\CFG";
                saveFile.Filter = Language.Localization.GetValue("CFG files(*.cfg)|*.cfg");
                saveFile.RestoreDirectory = true;
                if (saveFile.ShowDialog() == DialogResult.Cancel)
                    return;
                FileStream fs = new FileStream(saveFile.FileName, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
                for (int i = 0; i < listViewCFG.Items.Count; i++)
                {
                    sw.WriteLine(listViewCFG.Items[i].Text.ToString());
                }
                sw.Flush();
                sw.Close();
                fs.Close();
                MessageBox.Show(Language.Localization.GetValue("Save CFG successfully!"));
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                this.listViewCFG.LabelEdit = true;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void picCloseCFG_Click(object sender, EventArgs e)
        {
            try
            {
                this.tbcFunction.TabPages.Remove(tbpConfigurationBatch);
                listViewCFG.Items.Clear();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnApplyData_Click(object sender, EventArgs e)
        {
            try
            {
                //string filter = getQuantifiers();
                //DataRow[] drArray = _dtChangeDigit.Select(filter);
                DataTable dtNew = getQuantifiers(_dtChangeDigit);//_dtChangeDigit.Clone();
                //for (int i = 0; i < drArray.Length; i++)
                //{
                //    dtNew.ImportRow(drArray[i]);
                //}
                dgvDataView.DataSource = dtNew;
                _dtSelectOutput = dtNew;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void numericUpDownResult_ValueChanged(object sender, EventArgs e)
        {
            try
            {
                if (_dtChangeDigit == null) return;
                int iColumn = this.dgvDataView.FirstDisplayedScrollingColumnIndex;
                int iRow = this.dgvDataView.FirstDisplayedScrollingRowIndex;
                UpdateTableValue(_dtOutput);
                this.dgvDataView.FirstDisplayedScrollingColumnIndex = iColumn;
                if (iRow == -1) iRow = 0;
                this.dgvDataView.FirstDisplayedScrollingRowIndex = iRow;
                this.dgvDataView.Rows[0].Selected = false;
                //this. dgvDataView.DisplayRectangle = rt;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void UpdateTableValue(DataTable dt)
        {
            try
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    List<int> lstValue = new List<int>();
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        if (!dt.Columns[i].ColumnName.Trim().ToLower().Contains("id") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("type") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("lat")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("long") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("quarter") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("date")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("county") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("state") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("neighbor")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("pollutant") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("day") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("year")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("98th_percent_rank") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("name") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("_visibility_rank")
                            && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("ppb") && !dt.Columns[i].ColumnName.Trim().ToLower().Contains("cell") && !dt.Columns[i].ColumnName.ToLower().Contains("col") && !dt.Columns[i].ColumnName.ToLower().Contains("row") && !dt.Columns[i].ColumnName.ToLower().Contains("metric") && !dt.Columns[i].ColumnName.ToLower().Contains("statistic"))
                        {
                            if (!lstValue.Contains(i)) lstValue.Add(i);
                        }
                    }
                    if (lstValue.Count == 0)
                    {
                        dgvDataView.DataSource = dt;
                        return;
                    }
                    //string filter = getQuantifiers();
                    //DataRow[] drArray = dt.Select(filter);
                    DataTable dtNew = getQuantifiers(dt);//dt.Clone();
                    //for (int i = 0; i < drArray.Length; i++)
                    //{
                    //    dtNew.ImportRow(drArray[i]);
                    //}
                    foreach (DataRow dr in dtNew.Rows)
                    {
                        foreach (int index in lstValue)
                        {
                            //dr[index] = CommonClass.ToFixed(Convert.ToDouble(dr[index]), Convert.ToInt32(numericUpDownResult.Value));
                            dr[index] = CommonClass.ToFixed(Convert.ToDouble(dr[index]), Convert.ToInt32(numericUpDownResult.Value));
                            //dr[index] = CommonClass.ToFixedString(Convert.ToDouble(dr[index]), Convert.ToInt32(numericUpDownResult.Value));
                        }
                    }
                    //_dtOutput = dtNew;
                    _dtChangeDigit = dtNew;
                    _dtSelectOutput = dtNew;
                    dgvDataView.DataSource = dtNew;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }


        private void InitTatbleValue()
        {
            try
            {

            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        //Dictionary<string, double[]> dicMaxMinPoint = new Dictionary<string, double[]>();
        private void cboSpeciesTypeGIS_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (cboSpeciesTypeGIS == null || CommonClass.CurrentBaseScenario == null) return;
                string legendText = cboSpeciesTypeGIS.Text;
                MapPointLayer mLayer = default(MapPointLayer);
                mLayer = (MapPointLayer)mainMap.Layers[_currentLayerIndex];
                isPolygon = IsPolygon((mainMap.Layers[_currentLayerIndex] as IFeatureLayer).LegendText);//if draw a point file-> then draw model data-> isPolygon=true ->will not SetOutline in setMapPoint               
                _columnName = !(mLayer as IFeatureLayer).DataSet.DataTable.Columns.Contains(legendText) ? legendText.Replace("dv", "base").Replace("t_b", "t").Replace("_f", "") : legendText;//针对新格式的Visibility；modified by sclong

                //if (dicMaxMinPoint.ContainsKey(strKey))//added by Yangwenwei
                //{
                //    _dMaxValue = dicMaxMinPoint[strKey][1];
                //    _dMinValue = dicMaxMinPoint[strKey][0];
                //}
                //else
                //{
                //    _dMinValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), ""));
                //    _dMaxValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), ""));
                //    if (cboSpeciesTypeGIS.Enabled)
                //    {
                //        dicMaxMinPoint.Add(strKey, new double[2] { _dMinValue, _dMaxValue });
                //    }

                //}
                string strKey = (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).LegendText + _columnName;// "layerName+SpeciesName" 
                double min = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), string.Format("[{0}]<>-9 and [{0}]<>-7", _columnName)));//数值最小值
                double max = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), string.Format("[{0}]<>-9 and [{0}]<>-7", _columnName)));//数值最大值
                if (!CommonClass.dicLayerValueRange.ContainsKey(strKey))
                {
                    //min = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), string.Format("[{0}]<>-9 and [{0}]<>-7", _columnName)));
                    //max = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), string.Format("[{0}]<>-9 and [{0}]<>-7", _columnName)));
                    double minLegend = min;//图例最小值
                    double maxLenged = max;//图例最大值                 
                    if (!_columnName.Contains("Δ") && !_columnName.Contains("rrf"))//非差值和rrf，Set default legends for the Data viewer GIS view to put the scale to show US EPA NAAQS exceedances ，by sclong, 2017-03-05
                    {
                        string iniPath = Application.StartupPath + @"\SMAT.ini";
                        if (CommonClass.CurrentAnalysis == enumAnalysis.Ozone)
                        {
                            minLegend = 0;
                            maxLenged = Convert.ToDouble(CommonClass.IniReadValue("ozone calculation option", "NAAQS_value", iniPath));
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.DailyPM)
                        {
                            minLegend = 0;
                            maxLenged = Convert.ToDouble(CommonClass.IniReadValue("daily pm calculation option", "NAAQS_value", iniPath));
                        }
                        else if (CommonClass.CurrentAnalysis == enumAnalysis.AnnualPM)
                        {
                            minLegend = 0;
                            maxLenged = Convert.ToDouble(CommonClass.IniReadValue("annual pm calculation option", "NAAQS_value", iniPath));
                        }
                    }
                    CommonClass.dicLayerValueRange.Add(strKey, new Tuple<double, double>(minLegend, maxLenged));
                    //CommonClass.dicLayerValueRange.Add(strKey, new Tuple<double, double>(min, max));
                }


                #region Set up the color range and value range
                //added by Yangwenwei 2014.3.24
                if (!CommonClass.dicBlend.ContainsKey("GIS") && cboSpeciesTypeGIS.Enabled) //no color range record in dicBlend
                {
                    _dMinValue = CommonClass.dicLayerValueRange[strKey].Item1;
                    _dMaxValue = CommonClass.dicLayerValueRange[strKey].Item2;
                    colorBlend.SetValueRange(_dMinValue, _dMaxValue, true);

                    #region Save the color range in dicBlend
                    Dictionary<string, CommonClass.SaveBlend> dic = new Dictionary<string, CommonClass.SaveBlend>();
                    CommonClass.SaveBlend saveblend = new CommonClass.SaveBlend(colorBlend.ColorArray, colorBlend.ValueArray);
                    saveblend.min = _dMinValue;
                    saveblend.max = _dMaxValue;
                    dic.Add(strKey, saveblend);
                    CommonClass.dicBlend.Add("GIS", dic);
                    #endregion
                }
                else if (CommonClass.dicBlend["GIS"].ContainsKey(strKey))
                {
                    _dMaxValue = CommonClass.dicBlend["GIS"][strKey].max;
                    _dMinValue = CommonClass.dicBlend["GIS"][strKey].min;

                    SetValueRange frm = new SetValueRange();
                    frm.MinValue = CommonClass.dicBlend["GIS"][strKey].min;
                    frm.MaxValue = CommonClass.dicBlend["GIS"][strKey].max;
                    frm.ColorArray = CommonClass.dicBlend["GIS"][strKey].colorarray;
                    frm.ValueArray = CommonClass.dicBlend["GIS"][strKey].value;
                    _dMinValue = frm.MinValue;
                    _dMaxValue = frm.MaxValue;
                    colorBlend.SetValueRangeAndBundaryColor(frm, false);
                }
                else //no color range record in dicBlend
                {
                    _dMinValue = CommonClass.dicLayerValueRange[strKey].Item1;
                    _dMaxValue = CommonClass.dicLayerValueRange[strKey].Item2;
                    if (cboSpeciesTypeGIS.Enabled)
                    {
                        CommonClass.SaveBlend saveblend = new CommonClass.SaveBlend(colorBlend.ColorArray, colorBlend.ValueArray);
                        saveblend.min = _dMinValue;
                        saveblend.max = _dMaxValue;
                        CommonClass.dicBlend["GIS"].Add(strKey, saveblend);
                    }
                    colorBlend.SetValueRange(_dMinValue, _dMaxValue, true);
                }
                #endregion

                colorBlend._minPlotValue = _dMinValue;
                colorBlend._maxPlotValue = _dMaxValue;
                colorBlend.strKey = strKey;

                ResetMapColor(null, null);

                #region set up the color blend unit
                if (legendText.Contains("%"))
                    colorBlend.ValueUnit = "%";
                else if (CommonClass.CurrentAnalysis == enumAnalysis.Ozone || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone)
                    colorBlend.ValueUnit = "ppb";
                else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                    colorBlend.ValueUnit = "";
                else if (CommonClass.CurrentAnalysis == enumAnalysis.Visibility)
                    colorBlend.ValueUnit = "deciveiw";
                else if (legendText.ToLower().Contains("cell center distance"))
                    colorBlend.ValueUnit = "km";
                else
                    colorBlend.ValueUnit = "μg/m3";
                #endregion


                //lblMinMaxGIS.Text = "Min = " + CommonClass.dicLayerValueRange[strKey].Item1.ToString("F3") + "   Max = " + CommonClass.dicLayerValueRange[strKey].Item2.ToString("F3");             
                lblMinMaxGIS.Text = "Min = " + min.ToString("F3") + "   Max = " + max.ToString("F3");
                lblMinMaxGIS.Visible = true;

            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        
        FrmSelectMonitor frmSelectedMonitor;
        frmSelectMonitors frmMonitorCSV;

        private void plotControl1_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                string cell = plotControl1.TransformToGridCell(e.Location);
                if (cell != "")
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("Field", typeof(string));
                    dt.Columns.Add("Value", typeof(string));
                    string idlatlong = CommonClass.CurrentBaseScenario.dicLambertLatLong[cell];
                    string[] vars = idlatlong.Split(',');
                    string _lat = vars[1];
                    string _long = vars[2];

                    DataRow _dr = dt.NewRow();
                    _dr[0] = "id";
                    _dr[1] = vars[0];
                    dt.Rows.Add(_dr);
                    _dr = dt.NewRow();
                    _dr[0] = "lat";
                    _dr[1] = _lat;
                    dt.Rows.Add(_dr);
                    _dr = dt.NewRow();
                    _dr[0] = "long";
                    _dr[1] = _long;
                    dt.Rows.Add(_dr);

                    string key = _lat + "," + _long;
                    if (!dicValueMAP.ContainsKey(key))
                        key = "utm," + key;
                    foreach (KeyValuePair<string, double> keyvalue in dicValueMAP[key])
                    {
                        _dr = dt.NewRow();
                        _dr[0] = keyvalue.Key;
                        _dr[1] = keyvalue.Value;
                        dt.Rows.Add(_dr);
                    }
                    dgvGridInfo.DataSource = dt;
                }
                else
                    dgvGridInfo.DataSource = null;

                if (plotControl1.isMarkSelectedPoint)
                {
                    if (frmSelectedMonitor == null||frmSelectedMonitor.IsDisposed)
                    { frmSelectedMonitor = new FrmSelectMonitor(); }

                    if (plotControl1.SelectedPoint != null)
                    {
                        string selectMonitor = plotControl1.strSelectedPointLatLon;
                        var lstMonitors = frmMonitorCSV.dicMonitors.Keys.ToList();
                        if(lstMonitors.Contains(selectMonitor))
                        {
                            int i = lstMonitors.IndexOf(selectMonitor);
                            string latlong = frmMonitorCSV.lstLatLong[i];

                            frmSelectedMonitor.setData(latlong.Split(',')[0], latlong.Split(',')[1], frmMonitorCSV.currentColomn, frmMonitorCSV.dicMonitors[selectMonitor]);
                            frmSelectedMonitor.TopLevel = true;
                            frmSelectedMonitor.TopMost = true;
                            frmSelectedMonitor.Show();
                            frmSelectedMonitor.Location = plotControl1.PointToScreen(e.Location);
                        }

                    }
                }
                else
                {
                    if (frmSelectedMonitor != null && frmSelectedMonitor.Visible)
                    {
                        frmSelectedMonitor.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }

        }

        void SSIA_useMonitorChange(bool useMonitor)
        {
            try
            {
                if (trvAnalysis.Nodes.Count <= 0) { return; }
                if (useMonitor)
                {
                    trvAnalysis.Nodes[2].ImageKey = _unreadyImageKey;
                    trvAnalysis.Nodes[2].SelectedImageKey = _unreadyImageKey;
                }
                else
                {
                    switch (CommonClass.CurrentAnalysis)
                    {
                        case enumAnalysis.SSIAAnnualPM:
                            (CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA = null;
                            break;
                        case enumAnalysis.SSIADailyPM:
                            (CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).monitorInputD = null;
                            break;
                        case enumAnalysis.SSIAOzone:
                            //(CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).monitorInputA = null;
                            break;
                            //case enumAnalysis.SSIADeposition:
                            //    (CommonClass.CurrentBaseScenario.configuration as SSIADepositionConfiguration).monitorInputDep = null;
                            //    break;
                    }
                    trvAnalysis.Nodes[2].ImageKey = "skip";
                    trvAnalysis.Nodes[2].SelectedImageKey = "skip";
                }
            }
            catch
            { }
        }

        private void colorBlendMap_CustomizeValueRange(object sender, EventArgs e)
        {
            plotControl1.ResetNewAllGridsColor();
        }

        private void lstSpeciesTypeMap_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string name = lstSpeciesTypeMap.SelectedItem.ToString();
                //added by Yangwenwei 20131218
                plotControl1.Mapname = name;

                strMapNameColRow[1] = name;

                //change unit
                if (CommonClass.CurrentAnalysis == enumAnalysis.Ozone || CommonClass.CurrentAnalysis == enumAnalysis.SSIAOzone || CommonClass.CurrentAnalysis == enumAnalysis.BenMAPSeasonalOzone)
                    colorBlendMap.ValueUnit = "ppb";
                else if (CommonClass.CurrentAnalysis == enumAnalysis.Visibility)
                    colorBlendMap.ValueUnit = "deciveiw";
                else if (CommonClass.CurrentAnalysis == enumAnalysis.SSIADeposition)
                    colorBlendMap.ValueUnit = "";
                else
                    colorBlendMap.ValueUnit = "μg/m3";

                if (name.ToLower().Contains("rrf") || name.ToLower().Contains("cell") || name.ToLower().Contains("days"))
                {
                    colorBlendMap.ValueUnit = "";
                    //plotControl1.ColorBlendControl.ValueUnit = "";
                }
                //CommonClass.modelDefinition = new ModelDefinition();
                //CommonClass.modelDefinition.ActiveGridType = "12km";
                //bool ok = CommonClass.modelDefinition.ParseModelDef("");
                //if (!ok)
                //{
                //    return;
                //}
                //CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state.csv");
                CommonClass.modelDefinition.ParseGridValues(CommonClass.CurrentBaseScenario.dicLatLongLambert, dicValueMAP, name, ssiaDataOption);
                //CommonClass.modelDefinition.ShapeLCCFiles = new Dictionary<string, double[,]>();
                //CommonClass.modelDefinition.ShapeLCCFiles.Add(CommonClass.modelDefinition.ActiveGridType, CommonClass.ShapeLCC);

                //plotControl1.modelDef = CommonClass.modelDefinition.modelDef;
                //plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments();
                //plotControl1.ColorBlendControl = colorBlendMap;
                //colorBlendMap.ValueUnit = CommonClass.modelDefinition.modelDef.ValueUnit;
                plotControl1.NewGridValues = CommonClass.modelDefinition.GridValues;

                //write min max value and grid information
                //string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                //lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[1]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[0]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[0]) % 1000 + ")   Max = " + Convert.ToDouble(minmaxGridValue[3]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[2]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[2]) % 1000 + ")";
                //lblMinMax.Show();

                if (ssiaDataOption == 0)
                {
                    string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                    lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[1]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[0]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[0]) % 1000 + ")   Max = " + Convert.ToDouble(minmaxGridValue[3]).ToString("F3") + " at (" + Convert.ToInt32(minmaxGridValue[2]) / 1000 + "," + Convert.ToInt32(minmaxGridValue[2]) % 1000 + ")";
                    lblMinMax.Visible = true;
                }
                else
                {
                    string[] minmaxGridValue = CommonClass.modelDefinition.MinmaxValueGrid.Split(',');
                    lblMinMax.Text = "Min = " + Convert.ToDouble(minmaxGridValue[2]).ToString("F3") + " at (" + Math.Round(Convert.ToDouble(minmaxGridValue[0]), 2) + "," + Math.Round(Convert.ToDouble(minmaxGridValue[1]), 2) + ")   Max = " + Convert.ToDouble(minmaxGridValue[5]).ToString("F3") + " at (" + Math.Round(Convert.ToDouble(minmaxGridValue[3]), 2) + "," + Math.Round(Convert.ToDouble(minmaxGridValue[4]), 2) + ")";
                    lblMinMax.Visible = true;
                }

                #region Monitor Overlay function
                if (plotControl1.IsDrawMonitors)
                {
                    plotControl1.isMarkSelectedPoint = false;
                    frmMonitorCSV = new frmSelectMonitors();
                    frmMonitorCSV.UseDefaultFileAndColumn(lblMAPname.Text, lstSpeciesTypeMap.SelectedItem.ToString());

                    if (frmMonitorCSV.dicMonitors != null)
                    {
                        plotControl1.dicMonitors.Clear();
                        plotControl1.dicMonitors = frmMonitorCSV.dicMonitors;
                        plotControl1.IsDrawMonitors = true;
                        plotControl1.ResetNewAllGridsColor();
                    }
                }
                #endregion
            }
            catch
            { }
        }

        private void btnZoomIn_Click(object sender, EventArgs e)
        {
            try
            {
                bool ok = CommonClass.modelDefinition.ParseModelDef(smallDomianMAP, ssiaDataOption == 2);
                if (!ok)
                {
                    return;
                }
                plotControl1.modelDef = CommonClass.modelDefinition.modelDef;
                plotControl1.NewGridValues = CommonClass.modelDefinition.GridValues;
                btnZoomOut.Enabled = true;
                btnZoomIn.Enabled = false;
            }
            catch
            { }
        }

        private void btnZoomOut_Click(object sender, EventArgs e)
        {
            try
            {
                bool ok = CommonClass.modelDefinition.ParseModelDef("", ssiaDataOption == 2);
                if (!ok)
                {
                    return;
                }
                plotControl1.modelDef = CommonClass.modelDefinition.modelDef;
                plotControl1.NewGridValues = CommonClass.modelDefinition.GridValues;
                btnZoomOut.Enabled = false;
                btnZoomIn.Enabled = true;
            }
            catch
            { }
        }

        //added by Yangwenwei   Used for Language Change 20131113
        private void SMAT_CE_TextChanged(object sender, EventArgs e)
        {
            lblAnalysis.Text = Language.Localization.GetValue(lblAnalysis.Text);
            columnHeaderName.Text = Language.Localization.GetValue(columnHeaderName.Text);
            columnHeaderMessages.Text = Language.Localization.GetValue(columnHeaderMessages.Text);
            FileName.Text = Language.Localization.GetValue(FileName.Text);
            FileSize.Text = Language.Localization.GetValue(FileSize.Text);
            FileType.Text = Language.Localization.GetValue(FileType.Text);
            columnHeader1.Text = Language.Localization.GetValue(columnHeader1.Text);
            columnHeader2.Text = Language.Localization.GetValue(columnHeader2.Text);
            tips.SetToolTip(pboHelp, Language.Localization.GetValue(_stips));
            tips.SetToolTip(pboCreateCFG, Language.Localization.GetValue("Create a new project"));
            tips.SetToolTip(pboOpenCFG, Language.Localization.GetValue("Open an existing project"));
            tips.SetToolTip(btnUserGuide, Language.Localization.GetValue("Users' Guide"));
            tips.SetToolTip(btnAbout, Language.Localization.GetValue("About"));

            #region Change trvAnalysis
            string path = "";
            switch (CommonClass.CurrentAnalysis)
            {
                case enumAnalysis.AnnualPM:
                    path = Application.StartupPath + @"\Configs\Annual PM Analysis.xml";
                    break;
                case enumAnalysis.DailyPM:
                    path = Application.StartupPath + @"\Configs\Daily PM Analysis.xml";
                    break;
                case enumAnalysis.Ozone:
                    path = Application.StartupPath + @"\Configs\Ozone Analysis.xml";
                    break;
                case enumAnalysis.Visibility:
                    path = Application.StartupPath + @"\Configs\Visibility Analysis.xml";
                    break;
                case enumAnalysis.SSIAAnnualPM:
                    path = Application.StartupPath + @"\Configs\SSIA PM Analysis.xml";
                    break;
                case enumAnalysis.SSIADailyPM:
                    path = Application.StartupPath + @"\Configs\SSIA PM Analysis.xml";
                    break;
                case enumAnalysis.SSIAOzone:
                    path = Application.StartupPath + @"\Configs\SSIA Ozone Analysis.xml";
                    break;
                case enumAnalysis.SSIADeposition:
                    path = Application.StartupPath + @"\Configs\SSIA Deposition Analysis.xml";
                    break;
                default:
                    break;
            }
            if (path != "")
            {
                trvAnalysis.Nodes.Clear();

                loadTreeNodes(trvAnalysis.Nodes, path);
                // -------------initialize picture of all tree nodes------------
                foreach (TreeNode tr in trvAnalysis.Nodes)
                {
                    InitNodeImage(tr);
                    //ChangeNodeImage(tr);
                }
            }
            #endregion
        }

        private void btnBar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dtchartTemp == null) return;
                if (ichartType != 0)
                {
                    ChangecboType(0);
                    cboType.SelectedIndex = 0;
                }
                int count = 5;
                if (dgvDataList.Rows.Count < 5) count = dgvDataList.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                    checkCell.Value = true;
                }
                if (dgvDataList.Rows.Count > 5)
                {
                    for (int i = 5; i < dgvDataList.Rows.Count; i++)
                    {
                        DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                        checkCell.Value = false;
                    }
                }

                if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                {
                    if (cboType.Text == "Base_PM25" || cboType.Text == "Alt_PM25")
                    {
                        createZedGraphTwoBars(zgcChart, "Base_PM25", 1);
                    }
                    else
                    {
                        createGraph(zgcChart, cboType.Text);
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                {
                    if (cboType.Text == "Base_PM25" || cboType.Text == "Alt_PM25")
                    {
                        createZedGraphTwoBars(zgcChart, "Base_PM25", 1);
                    }
                    else
                    {
                        createGraph(zgcChart, cboType.Text);
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                {
                    if (cboType.Text == "Base_O3" || cboType.Text == "Alt_O3")
                    {
                        createZedGraphTwoBars(zgcChart, "Base_O3", 1);
                    }
                    else
                    {
                        createGraph(zgcChart, cboType.Text);
                    }
                }
                //tclFiltering.Enabled = true;
                ichartType = 0;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnDistribution_Click(object sender, EventArgs e)
        {
            try
            {
                if (dtchartTemp == null) return;
                if (ichartType == 0)
                {
                    ChangecboType(1);
                    cboType.SelectedIndex = 0;
                }
                int count = dgvDataList.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                    checkCell.Value = true;
                }
                string unit = "(μg/m3)";
                if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                    unit = "(ppb)";
                if (cboType.Text.Contains("Δ"))
                    unit = "Predicted Change " + unit;
                else
                    unit = "Concentration " + unit;
                DataTable dt = dtchartTemp.DefaultView.ToTable(false, "_id", cboType.Text);
                createDistribution(zgcChart, dt, unit);
                zgcChart.Refresh();
                //if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                //{
                //    DataTable dt = dtchartTemp.DefaultView.ToTable(false, "_id", cboType.Text);// "ΔPM25 (Alt-Base)");
                //    createDistribution(zgcChart, dt, "Predicted Change (μg/m3)");
                //}
                //else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                //{
                //    DataTable dt = dtchartTemp.DefaultView.ToTable(false, "_id", cboType.Text);//"ΔO3 (Alt-Base)");
                //    createDistribution(zgcChart, dt, "Predicted Change (ppb)");
                //}
                //else if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration)
                //{
                //    DataTable dt = dtchartTemp.DefaultView.ToTable(false, "_id", "b_pm25_ann_DV", "f_pm25_ann_DV");
                //    createDistribution(zgcChart, dt, "Annual");
                //}
                //tclFiltering.Enabled = false;
                cboFilter.Text = "";
                cboFilter.Enabled = false;
                ichartType = 1;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void createDistribution(ZedGraphControl zdControl, DataTable dt, string unit)
        {
            try
            {
                //----------画图------------
                zdControl.GraphPane = new GraphPane(new Rectangle(0, 0, zdControl.Width, zdControl.Height), "", "", "");
                GraphPane myPane = this.zgcChart.GraphPane;
                List<string> lstPane = new List<string>();
                myPane.CurveList.Clear();
                //----清空图中添加的文本----------
                myPane.GraphObjList.Clear();
                myPane.Title.Text = "Source 1";

                myPane.XAxis.Title.Text = "Cell";
                //if (unit == "SSIAAnnual")
                myPane.YAxis.Title.Text = unit;
                //else if (unit == "SSIADaily")
                //    myPane.YAxis.Title.Text = "Predicted Change (μg/m3)";
                //else if (unit == "SSIAOzone")
                //    myPane.YAxis.Title.Text = "Predicted Change (ppb)";
                myPane.XAxis.Scale.TextLabels = null;
                myPane.YAxis.Scale.TextLabels = null;

                //int count = dt.Rows.Count;
                double threshold = 0;
                double NAAQS = 0;
                if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                {
                    threshold = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold);
                    NAAQS = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS);
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                {
                    threshold = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold);
                    NAAQS = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS);
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                {
                    threshold = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold);
                    NAAQS = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS);
                }
                if (changeColor)
                {
                    PointPairList pointPairList = new PointPairList();
                    PointPairList pointPairList2 = new PointPairList();
                    Color c = Color.Black;
                    double d = 0;
                    if (cboType.Text.Contains("Δ"))
                    {
                        c = Color.Red;
                        d = threshold * 0.01 * NAAQS;
                    }
                    else
                    {
                        c = Color.Blue;
                        d = NAAQS;
                    }
                    PointPairList pointY = new PointPairList();
                    int min = Convert.ToInt32(dt.Rows[0][0]);
                    int max = min;
                    DataRow[] drs = dt.Select("[" + dt.Columns[1].ColumnName + "]<" + d);
                    DataRow[] drs2 = dt.Select("[" + dt.Columns[1].ColumnName + "]>=" + d);
                    foreach (DataRow dr in drs)
                    {
                        pointPairList.Add(new PointPair(Convert.ToInt32(dr[0]), Convert.ToDouble(dr[1])));
                        min = Math.Min(Convert.ToInt32(dr[0]), min);
                        max = Math.Max(Convert.ToInt32(dr[0]), max);
                    }
                    foreach (DataRow dr in drs2)
                    {
                        pointPairList2.Add(new PointPair(Convert.ToInt32(dr[0]), Convert.ToDouble(dr[1])));
                        min = Math.Min(Convert.ToInt32(dr[0]), min);
                        max = Math.Max(Convert.ToInt32(dr[0]), max);
                    }
                    if (plotLine)
                    {
                        pointY.Add((new PointPair(min * 0.95, d)));//myPane.XAxis.Scale.Min, d)));
                        pointY.Add((new PointPair(max * 1.11, d)));//myPane.XAxis.Scale.Max, d)));
                        LineItem myCurveY = myPane.AddCurve("", pointY, Color.Red, ZedGraph.SymbolType.None);
                        myCurveY.Line.IsVisible = true;
                        //myCurveY.Line.Width = 2F;
                        myPane.XAxis.Scale.Min = min * 0.95;
                        myPane.XAxis.Scale.Max = max * 1.11;
                    }

                    LineItem myCurve = myPane.AddCurve("", pointPairList, Color.Black, ZedGraph.SymbolType.Circle);
                    myCurve.Line.IsVisible = false;
                    myCurve.Symbol.Fill = new Fill(Color.Black);
                    myCurve.Symbol.Size = 4;
                    LineItem myCurve2 = myPane.AddCurve("", pointPairList2, c, ZedGraph.SymbolType.Circle);
                    myCurve2.Line.IsVisible = false;
                    myCurve2.Symbol.Fill = new Fill(c);
                    myCurve2.Symbol.Size = 4;
                }
                else
                {
                    if (plotLine)
                    {
                        double d = 0;
                        if (cboType.Text.Contains("Δ"))
                            d = threshold * 0.01 * NAAQS;
                        else
                            d = NAAQS;
                        PointPairList pointY = new PointPairList();
                        int min = 0;
                        int max = 0;
                        foreach (DataRow dr in dt.Rows)
                        {
                            min = Math.Min(Convert.ToInt32(dr[0]), min);
                            max = Math.Max(Convert.ToInt32(dr[0]), max);
                        }
                        pointY.Add((new PointPair(min, d)));//myPane.XAxis.Scale.Min, d)));
                        pointY.Add((new PointPair(max * 1.11, d)));//myPane.XAxis.Scale.Max, d)));
                        LineItem myCurveY = myPane.AddCurve("", pointY, Color.Red, ZedGraph.SymbolType.None);
                        myCurveY.Line.IsVisible = true;
                        //myCurveY.Line.Width = 2F;

                        myPane.XAxis.Scale.Max = max * 1.11;
                    }

                    PointPairList pointPairList = new PointPairList();
                    //switch (analysis)
                    //{
                    //    case "SSIAAnnual":
                    foreach (DataRow dr in dt.Rows)
                    {
                        pointPairList.Add(new PointPair(Convert.ToInt32(dr[0]), Convert.ToDouble(dr[1])));
                    }
                    //break;
                    //case "Annual":
                    //    foreach (DataRow dr in dt.Rows)
                    //    {
                    //        pointPairList.Add(new PointPair(Convert.ToInt32(dr[0]), Convert.ToDouble(dr[1]) - Convert.ToDouble(dr[2])));
                    //    }
                    //    break;
                    //}
                    LineItem myCurve = myPane.AddCurve("", pointPairList, Color.Black, ZedGraph.SymbolType.Circle);
                    myCurve.Line.IsVisible = false;
                    myCurve.Symbol.Fill = new Fill(Color.Black);
                    myCurve.Symbol.Size = 4;
                }
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);
                myPane.XAxis.Scale.FontSpec.Size = 11;
                myPane.YAxis.Scale.FontSpec.Size = 11;
                myPane.IsFontsScaled = false;//不随着缩放而放大
                zgcChart.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
                SetTitleAndAxis(myPane, _configureSymbol, "Distribution");//设置图例,by sclong，20180419
                zgcChart.AxisChange();
                //zgcChart.Refresh();
                dt.Dispose();
                GC.Collect();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnFrequency_Click(object sender, EventArgs e)
        {
            try
            {
                if (dtchartTemp == null) return;
                if (ichartType == 0)
                {
                    ChangecboType(1);
                    cboType.SelectedIndex = 0;
                }
                int count = dgvDataList.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0];
                    checkCell.Value = true;
                }

                List<double> lstDelta = new List<double>();
                if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                {
                    foreach (DataRow dr in dtchartTemp.Rows)
                    {
                        lstDelta.Add(Convert.ToDouble(dr[cboType.Text]));
                    }
                    createFrequency(zgcChart, lstDelta, "μg/m3");
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                {
                    foreach (DataRow dr in dtchartTemp.Rows)
                    {
                        lstDelta.Add(Convert.ToDouble(dr[cboType.Text]));
                    }
                    createFrequency(zgcChart, lstDelta, "ppb");
                }
                zgcChart.Refresh();
                //else if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration)
                //{
                //    DataTable dt = dtchartTemp.DefaultView.ToTable(false, "b_pm25_ann_DV", "f_pm25_ann_DV");
                //    foreach (DataRow dr in dtchartTemp.Rows)
                //    {
                //        lstDelta.Add(Convert.ToDouble(dr["b_pm25_ann_DV"]) - Convert.ToDouble(dr["f_pm25_ann_DV"]));
                //    }
                //    createFrequency(zgcChart, lstDelta);
                //}
                //tclFiltering.Enabled = false;
                cboFilter.Text = "";
                cboFilter.Enabled = false;
                ichartType = 2;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }


        private void createFrequency(ZedGraphControl zdControl, List<double> lstDelta, string unit)
        {
            try
            {
                //----------画图------------
                zdControl.GraphPane = new GraphPane(new Rectangle(0, 0, zdControl.Width, zdControl.Height), "", "", "");
                GraphPane myPane = this.zgcChart.GraphPane;
                List<string> lstPane = new List<string>();
                myPane.CurveList.Clear();
                //----清空图中添加的文本----------
                myPane.GraphObjList.Clear();
                myPane.Title.Text = "ecdf(y)";
                myPane.XAxis.Title.Text = "Predicted Change (" + unit + ")";
                myPane.YAxis.Title.Text = "Fn(x)";
                myPane.XAxis.Scale.TextLabels = null;
                myPane.YAxis.Scale.TextLabels = null;

                int count = lstDelta.Count;
                lstDelta.Sort();
                PointPairList pointPairList = new PointPairList();
                for (int i = 0; i < count; i++)
                {
                    double k = 0;
                    k = Convert.ToDouble(i) / Convert.ToDouble(count);
                    pointPairList.Add(new PointPair(lstDelta[i], k));
                }
                LineItem myCurve = myPane.AddCurve("", pointPairList, Color.Black, ZedGraph.SymbolType.None);
                //myCurve.Line.IsSmooth = true;
                //myCurve.Line.SmoothTension = 0.5F;
                //myCurve.Line.IsVisible = false;
                myCurve.Line.Width = 2F;

                if (plotLine)
                {
                    double threshold = 0;
                    double NAAQS = 0;
                    if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                    {
                        threshold = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.threshold);
                        NAAQS = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAAnnualPMAnalysisConfiguration).calculationOption.NAAQS);
                    }
                    else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                    {
                        threshold = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.threshold);
                        NAAQS = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIADailyPMAnalysisConfiguration).calculationOption.NAAQS);
                    }
                    else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                    {
                        threshold = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.threshold);
                        NAAQS = Convert.ToDouble((CommonClass.CurrentBaseScenario.configuration as SSIAOzoneAnalysisConfiguration).calculationOption.NAAQS);
                    }
                    double d = 0;
                    if (cboType.Text.Contains("Δ"))
                    {
                        d = threshold * 0.01 * NAAQS;
                    }
                    else
                    {
                        d = NAAQS;
                    }
                    PointPairList pointY = new PointPairList();
                    pointY.Add((new PointPair(d, 0)));
                    pointY.Add((new PointPair(d, 1)));
                    LineItem myCurveY = myPane.AddCurve("", pointY, Color.Red, ZedGraph.SymbolType.None);
                    myCurveY.Line.IsVisible = true;
                    //myCurveY.Line.Width = 2F;
                }

                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);
                myPane.XAxis.Scale.FontSpec.Size = 11;
                myPane.YAxis.Scale.FontSpec.Size = 11;
                myPane.YAxis.Scale.Min = 0;
                myPane.YAxis.Scale.Max = 1;
                myPane.IsFontsScaled = false;//不随着缩放而放大
                zgcChart.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
                SetTitleAndAxis(myPane, _configureSymbol, "Frequency");
                zgcChart.AxisChange();
                //zgcChart.Refresh();
                lstDelta.Clear();
                GC.Collect();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnChangeBoundary_Click(object sender, EventArgs e)
        {
            try
            {
                if (btnChangeBoundary.Text == "County")
                {
                    if (ssiaDataOption == 2)
                    {
                        if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("county_utm"))
                        {
                            CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\county_utm.csv");
                            CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("county_utm", CommonClass.ShapeLCC);
                        }
                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("county_utm");
                    }
                    else
                    {
                        if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("county"))
                        {
                            CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\county.csv");
                            CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("county", CommonClass.ShapeLCC);
                        }
                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("county");
                    }
                    btnChangeBoundary.Text = "State";
                }
                else
                {
                    if (ssiaDataOption == 2)
                    {
                        if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("state_utm"))
                        {
                            CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state_utm.csv");
                            CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("state_utm", CommonClass.ShapeLCC);
                        }
                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state_utm");
                    }
                    else
                    {
                        if (!CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].ContainsKey("state"))
                        {
                            CommonClass.ShapeLCC = CommonClass.ParseShapeLcc(Application.StartupPath + @"\Data\ShapeFiles\state.csv");
                            CommonClass.modelDefinition.ShapeLCCFiles[CommonClass.modelDefinition.ActiveGridType].Add("state", CommonClass.ShapeLCC);
                        }
                        plotControl1.SegmentsList = CommonClass.modelDefinition.GetShapesSegments("state");
                    }
                    btnChangeBoundary.Text = "County";
                }
                plotControl1.modelDef = CommonClass.modelDefinition.modelDef;
                plotControl1.NewGridValues = CommonClass.modelDefinition.GridValues;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnSavePic_Click(object sender, EventArgs e)
        {
            try
            {
                plotControl1.SaveRsmAndBlend(false);  //added and modified by Yangwenwei 20131219

                //Image imageMap = new Bitmap(stcMap.Panel2.Width - 2, plotControl1.Height);
                //Graphics gMap = Graphics.FromImage(imageMap);
                //gMap.CopyFromScreen(this.PointToScreen(new System.Drawing.Point(stcMain.Width - stcMap.Panel2.Width - 3, stcMain.Height - plotControl1.Height - 10)), new System.Drawing.Point(0, 0), new Size(this.Width, this.Height));

                //SaveFileDialog savePicture = new SaveFileDialog();
                //savePicture.Filter = "GIF(*.gif)|*.gif|BMP(*.bmp)|*.bmp|JPG(*.jpg)|*.jpg|PNG(*.png)|*.png";
                //savePicture.InitialDirectory = Application.StartupPath + @"\Result\Picture";
                //savePicture.Title = Language.Translate("Save image to...");
                //if (savePicture.ShowDialog() == DialogResult.Cancel) return;
                //string fileName = savePicture.FileName;

                //imageMap.Save(fileName);
                //MessageBox.Show(Language.Translate("Save map image successfully!"));
                //gMap.Dispose();
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        bool IsPolygon(string legendText)
        {
            isPolygon = false;
            if (CommonClass.CurrentBaseScenario == null) return false;
            if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration)
            {
                if (legendText.Contains("Baseline") || legendText.Contains("Future") || legendText.Contains("Delta") || (legendText.Contains("Spatial Field") && !legendText.Contains("Neighbor File Spatial Field")))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is DailyPMAnalysisConfiguration)
            {
                if (legendText.Contains("Baseline") || legendText.Contains("Future") || legendText.Contains("Delta"))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisConfiguration)
            {
                if (legendText.Contains("Baseline") || legendText.Contains("Future") || legendText.Contains("Model Data") || legendText.Contains("Sptl. Fld.") || (legendText.Contains("Spatial Field") && !legendText.Contains("Neighbor File Spatial Field")))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
            {
                if (legendText.ToLower().Contains("ssia combined annual pm receptor") || legendText.ToLower().Contains("ssia dispersion annual pm receptor") || legendText.ToLower().Contains("ssia grid annual pm data") || legendText.ToLower().Contains("ssia grid quarterly pm data"))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
            {
                if (legendText.Contains("SSIA Grid Daily PM Data") || legendText.Contains("SSIA Dispersion Daily PM Receptor") || legendText.Contains("SSIA Combined Daily PM Receptor") || legendText.Contains("SSIA Grid Quarterly PM Data") || legendText.Contains("SSIA Dispersion Quarterly PM Receptor") || legendText.Contains("SSIA Combined Quarterly PM Receptor"))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
            {
                if (legendText.Contains("SSIA Ozone Data"))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)     //added by Lijiabin
            {
                if (legendText.Contains("SSIA Deposition Data"))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisChinaConfiguration)
            {
                if (legendText.Contains("Baseline") || legendText.Contains("Future") || legendText.Contains("Delta") || legendText.Contains("Spatial Field"))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisChinaConfiguration)
            {
                if (legendText.Contains("Base") || legendText.Contains("Future") || legendText.Contains("Spatial Field"))
                    isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is BenMAPAnnualPMAnalysisConfiguration)
            {
                isPolygon = true;
            }
            else if (CommonClass.CurrentBaseScenario.configuration is BenMAPOzoneAnalysisConfiguration)
            {
                isPolygon = true;
            }
            return isPolygon;
        }

        int SSIAmodeloption(string legend)
        {
            int type = 0;
            legend = legend.ToLower();
            if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
            {
                if (legend.Contains("combined annual pm receptor") || legend.Contains("combined daily pm receptor"))
                    type = 1;
                else if (legend.Contains("grid annual pm receptor") || legend.Contains("grid quarterly pm receptor") || legend.Contains("grid daily pm receptor"))
                    type = 0;
                else if (legend.Contains("dispersion annual pm receptor") || legend.Contains("dispersion daily pm receptor") || legend.Contains("dispersion quarterly pm receptor"))
                    type = 2;
            }
            return type;
        }

        private void dgvDataView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0) return;
                string id = this.dgvDataView.Rows[dgvDataView.CurrentRow.Index].Cells[0].Value.ToString();
                //DataRow[] drArray;
                DataRow[] drArray = _dtOutput.Select(string.Format("_id='{0}'", id));
                //if (_dtOutput.Select(string.Format("_id='{0}'", id)).Count() != 0)
                //    drArray = _dtOutput.Select(string.Format("_id={0}", id));
                //else
                //    drArray = _dtOutput.Select(string.Format("_id='{0}'", id));
                DataTable dtNew = _dtOutput.Clone();
                for (int i = 0; i < drArray.Length; i++)
                {
                    dtNew.ImportRow(drArray[i]);
                }
                dgvDataView.DataSource = dtNew;
                _dtSelectOutput = dtNew;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void Lengend_OrderChanged(object sender, EventArgs e)
        {
            try
            {
                if (mainMap.Layers.Count <= 0) return;
                int SelectedLayerindex = -1;

                for (int i = mainMap.Layers.Count - 1; i >= 0; i--)
                {
                    if (mainMap.Layers[i].LegendText == "State_epa2" || mainMap.Layers[i].LegendText == "Counties" || mainMap.Layers[i].LegendText == "States" || mainMap.Layers[i].LegendText == "class14_region" || mainMap.Layers[i].LegendText == "Nation" || mainMap.Layers[i].LegendText == "China_prov_WGS84_LCC" || mainMap.Layers[i].LegendText.Contains("npsClassI"))
                    {
                        SelectedLayerindex = i;
                        mainMap.Layers.RemoveAt(i);
                    }
                }
                //setStandardMap();

                //MapLayerCollection mapLayerCollection = mainMap.Layers as MapLayerCollection;
                //mapLayerCollection.LockDispose();
                //IMapLayer tempLayer = null;
                //for (int i = 0; i < mainMap.Layers.Count; i++)
                //{
                //    if (mainMap.Layers[i].LegendText == "State_epa2" || mainMap.Layers[i].LegendText == "Counties" || mainMap.Layers[i].LegendText == "States" || mainMap.Layers[i].LegendText == "class14_region" || mainMap.Layers[i].LegendText == "Nation")
                //    {
                //        SelectedLayerindex = i;
                //tempLayer = mainMap.Layers[i];
                //break;
                //    }
                //}
                if (SelectedLayerindex < 0) return;
                //for (int i = SelectedLayerindex; i < mapLayerCollection.Count-1; i++)
                //{
                //    mapLayerCollection[i] = mapLayerCollection[i + 1];
                //}
                //mapLayerCollection[mapLayerCollection.Count - 1] = tempLayer;
                //mapLayerCollection.UnlockDispose();
                //mainMap.Layers.RemoveAt(SelectedLayerindex);
                setStandardMap();
                //mainMap.Layers.Insert(0, tempLayer);
                //mainMap.Refresh();
                Lengend.RefreshNodes();
                Lengend.Refresh();

                for (int i = mainMap.Layers.Count - 1; i >= 0; i--)
                {
                    string lt = mainMap.Layers[i].LegendText;
                    if (lt != "States"
                        && lt != "Counties"
                        && lt != "class14_region"
                        && lt != "npsClassI"
                        && lt != "State_epa2"
                        && lt != "China_prov_WGS84_LCC"
                        && lt != "SSIA Source Location")
                    {
                        _currentLayerIndex = i;
                        break;
                    }
                    _currentLayerIndex = -1;
                }

                string legendText = mainMap.Layers[_currentLayerIndex].LegendText;
                ShowSpecies(legendText);
                isPolygon = IsPolygon(legendText);//判断是不是polygon
                _columnName = (mainMap.Layers[_currentLayerIndex] as IFeatureLayer).Symbology.LegendText;
                //_columnName = mainMap.Layers[_currentLayerIndex].LegendItems.ToArray().First().LegendText;
                //if (isPolygon)
                //{
                //    MapPolygonLayer mLayer = default(MapPolygonLayer);
                //    mLayer = (MapPolygonLayer)mainMap.Layers[_currentLayerIndex];
                //    _dMinValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), ""));
                //    _dMaxValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), ""));
                //}
                //else
                {
                    //get minmax from dic.
                    if (CommonClass.dicBlend["GIS"].Keys.Contains(legendText + cboSpeciesTypeGIS.Text))
                    {
                        SetValueRange frm = new SetValueRange();
                        frm.MinValue = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS].min;
                        frm.MaxValue = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS].max;
                        frm.ColorArray = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS].colorarray;
                        frm.ValueArray = CommonClass.dicBlend["GIS"][legendText + cboSpeciesTypeGIS].value;
                        _dMinValue = frm.MinValue;
                        _dMaxValue = frm.MaxValue;
                        colorBlend.SetValueRangeAndBundaryColor(frm, false);

                    }//modified by Yangwenwei
                    else if (CommonClass.dicBlend["GIS"].ContainsKey(legendText))
                    {
                        SetValueRange frm = new SetValueRange();
                        frm.MinValue = CommonClass.dicBlend["GIS"][legendText].min;
                        frm.MaxValue = CommonClass.dicBlend["GIS"][legendText].max;
                        frm.ColorArray = CommonClass.dicBlend["GIS"][legendText].colorarray;
                        frm.ValueArray = CommonClass.dicBlend["GIS"][legendText].value;
                        _dMinValue = frm.MinValue;
                        _dMaxValue = frm.MaxValue;
                        colorBlend.SetValueRangeAndBundaryColor(frm, false);
                    }
                    else
                    {
                        MapPointLayer mLayer = default(MapPointLayer);
                        mLayer = (MapPointLayer)mainMap.Layers[_currentLayerIndex];
                        _dMinValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Min([{0}])", _columnName), ""));
                        _dMaxValue = Convert.ToDouble((mLayer as IFeatureLayer).DataSet.DataTable.Compute(string.Format("Max([{0}])", _columnName), ""));

                        colorBlend.SetValueRange(_dMinValue, _dMaxValue, true);
                    }
                }
                colorBlend._maxPlotValue = _dMaxValue;
                colorBlend._minPlotValue = _dMinValue;
                if (cboSpeciesTypeGIS.Enabled && cboSpeciesTypeGIS.Text != _columnName)//加了两个point 第一个显示base, 第二个显示future，删掉第二个 cboSpeciesTypeGIS应该显示base
                {
                    cboSpeciesTypeGIS.Text = _columnName;
                }
            }
            catch
            { }
        }

        void ShowSpecies(string legendText)
        {
            try
            {
                if (CommonClass.CurrentBaseScenario == null)
                {
                    cboSpeciesTypeGIS.Items.Clear();
                    cboSpeciesTypeGIS.Enabled = false;
                    return;
                }
                if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisConfiguration)
                {
                    if (legendText.Contains("Ozone Monitors -- monitor data, temporally adjusted"))
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("f_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("Δo3_DV");
                        cboSpeciesTypeGIS.Items.Add("rrf");
                        cboSpeciesTypeGIS.Enabled = true;
                    }
                    else if (legendText.Contains("Ozone Monitors -- county high monitoring sites, temporally adjusted"))
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("f_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("Δo3_DV");
                        cboSpeciesTypeGIS.Items.Add("rrf");
                        cboSpeciesTypeGIS.Enabled = true;
                    }
                    else if (legendText.Contains("Ozone Monitors_Max -- temporally adjusted"))
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_o3_DV_Max");
                        cboSpeciesTypeGIS.Items.Add("f_o3_DV_Max");
                        cboSpeciesTypeGIS.Items.Add("Δo3_DV_Max");
                        cboSpeciesTypeGIS.Items.Add("rrf");
                        cboSpeciesTypeGIS.Enabled = true;
                    }
                    else
                    {
                        cboSpeciesTypeGIS.Enabled = false;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is OzoneAnalysisChinaConfiguration)
                {
                    if (legendText.Contains("Monitors -- temporally adjusted"))
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("f_o3_DV");
                        cboSpeciesTypeGIS.Items.Add("Δo3_DV");
                        cboSpeciesTypeGIS.Enabled = true;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisConfiguration)
                {
                    if (legendText == "Annual PM25 Point")
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("f_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV(%)");
                        cboSpeciesTypeGIS.Enabled = true;
                    }
                    else if (legendText == "Quarterly PM25 Point")
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        for (int i = 1; i < 5; i++)
                        {
                            cboSpeciesTypeGIS.Items.Add("b_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("f_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i + "(%)");
                            cboSpeciesTypeGIS.Enabled = true;
                        }
                    }
                    else
                    {
                        cboSpeciesTypeGIS.Enabled = false;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is AnnualPMAnalysisChinaConfiguration)
                {
                    if (legendText == "Annual PM25 Point")
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        cboSpeciesTypeGIS.Items.Add("b_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("f_pm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV");
                        cboSpeciesTypeGIS.Items.Add("Δpm25_ann_DV(%)");
                        cboSpeciesTypeGIS.Enabled = true;
                    }
                    else if (legendText == "Quarterly PM25 Point")
                    {
                        cboSpeciesTypeGIS.Items.Clear();
                        for (int i = 1; i < 5; i++)
                        {
                            cboSpeciesTypeGIS.Items.Add("b_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("f_pm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i);
                            cboSpeciesTypeGIS.Items.Add("Δpm25_ann_q_DV_q" + i + "(%)");
                            cboSpeciesTypeGIS.Enabled = true;
                        }
                    }
                    else
                    {
                        cboSpeciesTypeGIS.Enabled = false;
                    }
                }
                else if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration || CommonClass.CurrentBaseScenario.configuration is SSIADepositionConfiguration)
                {
                    cboSpeciesTypeGIS.Items.Clear();
                    MapPointLayer mLayer = default(MapPointLayer);
                    mLayer = (MapPointLayer)mainMap.Layers[_currentLayerIndex];
                    cboSpeciesTypeGIS.Items.Clear();
                    for (int i = 0; i < (mLayer as IFeatureLayer).DataSet.DataTable.Columns.Count; i++)
                    {
                        string columnname = (mLayer as IFeatureLayer).DataSet.DataTable.Columns[i].ColumnName;
                        if (!columnname.ToLower().Contains("id") && !columnname.ToLower().Contains("gridcell") && !columnname.ToLower().Contains("long") && !columnname.ToLower().Contains("state")
                                && !columnname.ToLower().Contains("quarter") && !columnname.ToLower().Contains("lat") && !columnname.ToLower().Contains("type") && !columnname.ToLower().Contains("county")
                                && !columnname.ToLower().Contains("date") && !columnname.ToLower().Contains("neighbor") && !columnname.ToLower().Contains("pollutant") && !columnname.ToLower().Contains("name"))
                        {
                            cboSpeciesTypeGIS.Items.Add(columnname);
                        }
                    }
                    if (cboSpeciesTypeGIS.Items.Count > 0)
                        cboSpeciesTypeGIS.Enabled = true;
                    else
                        cboSpeciesTypeGIS.Enabled = false;
                }
            }
            catch
            { }
        }

        private void tsmiChina_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiChina.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void mainMap_MouseClick(object sender, MouseEventArgs e)
        {
            #region When you select a monitor using the Identify tool in GIS map in data viewer, the monitor never unselects.  Need a way to unselect all. added by sclong, 2017-03-05;
            var layers = mainMap.MapFrame.GetAllLayers();
            foreach (var mapLayer in layers)
            {
                IFeatureLayer layer = mapLayer as IFeatureLayer;
                layer.UnSelectAll();
            }
            #endregion
            /*
            var layers = mainMap.MapFrame.GetAllLayers();
            ILayer tempLayer = null;
            foreach (var mapLayer in layers)
            {
                IEnvelope env;
                mapLayer.MapFrame.ClearSelection(out env);
                if (mapLayer.IsSelected)
                {
                    tempLayer = mapLayer;
                    mapLayer.IsSelected = false;
                }
            }
            if (tempLayer == null)
            {
                tempLayer = mainMap.MapFrame;
            }
            mainMap.MapFrame.IsSelected = true;
            IEnvelope env1;
            mainMap.MapFrame.ClearSelection(out env1);
            mainMap.MapFrame.IsSelected = false;
            tempLayer.IsSelected = true;
            */
            if (e.Button == MouseButtons.Right)
            {
                this.ctmsSaveGIS.Show(MousePosition);
            }
        }

        private void tsmiSaveGIS_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter =
                "Bmp Format (*.bmp)|*.bmp|" +
                "PNG Format (*.png)|*.png|" +
                "Jpeg Format (*.jpg)|*.jpg|" +
                "Gif Format (*.gif)|*.gif|" +
                "Tiff Format (*.tif)|*.tif";
                saveFileDialog.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Picture";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    Stream myStream = saveFileDialog.OpenFile();
                    if (myStream != null)
                    {
                        ImageFormat format = ImageFormat.Png;
                        switch (saveFileDialog.FilterIndex)
                        {
                            case 1: format = ImageFormat.Bmp; break;
                            case 2: format = ImageFormat.Png; break;
                            case 3: format = ImageFormat.Jpeg; break;
                            case 4: format = ImageFormat.Gif; break;
                            case 5: format = ImageFormat.Tiff; break;
                        }

                        Bitmap destImage = new Bitmap(this.mainMap.Width, this.mainMap.Height);
                        Graphics g = Graphics.FromImage(destImage);
                        g.Clear(Color.White);
                        g.Dispose();
                        this.mainMap.DrawToBitmap(destImage, this.mainMap.ClientRectangle);
                        Graphics gDest = Graphics.FromImage(destImage);
                        gDest.Dispose();
                        destImage.Save(myStream, format);
                        myStream.Close();
                    }
                    MessageBox.Show(Language.Localization.GetValue("Save map image successfully!"));
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiSaveGISwithLegend_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter =
                "Bmp Format (*.bmp)|*.bmp|" +
                "PNG Format (*.png)|*.png|" +
                "Jpeg Format (*.jpg)|*.jpg|" +
                "Gif Format (*.gif)|*.gif|" +
                "Tiff Format (*.tif)|*.tif";
                saveFileDialog.InitialDirectory = CommonClass.ResultFilePath + @"\Result\Picture";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    Stream myStream = saveFileDialog.OpenFile();
                    if (myStream != null)
                    {
                        ImageFormat format = ImageFormat.Png;
                        switch (saveFileDialog.FilterIndex)
                        {
                            case 1: format = ImageFormat.Bmp; break;
                            case 2: format = ImageFormat.Png; break;
                            case 3: format = ImageFormat.Jpeg; break;
                            case 4: format = ImageFormat.Gif; break;
                            case 5: format = ImageFormat.Tiff; break;
                        }

                        Bitmap destImage = new Bitmap(this.mainMap.Width, tableLayoutPanel5.Height);
                        Graphics g = Graphics.FromImage(destImage);
                        g.Clear(System.Drawing.Color.FromArgb(215, 230, 255));
                        g.Dispose();
                        this.mainMap.DrawToBitmap(destImage, this.mainMap.ClientRectangle);

                        Graphics gDest = Graphics.FromImage(destImage);

                        Bitmap bmpBlend = colorBlend.DrawImage();
                        Graphics gSrc = colorBlend.CreateGraphics();// 必须用这个方法，用Graphics.FromImage(bmpBlend);无效，原因未明
                        IntPtr srcDC = gSrc.GetHdc();
                        IntPtr destDC = gDest.GetHdc();
                        WinBmpAPI.BitBlt(destDC, (destImage.Width - bmpBlend.Width) / 2, this.mainMap.Height, bmpBlend.Width, bmpBlend.Height, srcDC, 0, 0, 0xCC0020); //13369376);//modified by Yangwenwei
                        gSrc.ReleaseHdc(srcDC);
                        gDest.ReleaseHdc(destDC);
                        gSrc.Dispose();
                        gDest.Dispose();
                        destImage.Save(myStream, format);
                        myStream.Close();
                    }
                    MessageBox.Show(Language.Localization.GetValue("Save map image successfully!"));
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }
        /// <summary>
        /// 把GIS图片保存在剪贴板里随意粘贴
        /// 默认保存为png
        /// </summary>
        /// <remarks>
        /// add by ty 2016-07-09
        /// </remarks>
        private void saveImageAndLegendToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Bitmap destImage = new Bitmap(mainMap.Width, tableLayoutPanel5.Height);
                Graphics g = Graphics.FromImage(destImage);
                g.Clear(System.Drawing.Color.FromArgb(215, 230, 255));
                g.Dispose();
                mainMap.DrawToBitmap(destImage, mainMap.ClientRectangle);

                Graphics gSrc = colorBlend.CreateGraphics();// 必须用这个方法，用Graphics.FromImage(bmpBlend);无效，原因未明
                Graphics gDest = Graphics.FromImage(destImage);
                IntPtr srcDC = gSrc.GetHdc();
                IntPtr destDC = gDest.GetHdc();

                Bitmap bmpBlend = colorBlend.DrawImage();
                WinBmpAPI.BitBlt(destDC, (destImage.Width - bmpBlend.Width) / 2, mainMap.Height, bmpBlend.Width, bmpBlend.Height, srcDC, 0, 0, 0xCC0020);

                gSrc.ReleaseHdc(srcDC);
                gDest.ReleaseHdc(destDC);
                gSrc.Dispose();
                gDest.Dispose();

                if (destImage != null)
                {
                    Clipboard.Clear();
                    Clipboard.SetImage(destImage);
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiYRD_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiYRD.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void btnSetting_Click(object sender, EventArgs e)
        {
            try
            {
                SetZgcChart frm = new SetZgcChart();
                frm.ititle = zgcChart.GraphPane.Title.Text;
                frm.ix = zgcChart.GraphPane.XAxis.Title.Text;
                frm.iy = zgcChart.GraphPane.YAxis.Title.Text;
                frm.ixmin = Math.Round(zgcChart.GraphPane.XAxis.Scale.Min, 4);
                frm.ixmax = Math.Round(zgcChart.GraphPane.XAxis.Scale.Max, 4);
                frm.iymin = Math.Round(zgcChart.GraphPane.YAxis.Scale.Min, 4);
                frm.iymax = Math.Round(zgcChart.GraphPane.YAxis.Scale.Max, 4);
                frm.changeColor = changeColor;
                frm.plotLine = plotLine;
                frm.itype = ichartType;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    if (ichartType != 0)
                    {
                        plotLine = frm.plotLine;
                        if (ichartType == 1)
                            changeColor = frm.changeColor;
                        chartApply();
                    }
                    zgcChart.GraphPane.Title.Text = frm.ititle;
                    zgcChart.GraphPane.XAxis.Title.Text = frm.ix;
                    zgcChart.GraphPane.YAxis.Title.Text = frm.iy;
                    zgcChart.GraphPane.XAxis.Scale.Min = frm.ixmin;
                    zgcChart.GraphPane.XAxis.Scale.Max = frm.ixmax;
                    zgcChart.GraphPane.YAxis.Scale.Min = frm.iymin;
                    zgcChart.GraphPane.YAxis.Scale.Max = frm.iymax;
                    zgcChart.AxisChange();
                    zgcChart.Refresh();
                }
            }
            catch
            { }
        }

        private void ChangecboType(int iType)
        {
            try
            {
                cboType.Items.Clear();
                switch (iType)
                {
                    case 0:
                        for (int i = 0; i < dtchartTemp.Columns.Count; i++)
                        {
                            string columnname = dtchartTemp.Columns[i].ColumnName.Trim().ToLower();
                            if (!columnname.Contains("id") && !columnname.Contains("type")
                                && !columnname.Contains("lat") && !columnname.Contains("long")
                                && !columnname.Contains("quarter") && !columnname.Contains("date")
                                && !columnname.Contains("98th_percent_rank")
                                && !columnname.Contains("county") && !columnname.Contains("state")
                                && !columnname.Contains("neighbor") && !columnname.Contains("day")
                                && !columnname.Contains("year") && !columnname.Contains("pollutant")
                                && !columnname.Contains("name") && !columnname.Contains("_visibility_rank"))
                            {
                                cboType.Items.Add(dtchartTemp.Columns[i].ColumnName);
                            }
                        }
                        break;
                    case 1:
                        if (CommonClass.CurrentBaseScenario.configuration is SSIAAnnualPMAnalysisConfiguration)
                        {
                            //cboType.Items.Add("ΔPM25 (Alt-Base)");
                            //cboType.Items.Add("Alt_PM25 (Background_VNA)");
                            //cboType.Items.Add("Alt_PM25 (Background_eVNA)");
                            for (int i = 0; i < dtchartTemp.Columns.Count; i++)
                            {
                                string columnname = dtchartTemp.Columns[i].ColumnName.Trim();
                                if (columnname.Contains("Δ") || (columnname.Contains("Alt") && (columnname.Contains("VNA") || columnname.Contains("eVNA"))))
                                {
                                    cboType.Items.Add(dtchartTemp.Columns[i].ColumnName);
                                }
                            }
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIADailyPMAnalysisConfiguration)
                        {
                            for (int i = 0; i < dtchartTemp.Columns.Count; i++)
                            {
                                string columnname = dtchartTemp.Columns[i].ColumnName.Trim();
                                if (columnname.Contains("Δ") || (columnname.Contains("Alt") && (columnname.Contains("VNA") || columnname.Contains("eVNA"))))
                                {
                                    cboType.Items.Add(dtchartTemp.Columns[i].ColumnName);
                                }
                            }
                            //cboType.Items.Add("ΔPM25 (Alt-Base)");
                        }
                        else if (CommonClass.CurrentBaseScenario.configuration is SSIAOzoneAnalysisConfiguration)
                        {
                            //cboType.Items.Add("ΔO3 (Alt-Base)");
                            //cboType.Items.Add("Alt_O3 (Background_VNA)");
                            //cboType.Items.Add("Alt_O3 (Background_eVNA)");
                            for (int i = 0; i < dtchartTemp.Columns.Count; i++)
                            {
                                string columnname = dtchartTemp.Columns[i].ColumnName.Trim();
                                if (columnname.Contains("Δ") || (columnname.Contains("Alt") && (columnname.Contains("VNA") || columnname.Contains("eVNA"))))
                                {
                                    cboType.Items.Add(dtchartTemp.Columns[i].ColumnName);
                                }
                            }
                        }
                        break;
                }
                //change the drop down width of cboType
                if (cboType.Items.Count > 0)
                {
                    string str = "";
                    foreach (string s in cboType.Items)
                    {
                        str = s.Length > str.Length ? s : str;
                    }

                    using (Graphics g0 = this.CreateGraphics())
                    {
                        SizeF string_size = g0.MeasureString(str, cboType.Font);
                        cboType.DropDownWidth = (int)string_size.Width;
                    }
                }
            }
            catch
            { }
        }

        private void tsmiPRD_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiPRD.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsmiJJJ_Click(object sender, EventArgs e)
        {
            try
            {
                cboZoomTo.SelectedItem = tsmiJJJ.Text;
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void cboType_SelectionChangeCommitted(object sender, EventArgs e)
        {
            btnApply_Click(null, null);
        }

        private void cboFilter_SelectionChangeCommitted(object sender, EventArgs e)
        {
            btnApply_Click(null, null);
        }

        private void txtDistance_Validated(object sender, EventArgs e)
        {
            string strFileter = "";
            switch ((sender as TextBox).Name)
            {
                case "txtThreshold": strFileter = "Threshold"; break;
                case "txtDistance": strFileter = "Receptor <= "; break;

            }
            for (int i = 0; i < clboQuantifiers.Items.Count; i++)
            {
                if (clboQuantifiers.Items[i].ToString().Contains(strFileter))
                {
                    clboQuantifiers.SetItemChecked(i, true);
                }
            }
            btnApplyData_Click(null, null);
        }

        private void txtDistance_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                txtDistance_Validated(sender, null);
            }
        }

        private void chkChangeAllColorRange_CheckedChanged(object sender, EventArgs e)
        {
            try
            {

                if (chkChangeAllColorRange.Checked)
                {
                    #region  Apply the changes of the color blend to all layers by Yangwenwei 20151118
                    PointScheme myScheme1 = new PointScheme();

                    #region Get the top layer's symbology
                    for (int i = mainMap.Layers.Count - 1; i >= 0; i--)
                    {
                        if (!(mainMap.Layers[i].LegendText.Contains("Source Location") ||
                        mainMap.Layers[i].LegendText.Contains("Counties") ||
                        mainMap.Layers[i].LegendText.Contains("States") ||
                        mainMap.Layers[i].LegendText.Contains("class14_region") ||
                        mainMap.Layers[i].LegendText.Contains("npsClassI") ||
                        mainMap.Layers[i].LegendText.Contains("State_epa2") ||
                        mainMap.Layers[i].LegendText.Contains("China_prov_WGS84_LCC")))
                        {
                            myScheme1 = (PointScheme)(mainMap.Layers[i] as IFeatureLayer).Symbology.Copy();
                            break;
                        }
                        if (i == 0) return;//no layer in GIS,return
                    }
                    #endregion

                    #region apply the top layer's symbology to all FeatureLayers
                    foreach (var layer in mainMap.Layers)
                    {
                        if (layer.LegendText.Contains("Source Location") ||
                        layer.LegendText.Contains("Counties") ||
                        layer.LegendText.Contains("States") ||
                        layer.LegendText.Contains("class14_region") ||
                        layer.LegendText.Contains("npsClassI") ||
                        layer.LegendText.Contains("State_epa2") ||
                        layer.LegendText.Contains("China_prov_WGS84_LCC"))
                        { continue; }

                        PointScheme newScheme = (PointScheme)(layer as IFeatureLayer).Symbology.Copy();
                        for (int i = 0; i < newScheme.Categories.Count; i++)
                        {
                            newScheme.Categories[i].FilterExpression = myScheme1.Categories[i].FilterExpression.Replace(myScheme1.LegendText, (layer as IFeatureLayer).Symbology.LegendText);
                        }
                        //foreach (var item in newScheme.Categories)
                        //{
                        //    item.FilterExpression=item.FilterExpression.Replace(myScheme1.LegendText, (layer as IFeatureLayer).Symbology.LegendText);
                        //}
                        (layer as IFeatureLayer).Symbology = newScheme;
                    }
                    #endregion

                    #endregion
                }
                else
                {
                    //foreach (var layer in mainMap.Layers)
                    //{
                    //    if (layer.LegendText.Contains("Source Location") ||
                    //    layer.LegendText.Contains("Counties") ||
                    //    layer.LegendText.Contains("States") ||
                    //    layer.LegendText.Contains("class14_region") ||
                    //    layer.LegendText.Contains("State_epa2") ||
                    //    layer.LegendText.Contains("China_prov_WGS84_LCC"))
                    //    { continue; }

                    //    PointScheme newScheme = (PointScheme)(layer as IFeatureLayer).Symbology.Copy();
                    //    for (int i = 0; i < newScheme.Categories.Count; i++)
                    //    {
                    //        newScheme.Categories[i].FilterExpression = myScheme1.Categories[i].FilterExpression.Replace(myScheme1.LegendText, (layer as IFeatureLayer).Symbology.LegendText);
                    //    }
                    //    //foreach (var item in newScheme.Categories)
                    //    //{
                    //    //    item.FilterExpression=item.FilterExpression.Replace(myScheme1.LegendText, (layer as IFeatureLayer).Symbology.LegendText);
                    //    //}
                    //    (layer as IFeatureLayer).Symbology = newScheme;
                    //}
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void tsbtnPlotMonitors_Click(object sender, EventArgs e)
        {
            if (plotControl1.IsDrawMonitors)//remove the monitors
            {
                plotControl1.IsDrawMonitors = false; plotControl1.isMarkSelectedPoint = false;
                plotControl1.ResetNewAllGridsColor();
            }
            else//add monitors
            {
                try
                {
                    // string MapName = this.lblMAPname.Text;




                    frmMonitorCSV = new frmSelectMonitors();
                    frmMonitorCSV.UseDefaultFileAndColumn(lblMAPname.Text, lstSpeciesTypeMap.SelectedItem.ToString());

                    if (frmMonitorCSV.dicMonitors != null)
                    {
                        plotControl1.dicMonitors.Clear();
                        plotControl1.dicMonitors = frmMonitorCSV.dicMonitors;
                        plotControl1.IsDrawMonitors = true;
                        plotControl1.ResetNewAllGridsColor();
                    }

                    //DialogResult rt = frmMonitorCSV.ShowDialog();

                    //if (rt == DialogResult.OK)
                    //{
                    //    string p = frmMonitorCSV.selectedFilePath;
                    //    string c = frmMonitorCSV.selectedColomnName;


                    //    plotControl1.dicMonitors.Clear();
                    //    plotControl1.dicMonitors = frmMonitorCSV.dicMonitors;
                    //    plotControl1.drawMonitors = true;
                    //    plotControl1.ResetNewAllGridsColor();
                    //}
                    ////plotControl1.
                }

                catch (Exception ex)
                {
                    CommonClass.LogError(ex);

                }
            }
        }

        private void chkChartSelectAll_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvDataList.RowCount == 0)
                {
                    goto Exit;
                }
                // Select All
                if (chkChartSelectAll.Checked)
                {
                    for (int i = 0; i < dgvDataList.Rows.Count; i++)
                    {
                        ((DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0]).Value = true;
                    }
                }

                // Deselect All
                else
                {
                    for (int i = 0; i < dgvDataList.Rows.Count; i++)
                    {
                        ((DataGridViewCheckBoxCell)dgvDataList.Rows[i].Cells[0]).Value = false;
                    }
                }

            Exit:
                {
                    //message
                    return;
                }
            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        private void overlayLocationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (tsmiOverlayLocation.Checked)
                {
                    tsmiOverlayLocation.Checked = false;
                    plotControl1.IsDrawSSIASource = false;
                    plotControl1.ResetNewAllGridsColor();
                    //plotControl1.pointSource = null;

                }
                else
                {
                    DataTable dt = null;

                    string fileName = this.tlvDataViewer.SelectedItems[0].Text.ToString();
                    string filePath = this.tlvDataViewer.SelectedItems[0].Name.ToString();

                    if (this.tbcFunction.SelectedTab.Text == "Map")
                    {
                        //  WaitShow(Language.Translate("Drawing Data"));
                        {
                            #region
                            //string dataType = "";
                            FileStream fs = null;
                            fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
                            string[] sMatchArray = sr.ReadLine().Split(new char[] { ',' });
                            _dataType = sMatchArray[0];
                            fs.Dispose();
                            sr.Dispose();
                            sr.Close();
                            GC.Collect();
                            #endregion
                            #region
                            bool errorOccur = false;
                            if (_dataType.Trim().ToLower() == "quarter")
                            {
                                if (fileName.Contains("Daily All Years All Days PM25 Point"))
                                {
                                    dt = CommonClass.getDataTableForMapDaily(filePath, CommonClass.CurrentBaseScenario);
                                }
                                else if (fileName.Contains("Daily All Years High Days PM25 Point"))
                                {
                                    dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                                }
                                else
                                    dt = CommonClass.getDataTableForMap(filePath);
                            }
                            else if (filePath.Contains("SSIA Source Location"))//SSIA
                            {
                                dt = CommonClass.getDataSetFromCSV(filePath).Tables[0];
                            }
                            else
                            {
                                dt = CommonClass.getDataSetFromCSVAndFirstLine(filePath, ref _dataType, ref errorOccur);
                            }
                            #endregion
                        }
                        if (dt == null)
                        {
                            WaitClose();
                            MessageBox.Show(Language.Localization.GetValue("Empty data!"));
                            return;
                        }
                    }
                    PointF point;
                    ////读取坐标点经纬度
                    //string latlong = dt.Rows[0][1] + "," + dt.Rows[0][2];
                    //double x = double.Parse(dt.Rows[0][2].ToString());
                    //double y = double.Parse(dt.Rows[0][1].ToString());

                    int ssiamodeloption = SSIAmodeloption(fileName);
                    DotSpatial.Projections.ProjectionInfo p = new ProjectionInfo();
                    switch (ssiamodeloption)
                    {
                        case 0:
                        case 1: p = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projUSACMAQ); break;
                        case 2: p = DotSpatial.Projections.ProjectionInfo.FromProj4String(CommonClass.projUSAAERMOD); break;
                    }
                    //double[] arrayPoint = new double[] { x, y };
                    //DotSpatial.Projections.Reproject.ReprojectPoints(arrayPoint, null,
                    //    DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984,
                    //    p, 0, 1);

                    //point = new PointF((float)arrayPoint[0], (float)arrayPoint[1]);

                    point = new PointF(float.Parse(dt.Rows[0][2].ToString()), float.Parse(dt.Rows[0][1].ToString()));

                    plotControl1.IsDrawSSIASource = true;
                    plotControl1.pointSource = point;
                    //plotControl1.projForMap = p;
                    tsmiOverlayLocation.Checked = true;
                    plotControl1.ResetNewAllGridsColor();
                }

            }
            catch (Exception ex)
            {
                CommonClass.LogError(ex);
            }
        }

        #region Change title and legend
        public class TitleAndLegend
        {
            public string CustomTitle;
            public string[] CustomLegend;
            public string CustomYaxis;
        }
        private Dictionary<string, TitleAndLegend> dicTitleAndLegend = new Dictionary<string, TitleAndLegend>();
        //private string _customTitle = "";
        //private string[] _customLegend;
        //private string _customYaxis = "";
        private void zgcChart_TitleAndLegendChanged(string newTitle, string newYaxis, string[] newLegends)
        {
            if (dicTitleAndLegend.ContainsKey(cboType.Text))
            {
                dicTitleAndLegend[cboType.Text] = new TitleAndLegend() { CustomLegend = newLegends, CustomYaxis = newYaxis, CustomTitle = newTitle };

            }
            else
            {
                dicTitleAndLegend.Add(cboType.Text, new TitleAndLegend() { CustomLegend = newLegends, CustomYaxis = newYaxis, CustomTitle = newTitle });
            }
            chartApply();
            zgcChart.Refresh();
        }

        private void zgcChart_UndoChangeTitleAndLegend()
        {
            _configureSymbol = null;
            if (dicTitleAndLegend.ContainsKey(cboType.Text))
            {
                dicTitleAndLegend[cboType.Text] = new TitleAndLegend() { CustomLegend = null, CustomYaxis = "", CustomTitle = "" };

            }
            chartApply();
            zgcChart.Refresh();
        }
        private void zgcChart_ConfigurePlotChanged(ConfigureSymbol configureSymbol)
        {
            _configureSymbol = configureSymbol;
            chartApply();
            zgcChart.Refresh();
        }
        #endregion

        /// <summary>
        /// 在图形上显示值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="pane"></param>
        /// <param name="curve"></param>
        /// <param name="iPt">第几个柱子</param>
        /// <returns></returns>        /// 
        private string zgcChart_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt)
        {
            //return default(string);

            //Get the PointPair that is under the mouse
            PointPair pt = curve[iPt];

            //return curve.Label.Text + " is " + pt.Y.ToString("f2");// +" units at " + pt.X.ToString("f1") + " days";
            string lable = curve.GetXAxis(pane).Scale.TextLabels[iPt];
            if (lstReceptors.Count > 0)
            {
                lable = lstReceptors[iPt];
            }
            return string.Format("({0}, value={1})", lable, pt.Y.ToString("f3"));
            //return _ReceptorRegions[iPt] + " is " + pt.Y.ToString("f3");
        }

        private void SMAT_CE_MouseClick(object sender, MouseEventArgs e)
        {
            if (plotControl1.ClientRectangle.Contains(e.X, e.Y))
            {

            }
            else
            {

            }
        }

        private void SMAT_CE_Click(object sender, EventArgs e)
        {
            
        }

        private void plotControl1_Leave(object sender, EventArgs e)
        {
            plotControl1.isMarkSelectedPoint = false;
            if(frmSelectedMonitor!=null&& frmSelectedMonitor.Visible)
            {
                frmSelectedMonitor.Close();
            }
        }

        private void SMAT_CE_Resize(object sender, EventArgs e)
        {
            if (frmSelectedMonitor != null && frmSelectedMonitor.Visible)
            {
                frmSelectedMonitor.Close();
            }
        }


        //private void toolStripButton1_Click(object sender, EventArgs e)
        //{
        //    var layers = mainMap.MapFrame.GetAllLayers();
        //    foreach (var mapLayer in layers)
        //    {
        //        IEnvelope env;
        //        mapLayer.ClearSelection(out env);
        //        mapLayer.MapFrame.ClearSelection(out env);
        //        mapLayer.ClearSelection();

        //    }

        //}

    }
}
