Exemplo n.º 1
0
        /// <summary>
        /// This activates the labels for the specified feature layer that will be the specified expression
        /// where field names are in square brackets like "[Name]: [Value]".  This will label all the features,
        /// and remove any previous labeling.
        /// </summary>
        /// <param name="featureLayer">The FeatureLayer to apply the labels to.</param>
        /// <param name="expression">The string label expression to use where field names are in square brackets like [Name]</param>
        /// <param name="font">The font to use for these labels</param>
        /// <param name="fontColor">The color for the labels</param>
        public void AddLabels(IFeatureLayer featureLayer, string expression, Font font, Color fontColor)
        {
            featureLayer.ShowLabels = true;

            MapLabelLayer ll = new MapLabelLayer();
            ll.Symbology.Categories.Clear();
            LabelCategory lc = new LabelCategory();
            lc.Expression = expression;
            ll.Symbology.Categories.Add(lc);

            ILabelSymbolizer ls = ll.Symbolizer;
            ls.Orientation = ContentAlignment.MiddleCenter;
            ls.BackColorEnabled = false;
            ls.BackColorEnabled = false;
            ls.FontColor = fontColor;
            ls.FontFamily = font.FontFamily.ToString();
            ls.FontSize = font.Size;
            ls.FontStyle = font.Style;
            ls.LabelParts = LabelParts.LabelLargestPart;
            featureLayer.LabelLayer = ll;

            
        }
Exemplo n.º 2
0
 /// <summary>
 /// A default method to generate a label layer.
 /// </summary>
 protected override void OnCreateLabels()
 {
     LabelLayer = new MapLabelLayer(this);
 }