首页 > 其他分享 >State/condition for selected feature class/table in a geodatabase

State/condition for selected feature class/table in a geodatabase

时间:2022-09-22 22:22:16浏览次数:66  
标签:typeID egdb TypeID selected feature State fgdb table

rotected override void OnClick()
    {
      if (subscribed)
        ProjectWindowSelectedItemsChangedEvent.Unsubscribe(OnProjectWindowSelectedItem);
      else
        ProjectWindowSelectedItemsChangedEvent.Subscribe(OnProjectWindowSelectedItem);

      subscribed = !subscribed;
    }

    private async void OnProjectWindowSelectedItem(ProjectWindowSelectedItemsChangedEventArgs args)
    {
      if (args.IProjectWindow.SelectionCount > 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;
    }

 

And the daml

    <insertCondition id="myCondition" caption="">
      <or>
        <state id="FGDBItemSelected"/>
        <state id="EGDBItemSelected"/>
      </or>
    </insertCondition>

 

You can of course make the IsFGDBItem and IsEGDBItem routines more restrictive if you're only looking for feature classes or tables and not other data items like relationships, topologies etc.  Search the ADGeodatabase.daml file for specific TypeID strings for specific dataset types. 

 

 

标签:typeID,egdb,TypeID,selected,feature,State,fgdb,table
From: https://www.cnblogs.com/gisoracle/p/16721056.html

相关文章