ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ISymbolFactory Interface / ConstructStroke Method / ConstructStroke(CIMColor,Double,SimpleLineStyle) Method
ArcGIS.Core.CIM.CIMColor
The width of stroke to construct.
SimpleLineStyle
Example

In This Topic
    ConstructStroke(CIMColor,Double,SimpleLineStyle) Method
    In This Topic
    Constructs a stroke of specific color, width and style.
    Syntax
    Overloads Function ConstructStroke( _
       ByVal color As CIMColor, _
       ByVal width As Double, _
       ByVal lineStyle As SimpleLineStyle _
    ) As CIMStroke

    Parameters

    color
    ArcGIS.Core.CIM.CIMColor
    width
    The width of stroke to construct.
    lineStyle
    SimpleLineStyle

    Return Value

    Example
    Snippet Diagonal cross hatch fill
    /// <summary>
    /// Create a polygon symbol with a diagonal cross hatch fill. <br/>
    /// ![PolygonSymbolDiagonalCrossHatch](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-diagonal-crosshatch.png)
    /// </summary>
    /// <returns></returns>
    public static Task<CIMPolygonSymbol> CreateDiagonalCrossPolygonAsync()
    {
      return QueuedTask.Run<CIMPolygonSymbol>(() =>
      {
        var trans = 50.0;//semi transparent
        CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);
    
        //Stroke for the fill
        var solid = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 0, 0, trans), 1.0, SimpleLineStyle.Solid);
    
        //Mimic cross hatch
        CIMFill[] diagonalCross =
                  {
                    new CIMHatchFill() {
                        Enable = true,
                        Rotation = 45.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol() { SymbolLayers = new CIMSymbolLayer[1] { solid } }
                    },
                    new CIMHatchFill() {
                        Enable = true,
                        Rotation = -45.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol() { SymbolLayers = new CIMSymbolLayer[1] { solid } }
                    }
          };
        List<CIMSymbolLayer> symbolLayers = new List<CIMSymbolLayer>
          {
                    outline
          };
        foreach (var fill in diagonalCross)
          symbolLayers.Add(fill);
        return new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
      });
    }
    Snippet Cross hatch
    /// <summary>
    /// Create a polygon symbol using the ConstructHatchFill method . <br/>
    /// ![PolygonSymbolDiagonalCrossHatch](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/ConstructHatchFill.png)
    /// </summary>
    /// <returns></returns>
    private static Task<CIMPolygonSymbol> CreateHatchFillPolygonAsync()
    {
      return QueuedTask.Run<CIMPolygonSymbol>(() =>
      {
        CIMStroke lineStroke = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(51, 51, 51, 60), 4, SimpleLineStyle.Solid);
        //gradient
        var hatchFill = SymbolFactory.Instance.ConstructHatchFill(lineStroke, 45, 6, 0);
    
        List<CIMSymbolLayer> symbolLayers = new List<CIMSymbolLayer>
        {
          hatchFill
        };
        return new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
      });
    }
    Snippet Gradient color fill using CIMGradientFill
    /// <summary>
    /// Create a polygon symbol with a gradient color fill. <br/>
    /// ![PolygonSymbolGradientColor](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-gradient-color.png)
    /// </summary>
    /// <remarks>
    /// 1. Create a solid colored stroke with 50% transparency
    /// 1. Create a fill using gradient colors red through green
    /// 1. Apply both the stroke and fill as a symbol layer array to the new PolygonSymbol
    /// </remarks>
    /// <returns></returns>
    public static Task<CIMPolygonSymbol> CreateGradientFillAsync()
    {
      return QueuedTask.Run<CIMPolygonSymbol>(() =>
      {
        var trans = 50.0;//semi transparent
        CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);
        //Mimic cross hatch
        CIMFill solidColorHatch =
               new CIMGradientFill()
           {
             ColorRamp = ColorFactory.Instance.ConstructColorRamp(ColorRampAlgorithm.LinearContinuous,
                                      ColorFactory.Instance.RedRGB, ColorFactory.Instance.GreenRGB)
           };
        List<CIMSymbolLayer> symbolLayers = new List<CIMSymbolLayer>
          {
                    outline,
                    solidColorHatch
          };
    
        return new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
      });
    }
    Snippet Gradient fill using Color ramp
    /// <summary>
    /// Create a polygon symbol using the ConstructGradientFill method. Constructs a gradient fill using the specified color ramp. <br/>
    /// ![PolygonSymbolColorRamp](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/PolygonSymbolColorRamp.png)
    /// </summary>
    /// <returns></returns>
    public static Task<CIMPolygonSymbol> CreateGradientColorRampPolygonAsync()
    {
      return QueuedTask.Run<CIMPolygonSymbol>(() =>
      {
        //outine
        CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(49, 49, 49), 2.0, SimpleLineStyle.Solid);
    
        //gradient fill using a color ramp
        var gradientFill = SymbolFactory.Instance.ConstructGradientFill(GetColorRamp(), GradientFillMethod.Linear);
    
        List<CIMSymbolLayer> symbolLayers = new List<CIMSymbolLayer>
          {
                    outline,
                    gradientFill
          };
        return new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
      });
    
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also