Exemple #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>
        /// <exception cref="ArgumentNullException"><paramref name="featureLayer"/> must be not null.</exception>
        public static void AddLabels(this IFeatureLayer featureLayer, string expression, Font font, Color fontColor)
        {
            if (featureLayer == null)
            {
                throw new ArgumentNullException(nameof(featureLayer));
            }
            featureLayer.ShowLabels = true;

            var ll = new MapLabelLayer();

            ll.Symbology.Categories.Clear();
            var lc = new LabelCategory
            {
                Expression = expression
            };

            ll.Symbology.Categories.Add(lc);

            var ls = ll.Symbolizer;

            ls.Orientation          = ContentAlignment.MiddleCenter;
            ls.FontColor            = fontColor;
            ls.FontFamily           = font.FontFamily.ToString();
            ls.FontSize             = font.Size;
            ls.FontStyle            = font.Style;
            ls.PartsLabelingMethod  = PartLabelingMethod.LabelLargestPart;
            featureLayer.LabelLayer = ll;
        }
        /// <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 static void AddLabels(this IFeatureLayer featureLayer, string expression, Font font, Color fontColor)
        {
            featureLayer.ShowLabels = true;

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

            var ls = ll.Symbolizer;
            ls.Orientation = ContentAlignment.MiddleCenter;
            ls.FontColor = fontColor;
            ls.FontFamily = font.FontFamily.ToString();
            ls.FontSize = font.Size;
            ls.FontStyle = font.Style;
            ls.PartsLabelingMethod = PartLabelingMethod.LabelLargestPart;
            featureLayer.LabelLayer = ll;
        }
Exemple #3
0
 /// <summary>
 /// A default method to generate a label layer.
 /// </summary>
 protected override void OnCreateLabels()
 {
     LabelLayer = new MapLabelLayer(this);
 }
Exemple #4
0
 /// <summary>
 /// A default method to generate a label layer.
 /// </summary>
 protected override void OnCreateLabels()
 {
     LabelLayer = new MapLabelLayer(this);
 }