/** * 官网示例 * */ public void IFeatureClass_CreateFeature_Example(IFeatureClass featureClass) { //Function is designed to work with polyline data if (featureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) { return; } //create a geometry for the features shape ESRI.ArcGIS.Geometry.IPolyline polyline = new ESRI.ArcGIS.Geometry.PolylineClass(); ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass(); point.X = 0; point.Y = 0; polyline.FromPoint = point; point = new ESRI.ArcGIS.Geometry.PointClass(); point.X = 10; point.Y = 10; polyline.ToPoint = point; IFeature feature = featureClass.CreateFeature(); //Apply the constructed shape to the new features shape feature.Shape = polyline; ISubtypes subtypes = (ISubtypes)featureClass; IRowSubtypes rowSubtypes = (IRowSubtypes)feature; if (subtypes.HasSubtype) // does the feature class have subtypes? { rowSubtypes.SubtypeCode = 1; //in this example 1 represents the Primary Pipeline subtype } // initalize any default values that the feature has rowSubtypes.InitDefaultValues(); //Commit the default values in the feature to the database feature.Store(); //update the value on a string field that indicates who installed the feature. feature.set_Value(feature.Fields.FindField("InstalledBy"), "K Johnston"); //Commit the updated values in the feature to the database feature.Store(); }
//IFeatureClass CreateFeature Example private IFeature IFeatureClass_Create(IFeatureClass featureClass, IGeometry pGeometry) { IWorkspaceEdit iWE = (featureClass as IDataset).Workspace as IWorkspaceEdit; if (!iWE.IsBeingEdited()) { iWE.StartEditing(false); } iWE.StartEditOperation(); IFeature feature = featureClass.CreateFeature(); //Apply the constructed shape to the new features shape feature.Shape = pGeometry; //如果不是shp 则初始化子类型 if ((featureClass as IDataset).Workspace.WorkspaceFactory.WorkspaceType != esriWorkspaceType.esriFileSystemWorkspace) { ISubtypes subtypes = (ISubtypes)featureClass; IRowSubtypes rowSubtypes = (IRowSubtypes)feature; if (subtypes.HasSubtype) // does the feature class have subtypes? { rowSubtypes.SubtypeCode = 1; //in this example 1 represents the Primary Pipeline subtype } // initalize any default values that the feature has rowSubtypes.InitDefaultValues(); //Commit the default values in the feature to the database } feature.Store(); iWE.StopEditOperation(); //iWE.StopEditing(true); iWE = null; return(feature); }
/// <summary> /// Determines whether the specified field <paramref name="index" /> on the <paramref name="table" /> is editable by /// both ESRI and ArcFM. /// </summary> /// <param name="table">The object class.</param> /// <param name="index">The index.</param> /// <returns> /// <c>true</c> if the specified field index on the class is editable by both ESRI and ArcFM; otherwise, <c>false</c>. /// </returns> /// <exception cref="System.ArgumentNullException">table</exception> /// <exception cref="System.IndexOutOfRangeException"></exception> protected virtual bool IsEditable(IObjectClass table, int index) { if (table == null) { throw new ArgumentNullException("table"); } if (index < 0 || index > table.Fields.FieldCount - 1) { throw new IndexOutOfRangeException(); } IField field = table.Fields.Field[index]; if (field.Editable) { ISubtypes subtypes = (ISubtypes)table; if (!_FieldManagersByClassID.ContainsKey(table.ObjectClassID)) { _FieldManagersByClassID.Add(table.ObjectClassID, table.GetFieldManager(subtypes.DefaultSubtypeCode)); } IMMFieldManager fieldManager = _FieldManagersByClassID[table.ObjectClassID]; IMMFieldAdapter fieldAdapter = fieldManager.FieldByIndex(index); return(fieldAdapter.Editable); } return(false); }
//获得阀门的属性字段和信息 private void GetValves(IFeature pFeature, out string var1, out string var2, out string var3) { IFields pFields = pFeature.Fields; ISubtypes pWaterPtSubtypes = pFeatLayerValves.FeatureClass as ISubtypes; var1 = pFeature.get_Value(pFields.FindField("WATER_ID")).ToString(); var2 = pFeature.get_Value(pFields.FindField("PWV_TYPE")).ToString(); var3 = pFeature.get_Value(pFields.FindField("PWSHEETNO")).ToString(); IRowSubtypes pRowSubtypes = pFeature as IRowSubtypes; if (pRowSubtypes != null) { IDomain pDomain = pWaterPtSubtypes.get_Domain(pRowSubtypes.SubtypeCode, "PWV_TYPE"); if (pDomain != null) { ICodedValueDomain pCodedValDomain = pDomain as ICodedValueDomain; for (int i = 0; i <= pCodedValDomain.CodeCount - 1; i++) { if (pCodedValDomain.get_Value(i).ToString() == var2) { var2 = pCodedValDomain.get_Name(i).ToString(); } } } } }
//获得管线的属性字段和信息 private void GetWaterLineValue(out string var1, out string var2, out string var3, out string var4, out string var5) { IFields pFields = pFeatureWaterLine.Fields; var1 = pFeatureWaterLine.get_Value(pFields.FindField("WATER_ID")).ToString(); var2 = pFeatureWaterLine.get_Value(pFields.FindField("PIPEUSE_CODE")).ToString(); var3 = pFeatureWaterLine.get_Value(pFields.FindField("SHAPE_LENGTH")).ToString(); var4 = pFeatureWaterLine.get_Value(pFields.FindField("PWDIAM")).ToString(); var5 = pFeatureWaterLine.get_Value(pFields.FindField("PWMATERIAL")).ToString(); //根据子类型代码获得子类型名称 ISubtypes pWaterLineSubtypes = pFeatLayerWaterLines.FeatureClass as ISubtypes; IRowSubtypes pRowSubtypes = pFeatureWaterLine as IRowSubtypes; if (pRowSubtypes != null) { var2 = pWaterLineSubtypes.get_SubtypeName(pRowSubtypes.SubtypeCode); //获取属性域 IDomain pDomain = pWaterLineSubtypes.get_Domain(pRowSubtypes.SubtypeCode, "PWMATERIAL"); if (pDomain != null) { ICodedValueDomain pCodedValDomain = pDomain as ICodedValueDomain; for (int i = 0; i <= pCodedValDomain.CodeCount - 1; i++) { if (pCodedValDomain.get_Value(i) == var5) { var5 = pCodedValDomain.get_Name(i); } } } } }
/// <summary> /// Changes the field visibility to the specified <paramref name="visible" /> value for all subtypes in the specified /// <paramref name="table" /> object class /// that match the field name. /// </summary> /// <param name="source">The source.</param> /// <param name="table">The object class.</param> /// <param name="visible">if set to <c>true</c> if the field is visible.</param> /// <param name="fieldNames">The field names.</param> /// <exception cref="ArgumentNullException"> /// fieldNames /// or /// table /// </exception> public static void ChangeVisibility(this IMMConfigTopLevel source, IObjectClass table, bool visible, params string[] fieldNames) { if (source == null) { return; } if (fieldNames == null) { throw new ArgumentNullException("fieldNames"); } if (table == null) { throw new ArgumentNullException("table"); } // Change the hidden subtype of -1, which represents all subtypes. source.ChangeVisibility(table, ALL_SUBTYPES, visible, fieldNames); ISubtypes subtypes = (ISubtypes)table; IEnumerable <int> subtypeCodes = subtypes.HasSubtype ? subtypes.Subtypes.AsEnumerable().Select(o => o.Key) : new[] { subtypes.DefaultSubtypeCode }; // Change the individual subtypes. foreach (var subtypeCode in subtypeCodes) { source.ChangeVisibility(table, subtypeCode, visible, fieldNames); } }
//IFeatureClass CreateFeature Example private IFeature IFeatureClass_Create(IFeatureClass featureClass, IGeometry pGeometry) { if (featureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) { return(null); } IWorkspaceEdit iWE = (featureClass as IDataset).Workspace as IWorkspaceEdit; if (!iWE.IsBeingEdited()) { iWE.StartEditing(false); } IFeature feature = featureClass.CreateFeature(); //Apply the constructed shape to the new features shape feature.Shape = pGeometry; ISubtypes subtypes = (ISubtypes)featureClass; IRowSubtypes rowSubtypes = (IRowSubtypes)feature; if (subtypes.HasSubtype) // does the feature class have subtypes? { rowSubtypes.SubtypeCode = 1; //in this example 1 represents the Primary Pipeline subtype } // initalize any default values that the feature has rowSubtypes.InitDefaultValues(); //Commit the default values in the feature to the database feature.Store(); iWE.StopEditing(true); iWE = null; return(feature); }
/// <summary> /// Finds the code of the subtype that has the specified <paramref name="subtypeName" />. /// </summary> /// <param name="source">The table.</param> /// <param name="subtypeName">Name of the subtype.</param> /// <returns> /// Returns a <see cref="int" /> representing the code of the subtype; otherwise <c>-1</c>. /// </returns> /// <exception cref="System.ArgumentNullException">subtypeName</exception> public static int GetSubtypeCode(this ITable source, string subtypeName) { if (source == null) { return(-1); } if (subtypeName == null) { throw new ArgumentNullException("subtypeName"); } ISubtypes subtypes = (ISubtypes)source; if (subtypes.HasSubtype) { return(subtypes.DefaultSubtypeCode); } foreach (var subtype in subtypes.Subtypes.AsEnumerable().Where(subtype => subtype.Value.Equals(subtypeName, StringComparison.OrdinalIgnoreCase))) { return(subtype.Key); } return(-1); }
/// <summary> /// Gets all of the field ArcFM Auto Updaters that have been configured for the specified /// <paramref name="editEvent" /> on the <paramref name="table" /> object class for specified fields. /// </summary> /// <param name="source">The source.</param> /// <param name="table">The object class.</param> /// <param name="editEvent">The edit event.</param> /// <param name="fieldNames">The field names.</param> /// <returns> /// Returns a <see cref="Dictionary{Key, Value}" /> representing the automatic values for the subtypes and the /// individual fields. /// </returns> /// <exception cref="ArgumentNullException"> /// fieldNames /// or /// table /// </exception> public static Dictionary <int, Dictionary <string, IEnumerable <IMMAutoValue> > > GetAutoValues(this IMMConfigTopLevel source, IObjectClass table, mmEditEvent editEvent, params string[] fieldNames) { if (source == null) { return(null); } if (fieldNames == null) { throw new ArgumentNullException("fieldNames"); } if (table == null) { throw new ArgumentNullException("table"); } Dictionary <int, Dictionary <string, IEnumerable <IMMAutoValue> > > list = new Dictionary <int, Dictionary <string, IEnumerable <IMMAutoValue> > >(); var values = source.GetAutoValues(table, ALL_SUBTYPES, editEvent, fieldNames); list.Add(ALL_SUBTYPES, values); ISubtypes subtypes = (ISubtypes)table; if (subtypes.HasSubtype) { IEnumerable <int> subtypeCodes = subtypes.Subtypes.AsEnumerable().Select(o => o.Key).OrderBy(o => o); foreach (var subtypeCode in subtypeCodes) { values = source.GetAutoValues(table, subtypeCode, editEvent, fieldNames); list.Add(subtypeCode, values); } } return(list); }
/// <summary> /// Executes the geoprocessing function using the given array of parameter values. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="trackCancel">The track cancel.</param> /// <param name="environmentManager">Provides access to all the current environments and settings of the current client.</param> /// <param name="messages">The messages that are reported to the user.</param> /// <param name="utilities"> /// The utilities object that provides access to the properties and methods of a geoprocessing /// objects. /// </param> protected override void Execute(Dictionary <string, IGPValue> parameters, ITrackCancel trackCancel, IGPEnvironmentManager environmentManager, IGPMessages messages, IGPUtilities2 utilities) { IGPValue value = parameters["in_table"]; IObjectClass table = utilities.OpenTable(value); if (table != null) { IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; configTopLevel.Workspace = utilities.GetWorkspace(value); // Load all of the subtypes when the user specified "All" or "-1". int subtype = parameters["in_subtype"].Cast(-1); var subtypeCodes = new List <int>(new[] { subtype }); if (subtype == -1) { ISubtypes subtypes = (ISubtypes)table; subtypeCodes.AddRange(subtypes.Subtypes.AsEnumerable().Select(o => o.Key)); } IGPMultiValue onCreate = (IGPMultiValue)parameters["in_create"]; IGPMultiValue onUpdate = (IGPMultiValue)parameters["in_update"]; IGPMultiValue onDelete = (IGPMultiValue)parameters["in_delete"]; // Load the "Attribute" AUs. var uids = new Dictionary <mmEditEvent, IEnumerable <IUID> >(); uids.Add(mmEditEvent.mmEventFeatureCreate, onCreate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID)); uids.Add(mmEditEvent.mmEventFeatureUpdate, onUpdate.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID)); uids.Add(mmEditEvent.mmEventFeatureDelete, onDelete.AsEnumerable().Cast <IGPAutoValue>().Select(o => o.UID)); IGPValue field = parameters["in_field"]; int index = table.FindField(field.GetAsText()); // Enumerate through all of the subtypes making changes. foreach (var subtypeCode in subtypeCodes) { // Load the configurations for the table and subtype. IMMSubtype mmsubtype = configTopLevel.GetSubtypeByID(table, subtypeCode, false); // Load the field configurations. IMMField mmfield = null; mmsubtype.GetField(index, ref mmfield); // Update the list to have these UIDs removed. ID8List list = (ID8List)mmfield; base.Remove(uids, list, messages); } // Commit the changes to the database. configTopLevel.SaveFeatureClassToDB(table); // Success. parameters["out_results"].SetAsText("true"); } else { // Failure. parameters["out_results"].SetAsText("false"); } }
private void UpdateGrid() { IFields fields = this.m_pObject.Fields; ISubtypes subtypes = this.m_pObject.Class as ISubtypes; IDomain domain = null; ICodedValueDomain domain2 = null; for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); if (((((field.Type != esriFieldType.esriFieldTypeGeometry) && (field.Type != esriFieldType.esriFieldTypeOID)) && (field.Type != esriFieldType.esriFieldTypeRaster)) && field.Editable) && (subtypes.SubtypeFieldName != field.Name)) { domain = subtypes.get_Domain((this.m_pObject as IRowSubtypes).SubtypeCode, field.Name); if (domain is ICodedValueDomain) { IList list = new ArrayList(); domain2 = domain as ICodedValueDomain; if (field.IsNullable) { list.Add("<空>"); } for (int j = 0; j < domain2.CodeCount; j++) { list.Add(domain2.get_Name(j)); } this.m_pVertXtraGrid.ChangeItem(i, (Common.ControlExtend.ColumnAttribute)ColumnAttribute.CA_COMBOBOX, list, 0.0, 0.0); } else if ((((field.Type == esriFieldType.esriFieldTypeSmallInteger) || (field.Type == esriFieldType.esriFieldTypeSingle)) || (field.Type == esriFieldType.esriFieldTypeDouble)) || (field.Type == esriFieldType.esriFieldTypeInteger)) { double minValue = 0.0; double maxValue = 0.0; if (domain is IRangeDomain) { minValue = (double)(domain as IRangeDomain).MinValue; maxValue = (double)(domain as IRangeDomain).MaxValue; this.m_pVertXtraGrid.ChangeItem(i, (Common.ControlExtend.ColumnAttribute)ColumnAttribute.CA_SPINEDIT, null, 0.0, 0.0); } else { this.m_pVertXtraGrid.ChangeItem(i, (Common.ControlExtend.ColumnAttribute)ColumnAttribute.CA_TEXTEDIT, null, 0.0, 0.0); } } else { this.m_pVertXtraGrid.ChangeItem(i, (Common.ControlExtend.ColumnAttribute)ColumnAttribute.CA_TEXTEDIT, null, 0.0, 0.0); } } } }
/// <summary> /// Initializes a new instance of the <see cref="QueryBuilder" /> class. /// </summary> /// <param name="buildClass">The build class.</param> public QueryBuilder(IObjectClass buildClass) { _Subtypes = (ISubtypes)buildClass; _Workspace = ((IDataset)buildClass).Workspace; _WildcardManyMatch = ((ISQLSyntax)_Workspace).GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_WildcardManyMatch); _Cast = ((ISQLSyntax)_Workspace).GetFunctionName(esriSQLFunctionName.esriSQL_CAST); _UpperCase = ((ISQLSyntax)_Workspace).GetFunctionName(esriSQLFunctionName.esriSQL_UPPER); _DBMS = _Workspace.GetDBMS(); }
private static ConstraintNode CreateValidSubtypesConstraint( [NotNull] ISubtypes subtypeInfo, [NotNull] string subtypeField) { return(new ConstraintNode( GetSubtypeConstaint(subtypeInfo, subtypeField), "Invalid subtype", Codes[GdbConstraintIssueCodes.InvalidSubtype], subtypeField)); }
/// <summary> /// 创建子类 /// </summary> /// <param name="featureClass">要创建子类的要素类</param> /// <param name="subTypeFieldName">需创建子类的字段名</param> /// <param name="dicSubtypeItems">子类项</param> public static void CreateSubtypes(this IFeatureClass featureClass, string subTypeFieldName, Dictionary <int, string> dicSubtypeItems) { ISubtypes subtypes = featureClass as ISubtypes; subtypes.SubtypeFieldName = subTypeFieldName; foreach (var subtypeItem in dicSubtypeItems) { subtypes.AddSubtype(subtypeItem.Key, subtypeItem.Value); } subtypes.DefaultSubtypeCode = 0; }
/// <summary> /// Execute is called by Data Reviewer engine and passed the appropriate parameters. /// </summary> /// <param name="validateMe">IWorkspace object that contains the data being validated</param> /// <param name="arguments">comma delimited string of arguments</param> /// <returns> /// Collection of validation results. /// </returns> public IPLTSErrorCollection Execute(IWorkspace validateMe, string arguments) { m_ipWorkspace = validateMe; IPLTSErrorCollection ipRevResultCollection = new PLTSErrorCollectionClass(); //Split comma delimited string into array //This is the array of fully qualified feature class/table names string[] arrayOfArguments = arguments.Split(new char[] { ',' }, StringSplitOptions.None); //loop through the feature classes/tables and check for any attributes that violate domain constraints for (int i = 0; i < arrayOfArguments.Length; i++) { string strTableName = arrayOfArguments[i]; if (DatasetExists(validateMe, strTableName)) { ITable ipTable = (validateMe as IFeatureWorkspace).OpenTable(strTableName); bool bHasSubtype = false; ISubtypes ipSubtypes = ipTable as ISubtypes; if (null != ipSubtypes) { bHasSubtype = ipSubtypes.HasSubtype; } if (bHasSubtype) { IEnumSubtype ipEnumSubtype = ipSubtypes.Subtypes; if (null != ipEnumSubtype) { ipEnumSubtype.Reset(); int iSubtypeCode; string strSubtypeName; strSubtypeName = ipEnumSubtype.Next(out iSubtypeCode); while (null != strSubtypeName) { ValidateSubtype(ipRevResultCollection, ipSubtypes, iSubtypeCode); strSubtypeName = ipEnumSubtype.Next(out iSubtypeCode); } } } else { ValidateTable(ipRevResultCollection, ipTable); } } } m_ipWorkspace = null; return(ipRevResultCollection); }
private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e) { if (this.m_CanDo) { object obj2; ISubtypes featureClass = this.m_pFeatLayer.FeatureClass as ISubtypes; GridEditorItem row = this.gridView1.GetRow(e.RowHandle) as GridEditorItem; int index = this.m_pFeatLayer.FeatureClass.Fields.FindFieldByAliasName(row.Name); IField pField = this.m_pFeatLayer.FeatureClass.Fields.get_Field(index); if ((featureClass != null) && featureClass.HasSubtype) { if (featureClass.SubtypeFieldName == pField.Name) { IEnumSubtype subtypes = featureClass.Subtypes; subtypes.Reset(); int subtypeCode = 0; for (string str = subtypes.Next(out subtypeCode); str != null; str = subtypes.Next(out subtypeCode)) { if (e.Value.ToString() == str) { this.UpdateFieldValue(pField, subtypeCode); break; } } } else if (e.Value.ToString() == "<空>") { obj2 = DBNull.Value; this.UpdateFieldValue(pField, obj2); } else { this.UpdateFieldValue(pField, e.Value); } } else if (e.Value.ToString() == "<空>") { obj2 = DBNull.Value; this.UpdateFieldValue(pField, obj2); } else { this.UpdateFieldValue(pField, e.Value); } } }
/// <summary> /// Gets the subtype code and name that are assigned to the source. /// </summary> /// <param name="source">The object class.</param> /// <returns> /// Returns a <see cref="IEnumerable{T}" /> representing code and name of the subtypes; otherwise <c>null</c>. /// </returns> public static IEnumerable <KeyValuePair <int, string> > GetSubtypes(this ITable source) { if (source == null) { return(null); } ISubtypes subtypes = source as ISubtypes; if (subtypes == null) { return(null); } return(subtypes.Subtypes.AsEnumerable()); }
private void UpdateGrid() { IFields fields = this.m_pFeatLayer.FeatureClass.Fields; ISubtypes featureClass = this.m_pFeatLayer.FeatureClass as ISubtypes; for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); if (((((field.Type != esriFieldType.esriFieldTypeGeometry) && (field.Type != esriFieldType.esriFieldTypeOID)) && (field.Type != esriFieldType.esriFieldTypeRaster)) && field.Editable) && !(featureClass.SubtypeFieldName == field.Name)) { } } }
public void IMMConfigTopLevel_ChangeVisibility() { IFeatureClass testClass = base.GetTestClass(); Assert.IsNotNull(testClass); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); ISubtypes subtypes = (ISubtypes)testClass; IMMFieldManager fieldManager = testClass.GetFieldManager(subtypes.DefaultSubtypeCode); IMMFieldAdapter fieldAdapter = fieldManager.FieldByName(testClass.OIDFieldName); configTopLevel.ChangeVisibility(testClass, subtypes.DefaultSubtypeCode, false, testClass.OIDFieldName); Assert.IsFalse(fieldAdapter.Visible); }
/// <summary> /// Gets the coded value domain that contains all of the subtypes for the table. /// </summary> /// <param name="table">The table.</param> /// <returns> /// Returns a <see cref="IGPDomain" /> representing the coded value domain. /// </returns> protected IGPDomain GetSubtypes(IObjectClass table) { // Create a domain of all the subtypes. IGPCodedValueDomain codedValueDomain = new GPCodedValueDomainClass(); codedValueDomain.AddStringCode("-1", "All"); ISubtypes subtypes = (ISubtypes)table; if (subtypes.HasSubtype) { foreach (var o in subtypes.Subtypes.AsEnumerable()) { codedValueDomain.AddStringCode(o.Key.ToString(CultureInfo.InvariantCulture), o.Value); } } return(codedValueDomain as IGPDomain); }
private static string GetSubtypeConstaint([NotNull] ISubtypes subtypes, [NotNull] string fieldName) { IEnumSubtype enumSubtypes = subtypes.Subtypes; int subtypeCode; var sb = new StringBuilder(); for (string subtype = enumSubtypes.Next(out subtypeCode); subtype != null; subtype = enumSubtypes.Next(out subtypeCode)) { sb.AppendFormat(", {0}", subtypeCode); } string subtypeConstraint = fieldName + " IN (" + sb.ToString(1, sb.Length - 1) + ")"; return(subtypeConstraint); }
public static List <string> getClassNames(IFeatureClass Anno) { List <string> names = new List <string>(); ISubtypes subtypes = (ISubtypes)Anno; if (subtypes.HasSubtype) { IEnumSubtype enumSubs = subtypes.Subtypes; int subTypeCode; string subTypeName = enumSubs.Next(out subTypeCode); while (subTypeName != null) { names.Add(subTypeName); subTypeName = enumSubs.Next(out subTypeCode); } } names.Sort(); return(names); }
private void FillColumnValues(List <ColumnInfoViewModel> columnValues, IFeature feature) { int subtypeFieldIndex = -1; ISubtypes subtypes = feature.Class as ISubtypes; if (subtypes != null) { subtypeFieldIndex = subtypes.SubtypeFieldIndex; } KeyValueList <int, string> subtypeValues = ReadSubtypeDomainValues(feature); for (int columnIndex = 0; columnIndex < feature.Fields.FieldCount; columnIndex++) { IField field = feature.Fields.Field[columnIndex]; object value = feature.Value[columnIndex]; bool isSubtype = columnIndex == subtypeFieldIndex; KeyValueList <object, string> domainValues = ReadColumnDomainValues(field); ColumnInfoViewModel columnInfo = new ColumnInfoViewModel { ColumnName = field.Name, Alias = field.AliasName, FieldType = field.Type.ToString(), Required = field.Required, Editable = field.Editable, Nullable = field.IsNullable, Length = field.Length, Precision = field.Precision, Value = value.ToString(), IsSubtype = isSubtype, SubtypeValues = isSubtype ? subtypeValues : null, DomainValues = domainValues, }; if (columnInfo.Required) { columnInfo.ColumnName += " *"; } columnValues.Add(columnInfo); } }
/// <summary> /// Gets the subtype name that has the specified <paramref name="subtypeCode" />. /// </summary> /// <param name="source">The table.</param> /// <param name="subtypeCode">The subtype code.</param> /// <returns> /// Returns a <see cref="int" /> representing the name of the subtype; otherwise <c>null</c>. /// </returns> public static string GetSubtypeName(this ITable source, int subtypeCode) { if (source == null) { return(null); } ISubtypes subtypes = (ISubtypes)source; if (subtypes.HasSubtype) { return(null); } foreach (var subtype in subtypes.Subtypes.AsEnumerable().Where(subtype => subtype.Key == subtypeCode)) { return(subtype.Value); } return(null); }
/// <summary> /// Validates the attributes in a the subtype of a Feature Class/Table for domain constraints /// </summary> /// <param name="ipErrorCollection">Collection of validation results</param> /// <param name="ipSubtypes">Subtypes in the feature class/table</param> /// <param name="iSubtypeCode">SubtypeCode of the subtype that needs to be validated</param> private void ValidateSubtype(IPLTSErrorCollection ipErrorCollection, ISubtypes ipSubtypes, int iSubtypeCode) { if (null == ipSubtypes || null == ipErrorCollection) { return; } ITable ipTable = (ipSubtypes as ITable); if (null == ipTable) { return; } string strSubtypeFieldName = ipSubtypes.SubtypeFieldName; IFields ipFields = ipTable.Fields; if (null != ipFields) { long lFieldCount = ipFields.FieldCount; for (int i = 0; i < ipFields.FieldCount; i++) { IField ipField = ipFields.get_Field(i); if (!(ipField.Type == esriFieldType.esriFieldTypeBlob || ipField.Type == esriFieldType.esriFieldTypeGeometry || ipField.Type == esriFieldType.esriFieldTypeOID || ipField.Type == esriFieldType.esriFieldTypeRaster || ipField.Type == esriFieldType.esriFieldTypeGlobalID || ipField.Type == esriFieldType.esriFieldTypeGUID || ipField.Type == esriFieldType.esriFieldTypeXML)) { IDomain ipDomain = ipSubtypes.get_Domain(iSubtypeCode, ipField.Name); if (null != ipDomain) { ValidateAttributes(ipErrorCollection, ipTable, ipDomain, ipField.Name, true, strSubtypeFieldName, iSubtypeCode); } } } } }
/// <summary> /// Gets the domain that is assigned to the field. /// </summary> /// <param name="source">The row.</param> /// <param name="index">The index.</param> /// <returns> /// Returns a <see cref="IDomain" /> representing the domain for the field. /// </returns> /// <exception cref="IndexOutOfRangeException"></exception> public static IDomain GetDomain(this IRow source, int index) { if (source == null) { return(null); } if (index < 0 || index > source.Fields.FieldCount - 1) { throw new IndexOutOfRangeException(); } ISubtypes subtypes = (ISubtypes)source.Table; if (subtypes.HasSubtype) { string fieldName = source.Fields.Field[index].Name; IRowSubtypes rowSubtypes = (IRowSubtypes)source; return(subtypes.Domain[rowSubtypes.SubtypeCode, fieldName]); } return(source.Fields.Field[index].Domain); }
public static int getClassIDByName(IFeatureClass Anno, string name) { ISubtypes subtypes = (ISubtypes)Anno; if (subtypes.HasSubtype) { IEnumSubtype enumSubs = subtypes.Subtypes; int subTypeCode; string subTypeName = enumSubs.Next(out subTypeCode); while (subTypeName != null) { if (subTypeName.ToUpper() == name.ToUpper()) { return(subTypeCode); } subTypeName = enumSubs.Next(out subTypeCode); } } return(-1); }
public static string getClassNameById(IFeatureClass Anno, int id) { ISubtypes subtypes = (ISubtypes)Anno; if (subtypes.HasSubtype) { IEnumSubtype enumSubs = subtypes.Subtypes; int subTypeCode; string subTypeName = enumSubs.Next(out subTypeCode); while (subTypeName != null) { if (subTypeCode == id) { return(subTypeName); } subTypeName = enumSubs.Next(out subTypeCode); } } return(null); }
/// <summary> /// Gets all of the automatic values (i.e. ArcFM Auto Updaters) that have been configured for the specified /// <paramref name="editEvent" /> for all subtypes /// of the <paramref name="table" /> object class. /// </summary> /// <param name="source">The source.</param> /// <param name="table">The table.</param> /// <param name="editEvent">The edit event.</param> /// <returns> /// Returns a <see cref="Dictionary{Key, Value}" /> representing the automatic values for the specified event and /// object class. /// </returns> /// <exception cref="System.ArgumentNullException">table</exception> public static Dictionary <IMMSubtype, IEnumerable <IMMAutoValue> > GetAutoValues(this IMMConfigTopLevel source, IObjectClass table, mmEditEvent editEvent) { if (source == null) { return(null); } if (table == null) { throw new ArgumentNullException("table"); } Dictionary <IMMSubtype, IEnumerable <IMMAutoValue> > list = new Dictionary <IMMSubtype, IEnumerable <IMMAutoValue> >(); IMMSubtype subtype = source.GetSubtypeByID(table, ALL_SUBTYPES, false); if (subtype != null) { list.Add(subtype, subtype.GetAutoValues(editEvent)); } ISubtypes subtypes = (ISubtypes)table; if (subtypes.HasSubtype) { IEnumerable <int> subtypeCodes = subtypes.Subtypes.AsEnumerable().Select(o => o.Key).OrderBy(o => o); foreach (var subtypeCode in subtypeCodes) { subtype = source.GetSubtypeByID(table, subtypeCode, false); if (subtype == null) { continue; } list.Add(subtype, subtype.GetAutoValues(editEvent)); } } return(list); }
public static ICodedValueDomain CreateCodedValueDomainFromSubtypes(ISubtypes subtypes) { // string methodName = MethodInfo.GetCurrentMethod().Name; ICodedValueDomain domain = null; if (subtypes != null) { IEnumSubtype subtype = subtypes.Subtypes; domain = new CodedValueDomainClass(); subtype.Reset(); int subtypeCode; string subtypeValue = subtype.Next(out subtypeCode); while (subtypeValue != null) //use null subtype.next returns bstr type. { domain.AddCode(subtypeCode, subtypeValue); subtypeValue = subtype.Next(out subtypeCode); } } //else // _logger.LogFormat("{0}: Null subtypes parameter.", methodName, LogLevel.enumLogLevelWarn); return domain; }
private void UpdateGrid() { if (this.cboLayer.SelectedIndex != -1) { LayerObject selectedItem = this.cboLayer.SelectedItem as LayerObject; IFeatureLayer layer = selectedItem.Layer as IFeatureLayer; if (layer != null) { IFields fields = layer.FeatureClass.Fields; ISubtypes featureClass = layer.FeatureClass as ISubtypes; for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); if (((((field.Type != esriFieldType.esriFieldTypeGeometry) && (field.Type != esriFieldType.esriFieldTypeOID)) && (field.Type != esriFieldType.esriFieldTypeRaster)) && field.Editable) && !(featureClass.SubtypeFieldName == field.Name)) { } } } } }
internal FeatureData(String theName, IFeatureClass theFClass) { this.Name = theName; this.theGType = theFClass.ShapeType; this.theAlias = theFClass.AliasName; this.OIDName = theFClass.OIDFieldName; this.ShapeName = theFClass.ShapeFieldName; this.theDS = theFClass.FeatureDataset; this.theST = (ISubtypes)theFClass; this.theFlds = theFClass.Fields; this.isIdentical = 0; }
/// <summary> /// Validates the attributes in a the subtype of a Feature Class/Table for domain constraints /// </summary> /// <param name="ipErrorCollection">Collection of validation results</param> /// <param name="ipSubtypes">Subtypes in the feature class/table</param> /// <param name="iSubtypeCode">SubtypeCode of the subtype that needs to be validated</param> private void ValidateSubtype(IPLTSErrorCollection ipErrorCollection, ISubtypes ipSubtypes, int iSubtypeCode) { if (null == ipSubtypes || null == ipErrorCollection) return; ITable ipTable = (ipSubtypes as ITable); if (null == ipTable) return; string strSubtypeFieldName = ipSubtypes.SubtypeFieldName; IFields ipFields = ipTable.Fields; if(null != ipFields) { long lFieldCount = ipFields.FieldCount; for (int i = 0; i < ipFields.FieldCount; i++) { IField ipField = ipFields.get_Field(i); if (!(ipField.Type == esriFieldType.esriFieldTypeBlob || ipField.Type == esriFieldType.esriFieldTypeGeometry || ipField.Type == esriFieldType.esriFieldTypeOID || ipField.Type == esriFieldType.esriFieldTypeRaster || ipField.Type == esriFieldType.esriFieldTypeGlobalID || ipField.Type == esriFieldType.esriFieldTypeGUID || ipField.Type == esriFieldType.esriFieldTypeXML)) { IDomain ipDomain = ipSubtypes.get_Domain(iSubtypeCode, ipField.Name); if(null != ipDomain) ValidateAttributes(ipErrorCollection, ipTable, ipDomain, ipField.Name, true, strSubtypeFieldName, iSubtypeCode); } } } }
private static string GetDescricaoSubtipo(ISubtypes subtipos, object valor) { String r = String.Empty; int result; if (Int32.TryParse(valor.ToString(), out result) == false) return r; IEnumSubtype enumSubtp = subtipos.Subtypes; int SubtypeCode; string descSubtipo = enumSubtp.Next(out SubtypeCode); while (descSubtipo != null) { if (SubtypeCode == result) { r = descSubtipo; } descSubtipo = enumSubtp.Next(out SubtypeCode); } return r; }