Select to view content in your preferred language

New Button Condition for API

839
3
06-27-2011 10:43 PM
DarrylDempsey
Emerging Contributor
I'm developing an improved version of the Layer Attributes sample using a button control. The new addin will allow users to view, navigate through and export the attributes of any selected item having an underlying table.

Two questions for the ESRI AGX development folks:
1. Is it possible to add a new condition for the API, eg. Single Item with table selected?

At the moment I use the condition: Single Item selected, which leads to my second question:

2. In the meanwhile what is the most efficient way to test for this programmatically so I can enable/disable the button state as the user selects different items?
0 Kudos
3 Replies
AndreiIvanov
Deactivated User
Darryl,

you can check if layer has Table in OnUpdate method:

    public override void OnUpdate()
    {
      base.OnUpdate();
      Enabled = false;

      //single item check
      if (Application.SelectedItems.Count > 1 || Application.SelectedItems.Count == 0)
        return;

      // check for table
      MapItem mapItem = Application.SelectedItems.GetFirst();
      if (mapItem is PackageLayer)
      {
        PackageLayer pkLayer = mapItem as PackageLayer;
        Enabled = pkLayer.HasTable;
      }
      else if (mapItem is PackageChildLayer)
      {
        PackageChildLayer pkChildLayer = mapItem as PackageChildLayer;
        Enabled = pkChildLayer.HasTable;
      }
      else if (mapItem is FeatureLayer)
        Enabled = true;
    }
0 Kudos
DarrylDempsey
Emerging Contributor
Thank you, Andriy. Works like a charm.
Any chance of seeing a new condition added to the API?
0 Kudos
AndreiIvanov
Deactivated User
Not sure of API change for this case, as it is easy to override the method and add your own conditions, if needed.
0 Kudos