Beispiel #1
0
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            // TODO:  添加 TOCHelper.OnMouseDown 实现

            IBasicMap          map   = null;
            ILayer             layer = null;
            Object             other = null;
            esriTOCControlItem pItem = 0;

            pTOCCtl.HitTest(x, y, ref pItem, ref map, ref layer, ref other, ref other);
            if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
            {
                if (layer != null)
                {
                    pMainFrm.setCurrentLayer(layer);
                }
            }
        }
Beispiel #2
0
        private void TocCtrl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            AxTOCControl       tocCtrl  = (AxTOCControl)sender;
            esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          basicMap = null;
            ILayer             layer    = null;
            object             unk      = null;
            object             data     = null;

            tocCtrl.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data);

            switch (e.button)
            {
            case 1:
                break;

            case 2:
                break;

            default:
                break;
            }
        }
        //TOCControl控件的鼠标单击事件
        public void m_tocControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            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 (e.button == 1)
            {
                if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    try
                    {
                        ESRI.ArcGIS.Carto.ILegendClass pLC = new LegendClassClass();
                        ESRI.ArcGIS.Carto.ILegendGroup pLG = new LegendGroupClass();
                        if (other is ILegendGroup)
                        {
                            pLG = (ILegendGroup)other;
                        }
                        pLC = pLG.get_Class((int)index);
                        ISymbol pSym;
                        pSym = pLC.Symbol;


                        ISymbolSelector pSS = new SymbolSelectorClass();

                        bool bOK = false;
                        pSS.AddSymbol(pSym);
                        bOK = pSS.SelectSymbol(0);
                        if (bOK)
                        {
                            pLC.Symbol = pSS.GetSymbolAt(0);
                        }
                        this.m_mapControl.ActiveView.Refresh();
                        this.m_tocControl.Refresh();
                    }
                    catch (Exception exce)
                    { }
                }
            }
            if (e.button == 2)
            {
                //设置CustomProperty为layer (用于自定义的Layer命令)
                m_mapControl.CustomProperty = layer;
                //弹出右键菜单
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                }
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    #region

                    /*                 this.LoadMenu(layer);
                     * m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                     * m_menuLayer.RemoveAll();      */
                    #endregion
                    m_CurrentLayer = layer;
                    m_pGeoFeaLayer = m_CurrentLayer as IGeoFeatureLayer;
                    this.ChangeItemText();
                    Rectangle rect = new Rectangle();
                    rect = m_tocControl.RectangleToScreen(rect);
                    m_contextMemuLayer.Show(e.x + rect.Left, e.y + rect.Top);
                }
            }
        }
        /// <summary>
        /// 鼠标右键弹起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void TOCControlLayer_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            if (TOCControlLayer != null)
            {
                esriTOCControlItem pItem     = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          pBasicMap = null;
                ILayer             pLayer    = null;
                object             pOther    = null;
                object             pIndex    = null;
                this.TOCControlLayer.MousePointer = esriControlsMousePointer.esriPointerArrow;
                //TOCLayer.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref pOther, ref pIndex);

                TOCControlLayer.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pLayer, ref pOther, ref pIndex);
                //实现调整图层顺序功能
                if ((e.button == 1))
                {
                    return;
                }
                else
                {
                    if (pItem == esriTOCControlItem.esriTOCControlItemNone)
                    {
                        return;
                    }
                    //确定所选中的信息
                    this.TOCControlLayer.GetSelectedItem(ref pItem, ref pBasicMap, ref pLayer, ref pOther, ref pIndex);
                    //弹出相应的快捷菜单 根节点 子节点
                    if ((pItem == esriTOCControlItem.esriTOCControlItemMap))
                    {
                        m_pMapMenu.PopupMenu(e.x, e.y, TOCControlLayer.hWnd);
                    }
                    else if ((pItem == esriTOCControlItem.esriTOCControlItemLayer))
                    {
                        if (pLayer is IGroupLayer)
                        {
                            return;
                        }
                        if (pLayer is ICompositeLayer)
                        {
                            return;
                        }

                        //m_Symbol.Layer = pLayer;
                        //移除图层
                        m_RemoveLayer.Layer       = pLayer;
                        m_RemoveLayer.Enabled2    = true;
                        m_LayerAttribute.Enabled2 = true;
                        //一些图层是业务功能图层,不能删除
                        //if (pLayer.Name.Contains(g_DY) | pLayer.Name.Contains(g_BDZ) | pLayer.Name.Contains(g_GT) | pLayer.Name.Contains(g_XL))
                        //{
                        //    m_RemoveLayer.Enabled2 = false;
                        //}

                        m_LayerAttribute.Layer = pLayer;
                        //查看属性表

                        InitDataEditEnvironment(pLayer);
                        //基础下图层属性表不看查看

                        m_LayerAttribute.FrmMap  = m_FrmMap;
                        m_LayerSelectable1.Layer = pLayer;
                        m_LayerSelectable2.Layer = pLayer;
                        m_ZoomToLayer.Layer      = pLayer;
                        //缩放至图层
                        m_SetLabel.Layer = pLayer;
                        //设置标注
                        m_ShowLabelFeature.Layer = pLayer;
                        //显示标注
                        m_LayerExtent.Layer = pLayer;
                        //显示图层属性

                        ////区域定位图层不操作
                        //if (pLayer.Name == g_ZoneLocation)
                        //{
                        //    m_RemoveLayer.Enabled2 = false;
                        //    m_SetLabel.Enabled2 = false;
                        //    m_ShowLabelFeature.Enabled2 = false;
                        //}
                        m_pLayerMenu.PopupMenu(e.x, e.y, TOCControlLayer.hWnd);
                    }
                }
            }
        }