/// <summary>
        /// 当向导页的新一页出现前可以做的该页初始化工作。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void wizardLogistcCA_AfterSwitchPages(object sender, CristiPotlog.Controls.Wizard.AfterSwitchPagesEventArgs e)
        {
            //切换至逻辑回归计算页时,应首先读取地图图层信息,填写部分控件
            if (e.OldIndex == 1 && e.NewIndex == 2)
            {
                //如果不是第一次打开窗体,则再次读取地图数据
                application             = ArcMap.Application;
                document                = application.Document as IMxDocument;
                map                     = document.FocusMap;
                ArcGISOperator.FoucsMap = document.FocusMap;
                //如果图层选择框为空
                if (comboBoxTrainingStartImage.Items.Count == 0)
                {
                    for (int i = 0; i < map.LayerCount; i++)
                    {
                        string layerName = map.get_Layer(i).Name;
                        comboBoxTrainingStartImage.Items.Add(layerName);
                        comboBoxTrainingEndImage.Items.Add(layerName);
                        comboBoxSimStartImage.Items.Add(layerName);
                        comboBoxSimEndImage.Items.Add(layerName);
                    }
                }
            }
            //切换到土地利用类型设置页时首先获取图层信息,然后填充土地利用类型
            else if (e.OldIndex == 2 && e.NewIndex == 3)
            {
                listVariableLayersName.Clear();
                trainingStartImageName = comboBoxTrainingStartImage.SelectedItem.ToString();
                trainingEndImageName   = comboBoxTrainingEndImage.SelectedItem.ToString();
                for (int i = 0; i < dataGridViewVariableDatas.Rows.Count; i++)
                {
                    listVariableLayersName.Add(dataGridViewVariableDatas.Rows[i].Cells[0].Value.ToString());
                }

                //如果已经完成了回归,则不再进行
                if (isRegressed)
                {
                    return;
                }

                dataGridViewLandUse.Rows.Clear();
                IRasterLayer rasterLayer = ArcGISOperator.GetRasterLayerByName(trainingStartImageName);
                IRasterUniqueValueRenderer  rasterUniqueValueRenderer  = (IRasterUniqueValueRenderer)rasterLayer.Renderer;
                IRasterRendererUniqueValues rasterRendererUniqueValues = (IRasterRendererUniqueValues)rasterUniqueValueRenderer;
                IUniqueValues uniqueValues     = rasterRendererUniqueValues.UniqueValues;
                List <object> listUniqueValues = new List <object>();
                for (int i = 0; i < uniqueValues.Count; i++)
                {
                    listUniqueValues.Add(uniqueValues.get_UniqueValue(i));
                }
                int classCount = rasterUniqueValueRenderer.get_ClassCount(0);
                for (int i = 0; i < classCount; i++)
                {
                    dataGridViewLandUse.Rows.Add();
                    dataGridViewLandUse.Rows[i].Cells[0].Value = listUniqueValues[i];
                    dataGridViewLandUse.Rows[i].Cells[1].Value = rasterUniqueValueRenderer.get_Label(0, i);

                    ISymbol     symbol     = rasterUniqueValueRenderer.get_Symbol(0, i);
                    IFillSymbol fillSymbol = symbol as IFillSymbol;
                    //ISimpleFillSymbol simpleFillSymbol = (ISimpleFillSymbol)symbol;
                    //IColor esriColor = simpleFillSymbol.Color;
                    IColor    esriColor = fillSymbol.Color;
                    IRgbColor rgbColor  = new RgbColorClass();
                    rgbColor.CMYK = esriColor.CMYK;
                    Color color = Color.FromArgb(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
                    dataGridViewLandUse.Rows[i].Cells[3].Value =
                        GeneralOpertor.GetBitmap(15, 15, color);
                }
                ColumnLUCharacter.Items.Clear();
                ColumnLUCharacter.Items.Add(resourceManager.GetString("String6"));
                ColumnLUCharacter.Items.Add(resourceManager.GetString("String7"));
                ColumnLUCharacter.Items.Add(resourceManager.GetString("String8"));
            }
            //切换到逻辑回归计算页面时进行计算
            if (e.OldIndex == 3 && e.NewIndex == 4)
            {
                if (isRegressed)
                {
                    return;
                }

                dataGridViewLogisticRegressionCoeff.Rows.Clear();
                labelCalculte.Text           = resourceManager.GetString("String9");
                labelCalculte.Visible        = true;
                progressBarCalculate.Visible = true;
                Application.DoEvents();

                //1.读取起始图像、终止图像、各变量图像为数组
                IRasterLayer   rasterLayerStartImage = ArcGISOperator.GetRasterLayerByName(comboBoxTrainingStartImage.SelectedItem.ToString());
                IRasterLayer   rasterLayerEndImage   = ArcGISOperator.GetRasterLayerByName(comboBoxTrainingEndImage.SelectedItem.ToString());
                RasterSampling rasterSampling        = new RasterSampling();
                labelCalculte.Text = resourceManager.GetString("String12");
                Application.DoEvents();
                List <int> notNullRows;
                List <int> notNullColumns;
                trainingStartImage = ArcGISOperator.ReadRasterAndGetNotNullRowColumn(rasterLayerStartImage, out structRasterMetaData,
                                                                                     out notNullRows, out notNullColumns);
                //获取最小空间范围
                List <IRasterLayer> listVariablesLayers = new List <IRasterLayer>();
                for (int i = 0; i < listVariableLayersName.Count; i++)
                {
                    listVariablesLayers.Add(ArcGISOperator.GetRasterLayerByName(listVariableLayersName[i]));
                }
                ArcGISOperator.GetSmallestBound(rasterLayerStartImage, rasterLayerEndImage, listVariablesLayers, ref structRasterMetaData);

                labelCalculte.Text = resourceManager.GetString("String13");
                Application.DoEvents();
                trainingEndImage     = ArcGISOperator.ReadRaster(rasterLayerEndImage, structRasterMetaData.NoDataValue);
                float[,] changeImage = GeneralOpertor.GetBinaryImageByTwoImages(trainingStartImage, trainingEndImage, structRasterMetaData.RowCount,
                                                                                structRasterMetaData.ColumnCount, structRasterMetaData.NoDataValue);
                //GeneralOpertor.WriteDataFloat(GetOutputFolder() + @"\lr_change.txt", changeImage, structRasterMetaData.RowCount, structRasterMetaData.ColumnCount);

                foreach (string layerName in listVariableLayersName)
                {
                    labelCalculte.Text = resourceManager.GetString("String14") + layerName + ".....";
                    Application.DoEvents();
                    varibaleImages.Add(ArcGISOperator.ReadRaster(ArcGISOperator.GetRasterLayerByName(layerName), structRasterMetaData.NoDataValue));
                }
                //2.按设置的比例进行随机抽样,得到抽样结果,然后计算
                //1.进行抽样
                labelCalculte.Text = resourceManager.GetString("String11");
                Application.DoEvents();
                int samplingCellsCount = (int)(structRasterMetaData.RowCount * structRasterMetaData.ColumnCount * numericUpDownSamplingPrecent.Value / 100);
                float[,] datas = new float[samplingCellsCount, listVariableLayersName.Count + 1];
                //抽取真值的比例默认设置为一半
                datas = rasterSampling.SamplingData(varibaleImages, changeImage, (double)numericUpDownSamplingPrecent.Value,
                                                    50, structRasterMetaData, notNullRows, notNullColumns);
                //2.进行计算
                labelCalculte.Text = resourceManager.GetString("String9");
                Application.DoEvents();
                //输出抽样结果数据
                //GeneralOpertor.WriteDataFloat(GetOutputFolder() + @"\lrSamplingData.txt", datas,
                //    rasterSampling.SamplingCellsCount, listVariableLayersName.Count + 1);

                //3.使用Accord.NET进行逻辑回归计算
                labelCalculte.Text = resourceManager.GetString("String9");
                Application.DoEvents();
                LogisticRegression lr = new LogisticRegression();
                double[]           odds;
                double[]           stde;
                double[]           min;
                double[]           max;
                lr.LogisticRegresssionAanlysis(datas, rasterSampling.SamplingCellsCount, listVariableLayersName.Count + 1,
                                               out coef, out odds, out stde, out min, out max);

                for (int i = 0; i < listVariableLayersName.Count + 1; i++)
                {
                    dataGridViewLogisticRegressionCoeff.Rows.Add();
                    if (i == 0)
                    {
                        dataGridViewLogisticRegressionCoeff.Rows[i].Cells[0].Value = resourceManager.GetString("String15");
                    }
                    else
                    {
                        dataGridViewLogisticRegressionCoeff.Rows[i].Cells[0].Value = listVariableLayersName[i - 1];
                    }
                    dataGridViewLogisticRegressionCoeff.Rows[i].Cells[1].Value = coef[i];
                    dataGridViewLogisticRegressionCoeff.Rows[i].Cells[2].Value = odds[i];
                    dataGridViewLogisticRegressionCoeff.Rows[i].Cells[3].Value = stde[i];
                    dataGridViewLogisticRegressionCoeff.Rows[i].Cells[4].Value = max[i];
                    dataGridViewLogisticRegressionCoeff.Rows[i].Cells[5].Value = min[i];
                }

                labelCalculte.Visible        = false;
                progressBarCalculate.Visible = false;
                Application.DoEvents();
                isRegressed = true;
            }
            //切换到模拟参数设置页时给定控件初始值,同时保存模拟数据信息
            else if (e.OldIndex == 4 && e.NewIndex == 5)
            {
                if (comboBoxSimEndImage.SelectedIndex == -1)
                {
                    buttonCalConvertCells.Enabled = false;
                }
                else
                {
                    buttonCalConvertCells.Enabled = true;
                }
            }
            //切换到模拟过程参数设置页时给定控件初始值,同时保存模拟参数信息
            else if (e.OldIndex == 5 && e.NewIndex == 6)
            {
                simulationStartImageName = comboBoxSimStartImage.SelectedItem.ToString();
                if (comboBoxSimEndImage.SelectedIndex != -1)
                {
                    simulationEndImageName = comboBoxSimEndImage.SelectedItem.ToString();
                }

                convertCount         = Convert.ToInt32(numericUpDownConvertCount.Value);
                simulationIterations = Convert.ToInt32(numericUpDownIterations.Value);
                delta = Convert.ToInt32(numericUpDownDelta.Value);

                numericUpDownRefresh.Value     = 10;
                numericUpDownOutputImage.Value = 10;
                outputFolder             = GetOutputFolder();
                textBoxOutputFolder.Text = outputFolder;
            }
            //切换到完成页时填充摘要,同时保存模拟过程输出参数的信息
            else if (e.OldIndex == 6 && e.NewIndex == 7)
            {
                refreshInterval     = Convert.ToInt32(numericUpDownRefresh.Value);
                outputImageInterval = Convert.ToInt32(numericUpDownOutputImage.Value);
                if (radioButtonOutput.Checked)
                {
                    isOutput = true;
                }
                else
                {
                    isOutput = false;
                }
                outputFolder = textBoxOutputFolder.Text;

                textBoxSummay.Text = WriteSummay();
            }
        }