private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; NeuralNet ooC = new NeuralNet(cmbInRaster.Text, txtROI.Text, actFun, float.Parse(spinContribution.EditValue.ToString()), float.Parse(spinTraingRate.EditValue.ToString()), float.Parse(spinMomentum.EditValue.ToString()), float.Parse(spinCriteria.EditValue.ToString()), hiddenLyr, maxSweep, minActThres, txtOut.Text); ooC.Execute(); BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "面向对象识别", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } catch (Exception ex) { //此处调用成功并写出结果后仍会抛出异常。 Log.WriteLog(typeof(frmSegmentation), ex); if (File.Exists(txtOut.Text.TrimEnd())) { FileInfo fInfo = new FileInfo(txtOut.Text.TrimEnd()); if (fInfo.Length / (1024 * 1024) > 1) { BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "中分宽幅影像分类结果", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } } else { XtraMessageBox.Show("分类失败:\r\n" + ex.Message, "提示信息"); } } finally { frmWait.Close(); } }
// //执行 // private void btnRun_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; //获取组合的条件运算公式,若检查失败,提示并返回 RasterMapAlgebraOp op = new RasterMapAlgebraOp(Canvas.instance.decisionTree.GetLayer(0).nodeList[0], DecisionTree.variableTable); string msg = ""; if (!op.CheckExp(Canvas.instance.decisionTree.GetLayer(0).nodeList[0], out msg)) { XtraMessageBox.Show(msg); return; } SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "保存结果文件"; dialog.Filter = "tiff(*.tif)|*.tif|All files(*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { op.Execute(dialog.FileName); } //元数据 if (_treeFile.Contains("gf4.tree")) { BLL.ProductMeta meta = new ProductMeta(dialog.FileName, "GF4", "", "长时间序列识别结果", "作物识别结果"); meta.WriteGeoMeta(); } else { BLL.ProductMeta meta = new ProductMeta(dialog.FileName, "", "", "决策树识别结果", "作物识别结果"); meta.WriteGeoMeta(); } //快视图 BLL.ProductQuickView view = new BLL.ProductQuickView(dialog.FileName); view.Create(); if (DialogResult.OK == XtraMessageBox.Show("分类完毕,是否加分类载结果?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { MAP.AddRasterFileToMap(dialog.FileName); } //this.Close(); } catch (Exception ex) { XtraMessageBox.Show("分类失败:" + ex.Message); } finally { frmWait.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; MaximumLikeHood ooC = new MaximumLikeHood(cmbInRaster.Text, txtROI.Text, txtOut.Text); ooC.Execute(); BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "面向对象识别", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } catch (Exception ex) { //此处调用成功并写出结果后IDL仍会抛出异常。通过判断输出文件确定是否成功 Log.WriteLog(typeof(frmSegmentation), ex); if (File.Exists(txtOut.Text.TrimEnd())) { BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "面向对象识别", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); FileInfo fInfo = new FileInfo(txtOut.Text.TrimEnd()); if (fInfo.Length / (1024 * 1024) > 1) { if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } } else { XtraMessageBox.Show("分类失败:\r\n" + ex.Message, "提示信息"); } } finally { frmWait.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { BLL.frmWaitDialog frmWait = new BLL.frmWaitDialog("参数检查...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; string msg = ""; SampleBLL.SpatialError spError = new SampleBLL.SpatialError(_classFile, _classValue, 45, txtOut.Text); if (!spError.ChkParam(out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "误差空间表达..."; if (spError.Execute(out msg)) { BLL.ProductMeta meta = new BLL.ProductMeta(txtOut.Text.TrimEnd(), "", "", "误差空间表达", "误差空间表达"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (DialogResult.OK == XtraMessageBox.Show("执行成功!是否加载结果?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { BLL.MapAPI.AddRasterFileToMap(txtOut.Text); } } else { XtraMessageBox.Show(msg); return; } } catch (Exception ex) { BLL.Log.WriteLog(typeof(frmSpatialError), ex); XtraMessageBox.Show(ex.Message); } finally { frmWait.Close(); } }
// OK private void siB_Ok_Click(object sender, EventArgs e) { WaitDialogForm frmWait = new WaitDialogForm("正在生成...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; SampleAduit Aduit = new SampleAduit(); if (cBEMethod.Text == "分层比率估计") { if (Aduit.RatioPreprocessing(cBSamplePopu.Text, cBESample.Text, cBESamSurvey.Text, cBEPopuLayer.Text, cBESamLayer.Text, cBEPopuBasis.Text, cBESampleClassic.Text, cBExport.Text, cBESamBasis.Text, cBECunName.Text)) { BLL.ProductMeta meta = new BLL.ProductMeta(cBExport.Text.TrimEnd(), "", "", "总体估计", "抽样和推算结果"); meta.WriteDocMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(cBExport.Text.TrimEnd()); view.Create(); MessageBox.Show("估算成功!"); ExportData.report = cBExport.Text; } } else { if (Aduit.ProbabilityProcessing(cBSamplePopu.Text, cBESample.Text, cBEPopuBasis.Text, cBEPopuLayer.Text, cBESamLayer.Text, cBESamBasis.Text, cBESamSurvey.Text, cBECunName.Text, cBExport.Text)) { MessageBox.Show("估算成功!"); ExportData.report = cBExport.Text; } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Log.WriteLog(typeof(frmSampleSimulation), ex); } finally { frmWait.Close(); this.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("GF3分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; ClassificationBLL.GF3Classification gf3Class = new ClassificationBLL.GF3Classification(_GF3Polarity, _GF1, _pixelROI, _segmentROI, _class); frmWait.Caption = "参数检查..."; string msg = ""; if (!gf3Class.ChkPara(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "极化特征区域统计..."; if (!gf3Class.ZonalPolarity(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "图斑尺度分类..."; Application.DoEvents(); if (!gf3Class.SVMFeature(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "像元尺度分类..."; Application.DoEvents(); if (!gf3Class.SVMPixel(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "计算图斑信息熵..."; Application.DoEvents(); if (!gf3Class.Entropy()) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "混合图斑修正..."; Application.DoEvents(); if (!gf3Class.ClassMerge()) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } BLL.ProductMeta meta = new ProductMeta(_class, "GF3", "", "图斑像元综合分类", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(_class); view.Create(); if (DialogResult.OK == XtraMessageBox.Show("分类完毕!是否加载结果?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { MapAPI.AddRasterFileToMap(_class); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } finally { frmWait.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { string msg = ""; BLL.frmWaitDialog frmWait = new BLL.frmWaitDialog("高光谱分类...", "提示信息"); try { ClassificationBLL.HyperSpeClassification hyperClass = new ClassificationBLL.HyperSpeClassification(_Hyper, _ROI, _Result); frmWait.Caption = "参数检查..."; Application.DoEvents(); if (!hyperClass.ChkPara(out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "数据降维..."; Application.DoEvents(); if (!hyperClass.BandReduce(out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "svm分类..."; Application.DoEvents(); if (!hyperClass.SVM(out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "信息熵计算..."; Application.DoEvents(); if (!hyperClass.Entropy(out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "阈值计算..."; Application.DoEvents(); if (!hyperClass.CalEntropyMean(out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "纯净像元提取..."; Application.DoEvents(); if (!hyperClass.ExtractPurePixel(out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "混合像元分解..."; Application.DoEvents(); if (!hyperClass.MergePixel(out msg)) { if (!msg.StartsWith("对 COM 组件的调用返回了错误")) { XtraMessageBox.Show(msg); return; } } BLL.ProductMeta meta = new BLL.ProductMeta(txtOut.Text.TrimEnd(), "GF5", "", "高光谱分类", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (DialogResult.OK == XtraMessageBox.Show("分类完毕,是否加载结果?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { BLL.MapAPI.AddRasterFileToMap(_Result); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return; } finally { frmWait.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { string msg = string.Empty; frmWaitDialog frmWait = new frmWaitDialog("正在执行...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; string fishNet = string.Empty; string firstUnit = this.cmbFirstUnit.Text; if (chkNewNet.Checked) { SampleData.firstSample = cmbFirstUnit.Text; SampleData.villageField = cmbVillage.Text; SampleData.layerField = cmbLayer.Text; SampleData.farmLand = cmbCultivation.Text; SampleData.ASCDL = cmbASCDL.Text; SampleData.targetCrop = cmbCrop.SelectedIndex; if (!SampleSelection.ChkData(out msg)) { XtraMessageBox.Show(msg); return; } //一级单元范围内创建渔网 frmWait.Caption = "创建二级抽样单元..."; fishNet = System.IO.Path.Combine(ConstDef.PATH_TEMP, DateTime.Now.ToFileTime().ToString() + ".shp"); int width = int.Parse(spinLength.EditValue.ToString()); int height = int.Parse(this.spinWidth.EditValue.ToString()); if (!EnviVars.instance.GpExecutor.CreateFishNet(firstUnit, width, height, fishNet, out msg)) { XtraMessageBox.Show(msg); return; } } else { SampleData.firstSample = cmbFirstUnit.Text; SampleData.villageField = cmbVillage.Text; SampleData.layerField = cmbLayer.Text; SampleData.farmLand = cmbCultivation.Text; SampleData.ASCDL = cmbASCDL.Text; SampleData.targetCrop = cmbCrop.SelectedIndex; if (!SampleSelection.ChkData(out msg)) { XtraMessageBox.Show(msg); return; } if (string.IsNullOrEmpty(cmbSecondUint.Text)) { XtraMessageBox.Show("二级抽样单元为空!"); return; } fishNet = cmbSecondUint.Text; } //抽选样本 frmWait.Caption = "抽选样本..."; SamplePara para = new SamplePara(); para.isNum = chkSampleNum.Checked; para.sampleNum = int.Parse(this.spinSampleNum.EditValue.ToString()); para.sampleRate = double.Parse(this.spinPercent.EditValue.ToString()) / 100; SampleSelection.Sampling(firstUnit, cmbVillage.Text, cmbLayer.Text, fishNet, cmbCultivation.Text, para, txtOut.Text); SampleFrame sampleFrame = new SampleFrame(); frmWait.Caption = "计算耕地面积..."; if (!SampleSelection.CalLandArea(txtOut.Text, SampleData.farmLand, out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "计算分类面积..."; if (!sampleFrame.CalClassArea(txtOut.Text, SampleData.ASCDL, SampleData.targetCrop, out msg)) { XtraMessageBox.Show(msg); return; } BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "二级样方", "抽样和面积推算结果"); meta.WriteShpMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); System.Windows.Forms.DialogResult dialogResult = XtraMessageBox.Show("抽样完成,是否加载结果?", "提示信息", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { MapAPI.AddShpFileToMap(txtOut.Text); this.Close(); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); Log.WriteLog(typeof(frmSymbolSelector), ex); } finally { frmWait.Close(); } }
private void siBOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cBESave.Text.Trim())) { MessageBox.Show("错误信息:\n输出结果的值:是必需的"); } else { frmWaitDialog frmWait = new frmWaitDialog("正在生成...", "提示信息"); try { DataTable ExtandTable = new DataTable(); SampleSimulation Sim = new SampleSimulation(); int sampleSum = SamplingSum - sampleNum; //第一次抽样,剩余的样本总量 int sampleExtandNum = 0; //扩充的样本量 //每次抽样得到的样本 sampleTable = SampleZones[gridView1.FocusedRowHandle]; if (string.IsNullOrEmpty(tEExtend.Text.Trim()) && string.IsNullOrEmpty(tEScale.Text.Trim())) { ExtandTable = sampleTable; } else { if (cEExtend.Checked == true) { sampleExtandNum = Convert.ToInt32(tEExtend.Text); } else { sampleExtandNum = Convert.ToInt32(sampleSum * (Convert.ToDouble(tEScale.Text) / 100)); } if (0 > sampleExtandNum || sampleExtandNum > sampleSum) { MessageBox.Show("输入的扩充样本量超出范围,请重新输入!"); return; } else if (sampleExtandNum == 0) { ExtandTable = sampleTable; } else { ExtandTable = Sim.ExtendSample(sampleSumTable, sampleTable, sampleExtandNum, cBELayer.Text, cBEBasis.Text); } } if (ExtandTable != null) { if (Sim.CreateShpFile(cBFile.Text, ExtandTable, cBESave.Text)) { BLL.ProductMeta meta = new ProductMeta(cBESave.Text.TrimEnd(), "", "", "一级样本村", "抽样和面积推算结果"); meta.WriteShpMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(cBESave.Text.TrimEnd()); view.Create(); System.Windows.Forms.DialogResult dialogResult = XtraMessageBox.Show("保存样本成功,是否加载结果?", "提示信息", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { //添加结果到主地图视图 IFeatureClass pFC = EngineAPI.OpenFeatureClass(cBESave.Text); if (pFC != null) { IFeatureLayer pFLyr = new FeatureLayerClass(); pFLyr.FeatureClass = pFC; pFLyr.Name = (pFC as IDataset).Name; MapAPI.UniqueValueRender(pFLyr, "KC"); EnviVars.instance.MapControl.AddLayer(pFLyr); } } } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Log.WriteLog(typeof(frmSampleSimulation), ex); } finally { frmWait.Close(); this.Close(); } } }