Exemplo n.º 1
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (textBand1.Text == "" || textBand2.Text == "" || txtHeight.Text == "" || txtAngle.Text == "" || txtSaveFile.Text == "")
            {
                MessageBox.Show("请检查输入、输出以及参数设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            if (list_B1.Count != 0 && list_B1.Count != 0)
            {
                //for (int i = 0; i < list_B1.Count; i++)
                //{
                //    dic_BandList.Add(list_B1[i], list_B2[i]);
                //}


                //开始水汽计算程序
                try
                {
                    COM_IDL_connectLib.ICOM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                    oCom.CreateObject(0, 0, 0);

                    Object[] inputArray1 = list_B1.ToArray();
                    Object[] inputArray2 = list_B2.ToArray();

                    oCom.SetIDLVariable("inputarray1", inputArray1);
                    oCom.SetIDLVariable("inputarray2", inputArray2);
                    oCom.SetIDLVariable("height", Convert.ToDouble(txtHeight.Text));
                    oCom.SetIDLVariable("degree", Convert.ToDouble(txtAngle.Text));

                    oCom.SetIDLVariable("a", Convert.ToDouble(labelα.Text));
                    oCom.SetIDLVariable("b0", Convert.ToDouble(labelb0.Text));
                    oCom.SetIDLVariable("b1", Convert.ToDouble(labelb1.Text));
                    oCom.SetIDLVariable("b2", Convert.ToDouble(labelb2.Text));
                    oCom.SetIDLVariable("b3", Convert.ToDouble(labelb3.Text));
                    oCom.SetIDLVariable("b4", Convert.ToDouble(labelb4.Text));

                    oCom.SetIDLVariable("outputdir", txtSaveFile.Text);

                    //string tmp = "WaterVaporContent20141225,'" + inputArray1 + "','" + inputArray2 + "'," + txtHeight.Text + "," + txtAngle.Text + "," + labelα.Text + "," + labelb0.Text + "," + labelb1.Text + "," + labelb2.Text + "," + labelb3.Text + "," + labelb4.Text + ",'" + txtSaveFile.Text.ToString()+"'";

                    oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\WaterVaporContent20141225.pro'");
                    //oCom.ExecuteString(tmp);
                    oCom.ExecuteString("WaterVaporContent20141225,inputarray1,inputarray2,height,degree,a,b0,b1,b2,b3,b4,outputdir");

                    MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("未找到 *.tiff 文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            #region 数据合法性验证

            if (NumberMatch.Regex(txtNDVIv.Text))
            {
                label18.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label18.ForeColor = System.Drawing.Color.Black;
            }
            if (NumberMatch.Regex(txtNDVIs.Text))
            {
                label19.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label19.ForeColor = System.Drawing.Color.Black;
            }
            if (NumberMatch.Regex(txtNDVIw.Text))
            {
                label20.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label20.ForeColor = System.Drawing.Color.Black;
            }

            if (NumberMatch.Regex(txtF.Text))
            {
                label21.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label21.ForeColor = System.Drawing.Color.Black;
            }
            if (NumberMatch.Regex(txtEmissVegetation.Text))
            {
                label22.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label22.ForeColor = System.Drawing.Color.Black;
            }
            if (NumberMatch.Regex(txtEmissSoil4.Text))
            {
                label24.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label24.ForeColor = System.Drawing.Color.Black;
            }
            if (NumberMatch.Regex(txtEmissSoil3.Text))
            {
                label23.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label23.ForeColor = System.Drawing.Color.Black;
            }
            if ((NumberMatch.RegexSW(0, txtNDVIs.Text, txtNDVIv.Text)) || (NumberMatch.RegexSW(-1, txtNDVIw.Text, txtNDVIs.Text)))
            {
                MessageBox.Show("请注意,必须满足 NDVIw < NDVIs < NDVIv 条件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (NumberMatch.Regex(txtC1.Text) && radioC1.Checked == true)
            {
                label25.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label25.ForeColor = System.Drawing.Color.Black;
            }
            #endregion

            //a,b,输出路径判断
            if (txtaVegetation == null || txtaSoil == null || txtbSoil == null || txtbVegetation == null)
            {
                MessageBox.Show("植被或者土壤的 α 或者 β 为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtOuput.Text == "")
            {
                MessageBox.Show("输出目录为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //开始温度反演
            try
            {
                COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                oCom.CreateObject(0, 0, 0);
                //oCom.ExecuteString(".RESET_SESSION");

                int Cindex = 0;
                if (radioC1.Checked == true && txtC1.Text != "")
                {
                    Cindex = 0;
                }
                else
                {
                    Cindex = 1;
                }

                Object[] inputStringArray = allListFiles.ToArray();
                //object[] inputStringArray1 = { @"E:\temp-IRSA\2501\B1.tif", @"E:\temp-IRSA\2501\B2.tif", @"E:\temp-IRSA\2501\B3.tif", @"E:\temp-IRSA\2501\B4.tif", @"E:\temp-IRSA\2501\green.tif", @"E:\temp-IRSA\2501\red.tif", @"E:\temp-IRSA\2501\NIR.tif", @"E:\temp-IRSA\2501\SensorZenith.tif" };
                //string temp = "CAL_TEMPRETURE20140618," + inputStringArray + "," + txtNDVIv.Text + "," + txtNDVIs.Text + "," + txtNDVIw.Text + "," + txtF.Text + "," + txtEmissVegetation.Text + "," + txtEmissWater.Text + "," + txtEmissSoil3.Text + "," + txtEmissSoil4.Text + "," + Cindex + "," + txtC1.Text + "," + txtaVegetation.Text + "," + txtbVegetation.Text + "," + txtaSoil.Text + "," + txtbSoil.Text + ",'" + txtOuput.Text + "\\" + "'";

                #region 文件目录放在桌面上运行成功
                oCom.SetIDLVariable("inputArray", inputStringArray);
                oCom.SetIDLVariable("NDVIv", Convert.ToDouble(txtNDVIv.Text));
                oCom.SetIDLVariable("NDVIs", Convert.ToDouble(txtNDVIs.Text));
                oCom.SetIDLVariable("NDVIw", Convert.ToDouble(txtNDVIw.Text));
                oCom.SetIDLVariable("F", Convert.ToDouble(txtF.Text));
                oCom.SetIDLVariable("Ev", Convert.ToDouble(txtEmissVegetation.Text));
                oCom.SetIDLVariable("Ew", Convert.ToDouble(txtEmissWater.Text));
                oCom.SetIDLVariable("Es3", Convert.ToDouble(txtEmissSoil3.Text));
                oCom.SetIDLVariable("Es4", Convert.ToDouble(txtEmissSoil4.Text));
                oCom.SetIDLVariable("Cindex", Cindex);
                oCom.SetIDLVariable("C", Convert.ToDouble(txtC1.Text));
                oCom.SetIDLVariable("av", Convert.ToDouble(txtaVegetation.Text));
                oCom.SetIDLVariable("bv", Convert.ToDouble(txtbVegetation.Text));
                oCom.SetIDLVariable("as", Convert.ToDouble(txtaSoil.Text));
                oCom.SetIDLVariable("bs", Convert.ToDouble(txtbSoil.Text));
                object output = txtOuput.Text + "\\";
                oCom.SetIDLVariable("outputdirct", output);

                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\cal_tempreture20140618.pro'");
                //oCom.ExecuteString(temp);
                oCom.ExecuteString("CAL_TEMPRETURE20140618,inputArray,NDVIv,NDVIs,NDVIw,F,Ev,Ew,Es3,Es4,Cindex,C,av,bv,as,bs,outputdirct");
                MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.Close();
                #endregion

                //string[] inputStringArray1 = allListFiles.ToArray();
                //object output = txtOuput.Text + "\\";
                //string temp = "CAL_TEMPRETURE20140618,'" + inputStringArray1 + "'," + txtNDVIv.Text + "," + txtNDVIs.Text + "," + txtNDVIw.Text + "," + txtF.Text + "," + txtEmissVegetation.Text + "," + txtEmissWater.Text + "," + txtEmissSoil3.Text + "," + txtEmissSoil4.Text + "," + Cindex + "," + txtC1.Text + "," + txtaVegetation.Text + "," + txtbVegetation.Text + "," + txtaSoil.Text + "," + txtbSoil.Text + ",'" + txtOuput.Text + "\\" + "'";
                //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\cal_tempreture20140618.pro'");
                //oCom.ExecuteString(temp);
                //MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //this.Close();
            }
            catch (Exception ex)
            {
                string[] files = Directory.GetFiles(txtOuput.Text);
                if (files.Length != 0)
                {
                    MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }