ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMParagraphTextGraphic Class
Members Example

In This Topic
    CIMParagraphTextGraphic Class
    In This Topic
    Represents a paragraph text graphic.
    Object Model
    CIMParagraphTextGraphic ClassCIMParagraphTextGraphic ClassCIMGraphicFrame ClassCIMParagraphTextGraphic ClassGeometry ClassCIMSymbolReference Class
    Syntax
    Example
    Create_PolygonText
    //Create polygon paragraph text with basic text properties.
    
    //Construct on the worker thread
    await 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));
      //At 2.x - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords);
      Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords);
    
      //Set symbolology, 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 is <BOL>forced to wrap to other lines</BOL> so that we can see the effects." as String;
      //At 2.x - GraphicElement polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, text, sym);
      //         polyTxtElm.SetName("New Polygon Text"); 
      GraphicElement polyTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
                                    layout, TextType.RectangleParagraph, poly, sym, text, "New Polygon Text");
    
      //(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_CircleText
    //Create circle paragraph text with basic text settings and optionally a modified border.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build geometry
      Coordinate2D center = new Coordinate2D(4.5, 4);
      //At 2.x - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise);
      var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise);
      EllipticArcSegment cir = eabCir.ToSegment();
      var polyCir = PolygonBuilderEx.CreatePolygon(
                      PolylineBuilderEx.CreatePolyline(cir));
    
      //Set symbolology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular");
      string text = "Circle, circle, circle, circle, circle, circle, circle, circle, circle, circle, circle";
      //At 2.x - GraphicElement cirTxtElm = LayoutElementFactory.Instance.CreateCircleParagraphGraphicElement(layout, cir, text, sym);
      //         cirTxtElm.SetName("New Circle Text");
      GraphicElement cirTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
                                    layout, TextType.CircleParagraph, polyCir, sym, text, "New Circle Text");
    
      //(Optionally) Modify paragraph border 
      CIMGraphic cirTxtGra = cirTxtElm.GetGraphic();
      CIMParagraphTextGraphic cimCirTxtGra = cirTxtGra as CIMParagraphTextGraphic;
      cimCirTxtGra.Frame.BorderSymbol = new CIMSymbolReference();
      cimCirTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
      cirTxtElm.SetGraphic(cirTxtGra);
    });
    Create_EllipseText
    //Create ellipse paragraph text with basic text settings and optionally a modified border.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build geometry
      Coordinate2D center = new Coordinate2D(4.5, 2.75);
      //At 2.x - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise);
      var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise);
      EllipticArcSegment ellipse = eabElp.ToSegment();
      var polyElp = PolygonBuilderEx.CreatePolygon(
                      PolylineBuilderEx.CreatePolyline(ellipse));
    
      //Set symbolology, create and add element to layout
      CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlueRGB, 10, "Arial", "Regular");
      string text = "Ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse";
      //At 2.x - GraphicElement elpTxtElm = LayoutElementFactory.Instance.CreateEllipseParagraphGraphicElement(layout, ellipse, text, sym);
      //         elpTxtElm.SetName("New Ellipse Text");
      GraphicElement elpTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
                                    layout, TextType.EllipseParagraph, polyElp, sym, text, "New Ellipse Text");
    
      //(Optionally) Modify paragraph border 
      CIMGraphic elpTxtGra = elpTxtElm.GetGraphic();
      CIMParagraphTextGraphic cimElpTxtGra = elpTxtGra as CIMParagraphTextGraphic;
      cimElpTxtGra.Frame.BorderSymbol = new CIMSymbolReference();
      cimElpTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
      elpTxtElm.SetGraphic(elpTxtGra);
    });
    Create Rectangle Paragraph Text Element 1
    //Create rectangle text with background and border symbology.  
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //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));
      //At 2.x - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords);
      Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords);
    
      //Set symbolology, 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;
      //At 2.x - GraphicElement polyTxtElm =
      //           LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(
      //                                      layout, poly, text, sym);
      //         polyTxtElm.SetName("New Polygon Text");
    
      GraphicElement polyTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
        container, 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 a new field in the report
    //This is the gap between two fields
    double fieldIncrement = 0.9388875113593206276389;
    //On the QueuedTask
    //New field to add.
    var newReportField = new CIMReportField
    {
      Name = "POP1990",
      FieldOrder = 2,
    };
    //Get the "ReportSection element"                
    var mainReportSection = report.Elements.OfType<ReportSection>().FirstOrDefault();
    if (mainReportSection == null) return;
    
    //Get the "ReportDetails" within the ReportSectionElement. ReportDetails is where "fields" are.
    var reportDetailsSection = mainReportSection?.Elements.OfType<ReportDetails>().FirstOrDefault();
    if (reportDetailsSection == null) return;
    
    //Within ReportDetails find the envelope that encloses a field.
    //We get the first CIMParagraphTextGraphic in the collection so that we can add the new field next to it.                    
    var lastFieldGraphic = reportDetailsSection.Elements.FirstOrDefault((r) =>
    {
      var gr = r as GraphicElement;
      if (gr == null) return false;
      return (gr.GetGraphic() is CIMParagraphTextGraphic ? true : false);
    });
    //Get the Envelope of the last field
    var graphicBounds = lastFieldGraphic.GetBounds();
    
    //Min and Max values of the envelope
    var xMinOfFieldEnvelope = graphicBounds.XMin;
    var yMinOfFieldEnvelope = graphicBounds.YMin;
    
    var xMaxOfFieldEnvelope = graphicBounds.XMax;
    var YMaxOfFieldEnvelope = graphicBounds.YMax;
    //create the new Envelope to be offset from the existing field
    //At 2.x
    //MapPoint newMinPoint = MapPointBuilder.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope);
    //MapPoint newMaxPoint = MapPointBuilder.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope);
    //Envelope newFieldEnvelope = EnvelopeBuilder.CreateEnvelope(newMinPoint, newMaxPoint);
    
    MapPoint newMinPoint = MapPointBuilderEx.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope);
    MapPoint newMaxPoint = MapPointBuilderEx.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope);
    Envelope newFieldEnvelope = EnvelopeBuilderEx.CreateEnvelope(newMinPoint, newMaxPoint);
    
    //Create field
    GraphicElement fieldGraphic = ReportElementFactory.Instance.CreateFieldValueTextElement(reportDetailsSection, newFieldEnvelope, newReportField);
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CIM.CIMObject
          ArcGIS.Core.CIM.CIMGraphic
             ArcGIS.Core.CIM.CIMTextGraphicBase
                ArcGIS.Core.CIM.CIMParagraphTextGraphic

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also