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 }