Esempio n. 1
0
 public Form1()
 {
     InitializeComponent();
     axTOCControl1.SetBuddyControl(axMapControl1);
     com = new COM_IDL_connectLib.COM_IDL_connect();
     com.CreateObject(0, 0, 0);
 }
Esempio n. 2
0
        /// <summary>
        /// 构造函数,需要*.pro文件路径做参数
        /// </summary>
        /// <param name="profilename">*.pro文件路径</param>
        public IdlConnector(string profilename)
        {
            if (profilename == null)
            {
                return;
            }
            FileInfo finfor = new FileInfo(profilename);

            if (!finfor.Exists)
            {
                return;
            }
            idlCon = new COM_IDL_connectLib.COM_IDL_connect();
            idlCon.CreateObject(0, 0, 0);

            m_profilename  = profilename;
            m_functionName = Path.GetFileNameWithoutExtension(finfor.FullName);
            try
            {
                idlCon.ExecuteString(".RESET_SESSION");
                idlCon.ExecuteString(@".compile '" + m_profilename + "'");
            }
            catch (Exception ex) { throw ex; }

            m_runStr = m_functionName + ", ";
        }
Esempio n. 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                COM_IDL_connectLib.ICOM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                oCom.CreateObject(0, 0, 0);
                string temp = "edgeEnhance20141217,'" + textBox1.Text + "'," + comboBox1.SelectedIndex + ",'" + textBox2.Text + "'";
                //oCom.SetIDLVariable("inputfolder", textBox1.Text.ToString().Trim());
                //oCom.SetIDLVariable("method", comboBox1.SelectedIndex);
                //oCom.SetIDLVariable("outputfolder", textBox2.Text.ToString().Trim());

                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\edgeEnhance20141217.pro'");
                oCom.ExecuteString(temp);
                //oCom.ExecuteString("edgeEnhance20141217,inputfolder,method,outputfolder");
                MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //this.Close();
                textBox1.Text  = "";
                textBox2.Text  = "";
                comboBox1.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        //编译所有pro文件
        /// <summary>
        /// Compiles all.
        /// </summary>
        private void CompileAll()
        {
            oComIDL.CreateObject(0, 0, 0);

            foreach (string file in proFileList)
            {
                oComIDL.ExecuteString(@".compile '" + file + "'");
            }
        }
Esempio n. 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            string firstiamgepath  = "";
            string secondiamgepath = "";

            if (comboBox1.SelectedValue != null && comboBox2.SelectedValue != null)
            {
                string firstimage  = comboBox1.SelectedValue.ToString();
                string secondimage = comboBox2.SelectedValue.ToString();
                for (int i = 0; i < comboBox1.Items.Count; i++)
                {
                    if (comboBox1.SelectedValue.ToString() == list_layers[i].Name)
                    {
                        firstiamgepath = list_layers[i].FilePath;
                    }
                }

                for (int i = 0; i < comboBox2.Items.Count; i++)
                {
                    if (comboBox2.SelectedValue.ToString() == list_layers[i].Name)
                    {
                        secondiamgepath = list_layers[i].FilePath;
                    }
                }
            }

            try
            {
                COM_IDL_connectLib.ICOM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                oCom.CreateObject(0, 0, 0);
                string temp = "statistic20150306,'" + firstiamgepath + "','" + secondiamgepath + "',xmin=xmin,ymin=ymin,xmax=xmax,ymax=ymax,xmean=xmean,ymean=ymean,s1=s1,s2=s2,deviation=deviation,p1=p1,p2=p2,g1=g1,g2=g2,r=r,DI=DI";
                //oCom.SetIDLVariable("inputfolder", textBox1.Text.ToString().Trim());
                //oCom.SetIDLVariable("method", comboBox1.SelectedIndex);
                //oCom.SetIDLVariable("outputfolder", textBox2.Text.ToString().Trim());

                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\statistic20150306.pro'");
                oCom.ExecuteString(temp);
                //oCom.ExecuteString("noisesuppress20141217,inputfolder,method,outputfolder");
                //MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //this.Close();
                //comboBox1.Text = "";
                //comboBox2.Text = "";

                object deviation = oCom.GetIDLVariable("deviation");//输出像元方差
                labelPiancha.Text = Math.Round(Convert.ToDecimal(deviation), 6).ToString();

                object r = oCom.GetIDLVariable("r");//输出像元方差
                labelXiangguan.Text = Math.Round(Convert.ToDecimal(r), 6).ToString();

                object DI = oCom.GetIDLVariable("DI");//输出像元方差
                labelGuangpu.Text = Math.Round(Convert.ToDecimal(DI), 6).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (cmbInputFile.Text == "")
            {
                MessageBox.Show("输入为空,请选择输入文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (txtbOutput.Visible == true && txtbOutput.Text == "")
            {
                MessageBox.Show("输出为空,请选择输出文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (listBox1.SelectedItems.Count == 0)
            {
                MessageBox.Show("选择分类波段为空,请选择波段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else
            {
                COM_IDL_connectLib.COM_IDL_connect oComIDL = new COM_IDL_connectLib.COM_IDL_connect();
                oComIDL.CreateObject(0, 0, 0);
                oComIDL.ExecuteString(".RESET_SESSION");
                string str = ".compile '" + Application.StartupPath + "\\RSImage_KMeans.pro" + "'";
                oComIDL.ExecuteString(str);

                string       inputfile    = string.Empty;
                IRasterLayer pRasterLayer = pMap.get_Layer(cmbInputFile.SelectedIndex) as IRasterLayer;
                for (int i = 0; i < pRasterLayer.BandCount; i++)
                {
                    inputfile = pRasterLayer.FilePath;
                }

                string pos = "[";
                for (int i = 0; i < listBox1.SelectedIndices.Count; i++)
                {
                    pos += (int)listBox1.SelectedIndices[i] + ",";
                }
                pos = pos.Substring(0, pos.Length - 1) + "]";

                string str1 = "RSImage_KMeans" + ",'" + inputfile + "'" + "," + pos + ",'" + txtbOutput.Text + "'" + ",7,'" + dmudMinClass.Text + "'" + ",'" + dmudIterations.Text + "'" + ",'" + txtChangeThresh.Text + "'";
                oComIDL.ExecuteString(str1);

                if (MessageBox.Show("分类成功,是否显示结果?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    openraster_1 openrasterfile = new openraster_1();
                    openrasterfile.pMap = pMap;
                    openrasterfile.OpenRaster(txtbOutput.Text);
                    ShowResultOrNot = true;
                    this.Close();
                }
                else
                {
                    this.Close();
                }
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtInputDirectory.Text == "")
            {
                MessageBox.Show("输入为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (radioButton2.Checked == true && txtOutputNamePlus.Text == "")
            {
                MessageBox.Show("输出的文件名后缀为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtOuputDirectory.Text == "")
            {
                MessageBox.Show("输出目录为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                //COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                oCom.CreateObject(0, 0, 0);
                //oCom.ExecuteString(".RESET_SESSION");

                if (radioButton1.Checked == true)
                {
                    txtOutputNamePlus.Text = "";
                }
                string temp = "RADIOMETRIC_CORRECTION_RALATIVE20140719,'" + txtInputDirectory.Text + "','" + txtOuputDirectory.Text + "\\" + "','" + txtOutputNamePlus.Text + "'";
                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\RADIOMETRIC_CORRECTION_RALATIVE20140719.pro'");
                oCom.ExecuteString(temp);
                //oCom.DestroyObject();

                MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //this.Close();
                //清空TextBox
                this.txtInputDirectory.Text = "";
                //this.txtInputPZ.Text = "";
                //this.txtInputZY.Text = "";
                this.txtOuputDirectory.Text    = "";
                this.radioButton1.Checked      = true;
                this.txtOutputNamePlus.Visible = false;
                this.txtOutputNamePlus.Text    = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show("运行失败或者部分文件运行失败,请查看运行结果!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            //string tmp3 = "image_stretching," + "\"" + input + "\"," + pos + "," + in_min + "," + in_max + "," + out_min + "," + out_max + ",\"" + out_name + "\"," + method + "," + ValueOrPercent;
            //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\image_stretching.pro'");
            //oCom.ExecuteString(tmp3);
        }
Esempio n. 9
0
        private void btnSaveROI_Click(object sender, EventArgs e)
        {
            if (imageFilePath == "")
            {
                MessageBox.Show("没有分类图像!", "用户提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            string resultPath  = "";
            string txtfilePath = Application.StartupPath + "\\temp.txt";
            string executePath = Application.StartupPath;

            if (this.listView1.Items.Count == 0)
            {
                MessageBox.Show("当前没有需要保存的记录!", "用户提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else
            {
                SaveFileDialog sav = new SaveFileDialog();
                sav.Title      = "ROI保存";
                sav.DefaultExt = ".roi";
                if (sav.ShowDialog() == DialogResult.OK)
                {
                    resultPath = sav.FileName;

                    using (StreamWriter sw = new StreamWriter(txtfilePath))
                    {
                        sw.Write("");
                        for (int i = 0; i < listView1.Items.Count; i++)
                        {
                            int    colorindex = TransferColorToIDLIndexColor(listView1.Items[i].SubItems[3].Text);
                            string className  = listView1.Items[i].SubItems[1].Text;
                            string value      = listView1.Items[i].SubItems[4].Text + ":" + colorindex.ToString() + ":" + className;

                            sw.WriteLine(value);
                        }
                        sw.Close();
                    }

                    //记载IDL程序
                    COM_IDL_connectLib.COM_IDL_connect com = new COM_IDL_connectLib.COM_IDL_connect();
                    com.CreateObject(0, null, null);
                    com.ExecuteString(".compile '" + executePath + "\\createroi_polygon.pro'");
                    string executeStr = "createroi_polygon,'" + imageFilePath + "','" + txtfilePath + "','" + resultPath + "'";
                    com.ExecuteString(executeStr);
                    com.DestroyObject();
                    MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    bEditOrNot = false;
                }
            }
        }
Esempio n. 10
0
        private void button3_Click(object sender, EventArgs e)
        {
            FileStream   fs = File.Open("sharpen.txt", FileMode.Truncate, FileAccess.ReadWrite, FileShare.Read);
            StreamWriter sr = new StreamWriter(fs);

            sr.WriteLine(textBox1.Text); //开始写入值
            sr.WriteLine(textBox3.Text);
            sr.WriteLine(comboBox1.SelectedIndex);
            sr.WriteLine(textBox3.Text);
            sr.Close();
            fs.Close();
            MessageBox.Show("文件写入成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            try
            {
                COM_IDL_connectLib.ICOM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                oCom.CreateObject(0, 0, 0);
                //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\mytext.pro'");


                string temp = "cal_sharpen1,'";
                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\cal_sharpen1.pro'");
                oCom.ExecuteString(temp);
                MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);



                textBox1.Text = "";
                textBox3.Text = "";
                //comboBox1.Text = "";
                //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\cal_sharpen1.pro'");
                //string temp = "cal_sharpen1,'" + textBox1.Text + "'," + textBox3.Text + "'";
                // oCom.ExecuteString(temp);
                //MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //textBox1.Text = "";
                //textBox3.Text = "";
                //comboBox1.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 11
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                oCom.CreateObject(0, 0, 0);
                //oCom.ExecuteString(".RESET_SESSION");
                string temp = "TOAbrightnessTemperature,'";
                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\TOAbrightnessTemperature.pro'");
                oCom.ExecuteString(temp);

                MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            catch (Exception ex)
            {
                MessageBox.Show("运行失败或者部分文件运行失败,请查看运行结果!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            //string tmp3 = "image_stretching," + "\"" + input + "\"," + pos + "," + in_min + "," + in_max + "," + out_min + "," + out_max + ",\"" + out_name + "\"," + method + "," + ValueOrPercent;
            //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\image_stretching.pro'");
            //oCom.ExecuteString(tmp3);
        }
Esempio n. 12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cmbInputFile.Text == "" || txtInputROI.Text == "")
            {
                MessageBox.Show("输入为空,请选择输入文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (txtOutputImage.Visible == true && txtOutputImage.Text == "")
            {
                MessageBox.Show("输出为空,请选择输出文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else if (listBox1.SelectedItems.Count == 0)
            {
                MessageBox.Show("选择分类波段为空,请选择波段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else
            {
                COM_IDL_connectLib.COM_IDL_connect oComIDL = new COM_IDL_connectLib.COM_IDL_connect();
                oComIDL.CreateObject(0, 0, 0);
                oComIDL.ExecuteString(".RESET_SESSION");
                string str = ".compile '" + Application.StartupPath + "\\RSImage_parallelepiped.pro" + "'";
                oComIDL.ExecuteString(str);

                string inputfile = string.Empty;
                for (int i = 0; i < parallelepipedName.Count(); i++)
                {
                    string selectedFileName = cmbInputFile.SelectedItem.ToString().Trim();
                    if (selectedFileName == System.IO.Path.GetFileName(parallelepipedName[i]))
                    {
                        inputfile = parallelepipedName[i];
                    }
                    else
                    {
                        inputfile = cmbInputFile.Text.ToString().Trim();
                    }
                }

                string pos = "[";
                for (int i = 0; i < listBox1.SelectedIndices.Count; i++)
                {
                    pos += (int)listBox1.SelectedIndices[i] + ",";
                }
                pos = pos.Substring(0, pos.Length - 1) + "]";
                if (txtOutputRuleFile.Text == "")
                {
                    txtOutputRuleFile.Text = "0";
                }
                string str1 = "RSImage_parallelepiped" + ",'" + inputfile + "'" + "," + pos + ",'" + txtInputROI.Text + "'" + ",'" + txtOutputRuleFile.Text + "'" + ",'" + txtOutputImage.Text + "'";
                oComIDL.ExecuteString(str1);

                if (MessageBox.Show("分类成功,是否显示结果?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ShowResultOrNot = true;
                    this.Close();
                }
                else
                {
                    this.Close();
                }
            }
        }
Esempio n. 13
0
        private ProcessMode mode = ProcessMode.singleFile; // 默认为单文件模式

        private void FrmAutoSeg_Load(object sender, EventArgs e)
        {
            ocom = new COM_IDL_connectLib.COM_IDL_connect();
            ocom.CreateObject(0, 0, 0);
        }
Esempio n. 14
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtInputDirectory.Text == "")
            {
                MessageBox.Show("输入为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtBoxBias.Text == "" || txtBoxGain.Text == "")
            {
                MessageBox.Show("参数增益或者偏置为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!IsNumeric(txtBoxBias.Text.Trim()) || !IsNumeric(txtBoxGain.Text.Trim()))
            {
                MessageBox.Show("参数增益或者偏置格式不正确,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (radioButton2.Checked == true && txtOutputNamePlus.Text == "")
            {
                MessageBox.Show("输出的文件名后缀为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtOuputDirectory.Text == "")
            {
                MessageBox.Show("输出目录为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                double Gain = Convert.ToDouble(txtBoxGain.Text.Trim());
                double Bias = Convert.ToDouble(txtBoxBias.Text.Trim());

                //COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                oCom.CreateObject(0, 0, 0);
                //oCom.ExecuteString(".RESET_SESSION");

                if (radioButton1.Checked == true)
                {
                    txtOutputNamePlus.Text = "";
                }
                string temp = "radiometricCalibrationAbsolute20150306,'" + txtInputDirectory.Text + "','" + txtOuputDirectory.Text + "\\" + "','" + txtOutputNamePlus.Text + "'," + Gain + "," + Bias;
                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\radiometricCalibrationAbsolute20150306.pro'");
                oCom.ExecuteString(temp);
                //oCom.DestroyObject();

                MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //this.Close();
                //清空TextBox
                this.txtInputDirectory.Text = "";
                this.txtBoxBias.Text        = "";
                this.txtBoxGain.Text        = "";
                //this.txtInputPZ.Text = "";
                //this.txtInputZY.Text = "";
                this.txtOuputDirectory.Text    = "";
                this.radioButton1.Checked      = true;
                this.txtOutputNamePlus.Visible = false;
            }
            catch
            {
                MessageBox.Show("运行失败或部分文件运行失败,请查看运行结果!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //this.Close();
            }
            //string tmp3 = "image_stretching," + "\"" + input + "\"," + pos + "," + in_min + "," + in_max + "," + out_min + "," + out_max + ",\"" + out_name + "\"," + method + "," + ValueOrPercent;
            //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\image_stretching.pro'");
            //oCom.ExecuteString(tmp3);
        }
Esempio n. 15
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);
                }
            }
        }