private void testQRCodesOfSelectedLayerToolStripMenuItem_Click(object sender, EventArgs e) { try { IFeatureLayer mLayer; string mDistrictsShapefile = Application.StartupPath + "/GisData/districts.shp"; // Empty the list of processed QR-codes QRLib.ResetQRCodes(); var mQrTestResults = new List <QrTestResult>(); if (null == (mLayer = ExtFunctions.GetSelectedPointLayer(theMap))) { Log("The selected layer is not a point feature"); return; } else { dlgSaveFile.FileName = DateTime.Now.ToString("yyyyMMdd") + "-qrtest.log.xlsx"; dlgSaveFile.Title = "Please select a log file location (optional)"; dlgSaveFile.Filter = "Excel log files|*.log.xslx"; if (dlgSaveFile.ShowDialog() != System.Windows.Forms.DialogResult.OK) { QRLib.setLogFile(dlgSaveFile.FileName); } bool HasQRCode = false; foreach (var mColumn in mLayer.DataSet.GetColumns()) { if (mColumn.ColumnName == "QR_CODE") { HasQRCode = true; break; } } if (!HasQRCode) { Log("No QR code in selected layer"); } else { foreach (var mFeature in mLayer.DataSet.Features) { var mQRCode = mFeature.DataRow["QR_CODE"].ToString(); if (mFeature.FeatureType == FeatureType.Point) { DotSpatial.Topology.Point mPoint = (DotSpatial.Topology.Point)mFeature.BasicGeometry; var mResult = mQRCode.TestQRCode(mDistrictsShapefile, false, mPoint.X, mPoint.Y, true); if (mResult.HasIssue) { Log(mResult); } mQrTestResults.Add(mResult); } else { var mResult = mQRCode.TestQRCode( districtsShapefile: mDistrictsShapefile, checkForDuplicates: true); Log(mResult); mQrTestResults.Add(mResult); } Application.DoEvents(); } } using (var mCsvWriter = new CsvHelper.CsvWriter(new ExcelSerializer(dlgSaveFile.FileName))) { mCsvWriter.WriteRecords(mQrTestResults); Log("Processed " + mQrTestResults.Count + " records..."); Log("Wrote output to " + dlgSaveFile.FileName + "..."); Log("Operation completed"); } } } catch (Exception ex) { Log("Operation aborted: " + ex.Message); } }