Ejemplo n.º 1
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)
        {
            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);
                }
            }
        }
Ejemplo n.º 3
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;
             *  }
             * }
             * */
        }
Ejemplo n.º 4
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);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_tocControl.SelectItem(layer, null);
            }

            //设置CustomPropety为layer(用于自定义的Layer命令)
            m_mapControl.CustomProperty = layer;

            //弹出右键菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                //动态添加OpenAttributeTable菜单项
                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);
            }
        }
Ejemplo n.º 5
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;

            //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.esriTOCControlItemLayer)
            {
                //动态添加OpenAttributeTable菜单项
                m_menuLayer.AddItem(new OpenAttributeTable(layer), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.AddItem(new UpdateAreaPrimeter(layer), -1, 2, true, esriCommandStyles.esriCommandStyleTextOnly);
                m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                //移除OpenAttributeTable菜单项,以防止重复添加
                m_menuLayer.Remove(1);
                m_menuLayer.Remove(1);
            }
        }
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //获取鼠标点击信息

            axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex);

            if (e.button == 2)

            {
                if (pTocItem == esriTOCControlItem.esriTOCControlItemMap)

                {
                    pTocControl.SelectItem(pBasicMap, null);
                }

                else

                {
                    pTocControl.SelectItem(pLayer, null);
                }

                //设置CustomProperty为layer (用于自定义的Layer命令)

                pMapControl.CustomProperty = pLayer;

                //弹出右键菜单

                if (pTocItem == esriTOCControlItem.esriTOCControlItemMap)

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

                else

                {
                    pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd);
                }
            }
        }
Ejemplo n.º 7
0
 private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
 {
     if (e.button == 1)
     {
         //MessageBox.Show("左键按下");
     }
     else if (e.button == 2)
     {
         //MessageBox.Show("右键按下");
         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);
         }
         else
         {
             m_TOCControl.SelectItem(layer, null);
         }
         //设置CustomProperty为layer (用于自定义的Layer命令)
         m_mapControl.CustomProperty = layer;
         //弹出右键菜单
         //if (item == esriTOCControlItem.esriTOCControlItemMap)
         //    m_menuMap.PopupMenu(e.x, e.y, m_TOCControl.hWnd);
         if (item == esriTOCControlItem.esriTOCControlItemLayer)
         {
             m_MenuLayer.PopupMenu(e.x, e.y, m_TOCControl.hWnd);
         }
         else
         {
             MessageBox.Show("shit!");
         }
     }
 }
        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);
            }
            else if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_tocControl.SelectItem(layer, null);
            }
            else
            {
                return;
            }
            //设置 CustomProperty 为 layer (用于自定义的 Layer 命令)
            m_mapControl.CustomProperty = layer;
            //弹出右键菜单
            if (item == esriTOCControlItem.esriTOCControlItemMap)
            {
                m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            }
            if (item == esriTOCControlItem.esriTOCControlItemLayer)
            {
                m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
            }
        }
Ejemplo n.º 9
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;

            //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);
            }
        }
Ejemplo n.º 10
0
        private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;

            if (e.button == 2)
            {
                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 (layer != null)
                {
                    _tocControl.SelectItem(layer, null);
                    _mapControl.CustomProperty = layer;
                }
                if (item == esriTOCControlItem.esriTOCControlItemLayer) //单击图层
                {
                    if (layer is GroupLayer)                            //组图层
                    {
                        CreateGroupLayerPopupMenu();
                        toolbarMenu.PopupMenu(e.x, e.y, _tocControl.hWnd);
                    }
                    else//普通图层
                    {
                        CreatePopupMenu();
                        toolbarMenu.PopupMenu(e.x, e.y, _tocControl.hWnd);
                    }
                }
                else if (item == esriTOCControlItem.esriTOCControlItemMap)//单击地图
                {
                    CreateMapPopupMenu();
                    toolbarMenu.PopupMenu(e.x, e.y, _tocControl.hWnd);
                }
            }
        }
Ejemplo n.º 11
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            try
            {
                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);

                if (item == esriTOCControlItem.esriTOCControlItemNone)
                {
                    return;
                }

                // Load TOC context menu
                if (e.button == 2)
                {
                    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)
                    {
                        return;
                    }
                    if (item == esriTOCControlItem.esriTOCControlItemLayer)
                    {
                        m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd);
                    }
                }
                //Ensure the item gets selected

                //Load Simple Color pallette 071017 HK
                if (e.button == 1 && item == esriTOCControlItem.esriTOCControlItemLegendClass)
                {
                    IFeatureLayer    featureLayer    = layer as IFeatureLayer;
                    IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer;

                    DialogResult DR;
                    if (geoFeatureLayer.Renderer is ISimpleRenderer) // Only apply this function to simple Renderer
                    {
                        DR = cdColor.ShowDialog();
                    }
                    else
                    {
                        return;
                    }

                    IRgbColor pRGBcolor = new RgbColorClass();
                    if (DR == DialogResult.OK)
                    {
                        pRGBcolor = m_pSnippet.getRGB(cdColor.Color.R, cdColor.Color.G, cdColor.Color.B);
                    }

                    ISimpleRenderer simpleRenderer = (ISimpleRenderer)geoFeatureLayer.Renderer;

                    ISymbol pSymbol = simpleRenderer.Symbol;

                    //Update only color
                    switch (featureLayer.FeatureClass.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:
                        ISimpleMarkerSymbol pSimpleMarkerSymobl = (ISimpleMarkerSymbol)pSymbol;
                        pSimpleMarkerSymobl.Color = (IColor)pRGBcolor;
                        pSymbol = (ISymbol)pSimpleMarkerSymobl;
                        break;

                    case esriGeometryType.esriGeometryPolyline:
                        ISimpleLineSymbol pSimpleLineSymobl = (ISimpleLineSymbol)pSymbol;
                        pSimpleLineSymobl.Color = (IColor)pRGBcolor;
                        pSymbol = (ISymbol)pSimpleLineSymobl;
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        ISimpleFillSymbol pSimpleFillSymobl = (ISimpleFillSymbol)pSymbol;
                        pSimpleFillSymobl.Color = (IColor)pRGBcolor;
                        pSymbol = (ISymbol)pSimpleFillSymobl;

                        break;
                    }
                    simpleRenderer.Symbol    = pSymbol;
                    geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer;
                    m_tocControl.ActiveView.ContentsChanged();
                    m_mapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Ejemplo n.º 12
0
        private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            esriTOCControlItem item   = new esriTOCControlItem();
            IBasicMap          pMap   = null;
            ILayer             pLayer = new FeatureLayer();
            object             pOther = new object();
            object             pIndex = new object();

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

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

            esriTOCControlItem item1 = esriTOCControlItem.esriTOCControlItemNone;

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

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