public static void SetReferenceScale(IAnnotationLayer annotationLayer, double scale) { IFeatureLayer featureLayer = annotationLayer as IFeatureLayer; IFeatureClass featureClass = featureLayer.FeatureClass; IAnnoClass annoClass = featureClass.Extension as IAnnoClass; IAnnoClassAdmin3 annoClassAdmin3 = annoClass as IAnnoClassAdmin3; annoClassAdmin3.ReferenceScale = scale; }
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(); }