zoukankan      html  css  js  c++  java
  • TOCControl右键菜单

           新接触TOCControl空间的自定义菜单,其功能强大令人叹为观止。可用AddItem添加自定义Command、menu或者esriControls下的Command、menu;了解使用esriControls下的Command、menu,可以为开发者省下大量的时间。举例说明如下:自定义了一个添加图层的命令(在其中特别注意CustomProperty这个属性,它可以灵活附加传递多种数据)。

       class AddLayer : BaseCommand
        {
            private IMapControl3 m_mapControl;

            public AddLayer()
            {
                base.m_caption = "添加地图文档";
            }

            public override void OnClick()
            {
                ILayer layer = (ILayer)m_mapControl.CustomProperty;
                m_mapControl.Map.DeleteLayer(layer);
                OpenFileDialog openFileDialog1 = (OpenFileDialog)m_mapControl.CustomProperty;
                openFileDialog1.Title = "打开地图文档";
                openFileDialog1.Filter = "map documents(*.mxd)|*.mxd";
                openFileDialog1.ShowDialog();
                string filePath = openFileDialog1.FileName;
                if (m_mapControl.CheckMxFile(filePath))
                {
                    m_mapControl.MousePointer = esriControlsMousePointer.esriPointerHourglass;
                    m_mapControl.LoadMxFile(filePath);
                    m_mapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
                }
                else
                {
                    MessageBox.Show("地图文档无效!");
                }
            }

            public override void OnCreate(object hook)
            {
                m_mapControl = (IMapControl3)hook;
            }
        }

       toolbarMenu.AddItem(new AddLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);

       但其实足够了解esriControls下的现成命令的话,上述代码可以浓缩为:

         toolbarMenu.AddItem("esriControls.ControlsOpenDocCommand", -1, 0, false,esriCommandStyles.esriCommandStyleIconOnly);

       就这样。

  • 相关阅读:
    ORACLE DBA的职责
    oracle开发常用LOV
    Oracle Patch 版本的查询
    指定二次分配为主要分配
    系统日期格式引起的错误:出生日期不能为将来日期
    分享一个帮助你检测网站颜色对比度的在线web工具 checkmycolours
    最常用的CURL命令大全
    超棒的javascript移动触摸设备开发类库 QUOjs
    分享一个超炫HTML5开发的jQuery进度条插件 percentageloader
    纯CSS实现的3D简洁按钮设计
  • 原文地址:https://www.cnblogs.com/qingwufeiyang/p/3969791.html
Copyright © 2011-2022 走看看