Exemplo n.º 1
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            /* ArcGIS Snippet Title:
             * Find the selected layer in the table of contents
             *
             * Add the following reference to the project:
             * ESRI.ArcGIS.Controls
             *
             * Add the following ArcGIS Engine control to the project:
             * TOCControl
             *
             * Intended ArcGIS Products for this snippet:
             * ArcGIS Engine
             *
             * Notes:
             * This snippet is intended to be inserted into the OnMouseDown event of the TOC Control
             * The code assumes that a module-level variable (m_layer) has been declared as ILayer */

            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))
            {
                m_layer = layer;
            }
        }
        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;
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         TOCControl.ContextMenuStrip.Show(TOCControl, e.x, e.y);
     }
 }
Exemplo n.º 4
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //右键toc图层出现菜单和图层关联
            axTOCControl1.ContextMenuStrip = null;
            IBasicMap map = new MapClass();

            System.Object      other = null;
            System.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 && e.button == 2)
            {
                System.Drawing.Point pt = new System.Drawing.Point();
                pt.X = e.x;
                pt.Y = e.y;
                pt   = this.axTOCControl1.PointToScreen(pt);
                this.contextMenuStrip1.Show(pt);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer && e.button == 1)
            {
                if (layer is IAnnotationSublayer)   //注记层在表层,不参与移动
                {
                    return;
                }
                else
                {
                    pMoveLayer = layer;
                }
            }
        }
Exemplo n.º 5
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          map   = new MapClass();
            ILayer             layer = new FeatureLayerClass();
            object             other = new object();
            object             index = new object();
            esriTOCControlItem item  = new esriTOCControlItem();

            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 2)
            {
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    m_controlsSynchronizer.MapControl.CustomProperty = map;
                    m_TocMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
                else if (layer is IFeatureLayer)
                {
                    m_controlsSynchronizer.MapControl.CustomProperty = layer;
                    m_TocLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
                }
            }
            if (e.button == 1)
            {
                if (layer == null)
                {
                    return;
                }
                IFeatureLayer featurelayer = layer as IFeatureLayer;
                if (featurelayer == null)
                {
                    return;
                }
                IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featurelayer;
                ILegendClass     legendClass     = new LegendClassClass();
                ISymbol          symbol          = null;
                if (other is ILegendGroup && (int)index != -1)
                {
                    legendClass = ((ILegendGroup)other).get_Class((int)index);
                    symbol      = legendClass.Symbol;
                }
                if (symbol == null)
                {
                    return;
                }
                symbol = GetSymbolByControl(symbol);
                if (symbol == null)
                {
                    return;
                }
                legendClass.Symbol = symbol;
                this.Activate();
                //((IActiveView)m_MapDocument.get_Map(0)).ContentsChanged();

                axMapControl1.ActiveView.ContentsChanged();
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                axMapControl1.Refresh();
                axTOCControl1.Update();
            }
        }
Exemplo n.º 6
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            axTOCControl1.ContextMenuStrip = contextMenuStrip1;
            //judge the type of item selected in the TOC
            IBasicMap map   = new MapClass();
            ILayer    layer = null;

            System.Object      other = null;
            System.Object      index = null;
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;

            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 2 && item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                //transfer the screen point location to form location to popup the contextmenu
                System.Drawing.Point p = new System.Drawing.Point();
                p.X = e.x;
                p.Y = e.y;
                p   = this.axTOCControl1.PointToScreen(p);
                this.contextMenuStrip1.Show(p);
                layerName = layer.Name;
            }
            if (e.button == 1 && item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                strFileName = layer.Name;
            }
        }
Exemplo n.º 7
0
//        axTOCControl1 中判断鼠标点中的项目并弹出右键菜单

        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button == 2)
            {
                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
                    );

//                如果点中了一个 Map 项目

                if (item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    mapTOCMenuStrip.Show(axTOCControl1, e.x, e.y);

                    _hitMap = map as IMap;
                }

                else if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    layerTOCMenuStrip.Show(axTOCControl1, e.x, e.y);

                    _hitLayer = layer;
                }
            }
        }
Exemplo n.º 8
0
        private void axTOCControlLayerTree_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)//TOCC左键设置图例,右键弹出菜单
        {
            esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          pMap = null;
            object             unk = null, data = null;

            axTOCControlLayerTree.HitTest(e.x, e.y, ref pItem, ref pMap, ref _toccSelectedLayer, ref unk, ref data);
            if (e.button == 1)
            {
                if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    //取得图例
                    ILegendClass legendClass        = ((ILegendGroup)unk).get_Class((int)data);
                    var          symbolSelectorForm = new SymbolSelectorDevForm(legendClass, _toccSelectedLayer);
                    if (symbolSelectorForm.ShowDialog() == DialogResult.OK)
                    {
                        GoToMapView();
                        legendClass.Symbol = symbolSelectorForm.PSymbol;                                                //设置新的符号
                        axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); //更新主Map控件和图层控件
                    }
                    _effectLayer.SwipeLayer = _toccSelectedLayer;
                }
            }
            else if (e.button == 2)
            {
                if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    cMenuStripTocc.Show(axTOCControlLayerTree, new System.Drawing.Point(e.x, e.y));
                    ShowFieldLabelMenuItems(_toccSelectedLayer);
                }
            }
        }
Exemplo n.º 9
0
        private void TocControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            object             other = null;
            object             index = null;
            IBasicMap          map   = null;
            ILayer             layer = null;


            CurTOCControl = (sender as AxTOCControl).Object as ITOCControl2;
            //返回点后的指定的对象
            CurTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //如果点中的图例,则弹出符号设置窗口
            if ((e.button == 1) && (item == esriTOCControlItem.esriTOCControlItemLegendClass))
            {
                //暂不支持
            }
            else if ((e.button == 1) && (item == esriTOCControlItem.esriTOCControlItemLayer))
            {
                object obj = m_MapLayersController.GetLayerParent(layer);
                if (obj is ICompositeLayer)
                {
                    ILayer pParentLayer = (ILayer)obj;
                    bool   b            = layer.Visible;
                    if (b == false)
                    {
                        pParentLayer.Visible = true;
                    }
                }
            }
            else if (e.button == 2) //鼠标右键
            {
                switch (item)
                {
                case esriTOCControlItem.esriTOCControlItemNone:
                    break;

                case esriTOCControlItem.esriTOCControlItemMap:
                    CurTOCControl.SelectItem(map, null);
                    this.popMenuTOCMap.ShowPopup(MousePosition);
                    break;

                case esriTOCControlItem.esriTOCControlItemLegendClass:
                    break;

                case esriTOCControlItem.esriTOCControlItemLayer:
                    m_CurrentSelectLayer = layer;
                    CurTOCControl.SelectItem(layer, null);
                    popMenuTOCLayer.ShowPopup(MousePosition);     // new System.Drawing.Point(e.x, e.y));
                    break;

                case esriTOCControlItem.esriTOCControlItemHeading:
                    break;
                }

                CurActivityMapControl.CustomProperty = layer;
            }
            CurTOCControl = null;
        }
Exemplo n.º 10
0
        private void AxTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          pMap     = null;
            ILayer             pLayer   = null;
            object             legendgp = null;
            object             index    = null;
            esriTOCControlItem pItem    = esriTOCControlItem.esriTOCControlItemNone;

            axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index);  //点击测试,点击图例打开符号选择器
            if (e.button == 1)
            {
                ILegendGroup pLegendGroup = new LegendGroup();
                ILegendClass pLegendClass = new LegendClass();
                pLegendGroup = (ILegendGroup)legendgp;
                if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(index.ToString()));
                    if (pLegendClass == null)
                    {
                        return;
                    }
                    FormSymbolSelector dlg = new FormSymbolSelector(pLegendClass, pLayer);
                    if (dlg != null)
                    {
                        dlg.ShowDialog();
                        m_pTocControl.Update();
                        m_mapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                    }
                }
            }
        }
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2) return;

            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map = null; ILayer layer = null;
            object other = null; object index = null;

            //Determine what kind of item is selected
            m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            
            //Ensure the item gets selected 
            if (item == esriTOCControlItem.esriTOCControlItemMap) 
                m_tocControl.SelectItem(map, null);
            else
                m_tocControl.SelectItem(layer, null);
            
            //Set the layer into the CustomProperty (this is used by the custom layer commands)			
            m_mapControl.CustomProperty = layer;

            //Popup the correct context menu
            if (item == esriTOCControlItem.esriTOCControlItemMap) m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);

        }
Exemplo n.º 12
0
        private void TOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return;
            }
            //if ( m_pToolbarMenu.
            IBasicMap          map     = null;
            ILayer             layer   = null;
            ILayer             m_layer = null;
            object             other   = null;
            object             index   = null;
            esriTOCControlItem item    = esriTOCControlItem.esriTOCControlItemNone;

            TOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer,
                               ref other, ref index);
            if ((item == esriTOCControlItem.esriTOCControlItemLayer))
            {
                if (layer is IFeatureLayer)
                {
                    MapControl.CustomProperty = layer;
                    m_pToolbarMenu.PopupMenu(e.x, e.y, (int)TOCControl.Handle);
                }
            }
        }
Exemplo n.º 13
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return;
            }
            rightMenu();
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map = null; ILayer layer = null;
            object             other = null; object index = null;

            this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                this.axTOCControl1.SelectItem(map, null);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                this.axTOCControl1.SelectItem(layer, null);
            }
            axMapControl1.CustomProperty = layer;
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                System.Windows.MessageBox.Show("点击了Layers");
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                pToolMenuLayer.PopupMenu(e.x, e.y, this.axTOCControl1.hWnd);
            }
        }
Exemplo n.º 14
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //若果不是鼠标右键按下就直接退出
            if (e.button != 2)
            {
                return;
            }
            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);


            //确定选定的菜单类型,Map或是图层菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_tocControl.SelectItem(map, null);
                m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            }
            else
            {
                m_tocControl.SelectItem(layer, null);
                //添加 打开属性表
                m_menuLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                //移除OpenAttributeTable菜单项,以防止重复添加
                m_menuLayer.Remove(2);
            }
        }
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //make sure that the user right clicked
            if (2 != e.button)
            {
                return;
            }

            //use HitTest in order to test whether the user has selected a featureLayer
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map = null; ILayer layer = null;
            object             other = null; object index = null;

            //do the HitTest
            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //Determine what kind of item has been clicked on
            if (null == layer || !(layer is IFeatureLayer))
            {
                return;
            }

            //set the featurelayer as the custom property of the MapControl
            axMapControl1.CustomProperty = layer;

            //popup a context menu with a 'Properties' command
            m_contextMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
        }
Exemplo n.º 16
0
        private void axTOOControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            ///右键打开菜单项
            try
            {
                if (e.button == 1)
                {
                    return;
                }
                esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          pMap  = null;
                ILayer             Lyr   = null;
                object             unk   = null;
                object             data  = null;
                this.axTOOControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref Lyr, ref unk, ref data);

                if (pItem == esriTOCControlItem.esriTOCControlItemLayer && (Lyr as IFeatureLayer) != null)
                {
                    this.LyrContxtMenuStrip.Show(MousePosition);
                }
                if (pItem == esriTOCControlItem.esriTOCControlItemMap)
                {
                    this.MapMenuStrip.Show(MousePosition);
                }
                featureLyr = Lyr as IFeatureLayer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// tocControl鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_tocControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             index = null;
            object             other = null;

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

            if (e.button == 2) // 鼠标右键
            {
                switch (item)
                {
                case esriTOCControlItem.esriTOCControlItemMap:      // 点击的是地图
                    tocControl_contextMenuStrip.Show(m_tocControl, new System.Drawing.Point(e.x, e.y));
                    break;

                case esriTOCControlItem.esriTOCControlItemLayer:        // 点击的是图层
                    tocControlLayer_ContextMenu.Show(m_tocControl, new System.Drawing.Point(e.x, e.y));
                    break;

                case esriTOCControlItem.esriTOCControlItemHeading:
                    break;

                default:
                    tocControl_contextMenuStrip.Show(m_tocControl, new System.Drawing.Point(e.x, e.y));
                    break;
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 图层列表点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            this.axTOCControl1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data);
            if (e.button == 2)
            {
                switch (itemType)
                {
                case esriTOCControlItem.esriTOCControlItemLayer:
                    this.TOCRightLayer = layer;
                    this.contextMenuTOCFeatureLyr.Show(this.axTOCControl1, e.x, e.y);
                    break;

                case esriTOCControlItem.esriTOCControlItemMap:
                    this.contextMenuTOCMap.Show(this.axTOCControl1, e.x, e.y);
                    break;
                }
            }
            //else if (e.button == 1)
            //{
            //System.Drawing.Point pos = new System.Drawing.Point(e.x, e.y);
            //if (itemType == esriTOCControlItem.esriTOCControlItemLegendClass)
            //{
            //    //取得图例
            //    ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data);
            //    //创建符号选择器SymbolSelector实例
            //    SymbolSelectorForm SymbolSelectorFrm = new SymbolSelectorForm(pLegendClass, layer);
            //    if (SymbolSelectorFrm.ShowDialog() == DialogResult.OK)
            //    {
            //        //局部更新主Map控件
            //        this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //        //this.axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //        //设置新的符号
            //        pLegendClass.Symbol = SymbolSelectorFrm.pSymbol;
            //        //更新主Map控件和图层控件
            //        this.axMapControl1.ActiveView.Refresh();
            //        //this.axMapControl2.ActiveView.Refresh();
            //        this.axTOCControl1.Refresh();
            //    }
            //}
            //}

            //只有英文版本的engine才可以打开颜色选取
            //if (e.button == 1)
            //{
            //    switch (itemType)
            //    {
            //        case esriTOCControlItem.esriTOCControlItemLegendClass:
            //            ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data);
            //            SymbolSelectorForm newSymbolSelectorFrm = new SymbolSelectorForm(pLegendClass, layer);
            //            if (newSymbolSelectorFrm.ShowDialog() == DialogResult.OK)
            //            {
            //                this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //                pLegendClass.Symbol = newSymbolSelectorFrm.pSymbol;
            //                this.axTOCControl1.Update();
            //            }
            //            break;
            //    }
            //}
        }
Exemplo n.º 19
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;
                    }
                }
            }
        }
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2)
            {
                return;
            }

            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            //Determine what kind of item is selected
            m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //Ensure the item gets selected
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_tocControl.SelectItem(map, null);
            }
            else
            {
                m_tocControl.SelectItem(layer, null);
            }

            //Set the layer into the CustomProperty (this is used by the custom layer commands)
            m_mapControl.CustomProperty = layer;

            ISchematicLayer schLayer = layer as ISchematicLayer;

            if (schLayer != null)             /// attach menu for SchematicLayer
            {
                ISchematicTarget schematicTarget = new ESRI.ArcGIS.SchematicControls.EngineSchematicEnvironmentClass() as ISchematicTarget;
                if (schematicTarget != null)
                {
                    schematicTarget.SchematicTarget = schLayer;
                }

                //Popup the correct context menu

                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    m_menuSchematicLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                }
            }
            else             /// attach menu for Layer
            {
                //Popup the correct context menu
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                }
            }
        }
Exemplo n.º 21
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            try
            {
                esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap          basicMap = null;
                ILayer             layer    = null;
                object             unk      = null;
                object             data     = null;
                this.axTOCControl1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data);
                if (e.button == 2)//鼠标右键
                {
                    switch (itemType)
                    {
                    case esriTOCControlItem.esriTOCControlItemLayer:
                        this.TOCMenu.Show(this.axTOCControl1, e.x, e.y);
                        break;

                    case esriTOCControlItem.esriTOCControlItemMap:
                        this.TOCMenu.Show(this.axTOCControl1, e.x, e.y);
                        break;

                    default:
                        break;
                    }
                }
                else if (e.button == 1) //鼠标左键
                {
                    switch (itemType)
                    {
                    case esriTOCControlItem.esriTOCControlItemLegendClass:
                        ILegendClass      pLegendClass         = ((ILegendGroup)unk).get_Class((int)data);
                        FrmSymbolSelector newSymbolSelectorFrm = new FrmSymbolSelector(pLegendClass, layer);
                        if (newSymbolSelectorFrm.ShowDialog() == DialogResult.OK)
                        {
                            this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                            pLegendClass.Symbol = newSymbolSelectorFrm.pSymbol;
                            this.axTOCControl1.Update();
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message);
            }
        }
Exemplo n.º 22
0
 //ACTOOCONTROL右键功能;
 private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer_Toccontrol, ref other, ref index);
         if (item == esriTOCControlItem.esriTOCControlItemLayer && layer_Toccontrol != null)
         {
             IFeatureLayer pfeature = layer_Toccontrol as IFeatureLayer;
             this.pesriGeometryTyp = pfeature.FeatureClass.ShapeType;
             contextMenuStrip1.Show(Control.MousePosition);
             HmMap.index.SelectLayer = layer_Toccontrol;
         }
     }
 }
Exemplo n.º 23
0
        private int toIndex;                              //存放拖动图层移动到的索引号

        //TOC右键菜单的添加
        private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            try
            {
                //按下右键根据所选内容弹出菜单
                if (e.button == 2)
                {
                    esriTOCControlItem pItem  = esriTOCControlItem.esriTOCControlItemNone;
                    IBasicMap          pMap   = null;
                    ILayer             pLayer = null;
                    object             unk    = null;
                    object             data   = null;
                    axTOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
                    pTocFeatureLayer = pLayer as IFeatureLayer;
                    if (pItem == esriTOCControlItem.esriTOCControlItemLayer && pTocFeatureLayer != null)
                    {
                        TocContextMenu.Show(Control.MousePosition);
                    }
                }
                //按下左键准备移动图层
                if (e.button == 1)
                {
                    esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
                    IBasicMap          pMap = null; object unk = null;
                    object             data = null; ILayer pLayer = null;
                    axTOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
                    if (pLayer == null)
                    {
                        return;
                    }

                    pMoveLayerPoint.PutCoords(e.x, e.y);
                    if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
                    {
                        if (pLayer is IAnnotationSublayer)
                        {
                            return;
                        }
                        else
                        {
                            pMoveLayer = pLayer;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Exemplo n.º 24
0
        private void axTOCControl1_OnMouseDown_1(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            try
            {
                if (e.button == 2)
                {
                    esriTOCControlItem pItem  = esriTOCControlItem.esriTOCControlItemNone;
                    IBasicMap          pMap   = null;
                    ILayer             pLayer = null;
                    object             unk    = null;
                    object             data   = null;
                    axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
                    pTocFeatureLayer = pLayer as IFeatureLayer;
                    if (pItem == esriTOCControlItem.esriTOCControlItemLayer && pTocFeatureLayer != null)
                    {
                        btnLayerSel.Enabled   = !pTocFeatureLayer.Selectable;
                        btnLayerUnSel.Enabled = pTocFeatureLayer.Selectable;
                        contextMenuStrip1.Show(Control.MousePosition);
                    }
                }
                if (e.button == 1)
                {
                    esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
                    IBasicMap          pMap = null; object unk = null;
                    object             data = null; ILayer pLayer = null;
                    axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);
                    if (pLayer == null)
                    {
                        return;
                    }

                    pMoveLayerPoint.PutCoords(e.x, e.y);
                    if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
                    {
                        if (pLayer is IAnnotationSublayer)
                        {
                            return;
                        }
                        else
                        {
                            pMoveLayer = pLayer;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// 在TocControl的鼠标事件中实现右键菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            m_pTocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            //右键命令
            if (e.button == 2)
            {
                m_mapControl.CustomProperty = layer;
                if (item == esriTOCControlItem.esriTOCControlItemMap)//点击的是地图
                {
                    m_pTocControl.SelectItem(map, null);
                    mapMenu.PopupMenu(e.x, e.y, m_pTocControl.hWnd);
                }

                if (item == esriTOCControlItem.esriTOCControlItemLayer)//点击的是图层
                {
                    m_pTocControl.SelectItem(layer, null);
                    //setSecAndEdit(layer.Name);
                    layerMenu.PopupMenu(e.x, e.y, m_pTocControl.hWnd);
                }
            }

            /*
             * //左键移动
             * if(e.button==1)
             * {
             *  if (item == esriTOCControlItem.esriTOCControlItemLayer)
             *  {
             *      //如果是注记图层则返回
             *      if (layer is IAnnotationSublayer)
             *      {
             *          return;
             *      }
             *      //如何是组合图层的子图层
             *      if (index == null)
             *      {
             *          int removedIndex = -1;
             *          removedGroupLayer = QueryGroupLayer(layer, ref removedIndex);
             *      }
             *      removedLayer = layer;
             *  }
             * }
             * */
        }
Exemplo n.º 26
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item  = new esriTOCControlItem();
            IBasicMap          map   = new MapClass();
            ILayer             layer = new FeatureLayerClass();
            object             unk   = new object();
            object             data  = new object();

            axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref unk, ref data);
            if (e.button == 2 && item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                (m_pMapC2 as IMapControl4).CustomProperty = layer;
                m_pToolbarMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
            }
        }
Exemplo n.º 27
0
 private void m_pTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     try
     {
         esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone;
         IBasicMap          basicMap = null;
         object             unk      = null;
         object             data     = null;
         this.m_pTOCControl.HitTest(e.x, e.y, ref itemType, ref basicMap, ref m_pTOCLayer, ref unk, ref data);
     }
     catch (Exception ex)
     {
         DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message);
     }
 }
Exemplo n.º 28
0
        void axTOCControl_main_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap          map   = new MapClass();
            ILayer             layer = new FeatureLayerClass();
            object             index = new object();
            object             other = new object();
            esriTOCControlItem item  = new esriTOCControlItem();

            axTOCControl_main.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (e.button == 2 && item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                (m_pMapC2 as IMapControl4).CustomProperty = layer;
                m_pToolbarMenu.PopupMenu(e.x, e.y, axTOCControl_main.hWnd);
            }
        }
Exemplo n.º 29
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);
            }
        }
Exemplo n.º 30
0
        /*地图符号,图层属性的显示与修改筛选
         *
         */
        private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item  = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap          map   = null;
            ILayer             layer = null;
            object             other = null;
            object             index = null;

            axTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            //确定选定的菜单类型,Map或是图层菜单,元素
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                return;
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                if (e.button == 2)
                {//right click
                    choosedLayer = layer; choosedIndex = index;
                    LayerContextMenuStrip.Show(axTOCControl, e.x, e.y);
                    return;
                }
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
            {
                if (e.button == 1)                                                //鼠标左键
                {
                    CustomSymbology dlgCSymbol = new CustomSymbology(LPMenu.ElementShapeType2SymboloStyleType(ref layer));
                    if (dlgCSymbol.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        RenderWorkerObject.RendLayer(ref layer, dlgCSymbol.getChosedSymbol());
                    }
                    else
                    {
                        return;
                    }
                }
                else if (e.button == 2)                                            //鼠标右键
                {
                    LPMenu.SetLayer(ref layer);
                    LPMenu.ShowMenus(axTOCControl, e.x, e.y);
                    RenderWorkerObject.RendLayer(ref layer, LPMenu.retSymbol);
                }
            }
            axTOCControl.Refresh();
            axMapControl.Refresh();
            axMapControl.CustomProperty = layer;
        }
Exemplo n.º 31
0
        public void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button == 2)
            {

                esriTOCControlItem Item = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap pBasicMap = null;
                ILayer pLayer = null;
                object other = null;
                object index = null;
                axTOCControl1.HitTest(e.x, e.y, ref Item, ref pBasicMap, ref pLayer, ref other, ref index);          //实现赋值

                if (Item == esriTOCControlItem.esriTOCControlItemLayer)           //点击的是图层的话,就显示右键菜单
                {
                    if (this.toolStripComboBox2.SelectedItem == null)
                    {
                        contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
                        flaglayer = pLayer;
                        return;
                    }
                    else
                    {
                        if (pLayer.Name == this.toolStripComboBox2.SelectedItem.ToString())

                            //contextMenuStrip1.Show(axTOCControl1, new System.Drawing.Point(e.x, e.y));
                            contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
                        else
                        {
                            MessageBox.Show("请选择相同图层进行操作");
                            return;
                        }
                        //显示右键菜单,并定义其相对控件的位置,正好在鼠标出显示
                    }
                }
            }
            if (e.button == 1)
            {
                esriTOCControlItem Item = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap pBasicMap = null;
                ILayer pLayer = null;
                object other = null;
                object index = null;
                axTOCControl1.HitTest(e.x, e.y, ref Item, ref pBasicMap, ref pLayer, ref other, ref index);

                mEngineEditor.StopEditing(true);
            }
            istoolenable(false);
        }
Exemplo n.º 32
0
        /// <summary>
        /// TOCC左键设置图例,右键弹出菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tocCtrl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            var       item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap basicMap = null;
            object    unk = null, data = null;

            TocControl.HitTest(e.x, e.y, ref item, ref basicMap, ref SelectedLayer, ref unk, ref data);
            if (e.button == 2)
            {
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {
                    ToccMenuStrip.Show(TocControl, new System.Drawing.Point(e.x, e.y));
                    ShowFieldLabelMenuItems(SelectedLayer);
                }
            }
        }
Exemplo n.º 33
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);
        }
		private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
		{
			if (e.button != 2) return;

			esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
			IBasicMap map = null;
			ILayer layer = null;
			object other = null;
			object index = null;

			//Determine what kind of item is selected
			m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

			//Ensure the item gets selected 
			if (item == esriTOCControlItem.esriTOCControlItemMap)
				m_tocControl.SelectItem(map, null);
			else
				m_tocControl.SelectItem(layer, null);

			//Set the layer into the CustomProperty (this is used by the custom layer commands)			
			m_mapControl.CustomProperty = layer;

			ISchematicLayer schLayer = layer as ISchematicLayer;
			if (schLayer != null) /// attach menu for SchematicLayer
			{
				ISchematicTarget schematicTarget = new ESRI.ArcGIS.SchematicControls.EngineSchematicEnvironmentClass() as ISchematicTarget;
				if (schematicTarget != null)
					schematicTarget.SchematicTarget = schLayer;

				//Popup the correct context menu

				if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuSchematicLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
			}
			else /// attach menu for Layer
			{
				//Popup the correct context menu
				if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
			}
		}
Exemplo n.º 35
0
        /// <summary>
        /// Mouse down event for the TOC control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            try
            {
                //right click button
                if (e.button != 2) return;

                esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap map = null; ILayer layer = null;
                object other = null; object index = null;

                //Determine what kind of item is selected
                getSetTocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                //Ensure the item gets selected
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                    getSetTocControl.SelectItem(map, null);
                else
                    getSetTocControl.SelectItem(layer, null);

                //Set the layer into the CustomProperty (this is used by the custom layer commands)
                getSetMapControl.CustomProperty = layer;

                //Popup the correct context menu
                if (item == esriTOCControlItem.esriTOCControlItemMap) getSetMenuMap.PopupMenu(e.x, e.y, getSetTocControl.hWnd);
                if (item == esriTOCControlItem.esriTOCControlItemLayer) getSetMenuLayer.PopupMenu(e.x, e.y, getSetTocControl.hWnd);
            }
            catch (COMException COMex)
            {
                MessageBox.Show("Error " + COMex.ErrorCode.ToString() + ": " + COMex.Message);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Exemplo n.º 36
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //如果不是右键按下直接返回
            if (e.button != 2) return;

            if (e.button == 2)
            {

                esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
                IBasicMap map = null;
                ILayer layer = null;
                object other = null;
                object index = null;
                RightMenu rtMenu = new RightMenu(axTOCControl1);
                IToolbarMenu m_meunLayer = rtMenu.getToolbarMenu();
                m_meunLayer.SetHook(m_mapControl);
                //判断所选菜单的类型
                rtMenu.m_TocC.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                //确定选定的菜单类型,Map 或是图层菜单
                if (item == esriTOCControlItem.esriTOCControlItemMap)
                    rtMenu.m_TocC.SelectItem(map, null);
                else
                    rtMenu.m_TocC.SelectItem(layer, null);

                //设置CustomProperty 为layer (用于自定义的Layer 命令)
                m_mapControl.CustomProperty = layer;
                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {

                    //动态添加ShowAttributeTable菜单项
                    m_meunLayer.AddItem(new OpenAttributeTable(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                    m_meunLayer.PopupMenu(e.x, e.y, rtMenu.m_TocC.hWnd);
                    //移除OpenAttributeTable菜单项,以防止重复添加
                    m_meunLayer.Remove(2);
                }
            }
        }
Exemplo n.º 37
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //确定选择的对象(map or layer)  //hittest右键快捷菜单位置x y等参数
            axTOCControl1.HitTest(e.x, e.y, ref m_item, ref m_map, ref m_pLayer, ref m_other, ref m_index);

            if (e.button == 2) //右键响应
            {
                //弹出快捷菜单
                if (m_item == esriTOCControlItem.esriTOCControlItemMap)
                {
                    axTOCControl1.SelectItem(m_map, null);
                }
                else if (m_item == esriTOCControlItem.esriTOCControlItemLayer && !(m_pLayer is IGroupLayer))
                {
                    axTOCControl1.SelectItem(m_pLayer, null);
                    contextMenuStrip1.Show(axTOCControl1,e.x + 5, e.y + 10);
                }
            }
        }
Exemplo n.º 38
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            IBasicMap map = null;//实现TOC的右键快捷菜单
            object other = null;
            object index = null;
            esriTOCControlItem item = new esriTOCControlItem();
            this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref m_layer, ref other, ref index);
            if (e.button == 2 && item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                this.OpenAttribute.Enabled = false;
                this.ClearAttribute.Enabled = false;
                this.SelectBand.Enabled = false;
                if (m_layer is IFeatureLayer)
                {
                    this.OpenAttribute.Enabled = true;
                    this.ClearAttribute.Enabled = true;
                }
                else
                {
                    this.SelectBand.Enabled = true;
                }

                System.Drawing.Point point = new System.Drawing.Point(e.x, e.y);
                this.conMenuTOC.Show(axTOCControl1, point);
            }
        }
Exemplo n.º 39
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //make sure that the user right clicked
            if (2 != e.button)
                return;

            //use HitTest in order to test whether the user has selected a featureLayer
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map = null;
            ILayer layer = null;
            object other = null;
            object index = null;

            //do the HitTest
            toccontrol.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //set the featurelayer as the custom property of the MapControl
            axMapControl1.CustomProperty = layer;

            //Ensure the item gets selected
            if (item == esriTOCControlItem.esriTOCControlItemMap)
                toccontrol.SelectItem(map, null);
            else
                toccontrol.SelectItem(layer, null);

            //Set the layer into the CustomProperty (this is used by the custom layer commands)
            axMapControl1.CustomProperty = layer;

            //Popup the correct context menu
            if (item == esriTOCControlItem.esriTOCControlItemMap)
                m_tocMapContextMenu.PopupMenu(e.x, e.y, toccontrol.hWnd);

            if (item == esriTOCControlItem.esriTOCControlItemLayer)
                m_tocLayerContextMenu.PopupMenu(e.x, e.y, toccontrol.hWnd);
        }
Exemplo n.º 40
0
 private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone;
     IBasicMap basicMap = null;
     ILayer layer = null;
     object unk = null;
     object data = null;
     //this.axTOCControl.GetSelectedItem(ref itemType, ref basicMap, ref layer, ref unk, ref data);
     this.axTOCControl.HitTest(e.x,e.y,ref itemType, ref basicMap, ref layer, ref unk, ref data);
     if (e.button == 2)
     {
         //switch (itemType)
         //{
         //    case esriTOCControlItem.esriTOCControlItemNone:
         //        MessageBox.Show("None");
         //        break;
         //    case esriTOCControlItem.esriTOCControlItemMap:
         //        MessageBox.Show("Map\n" + basicMap.Name);
         //        break;
         //    case esriTOCControlItem.esriTOCControlItemLayer:
         //        MessageBox.Show("Layer\n" + layer.Name);
         //        break;
         //    case esriTOCControlItem.esriTOCControlItemLegendClass:
         //        MessageBox.Show("Legend\n" + ((ILegendGroup)unk).get_Class((int)data).Description + "\n" + ((ILegendGroup)unk).get_Class((int)data).Label);
         //        break;
         //    case esriTOCControlItem.esriTOCControlItemHeading:
         //        MessageBox.Show("Heading\n" + ((ILegendGroup)unk).Heading);
         //        break;
         //}
         switch (itemType)
         {
             case esriTOCControlItem.esriTOCControlItemLayer:
                 this.TOCRightLayer = layer;
                 this.contextMenuTOCFeatureLyr.Show(this.axTOCControl, e.x, e.y);
                 break;
             case esriTOCControlItem.esriTOCControlItemMap:
                 this.contextMenuTOCMap.Show(this.axTOCControl, e.x, e.y);
                 break;
         }
     }
     if (e.button == 1)
     {
         switch (itemType)
         {
             case esriTOCControlItem.esriTOCControlItemLegendClass:
                 ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data);
                 SymbolSelectorFrm newSymbolSelectorFrm = new SymbolSelectorFrm(pLegendClass, layer);
                 if (newSymbolSelectorFrm.ShowDialog() == DialogResult.OK)
                 {
                     this.mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                     pLegendClass.Symbol = newSymbolSelectorFrm.pSymbol;
                     this.axTOCControl.Update();
                 }
                 break;
         }
     }
 }
Exemplo n.º 41
0
 private void axTOCControlMain_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     TocContentMenu t = new TocContentMenu();
     t.axTOCControl_OnMouseDown(sender, e, this.axMapControlMain);
 }
Exemplo n.º 42
0
        /// <summary>
        /// ͼ���б����¼�
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            this.axTOCControl1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data);
            if (e.button == 2)
            {
                switch (itemType)
                {
                    case esriTOCControlItem.esriTOCControlItemLayer:
                        this.TOCRightLayer = layer;
                        this.contextMenuTOCFeatureLyr.Show(this.axTOCControl1, e.x, e.y);
                        break;
                    case esriTOCControlItem.esriTOCControlItemMap:
                        this.contextMenuTOCMap.Show(this.axTOCControl1, e.x, e.y);
                        break;
                }
            }
            //else if (e.button == 1)
            //{
                //System.Drawing.Point pos = new System.Drawing.Point(e.x, e.y);
                //if (itemType == esriTOCControlItem.esriTOCControlItemLegendClass)
                //{
                //    //ȡ��ͼ��
                //    ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data);
                //    //��������ѡ����SymbolSelectorʵ��
                //    SymbolSelectorForm SymbolSelectorFrm = new SymbolSelectorForm(pLegendClass, layer);
                //    if (SymbolSelectorFrm.ShowDialog() == DialogResult.OK)
                //    {
                //        //�ֲ�������Map�ؼ�
                //        this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                //        //this.axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                //        //�����µķ���
                //        pLegendClass.Symbol = SymbolSelectorFrm.pSymbol;
                //        //������Map�ؼ���ͼ��ؼ�
                //        this.axMapControl1.ActiveView.Refresh();
                //        //this.axMapControl2.ActiveView.Refresh();
                //        this.axTOCControl1.Refresh();
                //    }
                //}
            //}

            //ֻ��Ӣ�İ汾��engine�ſ��Դ���ɫѡȡ
            //if (e.button == 1)
            //{
            //    switch (itemType)
            //    {
            //        case esriTOCControlItem.esriTOCControlItemLegendClass:
            //            ILegendClass pLegendClass = ((ILegendGroup)unk).get_Class((int)data);
            //            SymbolSelectorForm newSymbolSelectorFrm = new SymbolSelectorForm(pLegendClass, layer);
            //            if (newSymbolSelectorFrm.ShowDialog() == DialogResult.OK)
            //            {
            //                this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //                pLegendClass.Symbol = newSymbolSelectorFrm.pSymbol;
            //                this.axTOCControl1.Update();
            //            }
            //            break;
            //    }
            //}
        }
Exemplo n.º 43
0
        private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map = null;
            ILayer layer = null;
            object other = null;
            object index = null;

            _tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (index != null)
            {
                currentIndex = (int)index;
            }
            else
            {
                currentIndex = 0;
            }

            legend = other;
            currentLayer = layer;
            //确保有项目被选择
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                _tocControl.SelectItem(map, null);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                _tocControl.SelectItem(layer, null);
            }
            //else if (item == esriTOCControlItem.esriTOCControlItemLegendClass)
            //{
            //    _tocControl.SelectItem(other, null);
            //}

            //选择的是Map
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                //将Map信息传递给propertyGrid控件
                MapInfo _mapInfo = new MapInfo(_mapControl.Map);
                //propertyGrid.SelectedObject = _mapInfo;
                //如果是右键点击,弹出菜单
                if (e.button == 2)
                {
                    _mapMenu.PopupMenu(e.x, e.y, _tocControl.hWnd);
                }
            }

            //选择的是 Layer
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                if(e.button == 2)
                {
                    this._mapControl.CustomProperty = layer;
                    _layerMenu.PopupMenu(e.x, e.y, _tocControl.hWnd);
                }

                /**
                 //将Layer信息传递给PropertyGrid控件
                _mapControl.CustomProperty = layer;
                IFeatureLayer pFeatLyr = layer as IFeatureLayer;
                if (pFeatLyr == null)
                    return;
                MyMainGIS.Library.MapLayerInfo _mapLyrInfo = new MyMainGIS.Library.MapLayerInfo(pFeatLyr, _mapControl.Map);
                propertyGrid.SelectedObject = _mapLyrInfo;
                //_App.StatusBar.Panels[0].Text = "当前选择图层:" + layer.Name;

                //数据表中出现当前图层数据
                //获取有效的图层名称 a_b被解析为a.b
                string LayerName = LayerDataTable.getValidFeatureClassName(layer.Name);
                //判断当前图层是否存在Selection
                IFeatureSelection pFeatureSelection = layer as IFeatureSelection;
                if (pFeatureSelection.SelectionSet.Count > 0)
                {
                    LayerName += "_Selection";
                    if (_App.MainDataSet.Tables.Contains(LayerName))
                    {
                        _App.MainDataSet.Tables.Remove(LayerName);
                    }
                    DataTable dt = LayerDataTable.CreateDataTable(layer, LayerName);
                    _App.MainDataSet.Tables.Add(dt);
                }
                else
                {
                    if (!this._App.MainDataSet.Tables.Contains(LayerName))
                    {
                        DataTable dt = LayerDataTable.CreateDataTable(layer, LayerName);
                        _App.MainDataSet.Tables.Add(dt);
                    }
                }
                bindingSource.DataSource = _App.MainDataSet;
                bindingSource.DataMember = LayerName;
                dataGridView.DataSource = bindingSource;
                //DataPanel.Text = "数据表[" + LayerName + "]" + "  记录数:" + _DataSet.Tables[LayerName].Rows.Count.ToString();
                dataGridView.Refresh();
                */

            }

            //Legend  选择的是遥感影像 修改波段 RGB
            if (item == esriTOCControlItem.esriTOCControlItemLegendClass && e.button == 1)
            {
                IRasterLayer pRasterLayer = layer as IRasterLayer;
                if (pRasterLayer != null && pRasterLayer.BandCount > 1) //判断是影像后排除单波段影像。
                {
                    BandSelectorMenu.Items.Clear();
                    BandSelectorMenu.Items.Add("不可见");
                    ToolStripSeparator separator = new ToolStripSeparator();
                    BandSelectorMenu.Items.Add(separator);

                    string toolItem;
                    for (int i = 0; i < pRasterLayer.BandCount; i++)
                    {
                        toolItem = "Band_" + (i + 1);
                        BandSelectorMenu.Items.Add(toolItem);
                    }
                    IRasterRGBRenderer pRGBRender = pRasterLayer.Renderer as IRasterRGBRenderer;
                    ToolStripMenuItem VisuableItem = BandSelectorMenu.Items[0] as ToolStripMenuItem;
                    ToolStripMenuItem ChangeItem;
                    if ((int)index == 0)
                    {
                        if (pRGBRender.UseRedBand == false)
                        {
                            VisuableItem.Checked = true;
                        }
                        else
                        {
                            ChangeItem = BandSelectorMenu.Items[pRGBRender.RedBandIndex + 2] as ToolStripMenuItem;
                            ChangeItem.Checked = true;
                        }
                    }
                    if ((int)index == 1)
                    {
                        if (pRGBRender.UseGreenBand == false)
                        {
                            VisuableItem.Checked = true;
                        }
                        else
                        {
                            ChangeItem = BandSelectorMenu.Items[pRGBRender.GreenBandIndex + 2] as ToolStripMenuItem;
                            ChangeItem.Checked = true;
                        }
                    }
                    if ((int)index == 2)
                    {
                        if (pRGBRender.UseBlueBand == false)
                        {
                            VisuableItem.Checked = true;
                        }
                        else
                        {
                            ChangeItem = BandSelectorMenu.Items[pRGBRender.BlueBandIndex + 2] as ToolStripMenuItem;
                            ChangeItem.Checked = true;
                        }
                    }

                    BandSelectorMenu.Show(axTOCControl1, e.x, e.y);
                }

            }
        }
    private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
    {
      //make sure that the user right clicked
      if (2 != e.button)
        return;

      //use HitTest in order to test whether the user has selected a featureLayer
      esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
      IBasicMap map = null; ILayer layer = null;
      object other = null; object index = null;

      //do the HitTest
      axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

      //Determine what kind of item has been clicked on
      if (null == layer || !(layer is IFeatureLayer))
        return;

      //set the featurelayer as the custom property of the MapControl
      axMapControl1.CustomProperty = layer;

      //popup a context menu with a 'Properties' command
      m_contextMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
    }
Exemplo n.º 45
0
        /// <summary>
        /// 图层树控件事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap map = null;
            ILayer layer = null;
            object other = null;
            object index = null;

            _tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            if (index != null)
            {
                currentIndex = (int)index;
            }
            else
            {
                currentIndex = 0;
            }

            //确保有项目被选择
            //if (item == esriTOCControlItem.esriTOCControlItemMap)
            //{
            //    _tocControl.SelectItem(map, null);
            //}
            if (item == esriTOCControlItem.esriTOCControlItemLayer && layer == currentLayer)
            {
                _tocControl.SelectItem(layer, null);
            }
            legend = other;
            currentLayer = layer;
            //选择的是Map
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                //将Map信息传递给propertyGrid控件
                MapInfo _mapInfo = new MapInfo(_mapControl.Map);
                //propertyGrid.SelectedObject = _mapInfo;
                //如果是右键点击,弹出菜单
                if (e.button == 2)
                {
                    _mapMenu.PopupMenu(e.x, e.y, _tocControl.hWnd);
                }
            }

            //选择的是 Layer
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                if(e.button == 2)
                {
                    this._mapControl.CustomProperty = layer;
                    _layerMenu.PopupMenu(e.x, e.y, _tocControl.hWnd);
                }

            }

            //Legend  选择的是遥感影像 修改波段 RGB
            if (item == esriTOCControlItem.esriTOCControlItemLegendClass && e.button == 1)
            {
                IRasterLayer pRasterLayer = layer as IRasterLayer;
                if (pRasterLayer != null && pRasterLayer.BandCount > 1) //判断是影像后排除单波段影像。
                {
                    BandSelectorMenu.Items.Clear();
                    BandSelectorMenu.Items.Add("不可见");
                    ToolStripSeparator separator = new ToolStripSeparator();
                    BandSelectorMenu.Items.Add(separator);

                    string toolItem;
                    for (int i = 0; i < pRasterLayer.BandCount; i++)
                    {
                        toolItem = "Band_" + (i + 1);
                        BandSelectorMenu.Items.Add(toolItem);
                    }
                    IRasterRGBRenderer pRGBRender = pRasterLayer.Renderer as IRasterRGBRenderer;
                    ToolStripMenuItem VisuableItem = BandSelectorMenu.Items[0] as ToolStripMenuItem;
                    ToolStripMenuItem ChangeItem;
                    if ((int)index == 0)
                    {
                        if (pRGBRender.UseRedBand == false)
                        {
                            VisuableItem.Checked = true;
                        }
                        else
                        {
                            ChangeItem = BandSelectorMenu.Items[pRGBRender.RedBandIndex + 2] as ToolStripMenuItem;
                            ChangeItem.Checked = true;
                        }
                    }
                    if ((int)index == 1)
                    {
                        if (pRGBRender.UseGreenBand == false)
                        {
                            VisuableItem.Checked = true;
                        }
                        else
                        {
                            ChangeItem = BandSelectorMenu.Items[pRGBRender.GreenBandIndex + 2] as ToolStripMenuItem;
                            ChangeItem.Checked = true;
                        }
                    }
                    if ((int)index == 2)
                    {
                        if (pRGBRender.UseBlueBand == false)
                        {
                            VisuableItem.Checked = true;
                        }
                        else
                        {
                            ChangeItem = BandSelectorMenu.Items[pRGBRender.BlueBandIndex + 2] as ToolStripMenuItem;
                            ChangeItem.Checked = true;
                        }
                    }

                    BandSelectorMenu.Show(axTOCControl1, e.x, e.y);
                }

            }
        }
Exemplo n.º 46
0
        private void TocControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
            object other = null;
            object index = null;
            IBasicMap map = null;
            ILayer layer = null;

            CurTOCControl = (sender as AxTOCControl).Object as ITOCControl2;
            //���ص���ָ���Ķ���
            CurTOCControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

            //������е�ͼ�����򵯳��������ô���
            if ((e.button == 1) && (item == esriTOCControlItem.esriTOCControlItemLegendClass))
            {
                //�ݲ�֧��
            }
            else if ((e.button == 1) && (item == esriTOCControlItem.esriTOCControlItemLayer))
            {
                object obj = m_MapLayersController.GetLayerParent(layer);
                if (obj is ICompositeLayer)
                {
                    ILayer pParentLayer = (ILayer)obj;
                    bool b = layer.Visible;
                    if (b == false)
                    {
                        pParentLayer.Visible = true;
                    }
                }
            }
            else if (e.button == 2) //����Ҽ�
            {
                switch (item)
                {
                    case esriTOCControlItem.esriTOCControlItemNone:
                        break;
                    case esriTOCControlItem.esriTOCControlItemMap:
                        CurTOCControl.SelectItem(map, null);
                        this.popMenuTOCMap.ShowPopup(MousePosition);
                        break;
                    case esriTOCControlItem.esriTOCControlItemLegendClass:
                        break;
                    case esriTOCControlItem.esriTOCControlItemLayer:
                        m_CurrentSelectLayer = layer;
                        CurTOCControl.SelectItem(layer, null);
                        popMenuTOCLayer.ShowPopup(MousePosition); // new System.Drawing.Point(e.x, e.y));
                        break;
                    case esriTOCControlItem.esriTOCControlItemHeading:
                        break;
                }

                CurActivityMapControl.CustomProperty = layer;
            }
            CurTOCControl = null;
        }
Exemplo n.º 47
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;
                    }
                }
            }
        }
Exemplo n.º 48
0
        // TOCControl events
        void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (2 != e.button)
                return;
            esriTOCControlItem tocItem = esriTOCControlItem.esriTOCControlItemNone;
            IBasicMap basicMap = null;
            ILayer layer = null;
            object unk = null;
            object objdata = null;

            axTOCControl1.HitTest(e.x, e.y, ref tocItem, ref basicMap, ref layer, ref unk, ref objdata);

            if (null == layer || !(layer is IFeatureLayer))
                return;

            axMapControl1.CustomProperty = layer;
            m_ContextMenu.PopMenu(e.x, e.y, axTOCControl1.hWnd);
        }
Exemplo n.º 49
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button != 2) return;
            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);
            //m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
            //确定选定的菜单类型,Map或是图层菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)

                axTOCControl1.SelectItem(map, null);
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)

                axTOCControl1.SelectItem(layer, null);
            else
                return;

            //设置CustomProperty为layer (用于自定义的Layer命令)
            IMapControl3 m_mapControl = (IMapControl3)this.axMapControl1.Object;
            m_mapControl.CustomProperty = layer;
            //弹出右键菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)

                m_menuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd);

            if (item == esriTOCControlItem.esriTOCControlItemLayer)

                m_menuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
        }
Exemplo n.º 50
0
 private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     this.axTOCControl1.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref unk, ref data);
     if (e.button == 2)
     {
         switch (itemType)
         {
             case esriTOCControlItem.esriTOCControlItemLayer:
                 this.TOCRightLayer = layer;
                 this.contextMenuTOCFeatureLyr.Show(this.axTOCControl1, e.x, e.y);
                 break;
             case esriTOCControlItem.esriTOCControlItemMap:
                 this.contextMenuTOCMap.Show(this.axTOCControl1, e.x, e.y);
                 break;
         }
     }
 }
Exemplo n.º 51
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            if (e.button == 2)
            {
                IBasicMap map = new MapClass();
                ILayer layer = new FeatureLayerClass();
                object other = new object();
                object index = new object();
                esriTOCControlItem item = new esriTOCControlItem();

                try
                {
                    axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);

                }
                catch (Exception eX)
                {
                    MessageBox.Show(eX.Message);

                }

                if (item == esriTOCControlItem.esriTOCControlItemLayer)
                {

                    if (layer != null)
                    {
                        this.setCurrentLayer(layer);

                    }

                }
            }
        }