Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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? Thanks.

ArcEngine 10, C#, VS2010

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Symbol here returns a reference because it is a get/putref property. The font returns a clone because it is a get/put. ArcObjects only document deviations from this behavior (see help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/…) for a full description of the behavior. –  Craig Williams Feb 19 '11 at 6:18
    
Also, I recommend changing the size on ITextSymbol itself rather than the font. The Microsoft stdole.FontDisp object has some odd sizing behavior in some circumstances. –  Craig Williams Feb 19 '11 at 6:20
    
@craig great to see you here! I've always been confused about the get/set (dumbell) symbols on the OMD's. It seems like there should be one that has a hollow square on the left to show that you are getting a reference and not a copy. For example IGeoFeatureLayer.Featureclass does not returns a clone of a featureclass, even though it has same get/set as ILabelEngineLayerProperties.Symbol. –  Kirk Kuykendall Feb 22 '11 at 19:04
    
I've had similar thoughts on the subject of the dumbbell symbols, but the symbols actually come down to what IDL for COM interfaces allows. You have the options of propget, propput, or propputref. The bars on the diagrams are assigned to these. Since there is no propgetref, there is no left hand hollow bell. BTW. IGeoFeatureLayer.FeatureClass and ILabelEngineLayerProperties.Symbol both return references. The issue in this post is that the Font property off ITextSymbol returns a clone. –  Craig Williams Feb 24 '11 at 6:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.