渲染标签文字(光晕效果)

[转载]渲染标签文字(光晕效果)

/// <summary>
        /// 渲染标签文字
        /// </summary>
        /// <param name="geoLayer"></param>
        /// <param name="field"></param>
        public static void RenderLabel(IGeoFeatureLayer geoLayer,string field)
        {
            IMultiLayerFillSymbol marker = new MultiLayerFillSymbolClass();
            ISimpleFillSymbol fill = new SimpleFillSymbolClass();
            ISimpleLineSymbol line = new SimpleLineSymbolClass();
            line.Width = 0.5;
            line.Color = Converter.ToRGBColor(Color.White) as IColor;
            fill.Style = esriSimpleFillStyle.esriSFSSolid;
            fill.Color = Converter.ToRGBColor(Color.White);
            marker.AddLayer(fill as IFillSymbol);
            marker.Outline = line as ILineSymbol;
            ITextSymbol symbol = new TextSymbolClass();
            symbol.Size = 10;
            IMask mask = symbol as IMask;
            mask.MaskSymbol = marker as IFillSymbol;
            mask.MaskStyle = esriMaskStyle.esriMSHalo;
            mask.MaskSize = 1;

            IAnnotateLayerPropertiesCollection annoCollection = geoLayer.AnnotationProperties;
            annoCollection.Clear();
            ILabelEngineLayerProperties lblPro = new LabelEngineLayerPropertiesClass();
            lblPro.Expression = string.Format("[{0}]", field);
            lblPro.Symbol = mask as ITextSymbol;
            IAnnotateLayerProperties alp = (IAnnotateLayerProperties)lblPro;
            annoCollection.Add(alp);
            geoLayer.DisplayAnnotation = true;
        }
原文地址:https://www.cnblogs.com/lauer0246/p/1190773.html