Пример #1
0
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            if (e.button == 1 && pMovelayer != null)
            {
                esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          map   = null;
                ILayer             layer = null;
                object             other = null;
                object             index = null;
                axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
                IMap   pMap = axMapControl1.ActiveView.FocusMap;
                ILayer pTempLayer;
                int    toindex = 0;
                if (item == esriTOCControlItem.esriTOCControlItemLayer && layer != null)
                {
                    if (pMovelayer != layer)
                    {
                        for (int i = 0; i < pMap.LayerCount; i++)
                        {
                            pTempLayer = pMap.get_Layer(i);
                            if (pTempLayer == layer)
                            {
                                toindex = i;;
                            }
                        }
                        pMap.MoveLayer(pMovelayer, toindex);
                    }
                }

                axMapControl1.ActiveView.Refresh();
                axMapControl1.Update();
                pMovelayer = null;
            }
        }
Пример #2
0
 private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
 {
     if (e.button == 1)
     {
         esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          map   = null;
         ILayer             layer = null;
         object             other = null;
         object             index = null;
         axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
         IMap pMap = axMapControl_1.ActiveView.FocusMap;
         if (item == esriTOCControlItem.esriTOCControlItemLayer || layer != null)
         {
             //预移动图层和鼠标当前位置图层不一致时
             if (pMoveLayer != layer)
             {
                 ILayer pTempLayer;
                 for (int i = 0; i < pMap.LayerCount; i++)
                 {
                     pTempLayer = pMap.get_Layer(i);
                     //获取鼠标当前位置图层的索引值
                     if (pTempLayer == layer)
                     {
                         toIndex = i;
                     }
                 }
                 pMap.MoveLayer(pMoveLayer, toIndex);
                 axMapControl_1.ActiveView.Refresh();
                 axTOCControl1.Update();
             }
         }
     }
 }
Пример #3
0
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            if (e.button == 2)
            {
                IBasicMap          map   = null;
                ILayer             layer = null;
                object             other = null;
                object             index = null;
                esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;

                axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    if (layer is IAnnotationSublayer)
                    {
                        _curLayer = null;
                    }
                    else
                    {
                        _curLayer = layer;
                    }
                }
                else
                {
                    _curLayer = null;
                }

                PopupContextMenu(e.x, e.y);
            }
        }
Пример #4
0
 private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent 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);
         IMap pMap = this.axMapControl1.ActiveView.FocusMap;
         if (item == esriTOCControlItem.esriTOCControlItemLayer || layer != null)
         {
             if (pMoveLayer != null)
             {
                 ILayer pTempLayer;
                 for (int i = 0; i < pMap.LayerCount; i++)
                 {
                     pTempLayer = pMap.get_Layer(i);
                     if (pTempLayer == layer)
                     {
                         toIndex = i;
                     }
                 }
                 pMap.MoveLayer(pMoveLayer, toIndex);
                 axMapControl1.ActiveView.Refresh();
                 mTOCControl.Update();//更新tocControl空间
             }
         }
     }
 }
Пример #5
0
 private void axTOCControl1_OnMouseUp_1(object sender, ITOCControlEvents_OnMouseUpEvent e)
 {
     try
     {
         if (e.button == 1 && pMoveLayer != null && pMoveLayerPoint.Y != e.y)
         {
             esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
             IBasicMap          pBasicMap = null; object unk = null;
             object             data = null; ILayer pLayer = null;
             axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pLayer, ref unk, ref data);
             IMap pMap = axMapControl1.ActiveView.FocusMap;
             if (pItem == esriTOCControlItem.esriTOCControlItemLayer || pLayer != null)
             {
                 if (pMoveLayer != pLayer)
                 {
                     ILayer pTempLayer;
                     //获得鼠标弹起时所在图层的索引号
                     for (int i = 0; i < pMap.LayerCount; i++)
                     {
                         pTempLayer = pMap.get_Layer(i);
                         if (pTempLayer == pLayer)
                         {
                             toIndex = i;
                         }
                     }
                 }
             }
             //移动到最前面
             else if (pItem == esriTOCControlItem.esriTOCControlItemMap)
             {
                 toIndex = 0;
             }
             //移动到最后面
             else if (pItem == esriTOCControlItem.esriTOCControlItemNone)
             {
                 toIndex = pMap.LayerCount - 1;
             }
             pMap.MoveLayer(pMoveLayer, toIndex);
             axMapControl1.ActiveView.Refresh();
             axTOCControl1.Update();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #6
0
        private void axTOCControl_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            //esriTOCControlItem pItem = new esriTOCControlItem();
            //IBasicMap pMap = new MapClass();
            //ILayer pLayer = new FeatureLayerClass();
            //object pOther = new object();
            //object pIndex = new object();
            //int i,j;
            //bool bUpdataToc;
            //axTOCControl.MousePointer = esriControlsMousePointer.esriPointerArrow;
            ////实现调整图层顺序功能
            //if(e.button == 1)
            //{
            //    axTOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref pOther, ref pIndex);
            //}

            //if (pItem == esriTOCControlItem.esriTOCControlItemLayer || pItem == esriTOCControlItem.esriTOCControlItemLegendClass)
            //{
            //    if (pLayer == null || _SelSymLayer == null || _SelSymLayer == pLayer)
            //        return;
            //    if (e.button == 1)
            //    {
            //        int Toindex = -1;
            //        for (i = 0; i < pMap.LayerCount; i++)
            //        {
            //            ILayer pLayTmp;
            //            pLayTmp = pMap.get_Layer(i);
            //            //得到点击当前的索引值
            //            if (pLayer == pLayTmp)
            //            {
            //                Toindex = i;
            //                break ;
            //            }
            //        }
            //        if (Toindex > 0)
            //        {
            //            ((IMap)pMap).MoveLayer(_SelSymLayer, i);
            //            (MapControlLayer.Map as IActiveView).Refresh();
            //        }
            //    }
            //}
        }
Пример #7
0
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            ILayer layer = null;
            object other = null;
            object index = null;
            IBasicMap map = null;
            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            IDataset dataset = (IDataset)layer;
            IFeatureLayer fl = (IFeatureLayer)layer;
            if (e.button == 2)
            {
                if (null == layer || !(layer is IFeatureLayer))
                {
                    return;
                }
                _mapControl.CustomProperty = layer;
                this._tocContextMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);

            }
        }
        public void MoveToTargetLayer(object sender, ITOCControlEvents_OnMouseUpEvent 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);

                IMap pmap = m_MapControl.ActiveView.FocusMap;

                if (item == esriTOCControlItem.esriTOCControlItemLayer || layer != null)
                {
                    if (m_MoveLayer != layer)
                    {
                        ILayer pTempLayer;
                        for (int i = 0; i < pmap.LayerCount; i++)
                        {
                            pTempLayer = pmap.get_Layer(i);
                            if (pTempLayer == layer)
                            {
                                ToIndex = i;
                            }
                        }
                        pmap.MoveLayer(m_MoveLayer, ToIndex);

                        m_MapControl.ActiveView.Refresh();

                        // m_TOCControl.Update();
                    }
                }
            }
        }
Пример #9
0
        //TOCControl1鼠标点击事件,左键 符号变更,右键菜单
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            this.axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex);
            axMapControl1.CustomProperty = pLayer;
            if (e.button == 1)  //符号变更
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    ILegendClass pLegend = new LegendClassClass();          //首先获取图例,然后赋值过去
                    ISymbol      symbol  = null;                            //新建 symbol,从符号窗体中最后就是获得这个东西
                    if (oLegendGroup is ILegendGroup && (int)oIndex != -1)
                    {
                        pLegend = ((ILegendGroup)oLegendGroup).get_Class((int)oIndex) as ILegendClass;
                    }
                                                                                               //给上面建的图例类赋值

                    FormSymbology frm = new FormSymbology(pLegend, pLayer);                    //新建符号窗体,并将该赋值的赋值过去
                    frm.ShowDialog();                                                          //显示对话框,之后就获得了 symbol 了
                        symbol     = frm.pStyleGalleryItem.Item as ISymbol;                    //调用窗体的 public 字段
                    pLegend.Symbol = symbol;                                                   //将 symbol 赋值给图例
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);    //刷新地图
                }
            }
            else if (e.button == 2) //加载右键菜单
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                }
                else if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                    ITOCControl toc = axTOCControl1.Object as ITOCControl;
                    toc.Update();
                }
            }
        }
        //TOCControl1鼠标点击事件,左键 符号变更,右键菜单
        private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
        {
            this.axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex);
            axMapControl1.CustomProperty = pLayer;
            if (e.button == 1)  //符号变更
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    ILegendClass pLegend = new LegendClassClass();        //首先获取图例,然后赋值过去
                    ISymbol symbol = null;                    //新建 symbol,从符号窗体中最后就是获得这个东西
                    if (oLegendGroup is ILegendGroup && (int)oIndex != -1)
                        pLegend = ((ILegendGroup)oLegendGroup).get_Class((int)oIndex) as ILegendClass;  //给上面建的图例类赋值

                    FormSymbology frm = new FormSymbology(pLegend, pLayer);      //新建符号窗体,并将该赋值的赋值过去
                    frm.ShowDialog();                             //显示对话框,之后就获得了 symbol 了
                    symbol = frm.pStyleGalleryItem.Item as ISymbol;              //调用窗体的 public 字段
                    pLegend.Symbol = symbol;                        //将 symbol 赋值给图例
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);  //刷新地图
                }
            }
            else if (e.button == 2) //加载右键菜单
            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemMap)
                {

                }
                else if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                    ITOCControl toc = axTOCControl1.Object as ITOCControl;
                    toc.Update();
                }
            }
        }
Пример #11
0
 private void axTOCControl1_OnMouseUp_1(object sender, ITOCControlEvents_OnMouseUpEvent e)
 {
 }
Пример #12
0
 private void TocCtrl_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e)
 {
     //throw new NotImplementedException();
 }
Пример #13
0
        /// <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);
                    }
                }
            }
        }