How to access or set Text Symbol from Table Frame using ArcGIS Pro SDK

713
4
Jump to solution
04-21-2022 04:38 AM
by Anonymous User
Not applicable

Hi,

I'm using the Table Frame functionality in the ArcGIS Pro application where I need to set the Text symbol part that appears when we go to the Table Frame properties table, beside that there is one tab "Text Symbol" that I need to access through the backend using C#.

ShabinaBano_0-1650541044194.png

 

Is there anyone who knows how to do this or can provide the code snippet ?

 

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
CharlesMacleod
Esri Regular Contributor

 

 

internal class Button1 : Button {
  protected override void OnClick() {
     var layout = LayoutView.Active.Layout;
     if (layout == null)
       return;

     QueuedTask.Run(() => {
      var tableFrame = layout.GetElements().OfType<TableFrame>().FirstOrDefault();
      if (tableFrame != null) {
        //change the text symbol
        //the property panel conflates the symbols for each field
        var frame_def = tableFrame.GetDefinition() as CIMTableFrame;
        var fields = frame_def.Fields?.ToList() ?? new List<CIMTableFrameField>();

        var green = ColorFactory.Instance.CreateColor(
                       System.Windows.Media.Colors.ForestGreen);
        var size = 11;
        var fontName = "Bernard MT Condensed";
        var textSymbol = SymbolFactory.Instance.ConstructTextSymbol(green, size, fontName);							

        foreach (var frameField in fields) {
          //to mimic the property sheet, change heading and field symbols
	  frameField.HeadingTextSymbol.Symbol = textSymbol;
          frameField.TextSymbol.Symbol = textSymbol;
        }
        //these are defaults for new fields - optional - but, based on
        //some experimentation, they need to match if u want the property
        //sheet to show the changed symbology.
        frame_def.DefaultTableFrameField.HeadingTextSymbol.Symbol = textSymbol;				 
        frame_def.DefaultTableFrameField.TextSymbol.Symbol = textSymbol;

        //commit the changes
        tableFrame.SetDefinition(frame_def);
       }
     });
   }
}

 

Take a look at https://www.youtube.com/watch?v=MP90p-jkA5Q&t=14s  on Youtube for on some guidance on how to figure these kind of things out. The session content is here: UnderstandingTheCIM.zip 

View solution in original post

4 Replies
CharlesMacleod
Esri Regular Contributor

 

 

internal class Button1 : Button {
  protected override void OnClick() {
     var layout = LayoutView.Active.Layout;
     if (layout == null)
       return;

     QueuedTask.Run(() => {
      var tableFrame = layout.GetElements().OfType<TableFrame>().FirstOrDefault();
      if (tableFrame != null) {
        //change the text symbol
        //the property panel conflates the symbols for each field
        var frame_def = tableFrame.GetDefinition() as CIMTableFrame;
        var fields = frame_def.Fields?.ToList() ?? new List<CIMTableFrameField>();

        var green = ColorFactory.Instance.CreateColor(
                       System.Windows.Media.Colors.ForestGreen);
        var size = 11;
        var fontName = "Bernard MT Condensed";
        var textSymbol = SymbolFactory.Instance.ConstructTextSymbol(green, size, fontName);							

        foreach (var frameField in fields) {
          //to mimic the property sheet, change heading and field symbols
	  frameField.HeadingTextSymbol.Symbol = textSymbol;
          frameField.TextSymbol.Symbol = textSymbol;
        }
        //these are defaults for new fields - optional - but, based on
        //some experimentation, they need to match if u want the property
        //sheet to show the changed symbology.
        frame_def.DefaultTableFrameField.HeadingTextSymbol.Symbol = textSymbol;				 
        frame_def.DefaultTableFrameField.TextSymbol.Symbol = textSymbol;

        //commit the changes
        tableFrame.SetDefinition(frame_def);
       }
     });
   }
}

 

Take a look at https://www.youtube.com/watch?v=MP90p-jkA5Q&t=14s  on Youtube for on some guidance on how to figure these kind of things out. The session content is here: UnderstandingTheCIM.zip 

by Anonymous User
Not applicable

 @CharlesMacleod Thank you so much, it worked out great!! and if you have any idea Could you please also tell me how to set the border of the Table Frame from the backend ?

 

0 Kudos
CharlesMacleod
Esri Regular Contributor

There are multiple symbols it seems that control the borders - for the rows, the header, columns, etc. However, the "outer" border is this one:

var frame_def = tableFrame.GetDefinition() as CIMTableFrame;
var dashed_line = SymbolFactory.Instance.ConstructLineSymbol(
   ColorFactory.Instance.CreateColor(System.Windows.Media.Colors.CadetBlue),
       1, SimpleLineStyle.Dash);
//change the outer border symbol
frame_def.GraphicFrame.BorderSymbol.Symbol = dashed_line;
tableFrame.SetDefinition(frame_def);
by Anonymous User
Not applicable

Many Thanks , It worked 🙂

0 Kudos