private void AddImageService(object sender, ExportedImageEventArgs e) { try { if (!string.IsNullOrEmpty(e.ErrorMessage)) { ErrorReport.ShowErrorMessage(e.ErrorMessage); } else if (e.Points != null && !string.IsNullOrEmpty(e.ExportOptions.OutputFile)) { Point3d point3d = new Point3d(e.Points[0].X, e.Points[0].Y, 0.0); Point3d point3d2 = new Point3d(e.Points[1].X, e.Points[1].Y, 0.0); Point3d point3d3 = new Point3d(e.Points[2].X, e.Points[2].Y, 0.0); Point3d p = new Point3d(e.Points[1].X, e.Points[2].Y, 0.0); Vector3d v = point3d2 - point3d; Vector3d v2 = point3d3 - point3d; ObjectId objectId = DocUtil.DefineRasterImage(AfaDocData.ActiveDocData.Document, e.ExportOptions.OutputFile, point3d, v, v2, "ESRI_" + e.MapName, e.ExportOptions.Transparency); if (!objectId.IsNull) { DocUtil.SetEntityDisableUndo(AfaDocData.ActiveDocData.Document, objectId, true); e.ExportOptions.BoundingBox = new Extent(point3d, p); e.ExportOptions.BoundingBox.SpatialReference = e.ExportOptions.OutputWKT; MSCImageService mSCImageService = MSCDataset.AddImageService((AGSImageService)e.MapService, objectId, e.ExportOptions); if (mSCImageService != null) { DocUtil.AttachHyperlink(AfaDocData.ActiveDocData.Document, objectId, mSCImageService.Name, mSCImageService.RestEndpoint); mSCImageService.UpdateToCurrentView(); mSCImageService.CheckForUpdates(); } } } } catch { if (string.IsNullOrEmpty(base.ErrorMessage)) { base.ErrorMessage = AfaStrings.ErrorGeneratingImage; } throw; } }