ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ISymbolFactory Interface / ConstructPolygonSymbol Method / ConstructPolygonSymbol(CIMColor,SimpleFillStyle) Method
ArcGIS.Core.CIM.CIMColor
SimpleFillStyle
Example

In This Topic
    ConstructPolygonSymbol(CIMColor,SimpleFillStyle) Method
    In This Topic
    Constructs a polygon symbol of specific color and style.
    Syntax
    Overloads Function ConstructPolygonSymbol( _
       ByVal color As CIMColor, _
       ByVal fillStyle As SimpleFillStyle _
    ) As CIMPolygonSymbol

    Parameters

    color
    ArcGIS.Core.CIM.CIMColor
    fillStyle
    SimpleFillStyle

    Return Value

    Example
    How to construct a polygon symbol of specific color and fill style
    {
      CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid);
    }
    Snippet Creates a text symbol with a halo
    /// <summary>
    /// Creates a text symbol with a red halo
    /// ![halo](https://ArcGIS.github.io/arcgis-pro-sdk/images/Labeling/halo.png)
    /// </summary>
    {
      CIMTextSymbol textSymbolWithHalo = await QueuedTask.Run(() =>
      {
        //create a polygon symbol for the halo
        var haloPoly = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid);
        //create text symbol using the halo polygon
        return SymbolFactory.Instance.ConstructTextSymbol(haloPoly, 10, "Arial", "Bold");
      });
      //Refer to the snippet "How to apply a Text Symbol to labels of a layer" below to see how to apply this text symbol to a label class
    
    }
    Snippet Creates a balloon callout text symbol
    /// <summary>
    /// Creates a black banner balloon callout text symbol. The [CIMBalloonCallout](https://doc.esri.com/en/arcgis-pro/latest/sdk/api-reference/#topic487.html) created is a rectangular polygon with rounded corners.
    /// ![lineCallOut](https://ArcGIS.github.io/arcgis-pro-sdk/images/Labeling/banner-callout.png)
    /// </summary>
    {
      await QueuedTask.Run(() =>
      {
        //create a text symbol
        var textSymbolBalloonCallout = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.WhiteRGB, 11, "Corbel", "Regular");
        //A balloon callout
        var balloonCallout = new CIMBalloonCallout();
        //set the callout's style
        balloonCallout.BalloonStyle = BalloonCalloutStyle.RoundedRectangle;
        //Create a solid fill polygon symbol for the callout.
        var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlackRGB, SimpleFillStyle.Solid);
        //Set the callout's background to be the black polygon symbol
        balloonCallout.BackgroundSymbol = polySymbol;
        //margin inside the callout to place the text
        balloonCallout.Margin = new CIMTextMargin
        {
          Left = 5,
          Right = 5,
          Bottom = 5,
          Top = 5
        };
        //assign the callout to the text symbol's callout property
        textSymbolBalloonCallout.Callout = balloonCallout;
      });
      //Refer to the snippet "How to apply a Text Symbol to labels of a layer" below to see how to apply this text symbol to a label class
    }
    Snippet Creates a background callout text symbol
    /// <summary>
    /// Creates a solid fill background text symbol with an Accent bar and leader line.  The [CIMBackgroundCallout](https://doc.esri.com/en/arcgis-pro/latest/sdk/api-reference/#topic474.html) created has a solid fill aqua polygon, with a black dash-dot-dash leader line and a solid accent bar.
    /// ![lineCallOut](https://ArcGIS.github.io/arcgis-pro-sdk/images/Labeling//background-callout.png)
    /// </summary>
    {
      await QueuedTask.Run(() =>
      {
        var textSymbolBackgroundCallout = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 8, "Tahoma", "Bold");
        //Create a call out
        var backgroundCalloutSymbol = new CIMBackgroundCallout();
        //Leader line
        //Get a line symbol
        var lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 1, SimpleLineStyle.DashDotDot);
        //Create a solid fill polygon symbol for the callout.
        var aquaBackground = ColorFactory.Instance.CreateRGBColor(190, 255, 232, 100);
        var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(aquaBackground, SimpleFillStyle.Solid);
        //assign the line to the callout
        backgroundCalloutSymbol.LeaderLineSymbol = lineSymbol;
        //Offset for the text
        textSymbolBackgroundCallout.OffsetX = 10;
        textSymbolBackgroundCallout.OffsetY = 10;
        //Assign the polygon to the background callout
        backgroundCalloutSymbol.BackgroundSymbol = polySymbol;
        //Accent bar
        var accentSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 2, SimpleLineStyle.Solid);
        backgroundCalloutSymbol.AccentBarSymbol = accentSymbol;
        //Set margins for the callout
        backgroundCalloutSymbol.Margin = new CIMTextMargin
        {
          Left = 5,
          Right = 5,
          Top = 5,
          Bottom = 5
        };
    
        //assign the callout to the textSymbol
        textSymbolBackgroundCallout.Callout = backgroundCalloutSymbol;
      });
      //Refer to the snippet "How to apply a Text Symbol to labels of a layer" below to see how to apply this text symbol to a label class
    }
    Procedural Symbol
    /// <summary>
    /// Create a procedural symbol that can be applied to a polygon building footprint layer
    /// ![ProceduralSymbol](https://ArcGIS.github.io/arcgis-pro-sdk/images/Symbology/polygon-procedural.png)
    /// Note: The rule package used in this method can be obtained from the Sample Data included in the arcgis-pro-sdk-community-samples repository.
    /// </summary>
    {
      //Note: Run withing QueuedTask
      string _rulePkgPath = @"C:\Data\RulePackages\Venice_2014.rpk";
      //Polygon symbol to hold the procedural layer
      var proceduralSymbol = SymbolFactory.Instance.ConstructPolygonSymbol();
    
      //Array of layers to hold a procedural symbol layer
      CIMSymbolLayer[] proceduralSymbolLyr =
            {
                new CIMProceduralSymbolLayer()
                {
                    PrimitiveName = "Venice Rule package 2014",
                    RulePackage = _rulePkgPath,
                    RulePackageName = "Venice_2014",
                }
      };
      proceduralSymbol.SymbolLayers = proceduralSymbolLyr;
      //To apply the symbol to a polygon feature layer
      //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer;
      //renderer.Symbol = proceduralSymbol.MakeSymbolReference();
      //theLayer.SetRenderer(renderer);
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also