Beispiel #1
0
        /// <summary>
        ///     右键弹出图层管理菜单,进行图层管理
        /// </summary>
        /// <params name="sender"></params>
        /// <params name="e"></params>
        private void tocControl_OP_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return; //左键则跳出
            }
            var       item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map   = null;
            ILayer    layer = null;
            object    unk   = null;
            object    data  = null;

            //判断选择类型,确定右键菜单的位置
            tocControl_OP.HitTest(e.x, e.y, ref item, ref map, ref layer, ref unk, ref data);
            if (layer == null)
            {
                return;
            }
            //确认所选项
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                tocControl_OP.SelectItem(map, null);
            }
            else
            {
                tocControl_OP.SelectItem(layer, null); //20140224 有bug
            }
            //设置图层的CustomProperty(在自定义图层命令中使用)
            mapControl_OP.CustomProperty = layer;

            //弹出菜单
            var menuMap = new LayersManagerMap();

            menuMap.SetHook(mapControl_OP);
            var menuLayer = new LayersManagerLayer();

            menuLayer.SetHook(mapControl_OP);
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                //选中的为地图
                menuMap.PopupMenu(e.x, e.y, tocControl_OP.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                //选中的为图层
                menuLayer.PopupMenu(e.x, e.y, tocControl_OP.hWnd);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     右键弹出图层管理菜单,进行图层管理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tocControl_WM_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return; //左键则跳出
            }
            var       item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map   = null;
            ILayer    layer = null;
            object    unk   = null;
            object    data  = null;

            //判断选择类型,确定右键菜单的位置
            tocControl_WM.HitTest(e.x, e.y, ref item, ref map, ref layer, ref unk, ref data);
            if (layer == null)
            {
                return;
            }
            //确认所选项
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                tocControl_WM.SelectItem(map, null);
            }
            else
            {
                tocControl_WM.SelectItem(layer, null); //20140224 有bug
            }
            //设置图层的CustomProperty(在自定义图层命令中使用)
            mapControl_WM.CustomProperty = layer;

            //弹出菜单
            var menuMap = new LayersManagerMap();

            menuMap.SetHook(mapControl_WM);
            var menuLayer = new LayersManagerLayer();

            menuLayer.SetHook(mapControl_WM);
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                //选中的为地图
                menuMap.PopupMenu(e.x, e.y, tocControl_WM.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                //选中的为图层
                menuLayer.PopupMenu(e.x, e.y, tocControl_WM.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLegendClass) //选中的为图例
            {
                return;

                ILegendClass pLC = new LegendClassClass();
                ILegendGroup pLG = new LegendGroupClass();
                if (unk is ILegendGroup)
                {
                    pLG = (ILegendGroup)unk;
                }
                pLC = pLG.get_Class((int)data);
                ISymbol pSym;
                pSym = pLC.Symbol;
                ISymbolSelector pSS = new
                                      SymbolSelectorClass();
                var bOK = false;
                pSS.AddSymbol(pSym);
                bOK = pSS.SelectSymbol(0);
                if (bOK)
                {
                    pLC.Symbol = pSS.GetSymbolAt(0);
                }
                mapControl_WM.ActiveView.Refresh();
                tocControl_WM.Refresh();
            }
        }