private void btnExecute_Click(object sender, EventArgs e) { string tblStr = cmbTable.Text; if (tblStr == "") { MessageBox.Show("You must specify a Table or Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lsbFields.Items.Count < 1 ) { MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lsbStats.Items.Count < 1) { MessageBox.Show("You must select at least on summary statistic", "No Stats", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } rasterUtil.localType[] statLst = new rasterUtil.localType[lsbStats.Items.Count]; ITable tbl = tblDic[tblStr]; string[] fldsArr = lsbFields.Items.Cast<string>().ToArray(); for (int i = 0; i < lsbStats.Items.Count; i++) { statLst[i] = (rasterUtil.localType)Enum.Parse(typeof(rasterUtil.localType),lsbStats.Items[i].ToString()); } this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Summarizing Fields. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { featureUtil ftrUtil = new featureUtil(); ftrUtil.summarizeAcrossFields(tbl, fldsArr, statLst, qWhere); if (mp != null && addToMap) { rp.Refresh(); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { rp.addMessage(ex.ToString()); } finally { Statistics.ModelHelper.closeProgressBar(); 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 summarizing" + t); rp.enableClose(); this.Close(); } }
private void btnExecute_Click(object sender, EventArgs e) { string rstNm = txtOutNm.Text; string funNm = cmbFunction.Text; int before = System.Convert.ToInt32(nudBefore.Value); int after = System.Convert.ToInt32(nudAfter.Value); if (rstNm == null || rstNm == "") { MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lsbRaster.Items.Count < 1) { MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (funNm == null || funNm == "") { MessageBox.Show("You must select at least on function", "No Function Selected", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IRasterBandCollection rsBc = new RasterClass(); for (int i = 0; i < lsbRaster.Items.Count; i++) { rsBc.AppendBands((IRasterBandCollection)rstDic[lsbRaster.Items[i].ToString()]); } IFunctionRasterDataset fdset = rsUtil.compositeBandFunction(rsBc); rasterUtil.localType op = (rasterUtil.localType)Enum.Parse(typeof(rasterUtil.localType), funNm); this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Calculating raster values. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { outraster = rsUtil.focalBandfunction(fdset, op, before, after); //rp.addMessage("Number of bands = " + ((IRasterBandCollection)outraster).Count); if (mp != null && addToMap) { rp.addMessage("Calculating Statistics..."); rp.Refresh(); IRasterLayer rstLyr = new RasterLayerClass(); //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset); rstLyr.CreateFromDataset((IRasterDataset)outraster); rstLyr.Name = rstNm; rstLyr.Visible = false; mp.AddLayer(rstLyr); } outrastername = rstNm; 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 Creating Rasters" + t); rp.enableClose(); this.Close(); } }
private void btnExecute_Click(object sender, EventArgs e) { string tblStr = cmbTable.Text; if (tblStr == "") { MessageBox.Show("You must specify a Table or Feature Class layer", "No Layer", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lsbFields.Items.Count < 1) { MessageBox.Show("You must select at least on Field to summarize", "No Fields", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lsbStats.Items.Count < 1) { MessageBox.Show("You must select at least on summary statistic", "No Stats", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } rasterUtil.localType[] statLst = new rasterUtil.localType[lsbStats.Items.Count]; ITable tbl = tblDic[tblStr]; string[] fldsArr = lsbFields.Items.Cast <string>().ToArray(); for (int i = 0; i < lsbStats.Items.Count; i++) { statLst[i] = (rasterUtil.localType)Enum.Parse(typeof(rasterUtil.localType), lsbStats.Items[i].ToString()); } this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Summarizing Fields. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { featureUtil ftrUtil = new featureUtil(); ftrUtil.summarizeAcrossFields(tbl, fldsArr, statLst, qWhere); if (mp != null && addToMap) { rp.Refresh(); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { rp.addMessage(ex.ToString()); } finally { Statistics.ModelHelper.closeProgressBar(); 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 summarizing" + t); rp.enableClose(); this.Close(); } }