Example #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);
                }
            }
        }
Example #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;
             *  }
             * }
             * */
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #6
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);
            }
        }
Example #8
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);
            }
        }
Example #9
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);
                }
            }
        }
Example #10
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;
            }
        }
Example #11
0
        private void axTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
        {
            //if (e.button == 1)
            //{
            //    esriTOCControlItem pItem = new esriTOCControlItem();
            //    IBasicMap pMap = new MapClass();
            //    ILayer pLayer = new FeatureLayerClass();
            //    object other = new object();
            //    object index = new object();
            //    ILegendGroup pLegendGroup;
            //    _SelSymLayer = null;

            //    axTOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref other, ref index);
            //    if (pLayer == null)
            //        return;

            //    if (pItem == esriTOCControlItem.esriTOCControlItemLayer)
            //    {
            //        if (pLayer.GetType() is IAnnotationSublayer) return;
            //        else
            //        {
            //            _SelSymLayer = pLayer;
            //        }
            //    }
            //}
            IBasicMap pMap   = null;
            ILayer    pLayer = null;

            System.Object        other      = null;
            System.Object        LayerIndex = null;
            System.Drawing.Point pPoint     = new System.Drawing.Point(e.x, e.y);

            esriTOCControlItem TOCItem    = esriTOCControlItem.esriTOCControlItemNone;
            ITOCControl2       tocControl = (ITOCControl2)axTOCControl.Object;

            tocControl.HitTest(e.x, e.y, ref TOCItem, ref pMap, ref pLayer, ref other, ref LayerIndex);
            if (e.button == 2 && GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu != null)
            {
                DevComponents.DotNetBar.ButtonItem     item         = null;
                DevComponents.DotNetBar.ContextMenuBar menuBar      = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"];
                DevComponents.DotNetBar.ContextMenuBar menuBarLayer = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"];
                this.Controls.Add(menuBar);
                this.Controls.Add(menuBarLayer);
                switch (TOCItem)
                {
                case esriTOCControlItem.esriTOCControlItemMap:
                    if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu.ContainsKey("TOCContextMenu2"))
                    {
                        if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"] != null)
                        {
                            if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"].Items.Count > 0)
                            {
                                item = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCContextMenu2"].Items[0] as DevComponents.DotNetBar.ButtonItem;
                                if (item != null)
                                {
                                    item.Popup(axTOCControl.PointToScreen(pPoint));
                                }
                            }
                        }
                    }
                    break;

                case esriTOCControlItem.esriTOCControlItemLayer:

                    if (!(pLayer is IGroupLayer || pLayer is IFeatureLayer || pLayer is IDataLayer))
                    {
                        return;
                    }
                    if (pLayer is IFeatureLayer || pLayer is IDataLayer)
                    {
                        IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                        if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu.ContainsKey("TOCLayerContextMenu2"))
                        {
                            if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"] != null)
                            {
                                if (GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"].Items.Count > 0)
                                {
                                    item = GeoDBIntegration.ModuleData.v_AppDBIntegra.DicContextMenu["TOCLayerContextMenu2"].Items[0] as DevComponents.DotNetBar.ButtonItem;
                                    if (item != null)
                                    {
                                        item.Popup(axTOCControl.PointToScreen(pPoint));
                                    }
                                }
                            }
                        }
                        if (axTOCControl.Buddy is IPageLayoutControl2)
                        {
                            IPageLayoutControl2 pPageLayoutControl = axTOCControl.Buddy as IPageLayoutControl2;
                            pPageLayoutControl.CustomProperty = pLayer;
                        }
                        else if (axTOCControl.Buddy is IMapControl3)
                        {
                            IMapControl3 pMapcontrol = axTOCControl.Buddy as IMapControl3;
                            pMapcontrol.CustomProperty = pLayer;
                        }
                    }
                    break;
                }
            }
        }