[GIS] Change annotation font size on a IGeoFeatureLayer

arcgis-10.0arcgis-enginec

I would like to change the font size for the annotations on an IGeoFeatureLayer. I tried to set it in the lpLabelEngine.Symbol.Font.Size below but the set doesn't persist.

     IGeoFeatureLayer geoLayer = thisLayer as IGeoFeatureLayer;
            if (geoLayer != null)
            {
             geoLayer.DisplayAnnotation = annotationsOn;
            IAnnotateLayerPropertiesCollection propertiesColl = geoLayer.AnnotationProperties;
            IAnnotateLayerProperties labelEngineProperties = new LabelEngineLayerProperties() as IAnnotateLayerProperties;
            IElementCollection placedElements = new ElementCollectionClass();
            IElementCollection unplacedElements = new ElementCollectionClass();
            propertiesColl.QueryItem(0, out labelEngineProperties, out placedElements, out unplacedElements);
            ILabelEngineLayerProperties lpLabelEngine = labelEngineProperties as ILabelEngineLayerProperties;
            if(geocode != null) lpLabelEngine.Expression = geocode;
            if(annotationLabelColor != null) lpLabelEngine.Symbol.Color = annotationLabelColor; 
            labelEngineProperties.AnnotationMinimumScale = minScale;
            labelEngineProperties.AnnotationMaximumScale = maxScale;
                if (fontsize != null) lpLabelEngine.Symbol.Font.Size = Convert.ToDecimal(fontsize);

Any ideas?

ArcEngine 10, C#, VS2010

Best Answer

Usually a Symbol properties are set by value, so I suspect lpLabelEngine.Symbol returns a copy. Try setting an ISymbol variable to lpLabelEngine.Symbol, make your changes, then assign it back. You might also need to do the same with ITextSymbol.Font.

The documentation on this is lacking. The only reliable way I know to determine this is to test your assumption with the = operator. if lpLabelEngine.Symbol != lpLabelEngine.Symbol then you know you need to re-assign.

Related Question