添加ArcGismap 内置图层属性模块
来源:互联网 发布:淘宝页面找不 编辑:程序博客网 时间:2024/06/01 10:43
首先新建 Base Command,如下图:
在TOCControl 右键添加该菜单项,注意LayerPropertiesCmd() 前面的文件位置,为当前该类所在的项目位置,默认为LayerPropertiesCmd() 。
IToolbarMenu.AddItem()函数中的参数
第一个参数:菜单项的内容,功能实现。
第二个参数:对于一个工具定义多个 type 的时候,才会用到,每一个 int 代表一个新的实现。
第三个参数:索引值,在菜单项上面显示的位置。默认为 -1,按书写顺序排序。
第四个参数:是否开始一个新组,就是在其上面有一个“——”的效果。
第五个参数:显示样式。
//添加图层属性菜单项 m_menuLayer.AddItem(new AE_test1.class_AE.LayerPropertiesCmd(), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
原文中没有引用using ESRI.ArcGIS.ArcMapUI;因此标记下。
using System;using System.Drawing;using System.Runtime.InteropServices;using ESRI.ArcGIS.ADF.BaseClasses;using ESRI.ArcGIS.ADF.CATIDs;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.Carto;using System.Windows.Forms;using ESRI.ArcGIS.ArcMapUI;namespace AE_test1.class_AE{ /// <summary> /// Command that works in ArcMap/Map/PageLayout /// </summary> [Guid("33766f65-aff7-45f1-8755-4ae854977568")] [ClassInterface(ClassInterfaceType.None)] [ProgId("AE_test1.class_AE.LayerPropertiesCmd")] public sealed class LayerPropertiesCmd : BaseCommand { #region COM Registration Function(s) [ComRegisterFunction()] [ComVisible(false)] static void RegisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType); // // TODO: Add any COM registration code here // } [ComUnregisterFunction()] [ComVisible(false)] static void UnregisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType); // // TODO: Add any COM unregistration code here // } #region ArcGIS Component Category Registrar generated code /// <summary> /// Required method for ArcGIS Component Category registration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryRegistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Register(regKey); ControlsCommands.Register(regKey); } /// <summary> /// Required method for ArcGIS Component Category unregistration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryUnregistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Unregister(regKey); ControlsCommands.Unregister(regKey); } #endregion #endregion private IHookHelper m_hookHelper = null; IActiveView m_activeView = null; IMapControl3 m_mapcontrol = null; IFeatureLayer currentLayer = null; public LayerPropertiesCmd() { base.m_category = "ControlsApplication"; base.m_caption = "图层属性"; base.m_message = "图层属性"; base.m_toolTip = "图层属性"; base.m_name = "LayerPropertiesCmd"; base.m_enabled = true; try { string bitmapResourceName = GetType().Name + ".bmp"; base.m_bitmap = new Bitmap(GetType(), bitmapResourceName); } catch (Exception ex) { MessageBox.Show("无效位图!!" + ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } #region Overridden Class Methods /// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (hook == null) return; m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = hook; } /// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_hookHelper.Hook is IToolbarControl) { IToolbarControl toolbarControl = m_hookHelper.Hook as IToolbarControl; m_mapcontrol = (IMapControl3)toolbarControl.Buddy; } if (m_hookHelper.Hook is IMapControl3) { m_mapcontrol = m_hookHelper.Hook as IMapControl3; } if (m_mapcontrol != null) { currentLayer = m_mapcontrol.CustomProperty as IFeatureLayer; m_activeView = m_mapcontrol.ActiveView; } if (currentLayer == null) return; SetupFeaturePropertySheet(currentLayer); } #endregion private bool SetupFeaturePropertySheet(ILayer layer) { if (layer == null) return false; ESRI.ArcGIS.Framework.IComPropertySheet pComPropSheet; pComPropSheet = new ESRI.ArcGIS.Framework.ComPropertySheet(); pComPropSheet.Title = layer.Name + " - 属性"; ESRI.ArcGIS.esriSystem.UID pPPUID = new ESRI.ArcGIS.esriSystem.UIDClass(); pComPropSheet.AddCategoryID(pPPUID); // General.... ESRI.ArcGIS.Framework.IPropertyPage pGenPage = new ESRI.ArcGIS.CartoUI.GeneralLayerPropPageClass(); pComPropSheet.AddPage(pGenPage); // Source ESRI.ArcGIS.Framework.IPropertyPage pSrcPage = new ESRI.ArcGIS.CartoUI.FeatureLayerSourcePropertyPageClass(); pComPropSheet.AddPage(pSrcPage); // Selection... ESRI.ArcGIS.Framework.IPropertyPage pSelectPage = new ESRI.ArcGIS.CartoUI.FeatureLayerSelectionPropertyPageClass(); pComPropSheet.AddPage(pSelectPage); // Display.... ESRI.ArcGIS.Framework.IPropertyPage pDispPage = new ESRI.ArcGIS.CartoUI.FeatureLayerDisplayPropertyPageClass(); pComPropSheet.AddPage(pDispPage); // Symbology.... ESRI.ArcGIS.Framework.IPropertyPage pDrawPage = new ESRI.ArcGIS.CartoUI.LayerDrawingPropertyPageClass(); pComPropSheet.AddPage(pDrawPage); // Fields... ESRI.ArcGIS.Framework.IPropertyPage pFieldsPage = new ESRI.ArcGIS.CartoUI.LayerFieldsPropertyPageClass(); pComPropSheet.AddPage(pFieldsPage); // Definition Query... ESRI.ArcGIS.Framework.IPropertyPage pQueryPage = new ESRI.ArcGIS.CartoUI.LayerDefinitionQueryPropertyPageClass(); pComPropSheet.AddPage(pQueryPage); // Labels.... ESRI.ArcGIS.Framework.IPropertyPage pSelPage = new ESRI.ArcGIS.CartoUI.LayerLabelsPropertyPageClass(); pComPropSheet.AddPage(pSelPage); // Joins & Relates.... ESRI.ArcGIS.Framework.IPropertyPage pJoinPage = new ESRI.ArcGIS.ArcMapUI.JoinRelatePageClass(); pComPropSheet.AddPage(pJoinPage); // Setup layer link ESRI.ArcGIS.esriSystem.ISet pMySet = new ESRI.ArcGIS.esriSystem.SetClass(); pMySet.Add(layer); pMySet.Reset(); // make the symbology tab active pComPropSheet.ActivePage = 4; // show the property sheet bool bOK = pComPropSheet.EditProperties(pMySet, 0); m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_activeView.Extent); ////更新图例 //IMapSurround pMapSurround = null; //ILegend pLegend = null; //for (int i = 0; i < m_map.MapSurroundCount; i++) //{ // pMapSurround = m_map.get_MapSurround(i); // if (pMapSurround is ILegend) // { // pLegend = pMapSurround as ILegend; // pLegend.AutoVisibility = true; // pLegend.Refresh(); // } //} return (bOK); } }}
0 0
- 添加ArcGismap 内置图层属性模块
- 内置属性,包与模块
- layui内置模块(layer弹出层)
- 图层和属性表字段添加进ComBox
- 在config.json里面给图层添加新属性
- Android Framework层添加一个HAL模块
- 地图(创建, 添加图块, 图层, 对象层,添加图块属性调整修改地图)
- 对内核模块添加sysfs属性
- 添加标注图层
- 添加图层
- 地图图层添加
- Swift——(一)为Swift内置类型添加属性
- supermap 在地图上显示 属性信息(添加图层)
- ArcEngine图层属性查询
- android动态添加图层
- MapX VC++ 添加图层
- android动态添加图层
- android动态添加图层
- Collections.sort
- http://dl.hi-spider.com/pkg/free_unreg.pkg
- Python Notes (8)
- jQuery Ajax使用实例
- Android-消息机制(一):过程及源码分析
- 添加ArcGismap 内置图层属性模块
- 解决“Dynamic Web Module 3.0 requires Java 1.6 or newer.”错误
- Java自学001(简单介绍、常量与变量)
- 263. Ugly Number
- input,checkbox启用禁用
- react demo11 (添加组件事件处理)
- react整理二阶段学习笔记
- "=="和 equals 方法究竟有什么区别?
- 向量的叉积及其应用