Exemplo n.º 1
0
 /// <summary>
 /// 根据输入的landsat7头文件MTL.txt和保存的位置,完成辐射定标,返回结果文件的路径
 /// </summary>
 /// <param name="inputStr">landsat头文件MTL.txt的路径</param>
 /// <param name="outputStr">定标后的保存文件夹</param>
 /// <returns>完成定标后的可见光和红外保存的路径,返回为字符串数组</returns>
 public static string[] IdlRadCalibration(string inputStr, string outputStr)
 {
     string[] resultStr = new string[2];
     try
     {
         //初始化COM_IDL_connectLib对象
         COM_IDL_connectLib.COM_IDL_connect oComIdl = new COM_IDL_connectLib.COM_IDL_connectClass();
         oComIdl.CreateObject(0, 0, 0);
         //定义IDL下的变量
         oComIdl.SetIDLVariable("inputFile", inputStr);
         oComIdl.SetIDLVariable("outputFolder", outputStr);
         //编译IDL源码
         oComIdl.ExecuteString(".compile '" + Application.StartupPath +
                               "\\IDLProcess\\ENVIPROVESS_TMCAL_DOIT.pro'");
         oComIdl.ExecuteString("ENVIPROVESS_TMCAL_DOIT,inputFile,outputFolder,mb_output=mb_output,thre_output=thre_output");
         //获取IDL下的变量值
         object objMulOutputName  = oComIdl.GetIDLVariable("mb_output");
         object objThreOutputName = oComIdl.GetIDLVariable("thre_output");
         //设置返回值
         resultStr[0] = objThreOutputName.ToString();
         resultStr[1] = objMulOutputName.ToString();
         oComIdl      = null;
     }
     catch (Exception e)
     {
         MessageBox.Show("辐射定标处理过程出现错误" + e.ToString());
     }
     return(resultStr);
 }
Exemplo n.º 2
0
 private void bt_OK_Click(object sender, EventArgs e)
 {
     {
         if (comboBoxSelect.SelectedItem == null)
         {
             MessageBox.Show("文件不能为空!");
             return;
         }
         if (textBoxZoom.Text == "")
         {
             MessageBox.Show("请输入放缩比例!");
             return;
         }
         if (textBoxOutPut.Text == "")
         {
             MessageBox.Show("请选择输出路径!");
             return;
         }
         string strRasterPath = GetFileNameByLayer.GetRasterFileName(m_pMap.get_Layer(comboBoxSelect.SelectedIndex));
         string strOutPut     = textBoxOutPut.Text;
         //float zoom = Convert.ToSingle(textBoxZoom.Text);
         COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
         oComIDL.CreateObject(0, 0, 0);
         //执行重采样
         oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\object_envi_resize__define.pro'");
         oComIDL.ExecuteString(@"s = obj_new('object_envi_resize','" + strRasterPath + "','" + strOutPut + "')");
         oComIDL.ExecuteString("s.EXECUTERESIZE," + textBoxZoom.Text + "," + textBoxZoom.Text + "," + cobox_method.SelectedIndex.ToString());
         //oComIDL.ExecuteString("Obj_destroy,s");
         oComIDL.DestroyObject();
         //加载放大后影像
         OpenRaster(strOutPut);
         this.Close();
     }
 }
Exemplo n.º 3
0
        private void bt_OK_Click(object sender, EventArgs e)
        {
            if (comboBoxSelect.SelectedItem == null)
            {
                MessageBox.Show("文件不能为空!");
                return;
            }
            //pCreatRalyr = (IRasterLayer)pMap.get_Layer(comboBoxOpen.SelectedIndex);
            string strFilePath = GetFileNameByLayer.GetRasterFileName(m_pMap.get_Layer(comboBoxSelect.SelectedIndex));

            //初始化ENVI

            COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();

            oComIDL.CreateObject(0, 0, 0);

            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\green.pro'");
            oComIDL.ExecuteString(@"green,'" + strFilePath + "','" + textBoxOutPut.Text + "'");
            oComIDL.DestroyObject();
            openraster_1 openrasterfile = new openraster_1();

            openrasterfile.pMap = m_pMap;
            openrasterfile.OpenRaster(textBoxOutPut.Text);
            this.Close();
        }
Exemplo n.º 4
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.listViewImage.Items.Count <= 1)
            {
                MessageBox.Show("请至少选择两景输入影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            List <string> list = new List <string>();
            foreach (ListViewItem item in this.listViewImage.Items)
            {
                string s = item.SubItems[0].Text.Trim();
                list.Add(s);
            }
            string[] sFilename     = (string[])list.ToArray();
            string   sImageOutPath = this.txt_ImageOutPath.Text.Trim();
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\FileMosaic.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("FileSeeds", sFilename);
                oCom.SetIDLVariable("OutFile", sImageOutPath);
                oCom.SetIDLVariable("BACKGROUND", "0");
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("FileMosaic,FileSeeds,OutFile,/TIFF,Message=Message,BACKGROUND=0");
                object objArr = oCom.GetIDLVariable("Message");
                //MessageBox.Show(objArr.ToString());
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("影像拼接完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled         = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 5
0
        private void bt_calibration_Click(object sender, EventArgs e)
        {
            //初始化ENVI

            COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
            oComIDL.CreateObject(0, 0, 0);
            //执行辐射定标
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\cal_calibration.pro'");

            IRasterLayer pDataLayer;

            pDataLayer = (IRasterLayer)pMap.get_Layer(comboBoxOpen.SelectedIndex);

            //执行辐射定标
            if (SensorcomboBox.SelectedIndex == 0)
            {
                oComIDL.ExecuteString(@"cal_calibration,'" + pDataLayer.FilePath + "','" + textBoxOut.Text + "'");
            }
            else if (SensorcomboBox.SelectedIndex == 1)
            {
                oComIDL.ExecuteString(@"cal_calibration,'" + pDataLayer.FilePath + "','" + textBoxOut.Text + "'");
            }


            oComIDL.DestroyObject();
            //加载辐射定标后影像
            //openraster_1 openrasterfile = new openraster_1();
            //openrasterfile.pMap = pMap;
            //openrasterfile.OpenRaster(textBoxOut.Text);
            OpenRaster(textBoxOut.Text);
            this.Close();
        }
Exemplo n.º 6
0
        private void btn_classstatis_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断

            string sImageInput = this.txt_ImageInput.Text.Trim();
            if (sImageInput.Equals(""))
            {
                MessageBox.Show("请选择待分类统计影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            #endregion
            this.btn_classstatis.Enabled = false;

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\GetFileHist.pro";
            string sCSVPath  = FileManage.getApplicatonPath();
            string sFullName = sCSVPath + "AllSense.csv";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("File", sImageInput);
                oCom.SetIDLVariable("CSVPath", sFullName);
                //oCom.SetIDLVariable("Background", "0");
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                //执行计算
                oCom.ExecuteString("GetFileHist,file,CSVPath,DataArray=DataArray");
                //获取计算结果
                object objArr = oCom.GetIDLVariable("DataArray");
                //MessageBox.Show(objArr.ToString());
                if (objArr == null)
                {
                    MessageBox.Show("输入影像有误,请重新选择分类后影像!");
                    return;
                }
                //将对象转为一维数组
                string[] arrStatistic = (string[])objArr;
                //表头
                string[] arrName = { "作物类型", "面积(亩)", "所占比例(%)" };
                //数组行按","拆分后转DataTable
                DataTable dt = StringFormater.Convert(arrName, arrStatistic);
                //数据绑定
                BindDataSource(dt);
                oCom.DestroyObject();
                //MessageBox.Show("影像裁剪完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_classstatis.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
        private void btn_classstatis_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断

            string sImageInput = this.txt_ImageInput.Text.Trim();
            if (sImageInput.Equals(""))
            {
                MessageBox.Show("请选择待分类统计影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            #endregion
            this.btn_classstatis.Enabled = false;

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\GetFileHist.pro";
            string sCSVPath = FileManage.getApplicatonPath();
            string sFullName = sCSVPath + "AllSense.csv";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                    //初始化
                    oCom.CreateObject(0, 0, 0);
                    //参数设置
                    oCom.SetIDLVariable("File", sImageInput);
                    oCom.SetIDLVariable("CSVPath", sFullName);
                    //oCom.SetIDLVariable("Background", "0");
                    //编译IDL功能源码
                    oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                    //执行计算
                    oCom.ExecuteString("GetFileHist,file,CSVPath,DataArray=DataArray");
                    //获取计算结果
                    object objArr = oCom.GetIDLVariable("DataArray");
                    //MessageBox.Show(objArr.ToString());
                    if (objArr == null)
                    {
                        MessageBox.Show("输入影像有误,请重新选择分类后影像!");
                        return;
                    }
                    //将对象转为一维数组
                    string[] arrStatistic = (string[])objArr;
                    //表头
                    string[] arrName = { "作物类型","面积(亩)","所占比例(%)"};
                    //数组行按","拆分后转DataTable
                    DataTable dt = StringFormater.Convert(arrName, arrStatistic);
                   //数据绑定
                    BindDataSource(dt);
                    oCom.DestroyObject();
                //MessageBox.Show("影像裁剪完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_classstatis.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 8
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     #region 输入与输出路径条件判断
     if (this.TextBox_YieldPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输入单产影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.TextBox_OutputPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     #endregion
     #region 界面参数获取
     //单产文件
     List <string> list_Yield = new List <string>();
     foreach (ListViewItem item in this.listView_Yield.Items)
     {
         string s = this.TextBox_YieldPath.Text + "\\" + item.SubItems[0].Text.Trim();
         list_Yield.Add(s);
     }
     string[] sFilename_Yield = (string[])list_Yield.ToArray();
     //输出路径
     string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
     #endregion
     #region
     //IDLSav的路径
     string sIDLSavPath = FileManage.getApplicatonPath();
     sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_N.pro";
     COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
     try
     {
         //初始化
         oCom.CreateObject(0, 0, 0);
         //参数设置
         oCom.SetIDLVariable("YieldFilenames", sFilename_Yield);
         oCom.SetIDLVariable("OutputPath", sFilename_Output);
         //编译idl功能源码
         oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
         oCom.ExecuteString("Nutrient_N,YieldFilenames,OutputPath,Message=Message");
         object objArr = oCom.GetIDLVariable("Message");
         //返回错误消息
         if (objArr != null)
         {
             MessageBox.Show(objArr.ToString());
             oCom.DestroyObject();
             return;
         }
         oCom.DestroyObject();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     #endregion
 }
Exemplo n.º 9
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (m_pMap.get_Layer(comboBox2.SelectedIndex) is IRasterLayer)
            {
                MessageBox.Show("选择数据错误!");
                return;
            }
            if (!(m_pMap.get_Layer(comboBox1.SelectedIndex) is IRasterLayer))
            {
                MessageBox.Show("选择数据错误!");
                return;
            }
            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormDescription("正在裁剪.....");      // 信息
            //获得shp文件路径
            IDataLayer     pShpLayer;
            IDatasetName   pDatasetName;
            IWorkspaceName pWSName;

            pShpLayer    = (IDataLayer)m_pMap.get_Layer(comboBox2.SelectedIndex);
            pDatasetName = (IDatasetName)pShpLayer.DataSourceName;
            pWSName      = pDatasetName.WorkspaceName;
            string pFilePath = pWSName.PathName;
            string pFileName = pDatasetName.Name;
            string ShpPath   = pFilePath + "\\" + pFileName + ".shp";

            //获得栅格文件
            IRasterLayer pDataLayer;

            pDataLayer = (IRasterLayer)m_pMap.get_Layer(comboBox1.SelectedIndex);
            //初始化ENVI
            COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
            oComIDL.CreateObject(0, 0, 0);
            //这个功能需要调用ENVI
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\startENVI.pro'");
            oComIDL.ExecuteString("startEnvi,/ShowProcess");

            ////执行图像裁剪
            //编译裁剪程序
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\cal_subset.pro'");
            //执行裁剪
            oComIDL.ExecuteString(@"cal_subset,'" + pDataLayer.FilePath + "','" + ShpPath + "','" + textBox1.Text + "'");

            //结束ENVI
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\endENVI.pro'");
            oComIDL.ExecuteString("endEnvi,");
            //加载图像裁剪后影像
            openraster_1 openrasterfile = new openraster_1();

            openrasterfile.pMap = m_pMap;
            openrasterfile.OpenRaster(textBox1.Text);
            //OpenRaster(textBox1.Text);
            splashScreenManager1.CloseWaitForm();
            this.Close();
        }
Exemplo n.º 10
0
 private void bt_histogram_ok_Click(object sender, EventArgs e)
 {
     pCreatRalyr = (IRasterLayer)pMap.get_Layer(comboBoxOpen.SelectedIndex);
     //初始化ENVI
     COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
     oComIDL.CreateObject(0, 0, 0);
     //执行线性拉伸
     oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\item_b_3.pro'");
     oComIDL.ExecuteString(@"item_b_3,'" + pCreatRalyr.FilePath + "','" + textBoxOut.Text + "'");
     oComIDL.DestroyObject();
     //加载线性拉伸后影像
     OpenRaster(textBoxOut.Text);
     this.Close();
 }
Exemplo n.º 11
0
 public static void InitializeIDL()
 {
     COM_IDL_connectLib.COM_IDL_connectClass oComIDL = null;
     try
     {
         oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
         oComIDL.CreateObject(0, 0, 0);
         IDLManagerModule.GlobeIDLManager.IDLDrawWidget = oComIDL;
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("IDL初始化失败:" + ex.Message);
     }
 }
Exemplo n.º 12
0
 private void bt_princ_Click(object sender, EventArgs e)
 {
     splashScreenManager1.ShowWaitForm();
     pCreatRalyr = (IRasterLayer)pMap.get_Layer(comboBoxOpen.SelectedIndex);
     //初始化ENVI
     COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
     oComIDL.CreateObject(0, 0, 0);
     oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\example_pc_rotate.pro'");
     oComIDL.ExecuteString(@"example_pc_rotate,'" + pCreatRalyr.FilePath + "','" + textBoxOut.Text + "'");
     oComIDL.DestroyObject();
     OpenRaster(textBoxOut.Text);
     splashScreenManager1.CloseWaitForm();
     this.Close();
 }
Exemplo n.º 13
0
        private void barBtnItemRecode_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string sIDLSavPath = FileManage.getApplicatonPath();

            sIDLSavPath = sIDLSavPath + "IDLSav\\recode.sav";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            //初始化
            oCom.CreateObject(0, 0, 0);
            oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
            oCom.ExecuteString("RECODE");
            CodeListXtraForm clxf = new CodeListXtraForm();

            clxf.ShowDialog();
        }
Exemplo n.º 14
0
        private void btn_His_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_ObserPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入地面观测数据文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            //地面观测数据文件
            string sFilename_Obser = this.TextBox_ObserPath.Text.Trim();
            ObserFilename = sFilename_Obser;
            #region
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\Histogram.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            //try
            //{
            //初始化
            oCom.CreateObject(0, 0, 0);
            //参数设置

            oCom.SetIDLVariable("ObserFilename", sFilename_Obser);

            //编译idl功能源码
            oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
            oCom.ExecuteString("Histogram,ObserFilename,Message=Message");
            object objArr = oCom.GetIDLVariable("Message");
            ////返回错误消息
            //if (objArr != null)
            //{
            //    MessageBox.Show(objArr.ToString());
            //    oCom.DestroyObject();
            //    return;
            //}
            //oCom.DestroyObject();
            oCom.DestroyObject();
            HistogramShow vHistogramShow = new HistogramShow(this);
            vHistogramShow.ShowDialog();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
            #endregion
        }
Exemplo n.º 15
0
        private void btn_DisplayIDL_Click(object sender, EventArgs e)
        {
            Point pBtn           = this.pDisplayBtnIDL;
            Point pMain          = this.Location;
            int   HeightMainForm = this.Size.Height;
            int   x = (System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width) / 2;
            int   y = pMain.Y + pBtn.Y + HeightMainForm + 8;

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = Application.StartupPath;
            sIDLSavPath = sIDLSavPath.Substring(0, Application.StartupPath.LastIndexOf("bin"));
            sIDLSavPath = sIDLSavPath + "IDLSav\\common_viewer.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置

                oCom.SetIDLVariable("w_xoffset", x);
                oCom.SetIDLVariable("w_yoffset", y);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("COMMON_VIEWER,w_xoffset,w_yoffset");
                object objArr = oCom.GetIDLVariable("Message");
                ////返回错误消息
                //if (objArr != null)
                //{
                //    MessageBox.Show(objArr.ToString());
                //    oCom.DestroyObject();
                //    return;
                //}
                oCom.DestroyObject();
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 16
0
        private void bt_OK_Click(object sender, EventArgs e)
        {
            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormDescription("正在提取水体信息");
            pCreatRalyr = (IRasterLayer)pMap.get_Layer(combo_input.SelectedIndex);
            //初始化ENVI
            COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
            oComIDL.CreateObject(0, 0, 0);
            oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\math_doit_water.pro'");
            oComIDL.ExecuteString(@"math_doit_water,'" + pCreatRalyr.FilePath + "','" + tb_output.Text + "'");
            oComIDL.DestroyObject();
            openraster_1 openrasterfile = new openraster_1();

            openrasterfile.pMap = pMap;
            openrasterfile.OpenRaster(tb_output.Text);
            //OpenRaster(tb_output.Text);
            splashScreenManager1.CloseWaitForm();
            this.Close();
        }
Exemplo n.º 17
0
 /// <summary>
 /// 大气校正IDL处理函数,输入影像以及保存路径
 /// </summary>
 /// <param name="inputfile">输入影像</param>
 /// <param name="outputfile">保存路径</param>
 public static void  IdlAtmoCorrection(string inputfile, string outputfile)
 {
     //程序报错,但是结果正确,未找到错误源
     try
     {
         //初始化COM_IDL_connectLib对象
         COM_IDL_connectLib.COM_IDL_connect oComIdl = new COM_IDL_connectLib.COM_IDL_connectClass();
         oComIdl.CreateObject(0, 0, 0);
         //定义IDL下的变量
         oComIdl.SetIDLVariable("inputfile", inputfile);
         oComIdl.SetIDLVariable("outputfile", outputfile);
         //编译IDL源码
         oComIdl.ExecuteString(".compile '" + Application.StartupPath +
                               "\\IDLProcess\\cal_quc.pro'");
         oComIdl.ExecuteString("CAL_QUC,inputfile,outputfile");
         oComIdl = null;
     }
     catch (Exception e)
     {
         MessageBox.Show("大气校正处理过程出现错误:\n" + e.ToString());
     }
 }
Exemplo n.º 18
0
 private void LineStretch_Click(object sender, EventArgs e)
 {
     if (textBoxOut.Text == "")
     {
         MessageBox.Show("请选择图像保存路径!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
     }
     else
     {
         pCreatRalyr = (IRasterLayer)pMap.get_Layer(comboBoxOpen.SelectedIndex);
         //初始化ENVI
         COM_IDL_connectLib.COM_IDL_connectClass oComIDL = new COM_IDL_connectLib.COM_IDL_connectClass();
         oComIDL.CreateObject(0, 0, 0);
         //执行线性拉伸
         //编译IDL功能源码
         oComIDL.ExecuteString(".compile '" + System.IO.Directory.GetCurrentDirectory() + @"\cal_quac.pro'");
         oComIDL.ExecuteString(@"example_stretch_doit,'" + pCreatRalyr.FilePath + "','" + textBoxOut.Text + "'");
         oComIDL.DestroyObject();
         //加载线性拉伸后影像
         OpenRaster(textBoxOut.Text);
         this.Close();
     }
 }
Exemplo n.º 19
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.listViewImage.Items.Count <= 0)
            {
                MessageBox.Show("请选择输入影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cbx_SensorType.SelectedValue.ToString().Equals("请选择"))
            {
                MessageBox.Show("请选择传感器类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cbx_BandBlue.SelectedValue.ToString().Equals("请选择"))
            {
                MessageBox.Show("请选择蓝光波段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cbx_BandGreen.SelectedValue.ToString().Equals("请选择"))
            {
                MessageBox.Show("请选择绿光波段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cbx_BandRed.SelectedValue.ToString().Equals("请选择"))
            {
                MessageBox.Show("请选择红光波段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cbx_BandNInfrared.SelectedValue.ToString().Equals("请选择"))
            {
                MessageBox.Show("请选择近红外波段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }



            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            List <string> list = new List <string>();
            foreach (ListViewItem item in this.listViewImage.Items)
            {
                string s = item.SubItems[0].Text.Trim();
                list.Add(s);
            }
            string[] sFilename      = (string[])list.ToArray();
            string   sSensorType    = this.cbx_SensorType.SelectedValue.ToString();
            string   sBandBlue      = this.cbx_BandBlue.SelectedValue.ToString();
            string   sBandGreen     = this.cbx_BandGreen.SelectedValue.ToString();
            string   sBandRed       = this.cbx_BandRed.SelectedValue.ToString();
            string   sBandNInfrared = this.cbx_BandNInfrared.SelectedValue.ToString();

            string sImageOutPath = this.txt_ImageOutPath.Text.Trim();
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\openfile.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("filename", sFilename);
                oCom.SetIDLVariable("ImageOutPath", sIDLSavPath);
                oCom.SetIDLVariable("SensorType", sSensorType);
                oCom.SetIDLVariable("BandBlue", sBandBlue);
                oCom.SetIDLVariable("BandGreen", sBandGreen);
                oCom.SetIDLVariable("BandRed", sBandRed);
                oCom.SetIDLVariable("BandNInfrared", sBandNInfrared);

                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("OpenFile,filename,ImageOutPath=ImageOutPath,OutType,ErrorMSG=msg");
                object objArr = oCom.GetIDLVariable("msg");
                //MessageBox.Show(objArr.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                oCom.DestroyObject();

                MessageBox.Show("格式转换完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled         = true;
                this.btn_OpenOutPut.Visible = true;
            }

            #endregion
        }
Exemplo n.º 20
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            try
            {
                //initial
                COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
                oCom.CreateObject(0, 0, 0);
                oCom.SetIDLVariable("path_input", cmbox_input.Text);
                oCom.SetIDLVariable("path_output", cmbox_output.Text);
                string root_dir = Application.StartupPath + @"\IDL\data_clip_nc\";

                switch (cmbox_sea.SelectedIndex.ToString() + cmbox_element.SelectedIndex.ToString())
                {
                //CHINA--SST
                case "00":
                    oCom.ExecuteString(".compile '" + root_dir + "china_sst_from_global_nc.pro'");
                    oCom.ExecuteString("china_sst_from_global_nc, path_input, path_output");
                    break;

                //CHINA--CHL
                case "01":
                    oCom.ExecuteString(".compile '" + root_dir + "china_chl_from_global_nc.pro'");
                    oCom.ExecuteString("china_chl_from_global_nc, path_input, path_output");
                    break;

                //CHINA--RRS 645
                case "02":
                    oCom.ExecuteString(".compile '" + root_dir + "china_rrs_from_global_nc.pro'");
                    oCom.ExecuteString("china_rrs_from_global_nc, path_input, path_output");
                    break;

                //CHINA--PAR
                case "03":
                    oCom.ExecuteString(".compile '" + root_dir + "china_par_from_global_nc.pro'");
                    oCom.ExecuteString("china_par_from_global_nc, path_input, path_output");
                    break;

                //ZHEJIANG--SST
                case "10":
                    oCom.ExecuteString(".compile '" + root_dir + "zhejiang_sst_from_global_nc.pro'");
                    oCom.ExecuteString("zhejiang_sst_from_global_nc, path_input, path_output");
                    break;

                //NANHAI--SST
                case "20":
                    oCom.ExecuteString(".compile '" + root_dir + "nanhai_sst_from_global_nc.pro'");
                    oCom.ExecuteString("nanhai_sst_from_global_nc, path_input, path_output");
                    break;

                default:
                    break;
                }
                //Frm_Message frm = new Frm_Message();
                //frm.ShowDialog();
                //Thread.Sleep(500);
                //frm.Close();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 21
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_HJPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入环境星影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_ObserPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入地面观测数据文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_OutputPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            #region 界面参数获取
            //环境星影像文件
            List<string> list_HJ = new List<string>();
            foreach (ListViewItem item in this.listView_HJ.Items)
            {
                string s = this.TextBox_HJPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_HJ.Add(s);
            }
            string[] sFilename_HJ = (string[])list_HJ.ToArray();
            //地面观测数据文件
            string sFilename_Obser = this.TextBox_ObserPath.Text.Trim();
            ObserFilename = sFilename_Obser;
            //输出路径
            string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
            #endregion
            #region
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_OM.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("HJFilenames", sFilename_HJ);
                oCom.SetIDLVariable("ObserFilename", sFilename_Obser);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);
                oCom.SetIDLVariable("sHistogram", sHistogram);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                oCom.ExecuteString("Nutrient_OM,HJFilenames,ObserFilename,OutputPath,sHistogram,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    oCom.DestroyObject();
                    this.btn_OK.Enabled = true;
                    return;
                                   }
                oCom.DestroyObject();
                MessageBox.Show("土壤有机质计算完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled = true;
                this.btn_OutputPath.Visible = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 22
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_Filename_Cropland.Text.Equals(""))
            {
                MessageBox.Show("请选择输入作物分布图路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_Filename_harvest.Text.Equals(""))
            {
                MessageBox.Show("请选择输入单产路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DateTime dtRSData = this.dT_RSData.Value;

            if (dtRSData.Date == System.DateTime.Now.Date)
            {
                DialogResult dr;
                dr = MessageBox.Show("请确认单产数据监测时间是否是今天!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.No)
                {
                    return;
                }
            }
            if (this.txt_outFilename_N.Text.Equals(""))
            {
                MessageBox.Show("请选择输入碱解氮含量输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_outFilename_O.Text.Equals(""))
            {
                MessageBox.Show("请选择输入有机质含量输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string FilenameCropland = this.txt_Filename_Cropland.Text.Trim();
            string FilenameHharvest = this.txt_Filename_harvest.Text.Trim();
            string outFilenameN     = this.txt_outFilename_N.Text.Trim();


            string outFilenameO = this.txt_outFilename_O.Text.Trim();
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\harvest_to_soil_nitrogen.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("in_farm_land", FilenameCropland);
                oCom.SetIDLVariable("in_crop_harvest", FilenameHharvest);
                oCom.SetIDLVariable("out_dir_N", outFilenameN);
                oCom.SetIDLVariable("out_dir_O", outFilenameO);
                //编译idl功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("harvest_to_soil_nitrogen,in_farm_land,in_crop_harvest,out_dir_N,out_dir_O,message = message");
                object objArr = oCom.GetIDLVariable("message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("养分监测完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled         = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 23
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_ImageInput.Text.Equals(""))
            {
                MessageBox.Show("请选择输入影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sMinclass = this.txt_minclass.Text;
            if (sMinclass.Equals(""))
            {
                MessageBox.Show("请输入最小分类数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int nMinclass;
            bool bMinclass = int.TryParse(sMinclass, out nMinclass);
            if (bMinclass==false)
            {
                MessageBox.Show("最小分类数只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sMaxclass = this.txt_maxclass.Text;
            if (sMaxclass.Equals(""))
            {
                MessageBox.Show("请输入最大分类数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int nMaxclass;
            bool bMaxclass = int.TryParse(sMaxclass, out nMaxclass);
            if (bMaxclass == false)
            {
                MessageBox.Show("最大分类数只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (nMaxclass < nMinclass)
            {
                MessageBox.Show("最大分类数不能小于最小分类数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sIterations = this.txt_Iterations.Text;
            if (sIterations.Equals(""))
            {
                MessageBox.Show("请选择最大迭代次数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int nIterations;
            bool bIterations = int.TryParse(sIterations, out nIterations);
            if (bIterations == false)
            {
                MessageBox.Show("最大迭代次数只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sChangethersh = this.txt_changethersh.Text;
            if (sChangethersh.Equals(""))
            {
                MessageBox.Show("请输入变化阈值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int nChangethersh;
            bool bChangethersh = int.TryParse(sChangethersh, out nChangethersh);
            if (bChangethersh == false)
            {
                MessageBox.Show("变化阈值只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (nChangethersh < 0 && nChangethersh>100)
            {
                MessageBox.Show("变化阈值只能为0-100的数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            float fChangethersh=0.00f;
            bool f = float.TryParse(sChangethersh, out fChangethersh);
            fChangethersh = fChangethersh / 100;

            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string sFilename = this.txt_ImageInput.Text.Trim();
            string sImageOutPath = this.txt_ImageOutPath.Text.Trim();
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\class_isodata.pro";

            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("inputfile", sFilename);
                oCom.SetIDLVariable("MIN_CLASSES", sMinclass);
                oCom.SetIDLVariable("NUM_CLASSES", sMaxclass);
                oCom.SetIDLVariable("ITERATIONS", sIterations);
                oCom.SetIDLVariable("CHANGE_THRESH", fChangethersh);
                oCom.SetIDLVariable("outputDir", sImageOutPath);
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("CLASS_ISODATA,inputfile,outputDir,ITERATIONS = ITERATIONS,NUM_CLASSES = NUM_CLASSES,CHANGE_THRESH = CHANGE_THRESH,MIN_CLASSES = MIN_CLASSES,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //MessageBox.Show(objArr.ToString());
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("分类完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            #endregion
        }
Exemplo n.º 24
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_LowPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_HighPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_OutputPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            #region 界面参数获取
            //低空间分辨率影像路径
            string sFilename_LowPath = this.TextBox_LowPath.Text.Trim() + Path.DirectorySeparatorChar;
            //高空间分辨率影像路径
            string sFilename_HighPath = this.TextBox_HighPath.Text.Trim() + Path.DirectorySeparatorChar;
            //输出路径
            string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
            //融合方法
            string sMethod = this.cbx_Method.SelectedValue.ToString();
            //相似像元窗口大小
            string sWinSize = this.cbx_WinSize.SelectedValue.ToString();
            //基准影像窗口大小
            string sTWinSize = this.txt_TWinSize.Text.Trim();
            #endregion
            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\TSFusion.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("CFileDir", sFilename_LowPath);
                oCom.SetIDLVariable("FFileDir", sFilename_HighPath);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);
                oCom.SetIDLVariable("Method", sMethod);
                oCom.SetIDLVariable("WinSize", sWinSize);
                oCom.SetIDLVariable("TWinSize", sTWinSize);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("TSFusion,CFileDir,FFileDir,OutputPath,Method,WinSize,TWinSize,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    oCom.DestroyObject();
                    this.btn_OK.Enabled = true;
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("时空融合完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled = true;
                this.btn_OpenOutputPath.Visible = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 25
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_ImageInput.Text.Equals(""))
            {
                MessageBox.Show("请选择输入影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sMinclass = this.txt_minclass.Text;
            if (sMinclass.Equals(""))
            {
                MessageBox.Show("请输入最小分类数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int  nMinclass;
            bool bMinclass = int.TryParse(sMinclass, out nMinclass);
            if (bMinclass == false)
            {
                MessageBox.Show("最小分类数只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sMaxclass = this.txt_maxclass.Text;
            if (sMaxclass.Equals(""))
            {
                MessageBox.Show("请输入最大分类数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int  nMaxclass;
            bool bMaxclass = int.TryParse(sMaxclass, out nMaxclass);
            if (bMaxclass == false)
            {
                MessageBox.Show("最大分类数只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (nMaxclass < nMinclass)
            {
                MessageBox.Show("最大分类数不能小于最小分类数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string sIterations = this.txt_Iterations.Text;
            if (sIterations.Equals(""))
            {
                MessageBox.Show("请选择最大迭代次数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int  nIterations;
            bool bIterations = int.TryParse(sIterations, out nIterations);
            if (bIterations == false)
            {
                MessageBox.Show("最大迭代次数只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sChangethersh = this.txt_changethersh.Text;
            if (sChangethersh.Equals(""))
            {
                MessageBox.Show("请输入变化阈值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int  nChangethersh;
            bool bChangethersh = int.TryParse(sChangethersh, out nChangethersh);
            if (bChangethersh == false)
            {
                MessageBox.Show("变化阈值只能为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (nChangethersh < 0 && nChangethersh > 100)
            {
                MessageBox.Show("变化阈值只能为0-100的数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            float fChangethersh = 0.00f;
            bool  f             = float.TryParse(sChangethersh, out fChangethersh);
            fChangethersh = fChangethersh / 100;

            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string sFilename     = this.txt_ImageInput.Text.Trim();
            string sImageOutPath = this.txt_ImageOutPath.Text.Trim();
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\class_isodata.pro";

            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("inputfile", sFilename);
                oCom.SetIDLVariable("MIN_CLASSES", sMinclass);
                oCom.SetIDLVariable("NUM_CLASSES", sMaxclass);
                oCom.SetIDLVariable("ITERATIONS", sIterations);
                oCom.SetIDLVariable("CHANGE_THRESH", fChangethersh);
                oCom.SetIDLVariable("outputDir", sImageOutPath);
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("CLASS_ISODATA,inputfile,outputDir,ITERATIONS = ITERATIONS,NUM_CLASSES = NUM_CLASSES,CHANGE_THRESH = CHANGE_THRESH,MIN_CLASSES = MIN_CLASSES,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //MessageBox.Show(objArr.ToString());
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("分类完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled         = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            #endregion
        }
Exemplo n.º 26
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_ImageInput.Text.Equals(""))
            {
                MessageBox.Show("请输入影像目录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (this.txt_ReferenceImage.Text.Equals(""))
            {
                MessageBox.Show("请选择参考文件总目录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_winrar.Text.Equals(""))
            {
                MessageBox.Show("请选择解压缩文件WinRAR目录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string sInputDIR     = this.txt_ImageInput.Text.Trim();
            string sReferenceDIR = this.txt_ReferenceImage.Text.Trim();
            string sOuputDIR     = this.txt_ImageOutPath.Text.Trim();
            string sWinrarDIR    = this.txt_winrar.Text.Trim();
            sInputDIR     = StringFormater.GetMarkedDirectory(sInputDIR);
            sReferenceDIR = StringFormater.GetMarkedDirectory(sReferenceDIR);
            sOuputDIR     = StringFormater.GetMarkedDirectory(sOuputDIR);
            sWinrarDIR    = StringFormater.GetMarkedDirectory(sWinrarDIR);
            DirectoryInfo source = new DirectoryInfo(sInputDIR);
            if (!source.Exists)
            {
                MessageBox.Show("输入文件夹不存在:" + sInputDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            source = new DirectoryInfo(sReferenceDIR);
            if (!source.Exists)
            {
                MessageBox.Show("参考文件夹不存在:" + sInputDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            source = new DirectoryInfo(sOuputDIR);
            if (!source.Exists)
            {
                try
                {
                    source.Create();
                }
                catch (Exception)
                {
                    MessageBox.Show("输出文件夹不存在,而且不能创建:" + sOuputDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            source = new DirectoryInfo(sWinrarDIR);
            if (!source.Exists)
            {
                MessageBox.Show("Winrar文件夹不存在:" + sWinrarDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                string sWinrarEXE = StringFormater.GetMarkedDirectory(sWinrarDIR) + "WinRAR.exe";
                if (!System.IO.File.Exists(sWinrarEXE))
                {
                    MessageBox.Show("WinRAR.exe 不存在:" + sWinrarEXE, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\HJPreProSysWinV3_1.pro";
            int iACTFlag    = this.checkBox2.Checked ? 1 : 0;
            int iDeleteFlag = this.checkBox1.Checked ? 1 : 0;
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                //oCom.SetIDLVariable("InputDIR", sInputDIR);
                //oCom.SetIDLVariable("OutPutDIR", sOuputDIR);
                //oCom.SetIDLVariable("WinrarDIR", sWinrarDIR);
                //oCom.SetIDLVariable("ATCFlag", iACTFlag);
                //oCom.SetIDLVariable("DeleteFlag", iDeleteFlag);
                oCom.ExecuteString(".compile '" + sIDLSavPath);
                this.toolStripStatusLabel2.Text = "运行中,请等候";
                this.statusStrip1.Refresh();
                string comstr = "HJPreProSysWinV3_1,'" + sInputDIR + "','" + sOuputDIR + "','" + sWinrarDIR + "','" + sReferenceDIR + "'," + iACTFlag.ToString() + "," + iDeleteFlag.ToString();

                oCom.ExecuteString(comstr);
                //oCom.ExecuteString("HJPreProSysWinV3_1,InputDIR,OutPutDIR,WinrarDIR,ATCFlag,DeleteFlag");
                this.toolStripStatusLabel2.Text = "运行完成";
                this.statusStrip1.Refresh();

                oCom.DestroyObject();
                MessageBox.Show("几何纠正完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled         = true;
                this.btn_OpenOutPut.Visible = true;
                //写配置文件
                string       sCfgPath = System.AppDomain.CurrentDomain.BaseDirectory + "ExeConfig.txt";
                StreamWriter sw       = new StreamWriter(sCfgPath);
                sw.WriteLine(this.txt_ImageInput.Text);
                sw.WriteLine(this.txt_ReferenceImage.Text);
                sw.WriteLine(this.txt_winrar.Text);
                sw.WriteLine(this.txt_ImageOutPath.Text);
                sw.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 27
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.listViewImage.Items.Count <= 1)
            {
                MessageBox.Show("请至少选择两景输入影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            List<string> list = new List<string>();
            foreach (ListViewItem item in this.listViewImage.Items)
            {
                string s = item.SubItems[0].Text.Trim();
                list.Add(s);
            }
            string[] sFilename = (string[])list.ToArray();
            string sImageOutPath = this.txt_ImageOutPath.Text.Trim();
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\FileMosaic.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("FileSeeds", sFilename);
                oCom.SetIDLVariable("OutFile", sImageOutPath);
                oCom.SetIDLVariable("BACKGROUND", "0");
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("FileMosaic,FileSeeds,OutFile,/TIFF,Message=Message,BACKGROUND=0");
                object objArr = oCom.GetIDLVariable("Message");
                //MessageBox.Show(objArr.ToString());
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("影像拼接完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 28
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_inputfile_cropLand.Text.Equals(""))
            {
                MessageBox.Show("请选择输入作物分布图!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_inputfile_bio.Text.Equals(""))
            {
                MessageBox.Show("请选择输入每天生物量存储路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_outfilepath_har.Text.Equals(""))
            {
                MessageBox.Show("请选择输入输出文件名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.dT_maize_s.Value.Year != this.dT_maize_e.Value.Year)
            {
                MessageBox.Show("请选择输入正确的玉米年份!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.dT_bean_s.Value.Year != this.dT_bean_e.Value.Year)
            {
                MessageBox.Show("请选择输入正确的大豆年份!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.dT_wheat_s.Value.Year != this.dT_wheat_e.Value.Year)
            {
                MessageBox.Show("请选择输入正确的小麦年份!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.dT_wheat_s.Value.Year != this.dT_maize_s.Value.Year || this.dT_wheat_s.Value.Year != this.dT_bean_s.Value.Year)
            {
                MessageBox.Show("请选择输入相同的作物年份!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string txtinputfilecropLand = this.txt_inputfile_cropLand.Text.Trim();
            string txtinputfilebio = this.txt_inputfile_bio.Text.Trim();
            string txtoutfilepathhar = this.txt_outfilepath_har.Text.Trim();
            int[] maizeLive = new int[6];
            DateTime ymd0 = this.dT_maize_s.Value;
            maizeLive[0] = ymd0.Year;
            maizeLive[1] = ymd0.Month;
            maizeLive[2] = ymd0.Day;
            DateTime ymd1 = this.dT_maize_e.Value;
            maizeLive[3] = ymd1.Year;
            maizeLive[4] = ymd1.Month;
            maizeLive[5] = ymd1.Day;

            int[] beanLive = new int[6];
            DateTime ymd2 = this.dT_bean_s.Value;
            beanLive[0] = ymd2.Year;
            beanLive[1] = ymd2.Month;
            beanLive[2] = ymd2.Day;
            DateTime ymd3 = this.dT_bean_e.Value;
            beanLive[3] = ymd3.Year;
            beanLive[4] = ymd3.Month;
            beanLive[5] = ymd3.Day;

            int[] wheatLive = new int[6];
            DateTime ymd4 = this.dT_wheat_s.Value;
            wheatLive[0] = ymd4.Year;
            wheatLive[1] = ymd4.Month;
            wheatLive[2] = ymd4.Day;
            DateTime ymd5 = this.dT_wheat_e.Value;
            wheatLive[3] = ymd5.Year;
            wheatLive[4] = ymd5.Month;
            wheatLive[5] = ymd5.Day;
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\crop_harvest_all.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            Thread t = new Thread(new ThreadStart(thread1));
            t.Start();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("in_hx_crop_class",txtinputfilecropLand);
                oCom.SetIDLVariable("in_file_bio", txtinputfilebio);
                oCom.SetIDLVariable("maize_live_day", maizeLive);
                oCom.SetIDLVariable("bean_live_day", beanLive);
                oCom.SetIDLVariable("wheat_live_day", wheatLive);
                oCom.SetIDLVariable("out_filename", txtoutfilepathhar);
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("crop_harvest_all,in_hx_crop_class=in_hx_crop_class,in_file_bio=in_file_bio,maize_live_day=maize_live_day,bean_live_day=bean_live_day,wheat_live_day=wheat_live_day,out_filename=out_filename,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    return;
                }
                oCom.DestroyObject();
                t.Abort();
                MessageBox.Show("单产计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled = true;
                this.btn_OpenOutPut.Visible = true;

            }
            catch (Exception ex)
            {
                t.Abort();
                MessageBox.Show("计算失败,请联系系统管理员!");
            }

            #endregion
        }
Exemplo n.º 29
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_YieldPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入单产影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_CropPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入作物分布影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_OutputPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.listView_Yield.Items.Count != this.listView_Crop.Items.Count)
            {
                MessageBox.Show("输入的单产影像与作物分布影像文件数不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_OK.Enabled = false;
            #region 界面参数获取
            //单产文件
            List<string> list_Yield = new List<string>();
            foreach (ListViewItem item in this.listView_Yield.Items)
            {
                string s = this.TextBox_YieldPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_Yield.Add(s);
            }
            string[] sFilename_Yield = (string[])list_Yield.ToArray();
            //作物分布
            List<string> list_Crop = new List<string>();
            foreach (ListViewItem item in this.listView_Crop.Items)
            {
                string s = this.TextBox_CropPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_Crop.Add(s);
            }
            string[] sFilename_Crop = (string[])list_Crop.ToArray();
            //输出路径
            string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
            //方法
            string sMethod = this.cbx_Method.SelectedValue.ToString();
            //参数
            string HisPara1 = this.txt_HistPara1.Text;//组距
            string HisPara2 = this.cbx_N.SelectedValue.ToString();//[mu-N*sigma,mu+N*sigma]中的N
            string Percent = this.txt_Percent.Text;//百分数
            #endregion
            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            if (sMethod == "高斯拟合")
            {
                sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_gaussfit.pro";
                COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
                //try
                //{
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置

                oCom.SetIDLVariable("YieldFilenames", sFilename_Yield);
                oCom.SetIDLVariable("CropClassifyFilenames", sFilename_Crop);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);

                oCom.SetIDLVariable("HisPara1", HisPara1);
                oCom.SetIDLVariable("HisPara2", HisPara2);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("Nutrient_GaussFit,YieldFilenames,CropClassifyFilenames,OutputPath,HisPara1,HisPara2,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                ////返回错误消息
                //if (objArr != null)
                //{
                //    MessageBox.Show(objArr.ToString());
                //    oCom.DestroyObject();
                //    this.btn_OK.Enabled = true;
                //    return;
                //}
                oCom.DestroyObject();
                MessageBox.Show("单产直方图分析完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled = true;
                this.btn_OpenOutputPath.Visible = true;
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message);
                //}
            }
            else
            {
                sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_percent.pro";
                COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
                //try
                //{
                //初始化
                oCom.CreateObject(0, 0, 0);

                oCom.SetIDLVariable("YieldFilenames", sFilename_Yield);
                oCom.SetIDLVariable("CropClassifyFilenames", sFilename_Crop);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);

                oCom.SetIDLVariable("HisPara1", HisPara1);
                oCom.SetIDLVariable("HisPara2", Percent);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("Nutrient_Percent,YieldFilenames,CropClassifyFilenames,OutputPath,HisPara1,HisPara2,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    oCom.DestroyObject();
                    this.btn_OK.Enabled = true;
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("单产直方图分析完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled = true;
                this.btn_OpenOutputPath.Visible = true;
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message);
                //}
            }
            #endregion
        }
Exemplo n.º 30
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_ImageInput.Text.Equals(""))
            {
                MessageBox.Show("请输入影像目录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (this.txt_ReferenceImage.Text.Equals(""))
            {
                MessageBox.Show("请选择参考文件总目录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_winrar.Text.Equals(""))
            {
                MessageBox.Show("请选择解压缩文件WinRAR目录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string sInputDIR = this.txt_ImageInput.Text.Trim();
            string sReferenceDIR = this.txt_ReferenceImage.Text.Trim();
            string sOuputDIR = this.txt_ImageOutPath.Text.Trim();
            string sWinrarDIR = this.txt_winrar.Text.Trim();
            sInputDIR = StringFormater.GetMarkedDirectory(sInputDIR);
            sReferenceDIR=StringFormater.GetMarkedDirectory(sReferenceDIR);
            sOuputDIR = StringFormater.GetMarkedDirectory(sOuputDIR);
            sWinrarDIR = StringFormater.GetMarkedDirectory(sWinrarDIR);
            DirectoryInfo source = new DirectoryInfo(sInputDIR);
            if (!source.Exists)
            {
                MessageBox.Show("输入文件夹不存在:" + sInputDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            source = new DirectoryInfo(sReferenceDIR);
            if (!source.Exists)
            {
                MessageBox.Show("参考文件夹不存在:" + sInputDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            source = new DirectoryInfo(sOuputDIR);
            if (!source.Exists)
            {
                try
                {
                    source.Create();
                }
                catch (Exception)
                {
                    MessageBox.Show("输出文件夹不存在,而且不能创建:" + sOuputDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            source = new DirectoryInfo(sWinrarDIR);
            if (!source.Exists)
            {
                MessageBox.Show("Winrar文件夹不存在:" + sWinrarDIR, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                string sWinrarEXE = StringFormater.GetMarkedDirectory(sWinrarDIR) + "WinRAR.exe";
                if (!System.IO.File.Exists(sWinrarEXE))
                {
                    MessageBox.Show("WinRAR.exe 不存在:" + sWinrarEXE, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\HJPreProSysWinV3_1.pro";
            int iACTFlag = this.checkBox2.Checked ? 1 : 0;
            int iDeleteFlag = this.checkBox1.Checked ? 1 : 0;
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                //oCom.SetIDLVariable("InputDIR", sInputDIR);
                //oCom.SetIDLVariable("OutPutDIR", sOuputDIR);
                //oCom.SetIDLVariable("WinrarDIR", sWinrarDIR);
                //oCom.SetIDLVariable("ATCFlag", iACTFlag);
                //oCom.SetIDLVariable("DeleteFlag", iDeleteFlag);
                oCom.ExecuteString(".compile '" + sIDLSavPath);
                this.toolStripStatusLabel2.Text = "运行中,请等候";
                this.statusStrip1.Refresh();
                string comstr = "HJPreProSysWinV3_1,'" + sInputDIR + "','" + sOuputDIR + "','" + sWinrarDIR + "','" + sReferenceDIR + "'," + iACTFlag.ToString() + "," + iDeleteFlag.ToString();

                oCom.ExecuteString(comstr);
                //oCom.ExecuteString("HJPreProSysWinV3_1,InputDIR,OutPutDIR,WinrarDIR,ATCFlag,DeleteFlag");
                this.toolStripStatusLabel2.Text = "运行完成";
                this.statusStrip1.Refresh();

                oCom.DestroyObject();
                MessageBox.Show("几何纠正完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled = true;
                this.btn_OpenOutPut.Visible = true;
                //写配置文件
                string sCfgPath = System.AppDomain.CurrentDomain.BaseDirectory + "ExeConfig.txt";
                StreamWriter sw = new StreamWriter(sCfgPath);
                sw.WriteLine(this.txt_ImageInput.Text);
                sw.WriteLine(this.txt_ReferenceImage.Text);
                sw.WriteLine(this.txt_winrar.Text);
                sw.WriteLine(this.txt_ImageOutPath.Text);
                sw.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 31
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_filename_a0.Text.Equals(""))
            {
                MessageBox.Show("请选择输入气象数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_inputfile_lat.Text.Equals(""))
            {
                MessageBox.Show("请选择输入经纬度数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_inputfile_HJ.Text.Equals(""))
            {
                MessageBox.Show("请选择输入文件路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.dT_maize_s.Text.Equals(""))
            {
                MessageBox.Show("请选择输出作物生长起始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_outfilepath_bio.Text.Equals(""))
            {
                MessageBox.Show("请选择输出文件路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string txtfilenamea = this.txt_filename_a0.Text.Trim();
            string txtinputfilelat = this.txt_inputfile_lat.Text.Trim();
            string txtinputfileHJ = this.txt_inputfile_HJ.Text.Trim()+"\\";
            string txtoutfilepathbio = this.txt_outfilepath_bio.Text.Trim()+ "\\";
            int[] cropLive = new int [3];
            DateTime ymd0 = this.dT_maize_s.Value;
            cropLive[0] = ymd0.Year ;
            cropLive[1] = ymd0.Month ;
            cropLive[2] = ymd0.Day;
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\bio_hongxing.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("meteorology_data", txtfilenamea);
                oCom.SetIDLVariable("latitude", txtinputfilelat);
                oCom.SetIDLVariable("start_end_day", cropLive);
                oCom.SetIDLVariable("HJ_file", txtinputfileHJ);
                oCom.SetIDLVariable("out_bio", txtoutfilepathbio);
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("bio_hongxing,latitude=latitude, HJ_file=HJ_file, meteorology_data=meteorology_data, out_bio=out_bio,start_end_day=start_end_day, Message= Message");
                object objArr = oCom.GetIDLVariable("Message");
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    this.btn_ok.Enabled = true;
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("每日生物量计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            #endregion
        }
Exemplo n.º 32
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     #region 输入与输出路径条件判断
     if (this.TextBox_AssImg.Text.Equals(""))
     {
         MessageBox.Show("请选择输入待评价影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.TextBox_RefImg.Text.Equals(""))
     {
         MessageBox.Show("请选择输入参考影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.TextBox_OutputPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.listView_Ass.Items.Count != this.listView_Ref.Items.Count)
     {
         MessageBox.Show("输入的待评价影像和参考影像文件数不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (!this.cbx_AbsDiffAve_1.Checked && !this.cbx_EA_2.Checked && !this.cbx_Bias_3.Checked)
     {
         MessageBox.Show("请至少选择一项评价指标!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     #endregion
     this.btn_OK.Enabled = false;
     #region 界面参数获取
     //待评价影像
     List <string> list_Ass = new List <string>();
     foreach (ListViewItem item in this.listView_Ass.Items)
     {
         string s = this.TextBox_AssImg.Text + "\\" + item.SubItems[0].Text.Trim();
         list_Ass.Add(s);
     }
     string[] sFilename_Ass = (string[])list_Ass.ToArray();
     this.sGlobal_Filename_Ass = sFilename_Ass;
     //参考影像
     List <string> list_Ref = new List <string>();
     foreach (ListViewItem item in this.listView_Ref.Items)
     {
         string s = this.TextBox_RefImg.Text + "\\" + item.SubItems[0].Text.Trim();
         list_Ref.Add(s);
     }
     string[] sFilename_Ref = (string[])list_Ref.ToArray();
     //输出路径
     string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
     sGlobal_OutDir = sFilename_Output;
     //评价指标
     string[] sQuaArr = new string[] { "", "", "", "" };
     if (this.cbx_AbsDiffAve_1.Checked)
     {
         sQuaArr[0] = "TRUE";
     }
     if (this.cbx_EA_2.Checked)
     {
         sQuaArr[1] = "TRUE";
     }
     if (this.cbx_Bias_3.Checked)
     {
         sQuaArr[2] = "TRUE";
     }
     if (this.cbx_LinearFit_4.Checked)
     {
         sQuaArr[3] = "TRUE";
     }
     #endregion
     #region 调用IDL程序
     //IDLSav的路径
     string sIDLSavPath = FileManage.getApplicatonPath();
     sIDLSavPath = sIDLSavPath + "IDLSav\\TSFusionAss.pro";
     COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
     try
     {
         //初始化
         oCom.CreateObject(0, 0, 0);
         //参数设置
         oCom.SetIDLVariable("F_files", sFilename_Ass);
         oCom.SetIDLVariable("Ref_files", sFilename_Ref);
         oCom.SetIDLVariable("OutPutPath", sFilename_Output);
         oCom.SetIDLVariable("QuaArr", sQuaArr);
         //编译2次idl功能源码(奇怪啊,非得编译两次才能运行,无法理解)
         oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
         oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
         //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
         //执行
         oCom.ExecuteString("TSFusionAss,Ref_files,F_files,OutPutPath,QuaArr,Message=Message");
         object objArr = oCom.GetIDLVariable("Message");
         //返回错误消息
         if (objArr != null)
         {
             MessageBox.Show(objArr.ToString());
             oCom.DestroyObject();
             this.btn_OK.Enabled = true;
             return;
         }
         oCom.DestroyObject();
         MessageBox.Show("时空融合质量评价完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.btn_OK.Enabled             = true;
         this.btn_OpenOutputPath.Visible = true;
         QuaAssShowForm vQuaAssShowForm = new QuaAssShowForm(this);
         vQuaAssShowForm.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     #endregion
     this.btn_OK.Enabled = true;
 }
Exemplo n.º 33
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_YieldPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入单产影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_OutputPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            #region 界面参数获取
            //单产文件
            List<string> list_Yield = new List<string>();
            foreach (ListViewItem item in this.listView_Yield.Items)
            {
                string s = this.TextBox_YieldPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_Yield.Add(s);
            }
            string[] sFilename_Yield = (string[])list_Yield.ToArray();
            //输出路径
            string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
            #endregion
            #region
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_N.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("YieldFilenames", sFilename_Yield);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                oCom.ExecuteString("Nutrient_N,YieldFilenames,OutputPath,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    oCom.DestroyObject();
                    return;
                }
                oCom.DestroyObject();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 34
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.listViewImage.Items.Count <= 0)
            {
                MessageBox.Show("请选择输入影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if(this.txt_ReferenceImage.Text.Equals(""))
            {
                MessageBox.Show("请选择输出范围!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            List<string> list = new List<string>();
            foreach (ListViewItem item in this.listViewImage.Items)
            {
                string s = item.SubItems[0].Text.Trim();
                list.Add(s);
            }
            string[] sFilename = (string[])list.ToArray();
            string sReferenceImage = this.txt_ReferenceImage.Text.Trim();
            string sImageOutPath = this.txt_ImageOutPath.Text.Trim();

            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\FileCut.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                foreach (string sFile in sFilename)
                {
                    //初始化
                    oCom.CreateObject(0, 0, 0);
                    //参数设置
                    oCom.SetIDLVariable("File", sFile);
                    oCom.SetIDLVariable("ReferFile", sReferenceImage);
                    oCom.SetIDLVariable("OUTPUTDIR", sImageOutPath);
                    oCom.SetIDLVariable("TIFF", "/TIFF");
                    //string sName = sFilename[0].ToString();
                    string outputname = StringFormater.getNewName(sFile, sImageOutPath);
                    oCom.SetIDLVariable("OUTPUTFILE", outputname);
                    //编译IDL功能源码
                    oCom.ExecuteString(".compile '" + sIDLSavPath + "'");

                    oCom.ExecuteString("FileCut,File,OUTPUTDIR=OUTPUTDIR,ReferFile,/TIFF,OUTPUTFILE=OUTPUTFILE,Message=Message");

                    object objArr = oCom.GetIDLVariable("Message");
                    //MessageBox.Show(objArr.ToString());
                    if (objArr != null)
                    {
                        MessageBox.Show(objArr.ToString());
                        return;
                    }
                    oCom.DestroyObject();
                }
                MessageBox.Show("影像裁剪完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 35
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_filename_a0.Text.Equals(""))
            {
                MessageBox.Show("请选择输入气象数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_inputfile_lat.Text.Equals(""))
            {
                MessageBox.Show("请选择输入经纬度数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_inputfile_HJ.Text.Equals(""))
            {
                MessageBox.Show("请选择输入文件路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.dT_maize_s.Text.Equals(""))
            {
                MessageBox.Show("请选择输出作物生长起始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_outfilepath_bio.Text.Equals(""))
            {
                MessageBox.Show("请选择输出文件路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string   txtfilenamea      = this.txt_filename_a0.Text.Trim();
            string   txtinputfilelat   = this.txt_inputfile_lat.Text.Trim();
            string   txtinputfileHJ    = this.txt_inputfile_HJ.Text.Trim() + "\\";
            string   txtoutfilepathbio = this.txt_outfilepath_bio.Text.Trim() + "\\";
            int[]    cropLive          = new int [3];
            DateTime ymd0 = this.dT_maize_s.Value;
            cropLive[0] = ymd0.Year;
            cropLive[1] = ymd0.Month;
            cropLive[2] = ymd0.Day;
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\bio_hongxing.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("meteorology_data", txtfilenamea);
                oCom.SetIDLVariable("latitude", txtinputfilelat);
                oCom.SetIDLVariable("start_end_day", cropLive);
                oCom.SetIDLVariable("HJ_file", txtinputfileHJ);
                oCom.SetIDLVariable("out_bio", txtoutfilepathbio);
                //编译IDL功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("bio_hongxing,latitude=latitude, HJ_file=HJ_file, meteorology_data=meteorology_data, out_bio=out_bio,start_end_day=start_end_day, Message= Message");
                object objArr = oCom.GetIDLVariable("Message");
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    this.btn_ok.Enabled = true;
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("每日生物量计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled         = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            #endregion
        }
Exemplo n.º 36
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     #region 输入与输出路径条件判断
     if (this.TextBox_LowPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.TextBox_HighPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.TextBox_OutputPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     #endregion
     #region 界面参数获取
     //低空间分辨率影像路径
     string sFilename_LowPath = this.TextBox_LowPath.Text.Trim() + Path.DirectorySeparatorChar;
     //高空间分辨率影像路径
     string sFilename_HighPath = this.TextBox_HighPath.Text.Trim() + Path.DirectorySeparatorChar;
     //输出路径
     string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
     //融合方法
     string sMethod = this.cbx_Method.SelectedValue.ToString();
     //相似像元窗口大小
     string sWinSize = this.cbx_WinSize.SelectedValue.ToString();
     //基准影像窗口大小
     string sTWinSize = this.txt_TWinSize.Text.Trim();
     #endregion
     #region 调用IDL程序
     //IDLSav的路径
     string sIDLSavPath = FileManage.getApplicatonPath();
     sIDLSavPath = sIDLSavPath + "IDLSav\\TSFusion.pro";
     COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
     try
     {
         //初始化
         oCom.CreateObject(0, 0, 0);
         //参数设置
         oCom.SetIDLVariable("CFileDir", sFilename_LowPath);
         oCom.SetIDLVariable("FFileDir", sFilename_HighPath);
         oCom.SetIDLVariable("OutputPath", sFilename_Output);
         oCom.SetIDLVariable("Method", sMethod);
         oCom.SetIDLVariable("WinSize", sWinSize);
         oCom.SetIDLVariable("TWinSize", sTWinSize);
         //编译idl功能源码
         oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
         //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
         oCom.ExecuteString("TSFusion,CFileDir,FFileDir,OutputPath,Method,WinSize,TWinSize,Message=Message");
         object objArr = oCom.GetIDLVariable("Message");
         //返回错误消息
         if (objArr != null)
         {
             MessageBox.Show(objArr.ToString());
             oCom.DestroyObject();
             this.btn_OK.Enabled = true;
             return;
         }
         oCom.DestroyObject();
         MessageBox.Show("时空融合完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.btn_OK.Enabled             = true;
         this.btn_OpenOutputPath.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     #endregion
 }
Exemplo n.º 37
0
 private void barBtnItemRecode_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     string sIDLSavPath = FileManage.getApplicatonPath();
     sIDLSavPath = sIDLSavPath + "IDLSav\\recode.sav";
     COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
     //初始化
     oCom.CreateObject(0, 0, 0);
     oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
     oCom.ExecuteString("RECODE");
     CodeListXtraForm clxf = new CodeListXtraForm();
     clxf.ShowDialog();
 }
Exemplo n.º 38
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_LowPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_HighPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_OutputPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.listView_Low.Items.Count != this.listView_High.Items.Count)
            {
                MessageBox.Show("输入的高低分辨率影像文件数不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cbx_Method.SelectedValue.ToString() == "PBIM" && this.TextBox_HLRatio.Text.Equals(""))
            {
                MessageBox.Show("请输入低高空间分辨率影像分辨率比值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_OK.Enabled = false;
            #region 界面参数获取
            //低空间分辨率影像
            List<string> list_Low = new List<string>();
            foreach (ListViewItem item in this.listView_Low.Items)
            {
                string s = this.TextBox_LowPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_Low.Add(s);
            }
            string[] sFilename_Low = (string[])list_Low.ToArray();
            //高空间分辨率影像
            List<string> list_High = new List<string>();
            foreach (ListViewItem item in this.listView_High.Items)
            {
                string s = this.TextBox_HighPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_High.Add(s);
            }
            string[] sFilename_High = (string[])list_High.ToArray();
            //输出路径
            string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
            //方法
            string sMethod = this.cbx_Method.SelectedValue.ToString();
            //参数
            string[] sPara = new string[] { "", "", "", "", "", "" };
            if (sMethod == "PBIM")
            {
                sPara[0] = this.TextBox_HLRatio.Text.ToString();
            }
            else if (sMethod == "High Pass Filter")
            {
                sPara[1] = this.cbx_Filter.SelectedValue.ToString();
            }
            else if (sMethod == "Wavelet Transform")
            {
                sPara[2] = this.cbx_Basis.SelectedValue.ToString();
                sPara[3] = this.cbx_Hr.SelectedValue.ToString();
                sPara[4] = this.cbx_Lr.SelectedValue.ToString();
                sPara[5] = this.cbx_Level.SelectedValue.ToString();
            }
            #endregion
            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\SpecFusion.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置

                oCom.SetIDLVariable("FilenameLow", sFilename_Low);
                oCom.SetIDLVariable("FilenameHigh", sFilename_High);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);

                oCom.SetIDLVariable("OutQuaFile", sOutQuaFile);
                oCom.SetIDLVariable("para", sPara);
                oCom.SetIDLVariable("Method", sMethod);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("SpecFusion,FilenameLow,FilenameHigh,OutputPath,Method,OutQuaFile,para,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    oCom.DestroyObject();
                    this.btn_OK.Enabled = true;
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("光谱融合完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled = true;
                this.btn_OpenOutputPath.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 39
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.listViewImage.Items.Count <= 0)
            {
                MessageBox.Show("请选择输入影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (this.txt_ReferenceImage.Text.Equals(""))
            {
                MessageBox.Show("请选择输出范围!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_ImageOutPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            List <string> list = new List <string>();
            foreach (ListViewItem item in this.listViewImage.Items)
            {
                string s = item.SubItems[0].Text.Trim();
                list.Add(s);
            }
            string[] sFilename       = (string[])list.ToArray();
            string   sReferenceImage = this.txt_ReferenceImage.Text.Trim();
            string   sImageOutPath   = this.txt_ImageOutPath.Text.Trim();

            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\FileCut.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                foreach (string sFile in sFilename)
                {
                    //初始化
                    oCom.CreateObject(0, 0, 0);
                    //参数设置
                    oCom.SetIDLVariable("File", sFile);
                    oCom.SetIDLVariable("ReferFile", sReferenceImage);
                    oCom.SetIDLVariable("OUTPUTDIR", sImageOutPath);
                    oCom.SetIDLVariable("TIFF", "/TIFF");
                    //string sName = sFilename[0].ToString();
                    string outputname = StringFormater.getNewName(sFile, sImageOutPath);
                    oCom.SetIDLVariable("OUTPUTFILE", outputname);
                    //编译IDL功能源码
                    oCom.ExecuteString(".compile '" + sIDLSavPath + "'");

                    oCom.ExecuteString("FileCut,File,OUTPUTDIR=OUTPUTDIR,ReferFile,/TIFF,OUTPUTFILE=OUTPUTFILE,Message=Message");

                    object objArr = oCom.GetIDLVariable("Message");
                    //MessageBox.Show(objArr.ToString());
                    if (objArr != null)
                    {
                        MessageBox.Show(objArr.ToString());
                        return;
                    }
                    oCom.DestroyObject();
                }
                MessageBox.Show("影像裁剪完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled         = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 40
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_LowPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_HighPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入低空间分辨率影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_OutputPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.listView_Low.Items.Count != this.listView_High.Items.Count)
            {
                MessageBox.Show("输入的高低分辨率影像文件数不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cbx_Method.SelectedValue.ToString() == "PBIM" && this.TextBox_HLRatio.Text.Equals(""))
            {
                MessageBox.Show("请输入低高空间分辨率影像分辨率比值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_OK.Enabled = false;
            #region 界面参数获取
            //低空间分辨率影像
            List <string> list_Low = new List <string>();
            foreach (ListViewItem item in this.listView_Low.Items)
            {
                string s = this.TextBox_LowPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_Low.Add(s);
            }
            string[] sFilename_Low = (string[])list_Low.ToArray();
            //高空间分辨率影像
            List <string> list_High = new List <string>();
            foreach (ListViewItem item in this.listView_High.Items)
            {
                string s = this.TextBox_HighPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_High.Add(s);
            }
            string[] sFilename_High = (string[])list_High.ToArray();
            //输出路径
            string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
            //方法
            string sMethod = this.cbx_Method.SelectedValue.ToString();
            //参数
            string[] sPara = new string[] { "", "", "", "", "", "" };
            if (sMethod == "PBIM")
            {
                sPara[0] = this.TextBox_HLRatio.Text.ToString();
            }
            else if (sMethod == "High Pass Filter")
            {
                sPara[1] = this.cbx_Filter.SelectedValue.ToString();
            }
            else if (sMethod == "Wavelet Transform")
            {
                sPara[2] = this.cbx_Basis.SelectedValue.ToString();
                sPara[3] = this.cbx_Hr.SelectedValue.ToString();
                sPara[4] = this.cbx_Lr.SelectedValue.ToString();
                sPara[5] = this.cbx_Level.SelectedValue.ToString();
            }
            #endregion
            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\SpecFusion.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置

                oCom.SetIDLVariable("FilenameLow", sFilename_Low);
                oCom.SetIDLVariable("FilenameHigh", sFilename_High);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);

                oCom.SetIDLVariable("OutQuaFile", sOutQuaFile);
                oCom.SetIDLVariable("para", sPara);
                oCom.SetIDLVariable("Method", sMethod);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("SpecFusion,FilenameLow,FilenameHigh,OutputPath,Method,OutQuaFile,para,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    oCom.DestroyObject();
                    this.btn_OK.Enabled = true;
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("光谱融合完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled             = true;
                this.btn_OpenOutputPath.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 41
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.txt_Filename_Cropland.Text.Equals(""))
            {
                MessageBox.Show("请选择输入作物分布图路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_Filename_harvest.Text.Equals(""))
            {
                MessageBox.Show("请选择输入单产路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DateTime dtRSData = this.dT_RSData.Value;

            if (dtRSData.Date == System.DateTime.Now.Date)
            {
                DialogResult dr;
                dr = MessageBox.Show("请确认单产数据监测时间是否是今天!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.No)
                {
                    return;
                }
            }
            if (this.txt_outFilename_N.Text.Equals(""))
            {
                MessageBox.Show("请选择输入碱解氮含量输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.txt_outFilename_O.Text.Equals(""))
            {
                MessageBox.Show("请选择输入有机质含量输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_ok.Enabled = false;
            #region 界面参数获取
            string FilenameCropland = this.txt_Filename_Cropland.Text.Trim();
            string FilenameHharvest = this.txt_Filename_harvest.Text.Trim();
            string outFilenameN = this.txt_outFilename_N.Text.Trim();

            string outFilenameO = this.txt_outFilename_O.Text.Trim();
            #endregion

            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\harvest_to_soil_nitrogen.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            try
            {
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置
                oCom.SetIDLVariable("in_farm_land", FilenameCropland);
                oCom.SetIDLVariable("in_crop_harvest", FilenameHharvest);
                oCom.SetIDLVariable("out_dir_N", outFilenameN);
                oCom.SetIDLVariable("out_dir_O", outFilenameO);
                //编译idl功能源码
                oCom.ExecuteString(".compile '" + sIDLSavPath + "'");
                oCom.ExecuteString("harvest_to_soil_nitrogen,in_farm_land,in_crop_harvest,out_dir_N,out_dir_O,message = message");
                object objArr = oCom.GetIDLVariable("message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("养分监测完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_ok.Enabled = true;
                this.btn_OpenOutPut.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }
Exemplo n.º 42
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            try
            {
                //acquire the year_start, year_end and element name
                int      year_from = cmbox_year_from.SelectedIndex + 2002;
                int      year_to   = cmbox_year_to.SelectedIndex + 2002;
                string[] ele_names = { "cdom",   "chlor",  "chlocx", "flh",    "kd490",  "par", "pic", "poc",
                                       "rrs488", "rrs531", "rrs547", "rrs645", "rrs667", "sst" };
                string[] fre_names = { "DAY", "MON" };

                //initial
                COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
                oCom.CreateObject(0, 0, 0);
                oCom.SetIDLVariable("path_input", cmbox_input.Text);
                oCom.SetIDLVariable("path_output", cmbox_output.Text);
                oCom.SetIDLVariable("year_start", year_from);
                oCom.SetIDLVariable("year_end", year_to);
                oCom.SetIDLVariable("NAD_str", ele_names[cmbox_element.SelectedIndex]);
                string root_dir = Application.StartupPath + @"\IDL\modis_data_query\";

                switch (fre_names[cmbox_frequency.SelectedIndex])
                {
                case "DAY":
                    oCom.ExecuteString(String.Format(".compile '{0}nasa_data_day_query.pro'", root_dir));
                    oCom.ExecuteString(String.Format(".compile '{0}nasa_data_day_query_batch.pro'", root_dir));
                    if (cb_filesave.Checked)
                    {
                        oCom.ExecuteString("nasa_data_day_query_batch, path_input, path_output, year_start, year_end, NAD_str, /OF_SAVE");
                    }
                    else
                    {
                        oCom.ExecuteString("nasa_data_day_query_batch, path_input, path_output, year_start, year_end, NAD_str");
                    }
                    //get the file path
                    file_path  = oCom.GetIDLVariable("!fp").ToString();
                    ofile_path = oCom.GetIDLVariable("!fp_of").ToString();
                    break;

                case "MON":
                    oCom.ExecuteString(String.Format(".compile '{0}nasa_data_mon_query.pro'", root_dir));
                    oCom.ExecuteString(String.Format(".compile '{0}nasa_data_mon_query_batch.pro'", root_dir));
                    if (cb_filesave.Checked)
                    {
                        oCom.ExecuteString("nasa_data_mon_query_batch, path_input, path_output, year_start, year_end, NAD_str, /OF_SAVE");
                    }
                    else
                    {
                        oCom.ExecuteString("nasa_data_mon_query_batch, path_input, path_output, year_start, year_end, NAD_str");
                    }
                    //get the file path
                    file_path  = oCom.GetIDLVariable("!fp").ToString();
                    ofile_path = oCom.GetIDLVariable("!fp_of").ToString();
                    break;

                default:
                    break;
                }

                link_openFile.Visible   = true;
                link_openFolder.Visible = true;
                link_openOFile.Visible  = true;
                if (cb_filesave.Checked)
                {
                    link_openOFile.Enabled = true;
                }
                else
                {
                    link_openOFile.Enabled = false;
                }

                rtb_status.Text  = "处理完成!";
                rtb_status.Text += "\n查找信息:" + fre_names[cmbox_frequency.SelectedIndex] + "/" +
                                   ele_names[cmbox_element.SelectedIndex].ToUpper() + " (" + year_from.ToString() +
                                   "年-" + year_to.ToString() + "年" + ")";

                //功能调用完毕后销毁对象,否则容易报错,没来得及回收资源
                //oCom.DestroyObject();
                //Marshal.ReleaseComObject(oCom);

                DialogResult dr = MessageBox.Show("处理完成!是否打开生成文件?", "信息提示",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dr == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(file_path);
                    if (cb_filesave.Checked)
                    {
                        System.Diagnostics.Process.Start(ofile_path);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                rtb_status.Text         = "处理失败!";
                link_openFile.Visible   = false;
                link_openFolder.Visible = false;
                link_openOFile.Visible  = false;
            }
        }
Exemplo n.º 43
0
        private void btn_His_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_ObserPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入地面观测数据文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            //地面观测数据文件
            string sFilename_Obser = this.TextBox_ObserPath.Text.Trim();
            ObserFilename = sFilename_Obser;
            #region
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            sIDLSavPath = sIDLSavPath + "IDLSav\\Histogram.pro";
            COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
            //try
            //{
            //初始化
            oCom.CreateObject(0, 0, 0);
            //参数设置

            oCom.SetIDLVariable("ObserFilename", sFilename_Obser);

            //编译idl功能源码
            oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
            oCom.ExecuteString("Histogram,ObserFilename,Message=Message");
            object objArr = oCom.GetIDLVariable("Message");
            ////返回错误消息
            //if (objArr != null)
            //{
            //    MessageBox.Show(objArr.ToString());
            //    oCom.DestroyObject();
            //    return;
            //}
            //oCom.DestroyObject();
            oCom.DestroyObject();
            HistogramShow vHistogramShow = new HistogramShow(this);
            vHistogramShow.ShowDialog();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
            #endregion
        }
Exemplo n.º 44
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            #region 输入与输出路径条件判断
            if (this.TextBox_YieldPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入单产影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_CropPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入作物分布影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.TextBox_OutputPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.listView_Yield.Items.Count != this.listView_Crop.Items.Count)
            {
                MessageBox.Show("输入的单产影像与作物分布影像文件数不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion
            this.btn_OK.Enabled = false;
            #region 界面参数获取
            //单产文件
            List <string> list_Yield = new List <string>();
            foreach (ListViewItem item in this.listView_Yield.Items)
            {
                string s = this.TextBox_YieldPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_Yield.Add(s);
            }
            string[] sFilename_Yield = (string[])list_Yield.ToArray();
            //作物分布
            List <string> list_Crop = new List <string>();
            foreach (ListViewItem item in this.listView_Crop.Items)
            {
                string s = this.TextBox_CropPath.Text + "\\" + item.SubItems[0].Text.Trim();
                list_Crop.Add(s);
            }
            string[] sFilename_Crop = (string[])list_Crop.ToArray();
            //输出路径
            string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
            //方法
            string sMethod = this.cbx_Method.SelectedValue.ToString();
            //参数
            string HisPara1 = this.txt_HistPara1.Text;             //组距
            string HisPara2 = this.cbx_N.SelectedValue.ToString(); //[mu-N*sigma,mu+N*sigma]中的N
            string Percent  = this.txt_Percent.Text;               //百分数
            #endregion
            #region 调用IDL程序
            //IDLSav的路径
            string sIDLSavPath = FileManage.getApplicatonPath();
            if (sMethod == "高斯拟合")
            {
                sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_gaussfit.pro";
                COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
                //try
                //{
                //初始化
                oCom.CreateObject(0, 0, 0);
                //参数设置

                oCom.SetIDLVariable("YieldFilenames", sFilename_Yield);
                oCom.SetIDLVariable("CropClassifyFilenames", sFilename_Crop);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);

                oCom.SetIDLVariable("HisPara1", HisPara1);
                oCom.SetIDLVariable("HisPara2", HisPara2);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("Nutrient_GaussFit,YieldFilenames,CropClassifyFilenames,OutputPath,HisPara1,HisPara2,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                ////返回错误消息
                //if (objArr != null)
                //{
                //    MessageBox.Show(objArr.ToString());
                //    oCom.DestroyObject();
                //    this.btn_OK.Enabled = true;
                //    return;
                //}
                oCom.DestroyObject();
                MessageBox.Show("单产直方图分析完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled             = true;
                this.btn_OpenOutputPath.Visible = true;
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message);
                //}
            }
            else
            {
                sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_percent.pro";
                COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
                //try
                //{
                //初始化
                oCom.CreateObject(0, 0, 0);

                oCom.SetIDLVariable("YieldFilenames", sFilename_Yield);
                oCom.SetIDLVariable("CropClassifyFilenames", sFilename_Crop);
                oCom.SetIDLVariable("OutputPath", sFilename_Output);

                oCom.SetIDLVariable("HisPara1", HisPara1);
                oCom.SetIDLVariable("HisPara2", Percent);
                //编译idl功能源码
                oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
                //oCom.ExecuteString("restore,\'" + sIDLSavPath + "\'");
                oCom.ExecuteString("Nutrient_Percent,YieldFilenames,CropClassifyFilenames,OutputPath,HisPara1,HisPara2,Message=Message");
                object objArr = oCom.GetIDLVariable("Message");
                //返回错误消息
                if (objArr != null)
                {
                    MessageBox.Show(objArr.ToString());
                    oCom.DestroyObject();
                    this.btn_OK.Enabled = true;
                    return;
                }
                oCom.DestroyObject();
                MessageBox.Show("单产直方图分析完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btn_OK.Enabled             = true;
                this.btn_OpenOutputPath.Visible = true;
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message);
                //}
            }
            #endregion
        }
Exemplo n.º 45
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     #region 输入与输出路径条件判断
     if (this.TextBox_HJPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输入环境星影像!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.TextBox_ObserPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输入地面观测数据文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.TextBox_OutputPath.Text.Equals(""))
     {
         MessageBox.Show("请选择输出影像路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     #endregion
     #region 界面参数获取
     //环境星影像文件
     List <string> list_HJ = new List <string>();
     foreach (ListViewItem item in this.listView_HJ.Items)
     {
         string s = this.TextBox_HJPath.Text + "\\" + item.SubItems[0].Text.Trim();
         list_HJ.Add(s);
     }
     string[] sFilename_HJ = (string[])list_HJ.ToArray();
     //地面观测数据文件
     string sFilename_Obser = this.TextBox_ObserPath.Text.Trim();
     ObserFilename = sFilename_Obser;
     //输出路径
     string sFilename_Output = this.TextBox_OutputPath.Text.Trim();
     #endregion
     #region
     //IDLSav的路径
     string sIDLSavPath = FileManage.getApplicatonPath();
     sIDLSavPath = sIDLSavPath + "IDLSav\\nutrient_OM.pro";
     COM_IDL_connectLib.COM_IDL_connectClass oCom = new COM_IDL_connectLib.COM_IDL_connectClass();
     try
     {
         //初始化
         oCom.CreateObject(0, 0, 0);
         //参数设置
         oCom.SetIDLVariable("HJFilenames", sFilename_HJ);
         oCom.SetIDLVariable("ObserFilename", sFilename_Obser);
         oCom.SetIDLVariable("OutputPath", sFilename_Output);
         oCom.SetIDLVariable("sHistogram", sHistogram);
         //编译idl功能源码
         oCom.ExecuteString(".compile -v '" + sIDLSavPath + "'");
         oCom.ExecuteString("Nutrient_OM,HJFilenames,ObserFilename,OutputPath,sHistogram,Message=Message");
         object objArr = oCom.GetIDLVariable("Message");
         //返回错误消息
         if (objArr != null)
         {
             MessageBox.Show(objArr.ToString());
             oCom.DestroyObject();
             this.btn_OK.Enabled = true;
             return;
         }
         oCom.DestroyObject();
         MessageBox.Show("土壤有机质计算完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.btn_OK.Enabled         = true;
         this.btn_OutputPath.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     #endregion
 }