private CadField CreateAttributeValue(MSCFeatureClass fc, string fieldName, object value) { CadField result; try { CadField cadField = FeatureClassAPI.FindField(fc.Fields, fieldName); if (cadField == null) { result = null; } else if (cadField.ReadOnly || !cadField.Visible) { result = null; } else { TypedValue value2 = CadField.CreateTypedValue(cadField.FieldType, value.ToString()); result = new CadField(cadField) { Value = value2 }; } } catch { result = null; } return(result); }
private void Default_PreviewTextInput(object sender, TextCompositionEventArgs e) { try { System.Windows.Controls.TextBox textBox = (System.Windows.Controls.TextBox)sender; if (textBox.Tag != null) { CadField.CadFieldType fType = (CadField.CadFieldType)textBox.Tag; DataRowView dataRowView = (DataRowView)((FrameworkElement)sender).DataContext; string text = textBox.Text + e.Text; string s = dataRowView.Row["FieldLength"].ToString(); int num = int.Parse(s); e.Handled = !this.IsValidText(fType, num, text); if (!e.Handled) { CadField cadField = (CadField)dataRowView.Row["BaseField"]; FieldDomain domain = cadField.Domain; if (domain != null) { bool flag = domain.IsWithinRangeValue(text); if (!flag) { e.Handled = true; } } } } } catch { e.Handled = false; } }
public bool IsWithinRangeValue(object newValue) { bool result; try { TypedValue typedValue = CadField.CreateTypedValue(this.FieldType, newValue.ToString()); TypedValue typedValue2 = CadField.CreateTypedValue(this.FieldType, this.MinValue.ToString()); TypedValue typedValue3 = CadField.CreateTypedValue(this.FieldType, this.MaxValue.ToString()); IComparable comparable = (IComparable)typedValue.Value; if (comparable.CompareTo(typedValue2.Value) < 0) { result = false; } else if (comparable.CompareTo(typedValue3.Value) > 0) { result = false; } else { result = true; } } catch { result = true; } return(result); }
public ResultBuffer CreateResultBuffer() { ResultBuffer resultBuffer = new ResultBuffer(); resultBuffer.Add(new TypedValue(5005, this.DisplayName)); resultBuffer.Add(CadField.CreateTypedValue(this.Value)); return(resultBuffer); }
public object ESRI_Attributes_Get(ResultBuffer rb) { object result; try { ObjectId argument = LspUtil.GetArgument(rb, 0, ObjectId.Null); if (argument == ObjectId.Null) { result = null; } else { string assocParam = LspUtil.GetAssocParam(rb, "FCNAME", null); string assocParam2 = LspUtil.GetAssocParam(rb, "STNAME", null); string fieldName = LspUtil.GetAssocParam(rb, "FIELDNAME", null); MSCFeatureClass featureClass = this.GetFeatureClass(assocParam, assocParam2); List <CadField> list; if (featureClass == null) { list = CadField.EntityCadFields(argument); } else { list = featureClass.GetEntityFields(argument); } if (!string.IsNullOrEmpty(fieldName)) { list = (from x in list where x.Name == fieldName select x).ToList <CadField>(); } if (list.Count == 0) { result = null; } else { List <TypedValue> list2 = new List <TypedValue>(); list2.Add(new TypedValue(5016, null)); foreach (CadField current in list) { LspUtil.AppendDottedPair(ref list2, current.Name, current.Value.Value); } list2.Add(new TypedValue(5017, null)); ResultBuffer resultBuffer = new ResultBuffer(list2.ToArray()); result = resultBuffer; } } } catch { result = null; } return(result); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { DataTemplate result; try { ContentPresenter contentPresenter = container as ContentPresenter; object arg_0D_0 = contentPresenter.Tag; DataGridCell dataGridCell = contentPresenter.Parent as DataGridCell; if (!dataGridCell.IsEditing) { result = this.DisplayOnlyTemplate; } else { DataRowView dataRowView = (DataRowView)dataGridCell.DataContext; string a = dataRowView[AfaStrings.Type].ToString(); CadField cadField = (CadField)dataRowView["BaseField"]; if (cadField != null && cadField.Domain != null && cadField.Domain.CodedValues.Count > 0) { result = this.CodedValueTemplate; } else if (a == "Date") { result = this.DateValueTemplate; } else if (a == "Double") { result = this.RealValueTemplate; } else if (a == "Integer") { result = this.IntegerValueTemplate; } else if (a == "Float") { result = this.RealValueTemplate; } else if (a == "Short") { result = this.IntegerValueTemplate; } else { result = this.PlainTemplate; } } } catch { result = this.PlainTemplate; } return(result); }
public TypedValue CheckValue(object testValue) { MSCCodedValue mSCCodedValue = this.GetCodedValue(testValue); if (mSCCodedValue == null) { if (this.FauxNull == null) { this.SetFauxNull(testValue); } mSCCodedValue = this.FauxNull; } return(CadField.CreateTypedValue(this.FieldType, mSCCodedValue.Value)); }
private CadField CreateAttributeValue(MSCFeatureClass fc, ref object firstValue, ref object secondValue) { TypedValue typedValue = (TypedValue)firstValue; TypedValue typedValue2 = (TypedValue)secondValue; string text = typedValue.Value.ToString(); object value = typedValue2.Value; string fieldName = text.ToString(); CadField cadField = FeatureClassAPI.FindField(fc.Fields, fieldName); if (cadField == null) { firstValue = null; secondValue = null; return(null); } if (cadField.ReadOnly || !cadField.Visible) { return(null); } TypedValue value2 = CadField.CreateTypedValue(cadField.FieldType, typedValue2.Value.ToString()); if (value2.TypeCode != cadField.Value.TypeCode) { firstValue = null; secondValue = null; return(null); } CadField cadField2 = new CadField(cadField); cadField2.Value = value2; if (cadField2.Value.TypeCode == 1) { string text2 = cadField2.Value.Value.ToString(); if (text2.Length > (int)cadField.Length) { firstValue = null; secondValue = null; return(null); } } firstValue = null; secondValue = null; return(cadField2); }
private void cbDomainValues_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataRowView dataRowView = (DataRowView)((FrameworkElement)sender).DataContext; CadField cadField = dataRowView["BaseField"] as CadField; System.Windows.Controls.ComboBox comboBox = (System.Windows.Controls.ComboBox)sender; if (comboBox.SelectedItem != null) { MSCCodedValue mSCCodedValue = (MSCCodedValue)comboBox.SelectedItem; if (mSCCodedValue == null) { return; } if (mSCCodedValue.Value == null) { return; } MSCCodedValue mSCCodedValue2 = new MSCCodedValue("test", cadField.FieldType, dataRowView["Value"]); if (!mSCCodedValue2.Value.Equals(mSCCodedValue.Value)) { dataRowView["Value"] = mSCCodedValue.Value; this.CommitEdit(dataRowView); if (cadField.TypeField) { this.PopulateFeatureClassPicker(AfaDocData.ActiveDocData.GetTopActiveFeatureClass(), AfaDocData.ActiveDocData.GetActiveSubtype(), this.originalObjectIds); this.FillRows(this.originalObjectIds); return; } try { ObservableCollection <MSCCodedValue> observableCollection = (ObservableCollection <MSCCodedValue>)dataRowView["CodedValues"]; MSCCodedValue mSCCodedValue3 = observableCollection.First((MSCCodedValue x) => x.DisplayName == Identify.VariesValue); if (mSCCodedValue3 != null) { observableCollection.Remove(mSCCodedValue3); } } catch { } } } }
public void Write(Database db, Transaction t) { try { DBDictionary dBDictionary = this.ParentDataset.Open(db, t, FieldDomain.DictionaryName, (OpenMode)1); DBDictionary dBDictionary2 = new DBDictionary(); this.Id = dBDictionary.SetAt(this.Name, dBDictionary2); dBDictionary2.DisableUndoRecording(true); t.AddNewlyCreatedDBObject(dBDictionary2, true); this.WriteTypedValue(db, t, dBDictionary2, "KeyName", new TypedValue(1, this.Name)); this.WriteTypedValue(db, t, dBDictionary2, "DisplayName", new TypedValue(1, this.DisplayName)); this.WriteTypedValue(db, t, dBDictionary2, "DomainType", new TypedValue(1, this.DomainType)); this.WriteTypedValue(db, t, dBDictionary2, "DomainFieldType", new TypedValue(90, this.FieldType)); if (this.DomainType == "RangeDomain") { this.WriteTypedValue(db, t, dBDictionary2, "DomainMinimum", CadField.CreateTypedValue(this.MinValue)); this.WriteTypedValue(db, t, dBDictionary2, "DomainMaximum", CadField.CreateTypedValue(this.MaxValue)); } if (this.DomainType == "CodedValueDomain") { List <TypedValue> list = new List <TypedValue>(); foreach (KeyValuePair <string, MSCCodedValue> keyValuePair in this.CodedValues) { MSCCodedValue value = keyValuePair.Value; list.Add(CadField.CreateTypedValue(value.DisplayName)); list.Add(CadField.CreateTypedValue(value.Value)); } try { ResultBuffer rb = new ResultBuffer(list.ToArray()); this.WriteResultBuffer(db, t, dBDictionary2, "CodedValues", rb); } catch (System.Exception) { } } } catch { } }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { DataTemplate result; try { ContentPresenter contentPresenter = container as ContentPresenter; DataGridCell dataGridCell = contentPresenter.Parent as DataGridCell; DataRowView dataRowView = (DataRowView)dataGridCell.DataContext; CadField cadField = (CadField)dataRowView.Row["BaseField"]; if (cadField != null) { if (cadField.Domain != null && cadField.Domain.CodedValues.Count > 0) { result = this.CodedValueTemplate; } else { esriFieldType extendedType = (esriFieldType)cadField.ExtendedType; if (extendedType == esriFieldType.esriFieldTypeDate) { result = this.DateValueTemplate; } else { result = this.PlainTemplate; } } } else { result = this.PlainTemplate; } } catch { result = this.PlainTemplate; } return(result); }
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 object ESRI_DeleteFeatureClassAttributes(ResultBuffer rb) { object result; try { TypedValue[] array = rb.AsArray(); if (array.Count <TypedValue>() < 1) { result = null; } else { TypedValue typedValue = array[0]; if (typedValue.TypeCode != 5006) { result = null; } else { ObjectId id = (ObjectId)typedValue.Value; List <string> list = new List <string>(); if (array.Count <TypedValue>() > 1) { TypedValue[] array2 = array; for (int i = 0; i < array2.Length; i++) { TypedValue typedValue2 = array2[i]; if (typedValue2.TypeCode == 5005) { list.Add(typedValue2.Value.ToString()); } } } List <CadField> list2 = CadField.EntityCadFields(id); if (list2.Count == 0) { result = LspUtil.LispTrue; } else { List <CadField> list3 = null; if (list.Count == 0) { list3 = list2; } else { list3 = new List <CadField>(); foreach (CadField current in list2) { foreach (string current2 in list) { if (string.Equals(current2, current.Name, StringComparison.CurrentCultureIgnoreCase) && !list3.Contains(current)) { list3.Add(current); } } } } if (list3.Count == 0) { result = LspUtil.LispTrue; } else { Document document = AfaDocData.ActiveDocData.Document; Database database = document.Database; using (document.LockDocument((DocumentLockMode)4, null, null, false)) { using (Transaction transaction = database.TransactionManager.StartTransaction()) { foreach (CadField current3 in list3) { if (!current3.ReadOnly && current3.Visible) { CadField.RemoveCadAttribute(database, transaction, id, current3); } } transaction.Commit(); } } result = LspUtil.LispTrue; } } } } } catch { result = null; } return(result); }
public object ESRI_GetFeatureClassFieldDefinition(ResultBuffer rb) { object result; try { TypedValue[] array = rb.AsArray(); if (array.Count <TypedValue>() < 2) { result = null; } else { TypedValue typedValue = array[0]; if (typedValue.TypeCode != 5005) { result = null; } else { string name = typedValue.Value.ToString(); string subtypeName = null; if (array.Count <TypedValue>() == 3) { TypedValue typedValue2 = array[2]; if (typedValue2.TypeCode != 5005) { result = null; return(result); } subtypeName = typedValue2.Value.ToString(); } MSCFeatureClass featureClassOrService = this.GetFeatureClassOrService(name, subtypeName); if (featureClassOrService == null) { result = null; } else { TypedValue typedValue3 = array[1]; if (typedValue3.TypeCode != 5005) { result = null; } else { string fieldName = typedValue3.Value.ToString(); if (featureClassOrService.Fields.Count == 0) { result = null; } else { CadField cadField = FeatureClassAPI.FindField(featureClassOrService.Fields, fieldName); if (cadField == null) { result = null; } else { List <TypedValue> list = new List <TypedValue>(); list.Add(new TypedValue(5016, null)); LspUtil.AppendDottedPair(ref list, 5005, "NAME", 5005, cadField.Name); LspUtil.AppendDottedPair(ref list, 5005, "TYPE", 5005, CadField.CodeString((int)cadField.FieldType)); LspUtil.AppendDottedPair(ref list, 5005, "RO", 5003, cadField.ReadOnly); if (cadField.FieldType == CadField.CadFieldType.String) { LspUtil.AppendDottedPair(ref list, 5005, "LENGTH", 5003, cadField.Length); } LspUtil.AppendDottedPair(ref list, "VALUE", cadField.Value); list.Add(new TypedValue(5017, null)); ResultBuffer resultBuffer = new ResultBuffer(list.ToArray()); result = resultBuffer; } } } } } } } catch { result = null; } return(result); }
public object ESRI_SetFeatureClassAttributes(ResultBuffer rb) { object result; try { TypedValue[] array = rb.AsArray(); if (array.Count <TypedValue>() < 3) { result = null; } else { TypedValue typedValue = array[0]; if (typedValue.TypeCode != 5006) { result = null; } else { ObjectId id = (ObjectId)typedValue.Value; TypedValue typedValue2 = array[1]; if (typedValue2.TypeCode != 5005) { result = null; } else { string name = typedValue2.Value.ToString(); MSCFeatureClass featureClass = this.GetFeatureClass(name, null); if (featureClass == null) { result = null; } else { Dictionary <string, object> dictionary = LspUtil.BuildAssocDictionary(rb); if (dictionary.Count == 0) { result = null; } else { List <CadField> list = new List <CadField>(); foreach (KeyValuePair <string, object> current in dictionary) { CadField cadField = this.CreateAttributeValue(featureClass, current.Key, current.Value); if (cadField != null) { list.Add(cadField); } } if (list.Count == 0) { result = null; } else { result = CadField.AddCadAttributesToEntity(id, list); } } } } } } } catch { result = null; } return(result); }
public MSCCodedValue(string name, CadField.CadFieldType type, object value) { this.DisplayName = name; this.Value = CadField.CreateTypedValue(type, value.ToString()).Value; }
public object ESRI_RemoveFeatureClassFieldDefinition(ResultBuffer rb) { object result; try { TypedValue[] array = rb.AsArray(); if (array.Count <TypedValue>() < 2) { result = null; } else { TypedValue typedValue = array[0]; if (typedValue.TypeCode != 5005) { result = null; } else { string name = typedValue.Value.ToString(); MSCFeatureClass localFeatureClass = this.GetLocalFeatureClass(name); if (localFeatureClass == null) { result = null; } else { TypedValue typedValue2 = array[1]; if (typedValue2.TypeCode != 5005) { result = null; } else { string fieldName = typedValue2.Value.ToString(); if (localFeatureClass.Fields.Count == 0) { result = null; } else { CadField cadField = FeatureClassAPI.FindField(localFeatureClass.Fields, fieldName); if (cadField == null) { result = null; } else if (cadField.ReadOnly) { result = null; } else if (localFeatureClass.Fields.Remove(cadField)) { localFeatureClass.Write(AfaDocData.ActiveDocData.Document); result = LspUtil.LispTrue; } else { result = null; } } } } } } } catch { result = null; } return(result); }
public object ESRI_AddFeatureClassFieldDefinition(ResultBuffer rb) { object result; try { TypedValue[] array = rb.AsArray(); if (array.Count <TypedValue>() < 2) { result = null; } else { TypedValue typedValue = array[0]; if (typedValue.TypeCode != 5005) { result = null; } else { string name = typedValue.Value.ToString(); MSCFeatureClass localFeatureClass = this.GetLocalFeatureClass(name); if (localFeatureClass == null) { result = null; } else { string text = null; string strVal = null; object obj = null; object obj2 = null; object obj3 = null; object obj4 = null; TypedValue[] array2 = array; for (int i = 0; i < array2.Length; i++) { TypedValue typedValue2 = array2[i]; if (typedValue2.TypeCode == 5016) { obj3 = null; obj4 = null; } else if (typedValue2.TypeCode == 5017) { obj3 = null; obj4 = null; } else if (typedValue2.TypeCode == 5018) { if (obj3 != null && obj4 != null) { TypedValue typedValue3 = (TypedValue)obj3; TypedValue typedValue4 = (TypedValue)obj4; string a = typedValue3.Value.ToString(); object value = typedValue4.Value; if (string.Equals(a, "NAME", StringComparison.CurrentCultureIgnoreCase)) { text = value.ToString(); } else if (string.Equals(a, "VALUE", StringComparison.CurrentCultureIgnoreCase)) { obj = value.ToString(); } else if (string.Equals(a, "TYPE", StringComparison.CurrentCultureIgnoreCase)) { strVal = value.ToString(); } else if (string.Equals(a, "LENGTH", StringComparison.CurrentCultureIgnoreCase)) { string s = value.ToString(); obj2 = short.Parse(s); } } } else if (obj3 == null) { obj3 = typedValue2; } else { obj4 = typedValue2; } } if (string.IsNullOrEmpty(text)) { result = null; } else { CadField cadField = FeatureClassAPI.FindField(localFeatureClass.Fields, text); if (cadField != null) { result = null; } else { CadField cadField2 = new CadField(); cadField2.Name = text; CadField.CadFieldType cadFieldType = CadField.FieldTypeCode(strVal); if (obj == null) { if (cadFieldType == CadField.CadFieldType.Double) { obj = 0.0; } if (cadFieldType == CadField.CadFieldType.Integer) { obj = 0; } if (cadFieldType == CadField.CadFieldType.Short) { obj = 0; } if (cadFieldType == CadField.CadFieldType.String) { obj = ""; } } if (obj != null) { cadField2.Value = new TypedValue((int)cadFieldType, obj); } if (obj2 == null && cadFieldType == CadField.CadFieldType.String) { obj2 = 255; } if (obj2 != null) { short num = short.Parse(obj2.ToString()); if (num > 0 && num < 256) { obj2 = num; } cadField2.Length = (short)obj2; } cadField2.ReadOnly = false; cadField2.TypeField = false; cadField2.Visible = true; localFeatureClass.Fields.Add(cadField2); localFeatureClass.Write(AfaDocData.ActiveDocData.Document); result = cadField2.Name; } } } } } } catch (SystemException) { result = null; } return(result); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; StringBuilder stringBuilder = null; foreach (object current in bindingGroup.Items) { DataRowView dataRowView = current as DataRowView; if (dataRowView != null) { try { DataRow row = dataRowView.Row; DataTable table = row.Table; string text = dataRowView.Row["Name"].ToString(); if (!CadField.IsValidFieldName(text)) { stringBuilder = new StringBuilder(); stringBuilder.Append(AfaStrings.InvalidFieldName); ValidationResult result = new ValidationResult(false, stringBuilder.ToString()); return(result); } foreach (DataRow dataRow in table.Rows) { if (dataRow != row && dataRow["Name"].ToString().Equals(text, StringComparison.CurrentCultureIgnoreCase)) { stringBuilder = new StringBuilder(); stringBuilder.Append(AfaStrings.DuplicateFieldName); ValidationResult result = new ValidationResult(false, stringBuilder.ToString()); return(result); } } string text2 = row["Value"].ToString(); string text3 = row["Type"].ToString(); if (string.IsNullOrEmpty(text3)) { row["Type"] = "String"; } CadField.GetTypeCode(text3); CadField.CadFieldType cadFieldType = CadField.FieldTypeCode(row["Type"].ToString()); if (!string.IsNullOrEmpty(text2) && !CadField.IsValidTypedValue(cadFieldType, text2)) { stringBuilder = new StringBuilder(); stringBuilder.Append(AfaStrings.ErrorValueNotEqualType); ValidationResult result = new ValidationResult(false, stringBuilder.ToString()); return(result); } string s = row["Length"].ToString(); int num = 0; if (cadFieldType == CadField.CadFieldType.String) { if (int.TryParse(s, out num)) { if (num < 0) { stringBuilder = new StringBuilder(); stringBuilder.Append(AfaStrings.InvalidLengthValue); ValidationResult result = new ValidationResult(false, stringBuilder.ToString()); return(result); } if (num == 0) { row["Length"] = "255"; dataRowView["Length"] = "255"; } } else { row["Length"] = "255"; dataRowView["Length"] = "255"; } } else { if (string.IsNullOrEmpty(row["Value"].ToString())) { row["Value"] = "0"; dataRowView["Value"] = "0"; } row["Length"] = "0"; dataRowView["Length"] = "255"; } if (cadFieldType == CadField.CadFieldType.String && num > 0 && text2.Length > num) { stringBuilder = new StringBuilder(); stringBuilder.Append(AfaStrings.ValueExceedsFieldLength); ValidationResult result = new ValidationResult(false, stringBuilder.ToString()); return(result); } } catch { stringBuilder = new StringBuilder(); stringBuilder.Append(AfaStrings.ErrorInDXFCode); ValidationResult result = new ValidationResult(false, stringBuilder.ToString()); return(result); } if (!string.IsNullOrEmpty(dataRowView.Row.RowError)) { if (stringBuilder == null) { stringBuilder = new StringBuilder(); } stringBuilder.Append(((stringBuilder.Length != 0) ? ", " : "") + dataRowView.Row.RowError); } } } if (stringBuilder != null) { return(new ValidationResult(false, stringBuilder.ToString())); } return(ValidationResult.ValidResult); }
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); }