• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

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

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. 

 

 

posted on 2022-09-22 22:14  gisai  阅读(64)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3