private void btnSaveROI_Click(object sender, EventArgs e) { if (imageFilePath == "") { MessageBox.Show("没有分类图像!", "用户提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } string resultPath = ""; string txtfilePath = Application.StartupPath + "\\temp.txt"; string executePath = Application.StartupPath; if (this.listView1.Items.Count == 0) { MessageBox.Show("当前没有需要保存的记录!", "用户提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else { SaveFileDialog sav = new SaveFileDialog(); sav.Title = "ROI保存"; sav.DefaultExt = ".roi"; if (sav.ShowDialog() == DialogResult.OK) { resultPath = sav.FileName; using (StreamWriter sw = new StreamWriter(txtfilePath)) { sw.Write(""); for (int i = 0; i < listView1.Items.Count; i++) { int colorindex = TransferColorToIDLIndexColor(listView1.Items[i].SubItems[3].Text); string className = listView1.Items[i].SubItems[1].Text; string value = listView1.Items[i].SubItems[4].Text + ":" + colorindex.ToString() + ":" + className; sw.WriteLine(value); } sw.Close(); } //记载IDL程序 COM_IDL_connectLib.COM_IDL_connect com = new COM_IDL_connectLib.COM_IDL_connect(); com.CreateObject(0, null, null); com.ExecuteString(".compile '" + executePath + "\\createroi_polygon.pro'"); string executeStr = "createroi_polygon,'" + imageFilePath + "','" + txtfilePath + "','" + resultPath + "'"; com.ExecuteString(executeStr); com.DestroyObject(); MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); bEditOrNot = false; } } }
private void btnOK_Click(object sender, EventArgs e) { if (txtInputDirectory.Text == "" || txtInputPZ.Text == "" || txtInputZY.Text == "") { MessageBox.Show("输入为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (radioButton2.Checked == true && txtOutputNamePlus.Text == "") { MessageBox.Show("输出的文件名后缀为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtOuputDirectory.Text == "") { MessageBox.Show("输出目录为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect(); oCom.CreateObject(0, 0, 0); oCom.ExecuteString(".RESET_SESSION"); if (radioButton1.Checked == true) { txtOutputNamePlus.Text = ""; } string temp = "RADIOMETRIC_CALIBRATION_INTEGRATION,'" + txtInputDirectory.Text + "','" + txtInputPZ.Text + "','" + txtInputZY.Text + "','" + txtOuputDirectory.Text + "\\" + "','" + txtOutputNamePlus.Text + "'"; oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\RADIOMETRIC_CALIBRATION_INTEGRATION.pro'"); oCom.ExecuteString(temp); oCom.DestroyObject(); MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //this.Close(); txtOutputNamePlus.Visible = false; txtInputDirectory.Text = ""; txtInputPZ.Text = ""; txtInputZY.Text = ""; txtOuputDirectory.Text = ""; txtOutputNamePlus.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } //string tmp3 = "image_stretching," + "\"" + input + "\"," + pos + "," + in_min + "," + in_max + "," + out_min + "," + out_max + ",\"" + out_name + "\"," + method + "," + ValueOrPercent; //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\image_stretching.pro'"); //oCom.ExecuteString(tmp3); }
/// <summary> /// 运行主要代码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void okBtn_Click(object sender, EventArgs e) { string runStr = ""; if (mode == ProcessMode.singleFile) { inputPath = this.inputTB.Text; outputPath = this.outputTB.Text; runStr = "rgb_classify,'" + inputPath + "','" + outputPath + "','" + "singleFileMode'"; } else if (mode == ProcessMode.multiFile) { inputPath = this.inputFolderTB.Text + "\\"; outputPath = this.outputFolderTB.Text + "\\"; runStr = "rgb_classify,'" + inputPath + "','" + outputPath + "','" + "multiFileMode'"; } else { MessageBox.Show("出错了", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (runStr != "") { if (inputPath == "" || outputPath == "") { MessageBox.Show("请输入正确的路径", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string proPath = AppDomain.CurrentDomain.BaseDirectory + "rgb_classify.pro"; ocom.ExecuteString(@".compile '" + proPath + "'"); ocom.ExecuteString(runStr); ocom.ExecuteString(@".run"); ocom.DestroyObject(); int temp = System.Runtime.InteropServices.Marshal.ReleaseComObject(ocom); MessageBox.Show("finish"); this.Close(); } }
/// <summary> /// //销毁对象 /// </summary> public void Distroy() { oComIDL.DestroyObject(); BLL.EnviVars.instance.IdlModel = null; }