Example #1
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //如果不是右键按下直接返回
            if (e.button != 2)
            {
                return;
            }

            if (e.button == 2)
            {
                esriTOCControlItem item        = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          map         = null;
                ILayer             layer       = null;
                object             other       = null;
                object             index       = null;
                RightMenu          rtMenu      = new RightMenu(axTOCControl1);
                IToolbarMenu       m_meunLayer = rtMenu.getToolbarMenu();
                m_meunLayer.SetHook(m_mapControl);
                //判断所选菜单的类型
                rtMenu.m_TocC.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                //确定选定的菜单类型,Map 或是图层菜单
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    rtMenu.m_TocC.SelectItem(map, null);
                }
                else
                {
                    rtMenu.m_TocC.SelectItem(layer, null);
                }

                //设置CustomProperty 为layer (用于自定义的Layer 命令)
                m_mapControl.CustomProperty = layer;
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    //动态添加ShowAttributeTable菜单项
                    m_meunLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_meunLayer.PopupMenu(e.x, e.y, rtMenu.m_TocC.hWnd);
                    //移除OpenAttributeTable菜单项,以防止重复添加
                    m_meunLayer.Remove(2);
                }
            }
        }
Example #2
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //如果不是右键按下直接返回
            if (e.button != 2) return;

            if (e.button == 2)
            {

                esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap map = null;
                ILayer layer = null;
                object other = null;
                object index = null;
                RightMenu rtMenu = new RightMenu(axTOCControl1);
                IToolbarMenu m_meunLayer = rtMenu.getToolbarMenu();
                m_meunLayer.SetHook(m_mapControl);
                //判断所选菜单的类型
                rtMenu.m_TocC.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                //确定选定的菜单类型,Map 或是图层菜单
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                    rtMenu.m_TocC.SelectItem(map, null);
                else
                    rtMenu.m_TocC.SelectItem(layer, null);

                //设置CustomProperty 为layer (用于自定义的Layer 命令)
                m_mapControl.CustomProperty = layer;
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {

                    //动态添加ShowAttributeTable菜单项
                    m_meunLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_meunLayer.PopupMenu(e.x, e.y, rtMenu.m_TocC.hWnd);
                    //移除OpenAttributeTable菜单项,以防止重复添加
                    m_meunLayer.Remove(2);
                }
            }
        }