ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Core Namespace / TextAndGraphicsElementsOptions Class
Members Example

In This Topic
    TextAndGraphicsElementsOptions Class
    In This Topic
    Gets and sets the application options for default font and graphic element symbology.
    Object Model
    TextAndGraphicsElementsOptions ClassCIMLineSymbol ClassCIMPointSymbol ClassCIMPolygonSymbol ClassCIMTextSymbol Class
    Syntax
    public class TextAndGraphicsElementsOptions 
    Public Class TextAndGraphicsElementsOptions 
    Example
    Get All Available Fonts
    //Note: see also SymbolFactory.Instance.GetAvailableFonts() which returns the
    //same list. Use for TextAndGraphicsElementsOptions.GetAvailableFonts() convenience
    
    QueuedTask.Run(() =>
    {
      //A list of tuples of Font name + associated Font Styles, one tuple per
      //font, is returned
      var fonts = ApplicationOptions.TextAndGraphicsElementsOptions.GetAvailableFonts();
      StringBuilder sb = new StringBuilder();
      sb.AppendLine("Pro Fonts\r\n============================");
      foreach (var font in fonts)
      {
        var styles = string.Join(",", font.fontStyles);
        sb.AppendLine($"{font.fontName}, [{styles}]");
      }
      System.Diagnostics.Debug.WriteLine(sb.ToString());
    });
    
    Get TextAndGraphicsElementsOptions
    QueuedTask.Run(() =>
    {
      //Get the default font (see also 'SymbolFactory.Instance.DefaultFont')
      var def_font = ApplicationOptions.TextAndGraphicsElementsOptions.GetDefaultFont();
      System.Diagnostics.Debug.WriteLine(
        $"\r\ndefault font: {def_font.fontName}, {def_font.styleName}");
    
      //Get the default graphics element symbols - point, line, poly, text
      var ptSymbol = ApplicationOptions.TextAndGraphicsElementsOptions.GetDefaultPointSymbol();
      var lineSymbol = ApplicationOptions.TextAndGraphicsElementsOptions.GetDefaultLineSymbol();
      var polySymbol = ApplicationOptions.TextAndGraphicsElementsOptions.GetDefaultPolygonSymbol();
      var textSymbol = ApplicationOptions.TextAndGraphicsElementsOptions.GetDefaultTextSymbol();
    });
    
    Set TextAndGraphicsElementsOptions
    QueuedTask.Run(() =>
    {
      //Set a default font. Use its default style
      ApplicationOptions.TextAndGraphicsElementsOptions.SetDefaultFont("tahoma");
      //or specify an explicit style
      ApplicationOptions.TextAndGraphicsElementsOptions.SetDefaultFont("tahoma", "bold");
    
      //Create symbols
      var ptSymbol2 = SymbolFactory.Instance.ConstructPointSymbol(
        ColorFactory.Instance.RedRGB, 14, SimpleMarkerStyle.Diamond);
      var lineSymbol2 = SymbolFactory.Instance.ConstructLineSymbol(
        ColorFactory.Instance.RedRGB, 2, SimpleLineStyle.Dash);
      var polySymbol2 = SymbolFactory.Instance.ConstructPolygonSymbol(
        ColorFactory.Instance.RedRGB, SimpleFillStyle.DiagonalCross);
      var textSymbol2 = SymbolFactory.Instance.ConstructTextSymbol(
        ColorFactory.Instance.RedRGB, 12);
    
      //Set default point, line, poly, text graphics element symbols
      ApplicationOptions.TextAndGraphicsElementsOptions.SetDefaultPointSymbol(ptSymbol2);
      ApplicationOptions.TextAndGraphicsElementsOptions.SetDefaultLineSymbol(lineSymbol2);
      ApplicationOptions.TextAndGraphicsElementsOptions.SetDefaultPolygonSymbol(polySymbol2);
      ApplicationOptions.TextAndGraphicsElementsOptions.SetDefaultTextSymbol(textSymbol2);
    });
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also