private void btnExecute_Click(object sender, EventArgs e) { string inRst1Nm = cmbRaster.Text; string inFocalStat = cmbFocalStat.Text; string outNmRst = txtOutName.Text; if (inRst1Nm == "" || inRst1Nm == null) { MessageBox.Show("You must specify an input raster for In Rasterr", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (inFocalStat == "" || inFocalStat == null) { MessageBox.Show("You must specify an Focal Statistic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (outNmRst == "" || outNmRst == null) { MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } HashSet <string> offsets = new HashSet <string>(); for (int i = 0; i < dgvAzDs.RowCount; i++) { string az = dgvAzDs[0, i].Value.ToString(); string ds = dgvAzDs[1, i].Value.ToString(); offsets.Add(az + ";" + ds); } if (offsets.Count < 1) { MessageBox.Show("Nothing specified for offset!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IRaster rs1 = rstDic[inRst1Nm]; IRaster outRs = null; rasterUtil.focalType fcType = (rasterUtil.focalType)Enum.Parse(typeof(rasterUtil.focalType), inFocalStat); esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Creating Raster. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; try { outRs = rsUtil.createRaster(rsUtil.calcFocalSampleFunction(rs1, offsets, fcType)); outraster = outRs; outrastername = outNmRst; if (mp != null && addToMap) { rp.Show(); rp.Refresh(); IRasterLayer rsLyr = new RasterLayerClass(); rsLyr.CreateFromRaster(outraster); rsLyr.Name = OutRasterName; rsLyr.Visible = false; mp.AddLayer(rsLyr); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { rp.addMessage(ex.ToString()); } finally { DateTime dt2 = DateTime.Now; TimeSpan ts = dt2.Subtract(dt); string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds ."; rp.stepPGBar(100); rp.addMessage("Finished Focal Sample Analysis" + t); rp.enableClose(); this.Close(); } }