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.
分类:
ArcGIS Pro二次开发
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
2020-09-22 第8章代码
2018-09-22 vs2010 :0X80041FEB 程序集无法修改版等内容
2018-09-22 VS2010 F5调试时出现:“ 尝试运行项目时出错:未捕获通过反射调用的方法引发的异常”解决
2015-09-22 拷贝地图 CopyAndOverwriteMap()
2015-09-22 增加图例 Legend和删除图例
2015-09-22 C# 新建文档CreateNewDocument
2015-09-22 axTOCControl右键