ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ColorFactory Class
Members Example

In This Topic
    ColorFactory Class
    In This Topic
    Provides methods for creating color.
    Object Model
    ColorFactory ClassCIMColor ClassCIMColor ClassCIMColorRamp ClassCIMColor ClassCIMHSVColor ClassCIMRGBColor ClassCIMColor ClassCIMColor ClassCIMColorRamp ClassCIMColor ClassCIMColor ClassIColorFactory InterfaceCIMColor ClassCIMColorRamp ClassCIMColor Class
    Syntax
    Public Class ColorFactory 
       Implements IColorFactory 
    public class ColorFactory : IColorFactory  
    Example
    Create Ellipse Graphic Element
    {
      //Note: Must be on QueuedTask.Run
    
      //Build geometry
      Coordinate2D center = new Coordinate2D(2, 2.75);
      var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45,
                                          ArcOrientation.ArcClockwise);
      var ellipse = eabElp.ToSegment();
    
      //Set symbology, create and add element to layout
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
                                      ColorFactory.Instance.GreenRGB, 2.0,
                              SimpleLineStyle.Dot);
      CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol(
                                ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical,
                                                        outline);
    
      var poly = PolygonBuilderEx.CreatePolygon(
        PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes));
    
      var elpElm = ElementFactory.Instance.CreateGraphicElement(
        layout, poly, ellipseSym, "New Ellipse");
    }
    Mesh material fill symbol
    /// <summary>
    /// Create a mesh symbol that can be applied to a multi-patch feature layer.
    /// A mesh symbol is a CIMMeshSymbol object.  Define an array of CIMSymbolLayers which contains a CIMMaterialSymbol layer with the specified properties such as Color, etc.
    /// Assign this array of CIMSymbolLayers to the CIMMeshSymbol.
    /// ![MeshSymbolOrange](https://ArcGIS.github.io/arcgis-pro-sdk/images/Symbology/mesh-material-orange.png)
    /// </summary>
    {
      //Note: Run withing QueuedTask
      CIMSymbolLayer[] materialSymbolLayer =
            {
                  new CIMMaterialSymbolLayer()
                  {
                      Color = ColorFactory.Instance.CreateRGBColor(230,152,0),
                      MaterialMode = MaterialMode.Multiply
                  }
             };
      var meshMaterialFillSymbol = new CIMMeshSymbol()
      {
        SymbolLayers = materialSymbolLayer
      };
    }
    Dash dot fill
    /// <summary>
    /// Create a polygon symbol with a dash dot fill. <br/>
    /// ![PolygonSymbolDashDot](https://ArcGIS.github.io/arcgis-pro-sdk/images/Symbology/polygon-dash-dot.png)
    /// </summary>
    {
      //Note: Run withing QueuedTask
      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 dashDot = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 1.0, SimpleLineStyle.DashDotDot);
      //Mimic cross hatch
      CIMFill[] solidColorHatch =
            {
    
               new CIMHatchFill()
              {
                  Enable = true,
                  Rotation = 0.0,
                  Separation = 2.5,
                  LineSymbol = new CIMLineSymbol(){SymbolLayers = new CIMSymbolLayer[1] {dashDot } }
              },
               new CIMSolidFill()
              {
                  Enable = true,
                  Color = ColorFactory.Instance.CreateRGBColor(255, 255, 0)
              },
    };
      List<CIMSymbolLayer> symbolLayers = [outline, .. solidColorHatch];
      //This is the polygon symbol with a dash dot fill
      CIMPolygonSymbol dashDotFillPolygon = new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
      //To apply the symbol to a polygon feature layer
      //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer;
      //renderer.Symbol = dashDotFillPolygon.MakeSymbolReference();
      //theLayer.SetRenderer(renderer);
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.ColorFactory

    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also