private void DoBandMath(IRasterDrawing drawing, string outFilename, string expression) { string extName = Path.GetExtension(outFilename).Replace(",", "").ToUpper(); if (extName == ".DAT") { extName = "MEM"; } else { extName = "LDF"; } IBandMathTool bandMathTool = new BandMathTool(); IProgressMonitor progress = _smartSession.ProgressMonitorManager.DefaultProgressMonitor; try { progress.Reset("正在执行波段运算...", 100); progress.Start(false); bandMathTool.Compute(drawing.DataProviderCopy, expression, extName, outFilename, (idx, tip) => { progress.Boost(idx, "正在执行波段运算..."); }); } finally { progress.Finish(); //if (MsgBox.ShowQuestionYesNo("波段运算已输出文件\"" + outFilename + "\",要打开文件吗?") == System.Windows.Forms.DialogResult.Yes) { OpenFileFactory.Open(outFilename); } } }
private void btnDoBandMath_Click(object sender, EventArgs e) { try { IBandMathTool bandMathTool = new BandMathTool(); using (IRasterDataProvider prd = GeoDataDriver.Open(txtFileName.Text) as IRasterDataProvider) { bandMathTool.Compute(prd, txtExpression.Text, cbDriverType.Text, txtOutFilename.Text, (idx, tip) => { Text = tip + ":" + idx.ToString() + "%"; }); } Text = "OK."; } catch (Exception ex) { MessageBox.Show(ex.Message); } }