public bool AddService(AGSExportOptions eo) { bool result; try { base.ErrorMessage = null; this.InitializeImageService(); eo.OutputFile = Utility.TemporaryFilePath(); eo.AcadDocument = AfaDocData.ActiveDocData.Document; Size size = Application.ToSystemDrawingSize(eo.AcadDocument.Window.DeviceIndependentSize); eo.Width = size.Width; eo.Height = size.Height; bool flag = this.ExportMapNow(eo, new ExportImageEventHandler(this.AddImageService), null); result = flag; } catch (SystemException ex) { if (this.CommandEnded != null) { this.CommandEnded(this, EventArgs.Empty); } ErrorReport.ShowErrorMessage(ex.Message); result = false; } return(result); }
private void RefreshProperties() { try { string text = this.Map.Parent.URL; string text2 = text; text = string.Concat(new string[] { text2, "/", this.Map.FullName, "/MapServer/", base.Id.ToString() }); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("?f={0}", "json"); IDictionary <string, object> dictionary = base.Service.Parent.MakeDictionaryRequest(text + stringBuilder); if (dictionary != null) { this.PopulateProperties(dictionary); } else { base.Properties.Add(AfaStrings.Error, AfaStrings.UnableToRetrieveServiceProperties); } } catch { ErrorReport.ShowErrorMessage(base.Service.Parent.ErrorMessage); } }
public static string CreateDefaultGeocoder() { string text = "ArcGIS World Geocoder"; string value = " http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"; string result; try { string path = AGSLocator.LocatorFolderLocation(); string text2 = Path.Combine(path, text + ".AGL"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(AGSLocator.cVer.ToString()); stringBuilder.AppendLine(text); stringBuilder.AppendLine(value); stringBuilder.AppendLine(false.ToString()); using (StreamWriter streamWriter = new StreamWriter(text2)) { streamWriter.Write(stringBuilder.ToString()); } result = text2; } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorSavingConnectionFile); result = ""; } return(result); }
public static string CreateNorthAmericanAddressLocator() { string text = "ArcGIS North American Address Locator"; string value = "http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA_10/GeocodeServer/"; string result; try { string path = AGSLocator.LocatorFolderLocation(); string text2 = Path.Combine(path, text + ".AGL"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(AGSLocator.cVer.ToString()); stringBuilder.AppendLine(text); stringBuilder.AppendLine(value); stringBuilder.AppendLine(false.ToString()); using (StreamWriter streamWriter = new StreamWriter(text2)) { streamWriter.Write(stringBuilder.ToString()); } result = text2; } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorSavingConnectionFile); result = ""; } return(result); }
public void Refresh() { this.ClearActiveFeatureClass(); this.CurrentImageService = null; this.CurrentMapService = null; this.DocPRJ = null; Document document = base.Document; Database arg_28_0 = document.Database; try { using (Transaction transaction = document.TransactionManager.StartTransaction()) { this.DocPRJ = new MSCPrj(); this.DocPRJ.Initialize(this.NOD, transaction); this.DocDataset.Initialize(document, transaction); MSCDataset.SetDefaultActiveFeatureClass(); MSCDataset.SetDefaultActiveRasterServices(); document.TransactionManager.QueueForGraphicsFlush(); document.TransactionManager.FlushGraphics(); document.Editor.UpdateScreen(); transaction.Commit(); if (AfaDocData.ActiveDocData.DocDataset.HasFeatureServicesOpenedForEditing()) { CmdLine.ExecuteQuietCommand("ESRI_UpdatePalette"); } } } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorInitializingGISDataset); } }
private bool RefreshConnection(AGSConnection connection) { Mouse.OverrideCursor = Cursors.Wait; if (!connection.Refresh()) { Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(connection.ErrorMessage); return(false); } Mouse.OverrideCursor = null; bool result; try { if (this.lbConnections.Items != null) { this.lbConnections.Items.Refresh(); } result = true; } catch { ErrorReport.ShowErrorMessage(AfaStrings.UnknownError); result = false; } return(result); }
private static void LoadImages() { try { foreach (OnlineSearchItem current in AGS_ESRIMaps.m_searchResult.Results) { if (!(current.Type != "Map Service") && current.Thumbnail != null) { string text = string.Concat(new string[] { AGS_ESRIMaps.AGOLUrl, "/sharing/content/items/", current.Id, "/info/", current.Thumbnail }); current.Thumbnail = text; Stream cachedURLStream = AGS_ESRIMaps.getCachedURLStream(new Uri(text)); if (cachedURLStream != null) { current.Image = AGS_ESRIMaps.createBitmap(cachedURLStream); } if (current.Image != null) { AGS_ESRIMaps.MapList.Add(current); } } } } catch (SystemException ex) { ErrorReport.ShowErrorMessage("Error loading images; " + ex.Message); AGS_ESRIMaps.ConnectionFailed = true; } }
public void RefreshService() { if (!this.ParentServiceConnected) { AGSConnection.ReestablishConnection(this.ConnectionURL, this.ConnectionName, this.UserName); } if (!this.ReconnectService()) { Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(AfaStrings.UnableToConnectService + this.Name); return; } if (!this.ParentDataset.ParentDocument.IsActive) { return; } Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; Editor editor = this.ParentDataset.ParentDocument.Editor; if (!this.RequestUpdateNow()) { editor.WriteMessage(AfaStrings.InvalidExtent); } if (!string.IsNullOrEmpty(this.ParentService.ErrorMessage)) { editor.WriteMessage(this.ParentService.ErrorMessage); } this.CancelRequests = false; Mouse.OverrideCursor = null; }
private static BitmapImage createBitmap(Stream stream) { BitmapImage result; try { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = stream; bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.CreateOptions = BitmapCreateOptions.None; bitmapImage.UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable); bitmapImage.EndInit(); if (!bitmapImage.IsDownloading) { bitmapImage.Freeze(); } result = bitmapImage; } catch (Exception ex) { Trace.WriteLine(ex.Message); ErrorReport.ShowErrorMessage("Error in creating bitmap. " + ex.Message); AGS_ESRIMaps.ConnectionFailed = true; result = null; } return(result); }
private static void BasemapWindow_ProcessFeaturedItems(string str) { try { JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); OnlineSearchResponse onlineSearchResponse = javaScriptSerializer.Deserialize <OnlineSearchResponse>(str); if (onlineSearchResponse != null) { AGS_ESRIMaps.m_searchResult = onlineSearchResponse; AGS_ESRIMaps.MapList = new List <OnlineSearchItem>(); AGS_ESRIMaps.LoadImages(); if (AGS_ESRIMaps.MapList.Count > 0) { AGS_ESRIMaps.ESRI_Maps = AGS_ESRIMaps.MapList; } else { ErrorReport.ShowErrorMessage(AfaStrings.NoArcGISOnlineMapsFound); AGS_ESRIMaps.ConnectionFailed = true; } } } catch (SystemException ex) { ErrorReport.ShowErrorMessage("Error processing featured items. " + ex.Message); } }
private static void ProcessBasemapWindowDownload(string str) { try { JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); OnlineSearchGroupsResponse onlineSearchGroupsResponse = javaScriptSerializer.Deserialize <OnlineSearchGroupsResponse>(str); if (onlineSearchGroupsResponse != null && onlineSearchGroupsResponse.Results != null && onlineSearchGroupsResponse.Results.Count == 1) { string id = onlineSearchGroupsResponse.Results[0].Id; string text = ""; text = text + "group:" + id + " AND (typekeywords:\"map service\") AND (tags:\"AFA250_base\")"; string str2 = text.Replace(" ", "%20"); string origRequestURI = AGS_ESRIMaps.AGOLUrl + "/sharing/search?f=json&sortField=numviews&sortOrder=desc&num=50&q=" + str2; string text2 = AGS_ESRIMaps.MakeWebRequest(origRequestURI); if (!AGS_ESRIMaps.ConnectionFailed && !string.IsNullOrEmpty(text2)) { AGS_ESRIMaps.BasemapWindow_ProcessFeaturedItems(text2); } else { ErrorReport.ShowErrorMessage(AfaStrings.UnableToQueryArcGISOnline); } } } catch (SystemException ex) { ErrorReport.ShowErrorMessage("Error downloading map images. " + ex.Message); } }
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); }
private bool GetServerInfo() { bool result; try { this.IsVerified = false; this.ErrorMessage = ""; if (string.IsNullOrEmpty(this.URL)) { this.ErrorMessage = AfaStrings.InvalidServerURL; result = false; } else { string uRL = this.URL; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("?f={0}", "json"); this.IsTokenBasedSecurity = false; IDictionary <string, object> dictionary = this.ParentConnection.MakeDictionaryRequest(uRL + stringBuilder); if (dictionary == null) { ErrorReport.ShowErrorMessage(AfaStrings.InvalidLocationService); result = false; } else if (!dictionary.ContainsKey("singleLineAddressField")) { ErrorReport.ShowErrorMessage(AfaStrings.InvalidLocationService); result = false; } else { if (dictionary.ContainsKey("serviceDescription")) { try { object obj; dictionary.TryGetValue("serviceDescription", out obj); this.Description = (obj as string); } catch { this.Description = null; } } this.IsVerified = true; result = true; } } } catch { this.ErrorMessage = AfaStrings.ErrorConnectingToServer; result = false; } return(result); }
public Geometry[] DensifyGeometry(SpatialReference inputSpRef, double segmentDeviation, Geometry[] inputGeometry) { if (inputGeometry == null) { return(inputGeometry); } if (inputGeometry.Length == 0) { return(inputGeometry); } if (inputGeometry[0] is PointN || inputGeometry[0] is MultipointN) { Geometry[] array = new Geometry[inputGeometry.Length]; inputGeometry.CopyTo(array, 0); return(array); } double maxSegmentLength = 0.0; bool useDeviationDensification = true; Geometry[] result; try { Geometry[] array2 = this._GeomServer.Densify(inputSpRef, inputGeometry, maxSegmentLength, useDeviationDensification, segmentDeviation); result = array2; } catch (SystemException ex) { if (base.Parent.Challenge()) { this._GeomServer.Credentials = base.Parent.Credentials; if (this._GeomServer.Credentials == null) { this._GeomServer.UseDefaultCredentials = true; } this._GeomServer.Proxy = WebRequest.DefaultWebProxy; try { Geometry[] array3 = this._GeomServer.Densify(inputSpRef, inputGeometry, maxSegmentLength, useDeviationDensification, segmentDeviation); result = array3; return(result); } catch { string arg_CA_0 = ex.Message; ErrorReport.ShowErrorMessage("Geometry Server.Densify: " + ex.Message); result = inputGeometry; return(result); } } string arg_ED_0 = ex.Message; ErrorReport.ShowErrorMessage("Geometry Server.Densify: " + ex.Message); result = inputGeometry; } return(result); }
public string GetSpatialReferenceWKID(string wkt) { string result; try { SpatialReference spatialReference = this._GeomServer.FindSRByWKT(wkt, null, true, true); if (!spatialReference.WKIDSpecified) { result = null; } else if (spatialReference.WKID == 0) { result = null; } else { result = spatialReference.WKID.ToString(); } } catch (WebException) { if (base.Parent.Challenge()) { this._GeomServer.Credentials = base.Parent.Credentials; if (this._GeomServer.Credentials == null) { this._GeomServer.UseDefaultCredentials = true; } this._GeomServer.Proxy = WebRequest.DefaultWebProxy; SpatialReference spatialReference2 = this._GeomServer.FindSRByWKT(wkt, null, true, true); if (!spatialReference2.WKIDSpecified) { result = null; } else if (spatialReference2.WKID == 0) { result = null; } else { result = spatialReference2.WKID.ToString(); } } else { ErrorReport.ShowErrorMessage(base.Parent.ErrorMessage); result = null; } } return(result); }
private bool SelectService() { bool result; try { this.btnCancel.IsEnabled = false; this.btnNext.IsEnabled = false; base.IsEnabled = false; AGSConnection aGSConnection = this.lbConnections.SelectedItem as AGSConnection; if (aGSConnection.ConnectionFailed) { this.RefreshConnection(aGSConnection); } if (!aGSConnection.ConnectionFailed) { if (this.PopulateConnection(aGSConnection)) { base.Close(); SelectService selectService = new SelectService(aGSConnection); if (selectService.IsValid) { this.ClearProgressBar(); Application.ShowModelessWindow(selectService); base.Close(); result = true; return(result); } } else { this.btnCancel.IsEnabled = true; this.btnNext.IsEnabled = true; base.IsEnabled = true; SelectConnection.WindowOpen = false; string text = aGSConnection.ErrorMessage; if (string.IsNullOrEmpty(text)) { text = "Populating Connection failed"; } ErrorReport.ShowErrorMessage(text); aGSConnection.ErrorMessage = ""; } } result = false; } catch { result = false; } return(result); }
public static void AddESRIMapWindow() { AGS_ESRIMaps.ESRI_Maps = null; AGS_ESRIMaps.ConnectionFailed = false; Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; try { AGS_ESRIMaps.LoadAllMapImages(); Mouse.OverrideCursor = null; try { while (AGS_ESRIMaps.ESRI_Maps == null && !AGS_ESRIMaps.ConnectionFailed) { System.Windows.Forms.Application.DoEvents(); } } catch { ErrorReport.ShowErrorMessage("Error while waiting for map images to load"); } } catch (SystemException ex) { Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage("Error loading map images. " + ex.Message); AGS_ESRIMaps.ConnectionFailed = true; return; } Mouse.OverrideCursor = null; if (!AGS_ESRIMaps.ConnectionFailed) { try { if (AGS_ESRIMaps.ESRI_Maps.Count > 0) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowModalWindow(new SelectESRIMap(AGS_ESRIMaps.ESRI_Maps)); } else { ErrorReport.ShowErrorMessage("Error loading maps from ESRI."); } } catch { ErrorReport.ShowErrorMessage("Error displaying ESRI Maps window."); } } }
private static Stream getCachedURLStream(Uri uri) { Stream result; try { result = AGS_ESRIMaps.getCachedURLStreamInternal(uri, 1); } catch { ErrorReport.ShowErrorMessage("Error in getting cached url stream"); AGS_ESRIMaps.ConnectionFailed = true; result = null; } return(result); }
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(); }
private void RefreshProperties() { string arg = base.Parent.URL + "/" + base.FullName + "/ImageServer"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("?f={0}", "json"); IDictionary <string, object> dictionary = base.Parent.MakeDictionaryRequest(arg + stringBuilder); if (dictionary != null) { this.PopulateProperties(dictionary); base.IsValid = true; return; } base.IsValid = false; ErrorReport.ShowErrorMessage(base.Parent.ErrorMessage); }
public bool UpdateRasterNow() { bool result; try { bool flag = DocUtil.UpdateRasterImage(this._doc, this._rasterID, this.ImageURL, this.BasePoint, this.V1, this.V2); if (flag) { this.lblReadyForUpdate.Text = "not ready"; } result = flag; } catch (SystemException ex) { ErrorReport.ShowErrorMessage("Catch in UpdateRasterNow: " + ex.Message); result = false; } return(result); }
private void btnAssign_Click(object sender, RoutedEventArgs e) { base.Close(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = AfaStrings.OpenCoordinateSystemSource; openFileDialog.Filter = "PRJ|*.prj|DWG|*.dwg|DXF|*.dxf"; openFileDialog.InitialDirectory = this.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") && 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); }
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; } }
public static void LoadAllMapImages() { try { AGS_ESRIMaps.AGOLUrl = AGS_ESRIMaps.GetArcGISOnlineURL(); string basemapGroupQuery = AGS_ESRIMaps.GetBasemapGroupQuery(); string text = AGS_ESRIMaps.AGOLUrl + "/sharing/community/groups?f=json&q=" + basemapGroupQuery; string origRequestURI = text.Replace(" ", "%20"); string text2 = AGS_ESRIMaps.MakeWebRequest(origRequestURI); if (!AGS_ESRIMaps.ConnectionFailed && !string.IsNullOrEmpty(text2)) { AGS_ESRIMaps.ProcessBasemapWindowDownload(text2); } else { ErrorReport.ShowErrorMessage(AfaStrings.UnableToQueryArcGISOnline); } } catch (SystemException ex) { ErrorReport.ShowErrorMessage("Error loading map images" + ex.Message); } }
private void Next_Click(object sender, RoutedEventArgs e) { base.Visibility = Visibility.Collapsed; this.tbServerName.Text = AGSConnection.FixName(this.tbServerName.Text); AGSConnection aGSConnection = null; try { aGSConnection = new AGSConnection(this.tbServerName.Text, this.tbServerURL.Text); } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorConnectingToServer); base.Visibility = Visibility.Visible; this.Succeeded = false; } if (aGSConnection != null && !aGSConnection.ConnectionFailed) { aGSConnection.UserName = this.tbUserName.Text; aGSConnection.Password = this.tbPassword.Password; Mouse.OverrideCursor = Cursors.Wait; if (!aGSConnection.LoadConnectionProperties()) { Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(aGSConnection.ErrorMessage); base.Visibility = Visibility.Visible; this.Succeeded = false; return; } Mouse.OverrideCursor = null; base.Close(); Mouse.OverrideCursor = Cursors.Wait; if (!aGSConnection.LoadChildren()) { Mouse.OverrideCursor = null; string text = aGSConnection.ErrorMessage; if (string.IsNullOrEmpty(text)) { text = AfaStrings.ErrorConnectingToServer; } ErrorReport.ShowErrorMessage(text); return; } Mouse.OverrideCursor = null; if (aGSConnection.FoldersLoaded && !aGSConnection.ConnectionFailed) { this.Succeeded = true; aGSConnection.SaveToFile(); App.Connections.Add(aGSConnection); SelectService selectService = new SelectService(aGSConnection); if (selectService.IsValid) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowModalWindow(selectService); if (selectService.DialogResult.HasValue) { bool arg_165_0 = selectService.DialogResult.Value; } } } } }
public FeatureClassProperties(MSCFeatureClass fc) { try { this._mColorList = this.InitColorList(); this._FC = fc; this._QueryData = new DataTable(); this._QueryData.Columns.Add("Type"); this._QueryData.Columns.Add("Value"); if (fc.Query != null) { TypedValue[] array = fc.Query.AsArray(); TypedValue[] array2 = array; for (int i = 0; i < array2.Length; i++) { TypedValue typedValue = array2[i]; if (typedValue.TypeCode == 62) { this.BuildColorRow(typedValue.Value.ToString()); } else { DataRow dataRow = this._QueryData.NewRow(); dataRow["Type"] = new DXFCode((int)typedValue.TypeCode).CodeString; dataRow["Value"] = typedValue.Value; this._QueryData.Rows.Add(dataRow); } } } this._QueryData.RowChanged += new DataRowChangeEventHandler(this._QueryData_RowChanged); this._FieldData = new DataTable(); this._FieldData.Columns.Add("Name"); this._FieldData.Columns.Add("Type"); this._FieldData.Columns.Add("Value"); this._FieldData.Columns.Add("DisplayValue"); this._FieldData.Columns.Add("Length", typeof(int)); this._FieldData.Columns.Add("ReadOnly", typeof(bool)); this._FieldData.Columns.Add("BaseField", typeof(CadField)); this._FieldData.Columns.Add("CodedValues", typeof(List <MSCCodedValue>)); this._FieldData.Columns.Add("CodedValue", typeof(MSCCodedValue)); this._FieldData.Columns.Add("Domain", typeof(FieldDomain)); this._FieldData.Columns.Add("CanEditType", typeof(bool)); if (fc.Fields != null) { foreach (CadField current in fc.Fields) { if (current != null && current.Visible) { DataRow dataRow2 = this._FieldData.NewRow(); dataRow2["Name"] = current.Name; dataRow2["Value"] = current.Value.Value; dataRow2["DisplayValue"] = dataRow2["Value"]; if (current.Value.TypeCode == 1) { dataRow2["Length"] = current.Length; } else { dataRow2["Length"] = 0; } dataRow2["Type"] = current.GetTypeString(); if (current.ReadOnly) { dataRow2["ReadOnly"] = true; } else { dataRow2["ReadOnly"] = false; } dataRow2["BaseField"] = current; this._FieldData.Rows.Add(dataRow2); if (current.Domain != null) { dataRow2["Domain"] = current.Domain; } dataRow2["CanEditType"] = true; if (current.Domain != null) { dataRow2["CanEditType"] = false; current.Value = current.Domain.CheckValue(current.Value.Value); dataRow2["CodedValues"] = current.Domain.CodedValuesDisplayList; dataRow2["CodedValue"] = current.Domain.GetCodedValue(current.Value.Value); dataRow2["DisplayValue"] = dataRow2["CodedValue"]; } } } } this._FieldData.RowChanged += new DataRowChangeEventHandler(this._FieldData_RowChanged); this.InitializeComponent(); this.lblName.Content = fc.Name; this.lblType.Content = MSCFeatureClass.GetTypeCodeString(fc.GeometryType); this.dgQuery.ItemsSource = this.QueryData.DefaultView; this.BuildQueryPropertyOptions(fc.GeometryType); this.dgFields.ItemsSource = this._FieldData.DefaultView; if (fc.ReadOnly || fc.IsSubType || fc.SubTypes.Count > 0) { this.dgQuery.IsEnabled = false; this.dgFields.IsEnabled = false; this.cbProperty.IsEnabled = false; this.cbAppend.IsEnabled = false; this.cbValue.IsEnabled = false; } } catch (Exception ex) { ErrorReport.ShowErrorMessage(ex.Message); } }
private void OnClickOK(object sender, RoutedEventArgs e) { if (null == Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument) { ErrorReport.ShowErrorMessage(AfaStrings.ErrorWritingFeatureClass); return; } ResultBuffer resultBuffer = this.BuildQueryResultBuffer(); if (resultBuffer.AsArray().Count <TypedValue>() == 0) { this._FC.Query = new ResultBuffer(new TypedValue[] { new TypedValue(8, "*") }); } else { this._FC.Query = resultBuffer; } List <CadField> list = new List <CadField>(); foreach (DataRow dataRow in this._FieldData.Rows) { CadField cadField = new CadField(); cadField.Name = CadField.FixFieldName(dataRow["Name"].ToString()); CadField.CadFieldType code = CadField.TypeCodeFromString(dataRow["Type"].ToString()); cadField.ExtendedType = CadField.ExtendedTypeFromString(dataRow["Type"].ToString()); cadField.Value = CadField.CreateTypedValue(code, dataRow["Value"].ToString()); if (dataRow["Domain"] is FieldDomain) { cadField.Domain = (FieldDomain)dataRow["Domain"]; } else { cadField.Domain = null; } CadField.CadFieldType arg_142_0 = cadField.FieldType; if (cadField.Value.TypeCode == 1) { string text = dataRow["Length"].ToString(); if (!string.IsNullOrEmpty(text)) { short length; if (short.TryParse(text, out length)) { cadField.Length = length; } else { cadField.Length = 254; } } else { cadField.Length = 254; } } list.Add(cadField); } this._FC.Fields = list; Database database = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.Database; try { using (Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.LockDocument()) { var transactionManager = database.TransactionManager; using (Transaction transaction = transactionManager.StartTransaction()) { this._FC.Write(database, transaction); transaction.Commit(); } } base.Close(); } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorWritingFeatureClass); } }
public void Execute(object param) { RibbonButton ribbonButton = param as RibbonButton; if (ribbonButton != null) { if (ribbonButton.Id == AfaStrings.RBN_BTN_ESRIMAPS) { try { if (Application.IsQuiescent) { CmdLine.CancelActiveCommand(); string cmdString = "_ESRI_AddESRIMap "; CmdLine.ExecuteQuietCommand(cmdString); } return; } catch (SystemException ex) { MessageBox.Show(ex.Message); return; } } if (ribbonButton.Id == AfaStrings.RBN_BTN_ADDMAPSERVICE) { CmdLine.CancelActiveCommand(); string cmdString2 = "_ESRI_AddService "; CmdLine.ExecuteQuietCommand(cmdString2); } else { if (ribbonButton.Id == AfaStrings.RBN_BTN_TOC) { CmdLine.CancelActiveCommand(); string cmdString3 = "ESRI_SHOWTOC "; CmdLine.ExecuteQuietCommand(cmdString3); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_LAYER_MANAGER) { CmdLine.CancelActiveCommand(); string cmdString4 = ".LAYER "; CmdLine.ExecuteQuietCommand(cmdString4); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_ASSIGN_COORDSYS) { CmdLine.CancelActiveCommand(); string cmdString5 = ".ESRI_ASSIGNCS "; CmdLine.ExecuteQuietCommand(cmdString5); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_LIST_COORDSYS) { CmdLine.CancelActiveCommand(); string cmdString6 = ".ESRI_LISTCS "; CmdLine.ExecuteQuietCommand(cmdString6); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_REMOVE_COORDSYS) { CmdLine.CancelActiveCommand(); string cmdString7 = ".esri_RemoveCS "; CmdLine.ExecuteQuietCommand(cmdString7); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_ZOOMEXTENTS) { CmdLine.CancelActiveCommand(); string cmdString8 = ".ESRI_ZOOMEXTENTS "; CmdLine.ExecuteQuietCommand(cmdString8); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_ZOOMPREVIOUS) { CmdLine.CancelActiveCommand(); string cmdString9 = "'_ZOOM _PREVIOUS "; CmdLine.ExecuteQuietCommand(cmdString9); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_ZOOMWINDOW) { CmdLine.CancelActiveCommand(); string cmdString10 = "'_ZOOM _WINDOW "; CmdLine.ExecuteQuietCommand(cmdString10); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_RESOURCECENTER) { Process.Start(AfaStrings.URI_RESOURCECENTER); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_HELP) { CmdLine.CancelActiveCommand(); string cmdString11 = "ESRI_ArcGISHELP "; CmdLine.ExecuteQuietCommand(cmdString11); return; } if (ribbonButton.Id == AfaStrings.RBN_BTN_ABOUT) { CmdLine.CancelActiveCommand(); string cmdString12 = "ESRI_AboutArcGIS "; CmdLine.ExecuteQuietCommand(cmdString12); return; } if (ribbonButton.Id == "Command") { CmdLine.CancelActiveCommand(); string cmdString13 = (string)ribbonButton.CommandParameter; CmdLine.ExecuteQuietCommand(cmdString13); return; } string message = "Placeholder for " + ribbonButton.Id; ErrorReport.ShowErrorMessage(message); return; } return; } }
public void RequestNewRaster(Extent newExtent) { AGSExportOptions localEO = null; try { if (this.CancelRequests) { return; } if (!this.ReconnectService()) { ErrorReport.ShowErrorMessage(AfaStrings.UnableToConnectService + this.Name); return; } localEO = (AGSExportOptions)Utility.CloneObject(this.ExportOptions); localEO.BoundingBox = newExtent; System.Drawing.Size size = Autodesk.AutoCAD.ApplicationServices.Application.ToSystemDrawingSize(this.ParentDataset.ParentDocument.Window.DeviceIndependentSize); localEO.Width = size.Width; localEO.Height = size.Height; this.SetParentLayerVisibility(); localEO.OutputFile = Utility.TemporaryFilePath(); newExtent.SpatialReference = localEO.OutputWKT; } catch { } try { this.UpdateForm._rasterID = this.RasterObjectId; ITask exportTask = this.ParentService.GetExportTask(localEO, this.UpdateForm); AsyncTaskManager asyncTaskManager = new AsyncTaskManager(); asyncTaskManager.TasksExecutionCompleted += new EventHandler(MSCRasterService.taskManager_TasksExecutionCompleted); asyncTaskManager.AddTask(exportTask); this.PendingRequestCount++; if (App.UseBeep) { Console.Beep(196, 800); } asyncTaskManager.RunTasks(); int times = 0; int maxTimes = 200000; Timer timer = new Timer { Interval = 10, Enabled = true }; timer.Tick += delegate(object s, EventArgs e) { if (times++ >= maxTimes) { timer.Stop(); timer.Dispose(); timer = null; times = 0; this.PendingRequestCount--; return; } if (!this.UpdateForm.IsReady()) { return; } if (!this.CancelRequests && this.PendingRequestCount < 4) { if (this.UpdateForm.UpdateRasterNow()) { this.CurrentExtent = localEO.BoundingBox; this.CurrentFileName = localEO.OutputFile; } this.OutstandingRequestInfo = null; this.PendingRequestCount--; timer.Stop(); timer.Dispose(); timer = null; return; } this.OutstandingRequestInfo = null; this.PendingRequestCount--; timer.Stop(); timer.Dispose(); timer = null; }; this.UpdateForm.SetReady(false); } catch (Exception) { } }
public void ExportImage(AGSExportOptions eo, ExportImageEventHandler action) { try { string arg = base.Parent.URL + "/" + base.FullName + "/ImageServer/exportImage"; StringBuilder arg2 = this.BuildURIRequest(eo); Mouse.OverrideCursor = Cursors.Wait; IDictionary <string, object> dictionary = base.Parent.MakeDictionaryRequest(arg + arg2); if (dictionary == null) { Mouse.OverrideCursor = null; if (string.IsNullOrEmpty(base.Parent.ErrorMessage)) { ErrorReport.ShowErrorMessage(AfaStrings.AnUnexpectedErrorOccured); } else { ErrorReport.ShowErrorMessage(base.Parent.ErrorMessage); } return; } SpatialReference spatialReference = null; if (dictionary != null) { object obj; if (!dictionary.TryGetValue("href", out obj)) { string text = AfaStrings.Error; if (dictionary.ContainsKey("error")) { IDictionary <string, object> dictionary2 = dictionary["error"] as IDictionary <string, object>; if (dictionary2.ContainsKey("details")) { object obj2; if (dictionary2.TryGetValue("details", out obj2)) { object[] array = obj2 as object[]; if (array != null) { text = text + " - " + array[0].ToString(); } } } else { text += AfaStrings.UnknownError; } } Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(text); return; } string text2 = obj as string; if (text2.Length > 0) { ExportedImage exportedImage = new ExportedImage(this, text2); if (dictionary.TryGetValue("width", out obj)) { exportedImage.Properties.Add("width", obj); } if (dictionary.TryGetValue("height", out obj)) { exportedImage.Properties.Add("height", obj); } if (dictionary.TryGetValue("scale", out obj)) { exportedImage.Properties.Add("scale", obj); } if (dictionary.TryGetValue("extent", out obj)) { IDictionary <string, object> dictionary3 = obj as IDictionary <string, object>; object obj3; if (dictionary3.TryGetValue("xmin", out obj3)) { exportedImage.Properties.Add("xmin", obj3); } if (dictionary3.TryGetValue("xmax", out obj3)) { exportedImage.Properties.Add("xmax", obj3); } if (dictionary3.TryGetValue("ymax", out obj3)) { exportedImage.Properties.Add("ymax", obj3); } if (dictionary3.TryGetValue("ymin", out obj3)) { exportedImage.Properties.Add("ymin", obj3); } if (dictionary3.TryGetValue("spatialReference", out obj3)) { IDictionary <string, object> dictionary4 = obj3 as IDictionary <string, object>; object obj4; if (dictionary4.TryGetValue("wkid", out obj4)) { exportedImage.Properties.Add("spatialReference", obj4); int num = int.Parse(obj4.ToString()); spatialReference = AGSSpatialReference.SpRefFromWKID(ref num); } else if (dictionary4.TryGetValue("wkt", out obj4)) { exportedImage.Properties.Add("spatialReference", obj4); string text3 = obj4.ToString(); spatialReference = AGSSpatialReference.SpRefFromWKT(ref text3); } } PointN pointN = new PointN(); if (spatialReference != null) { pointN.SpatialReference = spatialReference; } double num2 = double.Parse(exportedImage.Properties["xmin"].ToString()); double num3 = double.Parse(exportedImage.Properties["ymin"].ToString()); double num4 = double.Parse(exportedImage.Properties["xmax"].ToString()); double num5 = double.Parse(exportedImage.Properties["ymax"].ToString()); pointN.X = num2; pointN.Y = num3; pointN.Z = 0.0; PointN[] points = new PointN[] { pointN, new PointN { SpatialReference = spatialReference, X = num4, Y = num3, Z = 0.0 }, new PointN { SpatialReference = spatialReference, X = num2, Y = num5, Z = 0.0 } }; try { if (File.Exists(eo.OutputFile)) { File.Delete(eo.OutputFile); if (App.TempFiles.Contains(eo.OutputFile)) { App.TempFiles.Remove(eo.OutputFile); } } new WebClient(); if (!base.Parent.DownloadFile(text2, eo.OutputFile)) { eo.OutputFile = text2; if (string.IsNullOrEmpty(eo.OutputFile)) { ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile); } } } catch { eo.OutputFile = text2; if (string.IsNullOrEmpty(eo.OutputFile)) { ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile); } } finally { if (action != null) { action(this, new ExportedImageEventArgs(this, eo, points)); } } Mouse.OverrideCursor = null; return; } } } } catch { Mouse.OverrideCursor = null; } Mouse.OverrideCursor = null; }