public void SelectMoveLayer(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button == 1)
            {
                esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          map   = null;
                ILayer             layer = null;
                object             other = null;
                object             index = null;

                m_TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    if (layer is IAnnotationSublayer)
                    {
                        return;
                    }
                    else
                    {
                        m_MoveLayer = layer;
                    }
                }
            }
        }
Example #2
0
        public void SelectLayer(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item   = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          pMap   = null;
            ILayer             pLayer = null;
            object             pOther = new object();
            object             pIndex = new object();

            if (e.button == 2)
            {
                if (m_MapControl.LayerCount > 0)
                {
                    m_TOCControl.HitTest(e.x, e.y, ref item, ref pMap, ref pLayer, ref pOther, ref pIndex);

                    if (item == esriTOCControlItem.esriTOCControlItemMap)
                    {
                        m_TOCControl.SelectItem(pMap, null);
                        m_MapControl.CustomProperty = (IMap)pMap;
                        m_MapContextMenu.PopupMenu(e.x, e.y, m_TOCControl.hWnd);
                    }



                    if (item == esriTOCControlItem.esriTOCControlItemLayer)
                    {
                        m_TOCControl.SelectItem(pLayer, null);
                        m_MapControl.CustomProperty = pLayer;
                        m_LayerContextMenu.PopupMenu(e.x, e.y, m_TOCControl.hWnd);
                    }
                }
            }
            if (e.button == 1)
            {
                if (m_MapControl.LayerCount > 0)
                {
                    m_TOCControl.HitTest(e.x, e.y, ref item, ref pMap, ref pLayer, ref pOther, ref pIndex);


                    if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
                    {
                        MessageBox.Show("To Be Continue...");
                        ILegendClass pLegendClass;;
                        ILegendGroup pLegendGroup;
                        ISymbol      pSymbol;
                        pLegendGroup = (ILegendGroup)pOther;
                        pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(pIndex));
                        pSymbol      = pLegendClass.Symbol;

                        pSymbol = GetSimpleSymbolBySelector(pSymbol);

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

            esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          basicMap = null;
            ILayer             layer    = null;
            object             other    = null;
            object             data     = null;

            //判断所选菜单的类型
            m_tocControl.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref other, ref data);

            //确定选定的菜单类型, Map 或是图层菜单
            if (itemType == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_tocControl.SelectItem(basicMap, null);
            }
            else
            {
                m_tocControl.SelectItem(layer, null);
            }
            //设置 CustomProperty 为 layer ( 用于自定义的 Layer 命令)
            m_mapControl.CustomProperty = layer;
            //弹出右键菜单
            if (itemType == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            }
            if (itemType == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            }
        }
Example #4
0
        private IToolbarMenu _menuLayer = null; //�һ�Layer

        #endregion Fields

        #region Methods

        public void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e,AxMapControl pAxMapControl)
        {
            pTocControlDef = ((AxTOCControl)sender).Object as ITOCControlDefault;
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map = null;
            ILayer layer = null;
            object other = null;
            object index = null;
            pTocControlDef.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //ȷ������Ŀ��ѡ��
            if (item == esriTOCControlItem.esriTOCControlItemMap)
                pTocControlDef.SelectItem(map, null);
            else
                pTocControlDef.SelectItem(layer, null);

            //������Ҽ����,�����˵�
            if (e.button == 2)
            {
                //ѡ�����Map
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    _mapMenu = new ToolbarMenuClass();
                    _mapMenu.AddItem(new MapMenu(), 1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _mapMenu.AddItem(new MapMenu(), 2, 1, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _mapMenu.SetHook(pAxMapControl);
                    _mapMenu.PopupMenu(e.x, e.y, pTocControlDef.hWnd);
                }
                else if (item == esriTOCControlItem.esriTOCControlItemLayer) //ѡ����� Layer
                {
                    _menuLayer = new ToolbarMenuClass();
                    _menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ScaleThresholds(), 1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ScaleThresholds(), 2, 2, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ScaleThresholds(), 3, 3, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new LayerSelectable(), 1, 4, true, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new LayerSelectable(), 2, 5, false, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new ZoomToLayer(), -1, 6, true, esriCommandStyles.esriCommandStyleTextOnly);
                    _menuLayer.AddItem(new OpenAttributeTable(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
                    //_menuLayer.AddItem(new LayerProperty(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);

                    //Set the hook of each menu
                    pTocControlDef.SelectItem(layer, null);
                    _menuLayer.SetHook(pAxMapControl);
                    //Set the layer into the CustomProperty (this is used by the custom layer commands)
                    pAxMapControl.CustomProperty = layer;
                    //�����˵�
                    _menuLayer.PopupMenu(e.x, e.y, pTocControlDef.hWnd);
                }
            }
            if (e.button == 1)
            {
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    if (layer is IAnnotationSublayer) return;
                    else
                    {
                        //pmovelayer = layer;
                    }
                }
            }
        }