Public Overloads Function ConstructTextSymbol( _ ByVal color As CIMColor _ ) As CIMTextSymbol
public CIMTextSymbol ConstructTextSymbol( CIMColor color )
Parameters
- color
- ArcGIS.Core.CIM.CIMColor
Public Overloads Function ConstructTextSymbol( _ ByVal color As CIMColor _ ) As CIMTextSymbol
public CIMTextSymbol ConstructTextSymbol( CIMColor color )
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method must be called within the lambda passed to QueuedTask.Run |
{
//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);
}
{
//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);
}
{
//Note: Needs QueuedTask to run
//using the default font
var textSym1 = SymbolFactory.Instance.ConstructTextSymbol();
var textSym2 = SymbolFactory.Instance.ConstructTextSymbol(
ColorFactory.Instance.BlueRGB, 14);
//using a specific font
var textSym3 = SymbolFactory.Instance.ConstructTextSymbol("Arial");
var textSym4 = SymbolFactory.Instance.ConstructTextSymbol(
"Arial", "Narrow Bold");
//or query available fonts to ensure the font is there
var all_fonts = SymbolFactory.Instance.GetAvailableFonts();
var font = all_fonts.FirstOrDefault(f => f.fontName == "Arial");
if (!string.IsNullOrEmpty(font.fontName))
{
var textSym5 = SymbolFactory.Instance.ConstructTextSymbol(font.fontName);
//or with a font+style
var textSym6 = SymbolFactory.Instance.ConstructTextSymbol(
font.fontName, font.fontStyles.First());
}
//overloads - font + color and size, etc
var textSym7 = SymbolFactory.Instance.ConstructTextSymbol(
ColorFactory.Instance.BlueRGB, 14, "Times New Roman", "Italic");
//custom symbol - black stroke, red fill
var poly_symbol = SymbolFactory.Instance.ConstructPolygonSymbol(
SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.RedRGB),
SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 1));
var textSym8 = SymbolFactory.Instance.ConstructTextSymbol(
poly_symbol, 14, "Georgia", "Bold");
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)