ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / TextType Enumeration
Example Example

In This Topic
    TextType Enumeration
    In This Topic
    Specifies the available CIMGraphic text types
    Syntax
    Members
    MemberDescription
    CircleParagraph Circle paragraph text
    EllipseParagraph Ellipse paragraph text
    None None- default
    PointText Point text
    PolygonParagraph Polygon paragraph text
    RectangleParagraph Rectangle paragraph text
    SplinedText Text splined along a line or curve
    Remarks
    Example
    Create Circle Text Graphic
    {
      //Note: Must be on QueuedTask.Run
      //Build geometry
      Coordinate2D center = new Coordinate2D(4.5, 4);
      var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise);
      var cir = eabCir.ToSegment();
    
      var poly = PolygonBuilderEx.CreatePolygon(
        PolylineBuilderEx.CreatePolyline(cir, AttributeFlags.AllAttributes));
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
        ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular");
      string text = "Circle, circle, circle";
    
      var graphic = GraphicFactory.Instance.CreateSimpleTextGraphic(
        TextType.CircleParagraph, poly, sym, text);
    
      //Make an element to add to GraphicsLayer or Layout
      //var ge = ElementFactory.Instance.CreateGraphicElement(layout, graphic,
      //  "New Circle Text", true);
    }
    Create Bezier Graphic
    {
      //Note: Must be on QueuedTask.Run
    
      //Build geometry
      Coordinate2D pt1 = new Coordinate2D(3.5, 7.5);
      Coordinate2D pt2 = new Coordinate2D(4.16, 8);
      Coordinate2D pt3 = new Coordinate2D(4.83, 7.1);
      Coordinate2D pt4 = new Coordinate2D(5.5, 7.5);
      var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4);
      var bezSeg = bez.ToSegment();
      Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg, AttributeFlags.AllAttributes);
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
            ColorFactory.Instance.BlackRGB, 24, "Comic Sans MS", "Regular");
    
      var graphic = GraphicFactory.Instance.CreateSimpleTextGraphic(
        TextType.SplinedText, bezPl, sym, "Splined text");
    
      //Make an element to add to GraphicsLayer or Layout
      //var ge = ElementFactory.Instance.CreateGraphicElement(layout, graphic);
    }
    Create Point Text Element 1
    {
      //Create a simple point text element and assign basic symbology and text settings.
    
      //Note: Must be on QueuedTask.Run
      //Build 2D point geometry
      Coordinate2D coord2D = new Coordinate2D(3.5, 10);
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                    ColorFactory.Instance.RedRGB, 32, "Arial", "Regular");
      string textString = "Point text";
    
      //use ElementInfo to set placement properties during create
      var elemInfo = new ElementInfo()
      {
        Anchor = Anchor.CenterPoint,
        Rotation = 45
      };
      var ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.PointText, coord2D.ToMapPoint(), sym, textString,
                           "New Point Text", true, elemInfo);
    
      //Change additional text properties
      ptTxtElm.SetX(4.5);
      ptTxtElm.SetY(9.5);
    }
    Create Rectangle Paragraph Text Element 1
    {
      //Note: Must be on QueuedTask.Run
      //Create rectangle text with background and border symbology.  
      //Build 2D polygon geometry
      List<Coordinate2D> plyCoords = new List<Coordinate2D>();
      plyCoords.Add(new Coordinate2D(3.5, 7));
      plyCoords.Add(new Coordinate2D(4.5, 7));
      plyCoords.Add(new Coordinate2D(4.5, 6.7));
      plyCoords.Add(new Coordinate2D(5.5, 6.7));
      plyCoords.Add(new Coordinate2D(5.5, 6.1));
      plyCoords.Add(new Coordinate2D(3.5, 6.1));
      Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords);
    
      //Set symbology, create and add element to layout
      //Also notice how formatting tags are using within the text string.
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                        ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular");
      string text = "Some Text String that is really long and is " +
                    "<BOL>forced to wrap to other lines</BOL> so that " +
                    "we can see the effects." as String;
    
      GraphicElement polyTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.RectangleParagraph, poly, sym, text, "Polygon Paragraph");
    
      //(Optionally) Modify paragraph border 
      CIMGraphic polyTxtGra = polyTxtElm.GetGraphic();
      CIMParagraphTextGraphic cimPolyTxtGra = polyTxtGra as CIMParagraphTextGraphic;
      cimPolyTxtGra.Frame.BorderSymbol = new CIMSymbolReference();
      cimPolyTxtGra.Frame.BorderSymbol.Symbol =
                   SymbolFactory.Instance.ConstructLineSymbol(
                              ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
      polyTxtElm.SetGraphic(polyTxtGra);
    }
    Create Point Text Element 2
    {
      //Note: Must be on QueuedTask.Run
      //Build geometry
      Coordinate2D coord2D = new Coordinate2D(3.5, 10);
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
        ColorFactory.Instance.RedRGB, 32, "Arial", "Regular");
      string textString = "Point text";
    
      var elemInfo = new ElementInfo() { Anchor = Anchor.BottomLeftCorner };
      GraphicElement ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.PointText, coord2D.ToMapPoint(), sym, textString,
        "New Point Text", true, elemInfo);
    }
    Create Polygon Paragraph Text Element
    {
      //Note: Must be on QueuedTask.Run
    
      //Build geometry
      List<Coordinate2D> plyCoords = new List<Coordinate2D>();
      plyCoords.Add(new Coordinate2D(3.5, 7));
      plyCoords.Add(new Coordinate2D(4.5, 7));
      plyCoords.Add(new Coordinate2D(4.5, 6.7));
      plyCoords.Add(new Coordinate2D(5.5, 6.7));
      plyCoords.Add(new Coordinate2D(5.5, 6.1));
      plyCoords.Add(new Coordinate2D(3.5, 6.1));
      Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords);
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
           ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular");
      string text = "Some text string that is really long and " +
                    "<BOL>wraps to other lines</BOL>" +
                    " so that we can see the effects.";
    
      var ge = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.PolygonParagraph, poly, sym, text,
              "New Polygon Text", true);
    }
    Create Rectangle Paragraph Text Element 2
    {
      //Note: Must be on QueuedTask.Run
    
      //Build geometry
      Coordinate2D ll = new Coordinate2D(3.5, 4.75);
      Coordinate2D ur = new Coordinate2D(5.5, 5.75);
      Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur);
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                 ColorFactory.Instance.WhiteRGB, 10, "Arial", "Regular");
      string text = "Some text string that is really long and " +
                    "<BOL>wraps to other lines</BOL>" +
                    " so that we can see the effects.";
    
      //(Optionally) Modify border and background with 50% transparency 
      //CIMGraphic recTxtGra = recTxtElm.Graphic;
      //CIMParagraphTextGraphic cimRecTxtGra = recTxtGra as CIMParagraphTextGraphic;
      //CIMSymbolReference cimRecTxtBorder = cimRecTxtGra.Frame.BorderSymbol;
      //
      //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(
      //                    ColorFactory.Instance.BlackRGB, 1.0, SimpleLineStyle.Solid);
      //cimRecTxtBorder.Symbol = lineSym;
      //
      //CIMSymbolReference cimRecTxtBkgrd = cimRecTxtGra.Frame.BackgroundSymbol;
      //CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
      //                            ColorFactory.Instance.GreyRGB, SimpleFillStyle.Solid);
      //
      //CIMColor symCol = polySym.GetColor(IElementContainer container);
      //symCol.SetAlphaValue(50);
      //cimRecTxtBkgrd.Symbol = polySym;
      //recTxtElm.SetGraphic(recTxtGra);
    
      var ge = ElementFactory.Instance.CreateTextGraphicElement(layout,
                  TextType.RectangleParagraph, env, sym, text, "New Rectangle Text");
    }
    Create Circle Text Element
    {
      //Note: Must be on QueuedTask.Run(() => { ...
      //Build geometry
      Coordinate2D center = new Coordinate2D(4.5, 4);
      var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise);
      var cir = eabCir.ToSegment();
    
      var poly = PolygonBuilderEx.CreatePolygon(
        PolylineBuilderEx.CreatePolyline(cir, AttributeFlags.AllAttributes));
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                      ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular");
      string text = "Circle, circle, circle";
    
      GraphicElement cirTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.CircleParagraph, poly, sym, text, "New Circle Text", false);
    }
    Create Bezier Text Element
    {
      //Note: Must be on QueuedTask.Run
    
      //Build geometry
      Coordinate2D pt1 = new Coordinate2D(3.5, 7.5);
      Coordinate2D pt2 = new Coordinate2D(4.16, 8);
      Coordinate2D pt3 = new Coordinate2D(4.83, 7.1);
      Coordinate2D pt4 = new Coordinate2D(5.5, 7.5);
      var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4);
      var bezSeg = bez.ToSegment();
      Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg, AttributeFlags.AllAttributes);
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
        ColorFactory.Instance.BlackRGB, 24, "Comic Sans MS", "Regular");
    
      var ge = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.SplinedText, bezPl, sym, "this is the bezier text",
              "New Bezier Text", true, new ElementInfo() { Anchor = Anchor.CenterPoint });
    }
    Create Ellipse Text Element
    {
      //Note: Must be on QueuedTask.Run
    
      //Build geometry
      Coordinate2D center = new Coordinate2D(4.5, 2.75);
      var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise);
      var ellipse = eabElp.ToSegment();
    
      var poly = PolygonBuilderEx.CreatePolygon(
        PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes));
    
      //Set symbology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                            ColorFactory.Instance.BlueRGB, 10, "Arial", "Regular");
      string text = "Ellipse, ellipse, ellipse";
    
      GraphicElement ge = ElementFactory.Instance.CreateTextGraphicElement(
        layout, TextType.PolygonParagraph, poly, sym, text, "New Ellipse Text", false);
    }
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Desktop.Layouts.TextType

    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also