public object ESRI_CoordSys_Remove(ResultBuffer rb) { object result; try { Document document = AfaDocData.ActiveDocData.Document; int num = AfaDocData.ActiveDocData.DocDataset.MapServices.Count + AfaDocData.ActiveDocData.DocDataset.ImageServices.Count + AfaDocData.ActiveDocData.DocDataset.FeatureServices.Count; if (num > 0) { result = null; } else { string value = MSCPrj.ReadWKT(document); if (string.IsNullOrEmpty(value)) { result = null; } else { MSCPrj.RemoveWKT(document); result = LspUtil.LispTrue; } } } catch { result = null; } return(result); }
public void RequestNewRasterNow(Extent newExtent) { this.CancelRequests = true; AGSExportOptions aGSExportOptions = (AGSExportOptions)Utility.CloneObject(this.ExportOptions); aGSExportOptions.BoundingBox = newExtent; System.Drawing.Size size = Autodesk.AutoCAD.ApplicationServices.Application.ToSystemDrawingSize(this.ParentDataset.ParentDocument.Window.DeviceIndependentSize); this.ExportOptions.Width = size.Width; this.ExportOptions.Height = size.Height; aGSExportOptions.OutputFile = Utility.TemporaryFilePath(); try { string text = MSCPrj.ReadWKT(this.ParentDataset.ParentDocument); if (!string.IsNullOrEmpty(text)) { aGSExportOptions.OutputWKT = text; } } catch { } newExtent.SpatialReference = aGSExportOptions.OutputWKT; this.SetParentLayerVisibility(); this.PendingImage = null; this.ParentService.ExportMapNow(aGSExportOptions, new ExportImageEventHandler(this.UpdateExistingRaster), this.LastRequested); this.LastRequested = (AGSExportOptions)Utility.CloneObject(aGSExportOptions); this.CancelRequests = false; }
public Extent(Document doc) { Point3d point3d; Point3d point3d2; if (DocUtil.GetActiveExtents(doc, out point3d, out point3d2)) { Point3d point3d3 = new Point3d(point3d.X, point3d.Y, 0.0); Point3d point3d4 = new Point3d(point3d2.X, point3d2.Y, 0.0); this.XMin = new double?(point3d3.X); this.YMin = new double?(point3d3.Y); this.XMax = new double?(point3d4.X); this.YMax = new double?(point3d4.Y); try { this.SpatialReference = AfaDocData.ActiveDocData.DocPRJ.WKT; return; } catch { try { this.SpatialReference = MSCPrj.ReadWKT(doc); } catch { this.SpatialReference = ""; } return; } } this.XMin = (this.XMax = (this.YMin = (this.YMax = new double?(0.0)))); this.SpatialReference = ""; }
private bool AddServiceFromURL(string url) { if (null == Application.DocumentManager.MdiActiveDocument) { return(false); } Mouse.OverrideCursor = Cursors.Wait; AGSMapService aGSMapService = AGSMapService.BuildMapServiceFromURL(null, url); if (aGSMapService == null) { return(false); } string value = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument); if (string.IsNullOrEmpty(value)) { value = MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, aGSMapService.GetWKT()); } if (!aGSMapService.AddService()) { Mouse.OverrideCursor = null; return(false); } Mouse.OverrideCursor = null; return(true); }
public static void AssignPRJDialog() { string value = MSCPrj.ReadWKT(AfaDocData.ActiveDocData.Document); if (!string.IsNullOrEmpty(value) && AfaDocData.ActiveDocData.DocDataset.FeatureServices.Count > 0) { AfaDocData.ActiveDocData.Document.Editor.WriteMessage(AfaStrings.ChangeCoordSysErrorFeatureServicesPresent + "\n"); return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = AfaStrings.OpenCoordinateSystemSource; openFileDialog.Filter = "PRJ|*.prj|DWG|*.dwg|DXF|*.dxf"; openFileDialog.InitialDirectory = MSCPrj.LocatePRJDirectory(); openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; bool flag = false; string text = ""; do { if (openFileDialog.ShowDialog() == true) { string a = Path.GetExtension(openFileDialog.FileName).ToLower(); try { if (a == ".dwg" || a == ".dxf") { Database database = new Database(false, true); database.ReadDwgFile(openFileDialog.FileName, (FileOpenMode)3, true, ""); text = MSCPrj.ReadWKT(database); if (string.IsNullOrEmpty(text)) { ErrorReport.ShowErrorMessage(AfaStrings.NoValidCoordinateSystemFoundIn + openFileDialog.FileName); } } else if (a == ".prj") { text = File.ReadAllText(openFileDialog.FileName); } } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorReadingWKTStringFrom + openFileDialog.FileName); } if (!string.IsNullOrEmpty(text)) { flag = true; MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, text); } } else { flag = true; } }while (!flag); }
public static string CurrentWKT(Document doc, string defaultWKT) { string text = MSCPrj.ReadWKT(doc); if (string.IsNullOrEmpty(text)) { if (!string.IsNullOrEmpty(defaultWKT)) { MSCPrj.AssignWKT(doc, defaultWKT); } return(defaultWKT); } return(text); }
public void ZoomExtents() { this.CheckForUpdates(); string a = MSCPrj.ReadWKT(this.ParentDataset.ParentDocument); if (a != this.BoundaryExtent.SpatialReference) { ErrorReport.ShowErrorMessage(AfaStrings.CoordinateSystemsDontMatch); return; } Point3d minPoint = new Point3d(this.BoundaryExtent.XMin.Value, this.BoundaryExtent.YMin.Value, 0.0); Point3d maxPoint = new Point3d(this.BoundaryExtent.XMax.Value, this.BoundaryExtent.YMax.Value, 0.0); DocUtil.ZoomExtents(minPoint, maxPoint); this.CheckForUpdates(); }
public static bool AssignPRJFile(string fileName) { if (!File.Exists(fileName)) { return(false); } string a = Path.GetExtension(fileName).ToLower(); string text = ""; try { if (a == ".dwg" || a == ".dxf") { Database database = new Database(false, true); database.ReadDwgFile(fileName, (FileOpenMode)3, true, ""); text = MSCPrj.ReadWKT(database); if (string.IsNullOrEmpty(text)) { bool result = false; return(result); } } else { if (!(a == ".prj")) { bool result = false; return(result); } text = File.ReadAllText(fileName); } } catch { bool result = false; return(result); } if (!string.IsNullOrEmpty(text)) { string value = MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, text); if (!string.IsNullOrEmpty(value)) { return(true); } } return(false); }
public object ESRI_CoordSys_Get(ResultBuffer rb) { object result; try { Document document = AfaDocData.ActiveDocData.Document; string text = MSCPrj.ReadWKT(document); if (!string.IsNullOrEmpty(text)) { result = text; } else { result = null; } } catch { result = null; } return(result); }
protected void Read(ObjectId id, Transaction t) { try { DBDictionary dBDictionary = (DBDictionary)t.GetObject(this.AcadDictionaryID, 0); base.RasterObjectId = (ObjectId)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)330, "AutoCADID"); this.ServiceFullName = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ServiceFullName"); base.ConnectionName = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ConnectionName"); base.ConnectionURL = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ConnectionURL"); base.UserName = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "UserName"); base.ExportOptions = new AGSExportOptions(); this.InitExportOptions(); base.ExportOptions.Format = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ImageFormat"); base.ExportOptions.BoundingBox = DocUtil.ReadBoundingBox(t, dBDictionary); base.BoundaryExtent = new Extent(base.ExportOptions.BoundingBox); base.ExportOptions.OutputWKT = MSCPrj.ReadWKT(base.ParentDataset.ParentDocument); base.Dynamic = false; if (dBDictionary.Contains("Dynamic")) { Xrecord xrecord = (Xrecord)t.GetObject(dBDictionary.GetAt("Dynamic"), 0); TypedValue[] array = xrecord.Data.AsArray(); for (int i = 0; i < array.Length; i++) { TypedValue typedValue = array[i]; if (typedValue.TypeCode == 290) { base.Dynamic = (0 != Convert.ToInt16(typedValue.Value)); } } } base.ExportOptions.Dynamic = base.Dynamic; base.ExportOptions.TransCompression = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "Compression"); base.ExportOptions.Quality = (int)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)90, "Quality"); base.ExportOptions.Interpolation = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "Interpolation"); base.ExportOptions.MosaicMethod = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "MosaicMethod"); base.ExportOptions.OrderField = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "OrderField"); base.ExportOptions.OrderBaseValue = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "OrderBaseValue"); base.ExportOptions.LockRasterID = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "LockRasterID"); base.ExportOptions.MosaicOperator = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "MosaicOperator"); if (dBDictionary.Contains("Ascending")) { Xrecord xrecord2 = (Xrecord)t.GetObject(dBDictionary.GetAt("Ascending"), 0); TypedValue[] array2 = xrecord2.Data.AsArray(); for (int j = 0; j < array2.Length; j++) { TypedValue typedValue2 = array2[j]; if (typedValue2.TypeCode == 290) { base.ExportOptions.Ascending = (0 != Convert.ToInt16(typedValue2.Value)); } } } if (this.ReconnectService()) { base.RefreshConnectedService(); } } catch { } }
public object ESRI_Image_Update(ResultBuffer rb) { object result; try { if (null == Application.DocumentManager.MdiActiveDocument) { result = null; } else { string argument = LspUtil.GetArgument(rb, 0, null); MSCImageService mSCImageService; if (!string.IsNullOrEmpty(argument)) { mSCImageService = this.GetImageService(argument); } else { mSCImageService = AfaDocData.ActiveDocData.CurrentImageService; } if (mSCImageService == null) { result = null; } else { short num = short.Parse(mSCImageService.GetTransparency().ToString()); Point2d minPoint = mSCImageService.ExportOptions.BoundingBox.MinPoint; Point2d maxPoint = mSCImageService.ExportOptions.BoundingBox.MaxPoint; bool assocParam = LspUtil.GetAssocParam(rb, "DYNAMIC", mSCImageService.Dynamic); bool assocParam2 = LspUtil.GetAssocParam(rb, "VISIBLE", mSCImageService.GetVisibility()); short assocParam3 = LspUtil.GetAssocParam(rb, "TRANSPARENCY", num); Point2d assocParam4 = LspUtil.GetAssocParam(rb, "EXTMIN", minPoint); Point2d assocParam5 = LspUtil.GetAssocParam(rb, "EXTMAX", maxPoint); string assocParam6 = LspUtil.GetAssocParam(rb, "FORMAT", mSCImageService.ExportOptions.Format); string text = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument); if (mSCImageService != null) { mSCImageService.SetVisbility(assocParam2); if (assocParam3 != num) { mSCImageService.SetTransparency((int)assocParam3); } if (assocParam != mSCImageService.Dynamic) { mSCImageService.Dynamic = assocParam; } mSCImageService.ExportOptions.Format = assocParam6; mSCImageService.ExportOptions.OutputWKT = text; Extent extent = new Extent(assocParam4, assocParam5); if (extent.IsValid()) { extent.SetWKTFrom(text); mSCImageService.UpdateExtentLimit(extent); } mSCImageService.Write(); mSCImageService.RefreshService(); Mouse.OverrideCursor = null; result = true; } else { result = null; } } } } catch { result = null; } return(result); }
public object ESRI_Image_Add(ResultBuffer rb) { object result; try { if (null == Application.DocumentManager.MdiActiveDocument) { result = null; } else { string assocParam = LspUtil.GetAssocParam(rb, "URL", null); bool assocParam2 = LspUtil.GetAssocParam(rb, "DYNAMIC", true); bool assocParam3 = LspUtil.GetAssocParam(rb, "VISIBLE", true); short num = LspUtil.GetAssocParam(rb, "TRANSPARENCY", 0); Point2d assocParam4 = LspUtil.GetAssocParam(rb, "EXTMIN", Point2d.Origin); Point2d assocParam5 = LspUtil.GetAssocParam(rb, "EXTMAX", Point2d.Origin); string assocParam6 = LspUtil.GetAssocParam(rb, "FORMAT", "PNG24"); if (string.IsNullOrEmpty(assocParam)) { result = null; } else { Mouse.OverrideCursor = Cursors.Wait; AGSImageService aGSImageService = AGSImageService.BuildImageServiceFromURL(null, assocParam); if (aGSImageService != null) { string text = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument); if (string.IsNullOrEmpty(text)) { text = MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, aGSImageService.GetWKT()); } aGSImageService.ExportOptions.Dynamic = assocParam2; aGSImageService.ExportOptions.Format = assocParam6; if (num == 100) { num = 99; } aGSImageService.ExportOptions.Transparency = byte.Parse(num.ToString()); Extent extent = new Extent(assocParam4, assocParam5); if (extent.IsValid()) { extent.SetWKTFrom(text); aGSImageService.ExportOptions.BoundingBox = extent; } aGSImageService.ExportOptions.OutputWKT = text; if (!aGSImageService.AddService(aGSImageService.ExportOptions)) { Mouse.OverrideCursor = null; result = null; } else { Mouse.OverrideCursor = null; MSCImageService currentImageService = AfaDocData.ActiveDocData.CurrentImageService; if (!assocParam3) { currentImageService.Visible = false; } result = currentImageService.Name; } } else { result = null; } } } } catch { result = null; } return(result); }
public object ESRI_AddFeatureService(ResultBuffer rb) { if (null == Application.DocumentManager.MdiActiveDocument) { return(null); } string assocParam = LspUtil.GetAssocParam(rb, "URL", null); string assocParam2 = LspUtil.GetAssocParam(rb, "EDITMODE", "EDIT"); Point2d assocParam3 = LspUtil.GetAssocParam(rb, "EXTMIN", Point2d.Origin); Point2d assocParam4 = LspUtil.GetAssocParam(rb, "EXTMAX", Point2d.Origin); string assocParam5 = LspUtil.GetAssocParam(rb, "LAYERIDS", ""); bool assocParam6 = LspUtil.GetAssocParam(rb, "EXTRACT", false); if (string.IsNullOrEmpty(assocParam)) { return(null); } object result; try { Mouse.OverrideCursor = Cursors.Wait; string text = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument); AGSFeatureService aGSFeatureService = AGSFeatureService.BuildFeatureServiceFromURL(null, assocParam); if (aGSFeatureService != null) { if (string.IsNullOrEmpty(text)) { text = MSCPrj.AssignWKT(AfaDocData.ActiveDocData.Document, aGSFeatureService.GetWKT()); } if (assocParam2 != "EDIT") { aGSFeatureService.ExportOptions.Dynamic = false; } Extent extent = new Extent(assocParam3, assocParam4); aGSFeatureService.ExportOptions.OutputWKT = text; if (extent.IsValid()) { extent.SetWKTFrom(text); aGSFeatureService.ExportOptions.BoundingBox = extent; } List <int> layerList = null; bool flag; if (!string.IsNullOrEmpty(assocParam5)) { string[] array = assocParam5.Split(new char[] { ',' }); int[] collection = Array.ConvertAll <string, int>(array, new Converter <string, int>(int.Parse)); layerList = new List <int>(collection); if (assocParam6) { flag = aGSFeatureService.ExtractService(layerList); } else { flag = aGSFeatureService.AddService(layerList); } } else if (assocParam6) { flag = aGSFeatureService.ExtractService(layerList); } else { flag = aGSFeatureService.AddService(layerList); } Mouse.OverrideCursor = null; if (flag) { result = true; } else { result = false; } } else { Mouse.OverrideCursor = null; result = null; } } catch { Mouse.OverrideCursor = null; result = null; } return(result); }
public object ESRI_FeatureService_set(ResultBuffer rb) { object result; try { if (null == Application.DocumentManager.MdiActiveDocument) { result = null; } else { string argument = LspUtil.GetArgument(rb, 0, null); MSCFeatureService mSCFeatureService; if (!string.IsNullOrEmpty(argument)) { mSCFeatureService = this.GetFeatureService(argument); } else { mSCFeatureService = this.GetCurrentFeatureService(); } if (mSCFeatureService == null) { result = null; } else { AGSExportOptions exportOptions = mSCFeatureService.ExportOptions; bool assocParam = LspUtil.GetAssocParam(rb, "EDITMODE", exportOptions.Dynamic); Point2d assocParam2 = LspUtil.GetAssocParam(rb, "EXTMIN", exportOptions.BoundingBox.MinPoint); Point2d assocParam3 = LspUtil.GetAssocParam(rb, "EXTMAX", exportOptions.BoundingBox.MaxPoint); string text = MSCPrj.ReadWKT(Application.DocumentManager.MdiActiveDocument); if (mSCFeatureService != null) { if (assocParam) { mSCFeatureService.QueryOnly = false; mSCFeatureService.SetLayerLock(false); } else { mSCFeatureService.QueryOnly = true; mSCFeatureService.SetLayerLock(true); } mSCFeatureService.ExportOptions.Dynamic = assocParam; mSCFeatureService.ExportOptions.OutputWKT = text; Extent extent = new Extent(assocParam2, assocParam3); if (extent.IsValid()) { extent.SetWKTFrom(text); mSCFeatureService.UpdateExtentLimit(extent); } mSCFeatureService.Write(); Mouse.OverrideCursor = null; result = true; } else { result = null; } } } } catch { result = null; } return(result); }
protected void Read(ObjectId id, Transaction t) { try { DBDictionary dBDictionary = (DBDictionary)t.GetObject(this.AcadDictionaryID, 0); base.RasterObjectId = (ObjectId)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)330, "AutoCADID"); this.ServiceFullName = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ServiceFullName"); base.ConnectionName = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ConnectionName"); base.ConnectionURL = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ConnectionURL"); base.UserName = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "UserName"); base.BoundaryExtent = DocUtil.ReadBoundingBox(t, dBDictionary); base.ExportOptions = new AGSExportOptions(); this.InitExportOptions(); base.ExportOptions.Format = (string)DocUtil.ReadXRecord(t, dBDictionary, (DxfCode)1, "ImageFormat"); base.ExportOptions.BoundingBox = new Extent(base.BoundaryExtent); base.ExportOptions.OutputWKT = MSCPrj.ReadWKT(base.ParentDataset.ParentDocument); try { base.Dynamic = false; if (dBDictionary.Contains("Dynamic")) { Xrecord xrecord = (Xrecord)t.GetObject(dBDictionary.GetAt("Dynamic"), 0); TypedValue[] array = xrecord.Data.AsArray(); for (int i = 0; i < array.Length; i++) { TypedValue typedValue = array[i]; if (typedValue.TypeCode == 290) { base.Dynamic = (0 != Convert.ToInt16(typedValue.Value)); } } } base.ExportOptions.Dynamic = base.Dynamic; } catch { base.ExportOptions.Dynamic = false; } if (dBDictionary.Contains("ESRI_Layers")) { DBDictionary dBDictionary2 = (DBDictionary)t.GetObject(dBDictionary.GetAt("ESRI_Layers"), 0); using (DbDictionaryEnumerator enumerator = dBDictionary2.GetEnumerator()) { while (enumerator.MoveNext()) { DBDictionaryEntry current = enumerator.Current; MSCMapLayer mSCMapLayer = new MSCMapLayer(t, current.Key, current.Value); mSCMapLayer.ParentMap = this; if (mSCMapLayer.Layers != null) { foreach (MSCMapLayer current2 in mSCMapLayer.Layers) { current2.ParentMap = this; } } this.Layers.Add(mSCMapLayer); } } } if (this.ReconnectService()) { base.RefreshConnectedService(); } } catch { } }
private bool PerformLocate(string locateText) { Document document = AfaDocData.ActiveDocData.Document; Editor editor = document.Editor; if (string.IsNullOrEmpty(locateText)) { editor.WriteMessage(AfaStrings.InvalidPlaceText); return(false); } AGSGeometryServer sampleServer = AGSGeometryServer.GetSampleServer(); if (sampleServer == null) { ErrorReport.ShowErrorMessage(AfaStrings.UnableToConnectGeometryService); return(false); } string text = "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0],AUTHORITY[\"EPSG\",3857]]".ToString(); bool result; try { text = MSCPrj.ReadWKT(document); if (string.IsNullOrEmpty(text)) { text = "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0],AUTHORITY[\"EPSG\",3857]]".ToString(); MSCPrj.AssignWKT(document, "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0],AUTHORITY[\"EPSG\",3857]]"); } } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingWKT); result = false; return(result); } if (!MSCPrj.IsWKID(text)) { try { text = sampleServer.GetSpatialReferenceWKID(text); if (string.IsNullOrEmpty(text)) { string text2 = sampleServer.ErrorMessage; if (string.IsNullOrEmpty(text2)) { text2 = AfaStrings.UnsupportedCoordinateSystemForLocate; } ErrorReport.ShowErrorMessage(text2); result = false; return(result); } } catch { text = "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0],AUTHORITY[\"EPSG\",3857]]"; } } try { Convert.ToInt32(text); } catch { editor.WriteMessage(AfaStrings.UnsupportedCoordinateSystemForLocate); result = false; return(result); } Mouse.OverrideCursor = Cursors.Wait; AGSLocator aGSLocator = this.cbLocator.SelectedItem as AGSLocator; string uRL = aGSLocator.URL; string arg = uRL.TrimEnd(new char[] { '/', '\\' }); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("/findAddressCandidates?SingleLine="); stringBuilder.Append(this.tbPlace.Text); stringBuilder.AppendFormat("&outSR={0}", text); stringBuilder.AppendFormat("&f={0}", "json"); try { IDictionary <string, object> dictionary = aGSLocator.ParentConnection.MakeDictionaryRequest(arg + stringBuilder); if (dictionary.ContainsKey("error")) { editor.WriteMessage(AfaStrings.ErrorConnectingToServer); Mouse.OverrideCursor = null; result = false; } else { CadField cadField = new CadField(); cadField.Name = AfaStrings.SearchString; cadField.Value = new TypedValue(1, this.tbPlace.Text); cadField.ReadOnly = true; if (dictionary.ContainsKey("candidates")) { DocUtil.FixPDMode(); using (document.LockDocument((DocumentLockMode)20, null, null, false)) { List <ObjectId> list = new List <ObjectId>(); Database database = document.Database; try { using (Transaction transaction = document.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(database.BlockTableId, (OpenMode)1, false); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[(BlockTableRecord.ModelSpace)], (OpenMode)1, false); this.CreateLocationsFeatureClass(); DocUtil.FixPDMode(); string text3 = "ESRI_Locations"; ObjectId layer = DocUtil.GetLayer(database, transaction, ref text3, null); ObjectId blockDefinition = DocUtil.GetBlockDefinition(document, transaction, "ESRI_Locations"); IEnumerable <object> enumerable = dictionary["candidates"] as IEnumerable <object>; using (IEnumerator <object> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { IDictionary <string, object> dictionary2 = (IDictionary <string, object>)enumerator.Current; CadField cadField2 = null; CadField cadField3 = null; if (dictionary2.ContainsKey("address")) { string text4 = dictionary2["address"].ToString(); cadField3 = new CadField(); cadField3.Name = "Address"; cadField3.Value = new TypedValue(1, text4); cadField3.ReadOnly = true; } if (dictionary2.ContainsKey("score")) { try { int num = Convert.ToInt32(dictionary2["score"]); cadField2 = new CadField(); cadField2.Name = "Score"; cadField2.Value = new TypedValue(90, num); cadField2.ReadOnly = true; } catch { } } if (dictionary2.ContainsKey("location")) { try { IDictionary <string, object> dictionary3 = dictionary2["location"] as IDictionary <string, object>; double num2 = Convert.ToDouble(dictionary3["x"]); double num3 = Convert.ToDouble(dictionary3["y"]); Entity entity; if (blockDefinition != ObjectId.Null) { entity = new BlockReference(new Point3d(num2, num3, 0.0), blockDefinition); } else { entity = new DBPoint(new Point3d(num2, num3, 0.0)); } entity.LayerId = (layer); entity.ColorIndex = (256); ObjectId item = blockTableRecord.AppendEntity(entity); transaction.AddNewlyCreatedDBObject(entity, true); list.Add(item); if (cadField3 != null) { CadField.AddCadAttributeToEntity(database, transaction, entity.ObjectId, cadField3); } if (cadField2 != null) { CadField.AddCadAttributeToEntity(database, transaction, entity.ObjectId, cadField2); } CadField.AddCadAttributeToEntity(database, transaction, entity.ObjectId, cadField); document.TransactionManager.QueueForGraphicsFlush(); document.TransactionManager.FlushGraphics(); document.Editor.UpdateScreen(); } catch { } } } } transaction.Commit(); if (list.Count > 0) { ObjectId[] array = list.ToArray(); DocUtil.ZoomToEntity(array); AfaDocData.ActiveDocData.DocDataset.UpdateMaps(); AfaDocData.ActiveDocData.Document.Editor.UpdateScreen(); AfaDocData.ActiveDocData.Document.Editor.Regen(); Mouse.OverrideCursor = null; CmdLine.CancelActiveCommand(); TableView tableView = new TableView(AfaDocData.ActiveDocData.GetActiveFeatureClassOrSubtype(), array); Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(Autodesk.AutoCAD.ApplicationServices.Application.MainWindow.Handle, tableView, false); tableView.Uninitialize(); tableView.Dispose(); this.SelectAndDelete(); AfaDocData.ActiveDocData.DocDataset.UpdateMaps(); AfaDocData.ActiveDocData.Document.Editor.UpdateScreen(); AfaDocData.ActiveDocData.Document.Editor.Regen(); result = true; return(result); } Mouse.OverrideCursor = null; editor.WriteMessage(AfaStrings.NoFeaturesFound + " (" + this.tbPlace.Text + ")"); result = false; return(result); } } catch { Mouse.OverrideCursor = null; } } } Mouse.OverrideCursor = null; result = false; } } catch { Mouse.OverrideCursor = null; editor.WriteMessage(AfaStrings.ErrorConnectingToServer); result = false; } return(result); }