<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: State/condition for selected feature class/table in a geodatabase in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1081444#M6901</link>
    <description>&lt;P&gt;Hi Marvis,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a look at the existing conditions that live in the ADGeodatabase.daml file (which can be found in (installPath\bin\Extensions\Catalog). And it doesn't appear that there is anything that will help you in what you're trying to achieve.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However this may be a workaround for you.&amp;nbsp; Subscribe to the ArcGIS.Desktop.Core.Events.ProjectWindowSelectedItemsChangedEvent.&amp;nbsp; &amp;nbsp;In your delegate, examine the TypeID of the selected item and activate or deactivate your own states.&amp;nbsp; &amp;nbsp;Then in your daml file, create your own condition based on your state.&amp;nbsp; Here's a bit of a snippet to get you started&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override void OnClick()
    {
      if (subscribed)
        ProjectWindowSelectedItemsChangedEvent.Unsubscribe(OnProjectWindowSelectedItem);
      else
        ProjectWindowSelectedItemsChangedEvent.Subscribe(OnProjectWindowSelectedItem);

      subscribed = !subscribed;
    }

    private async void OnProjectWindowSelectedItem(ProjectWindowSelectedItemsChangedEventArgs args)
    {
      if (args.IProjectWindow.SelectionCount &amp;gt; 0)
      {
        // get the first selected item
        var selectedItem = args.IProjectWindow.SelectedItems.First();
        string typeID = selectedItem.TypeID;

        // TypeID for file gdb is "database_fgdb"
        // TypeID for file gdb items are "fgdb_table", "fgdb_relationship", "fgdb_fc_point", "fgdb_fc_polygon" etc
        if (IsFGDBItem(typeID))
          FrameworkApplication.State.Activate("FGDBItemSelected");
        else
          FrameworkApplication.State.Deactivate("FGDBItemSelected");

        // TypeID for enterprise gdb is "database_egdb"
        // TypeID for enterprise gdb items are "egdb_table", "egdb_relationship", "egdb_fc_point", "egdb_fc_polygon" etc
        if (IsEGDBItem(typeID))
          FrameworkApplication.State.Activate("EGDBItemSelected");
        else
          FrameworkApplication.State.Deactivate("EGDBItemSelected");
      }
    }
    private bool IsFGDBItem(string typeID)
    {
      if (typeID.StartsWith("fgdb_"))
        return true;
      return false;
    }

    private bool IsEGDBItem(string typeID)
    {
      if (typeID.StartsWith("egdb_"))
        return true;
      return false;
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the daml&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    &amp;lt;insertCondition id="myCondition" caption=""&amp;gt;
      &amp;lt;or&amp;gt;
        &amp;lt;state id="FGDBItemSelected"/&amp;gt;
        &amp;lt;state id="EGDBItemSelected"/&amp;gt;
      &amp;lt;/or&amp;gt;
    &amp;lt;/insertCondition&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can of course make the IsFGDBItem and&amp;nbsp;IsEGDBItem routines more restrictive if you're only looking for feature classes or tables and not other data items like relationships, topologies etc.&amp;nbsp; Search the ADGeodatabase.daml file for specific TypeID strings for specific dataset types.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jul 2021 17:39:03 GMT</pubDate>
    <dc:creator>NarelleChedzey</dc:creator>
    <dc:date>2021-07-21T17:39:03Z</dc:date>
    <item>
      <title>State/condition for selected feature class/table in a geodatabase</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1080963#M6877</link>
      <description>&lt;P&gt;I need to locate a state or condition for enabling a button when there's a&amp;nbsp;selected feature class or table in a geodatabase (file geodatabase and sde).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I utilized this sample&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/44183d0d5a9bc5da6fb8b9229211cc707dd2b874/Framework/ConditionQuery" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-comunity-samples/tree/44183d0d5a9bc5da6fb8b9229211cc707dd2b874/Framework/ConditionQuery&lt;/A&gt;&amp;nbsp;but these states/conditions are not exposed. I have also searched the daml files at&amp;nbsp;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference" target="_blank"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference&lt;/A&gt;&amp;nbsp;to no avail.&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/145101"&gt;@CharlesMacleod&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/9021"&gt;@UmaHarano&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 17:55:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1080963#M6877</guid>
      <dc:creator>MarvisKisakye1</dc:creator>
      <dc:date>2021-07-20T17:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: State/condition for selected feature class/table in a geodatabase</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1081119#M6889</link>
      <description>&lt;P&gt;I'll take a look and get back to you - but - FYI, there is no such thing as a private state or condition....if u did not "see" a state or condition being set then that probably means that there isn't one.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 23:03:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1081119#M6889</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2021-07-20T23:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: State/condition for selected feature class/table in a geodatabase</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1081444#M6901</link>
      <description>&lt;P&gt;Hi Marvis,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a look at the existing conditions that live in the ADGeodatabase.daml file (which can be found in (installPath\bin\Extensions\Catalog). And it doesn't appear that there is anything that will help you in what you're trying to achieve.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However this may be a workaround for you.&amp;nbsp; Subscribe to the ArcGIS.Desktop.Core.Events.ProjectWindowSelectedItemsChangedEvent.&amp;nbsp; &amp;nbsp;In your delegate, examine the TypeID of the selected item and activate or deactivate your own states.&amp;nbsp; &amp;nbsp;Then in your daml file, create your own condition based on your state.&amp;nbsp; Here's a bit of a snippet to get you started&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override void OnClick()
    {
      if (subscribed)
        ProjectWindowSelectedItemsChangedEvent.Unsubscribe(OnProjectWindowSelectedItem);
      else
        ProjectWindowSelectedItemsChangedEvent.Subscribe(OnProjectWindowSelectedItem);

      subscribed = !subscribed;
    }

    private async void OnProjectWindowSelectedItem(ProjectWindowSelectedItemsChangedEventArgs args)
    {
      if (args.IProjectWindow.SelectionCount &amp;gt; 0)
      {
        // get the first selected item
        var selectedItem = args.IProjectWindow.SelectedItems.First();
        string typeID = selectedItem.TypeID;

        // TypeID for file gdb is "database_fgdb"
        // TypeID for file gdb items are "fgdb_table", "fgdb_relationship", "fgdb_fc_point", "fgdb_fc_polygon" etc
        if (IsFGDBItem(typeID))
          FrameworkApplication.State.Activate("FGDBItemSelected");
        else
          FrameworkApplication.State.Deactivate("FGDBItemSelected");

        // TypeID for enterprise gdb is "database_egdb"
        // TypeID for enterprise gdb items are "egdb_table", "egdb_relationship", "egdb_fc_point", "egdb_fc_polygon" etc
        if (IsEGDBItem(typeID))
          FrameworkApplication.State.Activate("EGDBItemSelected");
        else
          FrameworkApplication.State.Deactivate("EGDBItemSelected");
      }
    }
    private bool IsFGDBItem(string typeID)
    {
      if (typeID.StartsWith("fgdb_"))
        return true;
      return false;
    }

    private bool IsEGDBItem(string typeID)
    {
      if (typeID.StartsWith("egdb_"))
        return true;
      return false;
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the daml&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    &amp;lt;insertCondition id="myCondition" caption=""&amp;gt;
      &amp;lt;or&amp;gt;
        &amp;lt;state id="FGDBItemSelected"/&amp;gt;
        &amp;lt;state id="EGDBItemSelected"/&amp;gt;
      &amp;lt;/or&amp;gt;
    &amp;lt;/insertCondition&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can of course make the IsFGDBItem and&amp;nbsp;IsEGDBItem routines more restrictive if you're only looking for feature classes or tables and not other data items like relationships, topologies etc.&amp;nbsp; Search the ADGeodatabase.daml file for specific TypeID strings for specific dataset types.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Narelle&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 17:39:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1081444#M6901</guid>
      <dc:creator>NarelleChedzey</dc:creator>
      <dc:date>2021-07-21T17:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: State/condition for selected feature class/table in a geodatabase</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1081886#M6914</link>
      <description>&lt;P&gt;This is a good workaround. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 18:14:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/state-condition-for-selected-feature-class-table/m-p/1081886#M6914</guid>
      <dc:creator>MarvisKisakye1</dc:creator>
      <dc:date>2021-07-22T18:14:10Z</dc:date>
    </item>
  </channel>
</rss>

