Exemplo n.º 1
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (axMapControl1.LayerCount == 0)
            {
                return;
            }
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            mTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 1)
            {
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    if (layer is IAnnotationSublayer)
                    {
                        return;
                    }
                    else
                    {
                        pMoveLayer = layer;
                    }
                }
            }
            if (e.button == 2)
            {
                //弹出右键菜单
                if (item == esriTOCControlItem.esriTOCControlItemMap)//判断是否点中map项目
                {
                    contextMenuStrip1.Show(axTOCControl1, e.x, e.y);
                    HitMap = map as IMap;
                }
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    contextMenuStrip1.Show(axTOCControl1, e.x, e.y);
                    selLayer = layer;
                    HitLayer = layer;
                }
            }
        }
Exemplo n.º 2
0
 //图层拖动
 private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 1)
     {
         esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          map   = null;
         ILayer             layer = null;
         object             other = null;
         object             index = null;
         mTOCControl.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
             {
                 pMoveLayer = layer;
             }
         }
     }
 }
Exemplo n.º 3
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            ITOCControl        pTOCControl = axTOCControl1.Object as ITOCControl;
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map = null; ILayer layer = null;
            object             other = null; object index = null;

            pTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 2)
            {
                switch (item)
                {
                case esriTOCControlItem.esriTOCControlItemMap:
                    this.contextMenuTOCMap.Show(this.axTOCControl1, e.x, e.y);
                    break;
                }
            }
        }
        private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
        {
            //Exit not a right mouse click
            if (e.button != 2)
            {
                return;
            }

            //Determine what kind of item has been clicked on
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map = null;
            object             other = null; object index = null;

            m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref m_layer, ref other, ref index);

            //Show the metadata for the layer
            if (m_layer == null)
            {
                return;
            }
            ShowMetadata(m_layer);
        }
Exemplo n.º 5
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item   = new esriTOCControlItem();
            IBasicMap          pMap   = null;
            ILayer             pLayer = new FeatureLayer();
            object             pOther = new object();
            object             pIndex = new object();

            //获取鼠标点击信息
            axTOCControl1.HitTest(e.x, e.y, ref item, ref pMap, ref pLayer, ref pOther, ref pIndex);
            if (e.button == 2)
            {
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    pTocControl.SelectItem(pMap, null);
                }
                else
                {
                    pTocControl.SelectItem(pLayer, null);
                }
                //设置CustomProperty为layer (用于自定义的Layer命令)
                pMapControl.CustomProperty = pLayer;
                //弹出右键菜单
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    //动态添加OpenAttributeTable菜单项
                    pToolMenuLayer.AddItem(new OpenAttribute(pLayer, pMapControl, axMapControl1), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                    //移除OpenAttributeTable菜单项,以防止重复添加
                    pToolMenuLayer.Remove(2);
                }
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    pToolMenuMap.PopupMenu(e.x, e.y, pTocControl.hWnd);
                }

                else
                {
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                }
            }

            esriTOCControlItem item1 = esriTOCControlItem.esriTOCControlItemNone;

            if (e.button == 1)
            {
                IBasicMap map   = null;
                ILayer    layer = null;
                object    other = null;
                object    index = null;

                m_TOCControl.HitTest(e.x, e.y, ref item1, ref map, ref layer, ref other, ref index);
                if (item1 == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    if (layer is IAnnotationSublayer)
                    {
                        return;
                    }
                    else
                    {
                        pMoveLayer = layer;
                    }
                }
            }
        }