ArcGIS Pro 3.4 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 static TextAndGraphicsElementsOptions TextAndGraphicsElementsOptions {get;}
    Public Shared ReadOnly Property TextAndGraphicsElementsOptions As TextAndGraphicsElementsOptions
    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
    
    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);
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also