public static string getSymbolNameById(IFeatureClass Anno, int id) { IAnnoClass aClas = (IAnnoClass)Anno.Extension; ISymbolCollection2 isc = (ISymbolCollection2)aClas.SymbolCollection; isc.Reset(); ISymbolIdentifier2 sId = (ISymbolIdentifier2)isc.Next(); while (sId != null) { if (sId.ID == id) { return(sId.Name); } sId = (ISymbolIdentifier2)isc.Next(); } return(null); }
public static int getSymbolIDByName(IFeatureClass Anno, string name) { IAnnoClass aClas = (IAnnoClass)Anno.Extension; ISymbolCollection2 isc = (ISymbolCollection2)aClas.SymbolCollection; isc.Reset();// very important to call Reset() if not you get no result from Next() ISymbolIdentifier2 sId = (ISymbolIdentifier2)isc.Next(); while (sId != null) { if (sId.Name.ToUpper() == name.ToUpper()) { return(sId.ID); } sId = (ISymbolIdentifier2)isc.Next(); } return(-1); }
public static List <string> getSymbolNames(IFeatureClass Anno) { List <string> names = new List <string>(); IAnnoClass aClas = (IAnnoClass)Anno.Extension; ISymbolCollection2 isc = (ISymbolCollection2)aClas.SymbolCollection; isc.Reset(); ISymbolIdentifier2 sId = (ISymbolIdentifier2)isc.Next(); while (sId != null) { names.Add(sId.Name); sId = (ISymbolIdentifier2)aClas.SymbolCollection.Next(); } names.Sort(); return(names); }
private void ProcessAnnotation(IAnnotationLayer annoLayer) { //get unique values IFeatureLayer featureLayer = annoLayer as IFeatureLayer; IDataStatistics dataStats = new DataStatisticsClass(); dataStats.Field = "SymbolID"; dataStats.SampleRate = -1; //all records IQueryFilter queryFilter = new QueryFilterClass(); queryFilter.SubFields = "SymbolID"; dataStats.Cursor = featureLayer.Search(queryFilter, true) as ICursor; object value = null; var enumVar = dataStats.UniqueValues; //now remove items IFeatureClass featureClass = featureLayer.FeatureClass; IAnnotationClassExtension annoClassExt = featureClass.Extension as IAnnotationClassExtension; ISymbolCollection2 symbolCollection = annoClassExt.SymbolCollection as ISymbolCollection2; ISymbolCollection2 newSymColl = new SymbolCollectionClass(); while (enumVar.MoveNext()) { value = enumVar.Current; ISymbolIdentifier2 symbolIdent = null; symbolCollection.GetSymbolIdentifier(Convert.ToInt32(value), out symbolIdent); newSymColl.set_Symbol(symbolIdent.ID, symbolIdent.Symbol); newSymColl.RenameSymbol(symbolIdent.ID, symbolIdent.Name); } //update class extension with the new collection IAnnoClassAdmin3 annoClassAdmin = annoClassExt as IAnnoClassAdmin3; annoClassAdmin.SymbolCollection = (ISymbolCollection)newSymColl; annoClassAdmin.UpdateProperties(); }
private int method_4(ISymbolCollection2 isymbolCollection2_0) { isymbolCollection2_0.Reset(); ISymbolIdentifier2 identifier = isymbolCollection2_0.Next() as ISymbolIdentifier2; IList list = new ArrayList(); while (identifier != null) { list.Add(identifier.ID); identifier = isymbolCollection2_0.Next() as ISymbolIdentifier2; } int num = 0; if (list.Count != 0) { while (list.IndexOf(num) != -1) { num++; } return(num); } return(num); }
public IFeatureClass CreateStandardAnnotationClass( IFeatureWorkspace featureWorkspace, IFeatureDataset featureDataset, String className, ISpatialReference spatialReference, double referenceScale, esriUnits referenceScaleUnits, String configKeyword ) { // Create an annotation class and provide it with a name. ILabelEngineLayerProperties labelEngineLayerProperties = new LabelEngineLayerPropertiesClass(); IAnnotateLayerProperties annotateLayerProperties = (IAnnotateLayerProperties) labelEngineLayerProperties; annotateLayerProperties.Class = className; // Get the symbol from the annotation class. Make any changes to its properties // here. ITextSymbol annotationTextSymbol = labelEngineLayerProperties.Symbol; ISymbol annotationSymbol = (ISymbol)annotationTextSymbol; // Create a symbol collection and add the default symbol from the // annotation class to the collection. Assign the resulting symbol ID // to the annotation class. ISymbolCollection symbolCollection = new SymbolCollectionClass(); ISymbolCollection2 symbolCollection2 = (ISymbolCollection2)symbolCollection; ISymbolIdentifier2 symbolIdentifier2 = null; symbolCollection2.AddSymbol(annotationSymbol, className, out symbolIdentifier2); labelEngineLayerProperties.SymbolID = symbolIdentifier2.ID; // Add the annotation class to a collection. IAnnotateLayerPropertiesCollection annotateLayerPropsCollection = new AnnotateLayerPropertiesCollectionClass(); annotateLayerPropsCollection.Add(annotateLayerProperties); // Create a graphics layer scale object. IGraphicsLayerScale graphicsLayerScale = new GraphicsLayerScaleClass(); graphicsLayerScale.ReferenceScale = referenceScale; graphicsLayerScale.Units = referenceScaleUnits; // Create the overposter properties for the standard label engine. IOverposterProperties overposterProperties = new BasicOverposterPropertiesClass() ; // Instantiate a class description object. //IObjectClassDescription ocDescription = new // AnnotationFeatureClassDescriptionClass(); //IFeatureClassDescription fcDescription = (IFeatureClassDescription)ocDescription; //// Get the shape field from the class description's required fields. //IFields requiredFields = ocDescription.RequiredFields; //int shapeFieldIndex = requiredFields.FindField(fcDescription.ShapeFieldName); //IField shapeField = requiredFields.get_Field(shapeFieldIndex); IFeatureLayer layer = (IFeatureLayer)mLayer; IFields fields = layer.FeatureClass.Fields; IField shapeField = fields.Field[fields.FindField(mField)]; IGeometryDef geometryDef = shapeField.GeometryDef; IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef; geometryDefEdit.SpatialReference_2 = spatialReference; // Create the annotation layer factory. IAnnotationLayerFactory annotationLayerFactory = new FDOGraphicsLayerFactoryClass(); // Create the annotation feature class and an annotation layer for it. IAnnotationLayer annotationLayer = annotationLayerFactory.CreateAnnotationLayer (featureWorkspace, featureDataset, className, geometryDef, null, annotateLayerPropsCollection, graphicsLayerScale, symbolCollection, false, false, false, true, overposterProperties, configKeyword); // Get the feature class from the feature layer. IFeatureLayer featureLayer = (IFeatureLayer)annotationLayer; IFeatureClass featureClass = featureLayer.FeatureClass; return(featureClass); }
public SymbolIdentifierWrap(IAnnotateLayerProperties iannotateLayerProperties_1, ISymbolIdentifier2 isymbolIdentifier2_1) { this.iannotateLayerProperties_0 = iannotateLayerProperties_1; this.isymbolIdentifier2_0 = isymbolIdentifier2_1; }