ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Core Namespace / ApplicationOptions Class / TextAndGraphicsElementsOptions Property
Example

In This Topic
    TextAndGraphicsElementsOptions Property
    In This Topic
    Gets the application text and graphics elements options.
    Syntax
    Public Shared ReadOnly Property TextAndGraphicsElementsOptions As TextAndGraphicsElementsOptions
    public static TextAndGraphicsElementsOptions TextAndGraphicsElementsOptions {get;}
    Remarks
    Use to set the default font and default point, line, polygon, and text symbology for graphics elements
    Example
    Get All Available Fonts
    {
      //Note: see also SymbolFactory.Instance.GetAvailableFonts() which returns the
      //same list. Use for TextAndGraphicsElementsOptions.GetAvailableFonts() convenience
      //A list of tuples of Font name + associated Font Styles, one tuple per
      //font, is returned
      //Note: Must be on QueuedTask.Run
      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
    {
      //Note: Must be on 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
    {
      //Note: Must be on 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);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also