private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { if (e.button == 2) { //Logic to determine which popup menu to show based on the current task and current tool IEngineEditTask currentTask = m_engineEditor.CurrentTask; switch (currentTask.UniqueName) { case "ControlToolsEditing_CreateNewFeatureTask": { if (((ICommand)axToolbarControl1.CurrentTool).Name == "ControlToolsEditing_Sketch") { m_toolbarMenuSketch.PopupMenu(e.x, e.y, axMapControl1.hWnd); } else if (((ICommand)axToolbarControl1.CurrentTool).Name == "ControlToolsEditing_Edit") { //SetEditLocation method must be called to enable commands ((IEngineEditSketch)m_engineEditor).SetEditLocation(e.x, e.y); m_toolbarMenuVertex.PopupMenu(e.x, e.y, axMapControl1.hWnd); } break; } case "ControlToolsEditing_ModifyFeatureTask": { //SetEditLocation method must be called to enable commands ((IEngineEditSketch)m_engineEditor).SetEditLocation(e.x, e.y); m_toolbarMenuVertex.PopupMenu(e.x, e.y, axMapControl1.hWnd); break; } } } }
//画线+测量 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { //this.Cursor = Cursors.Default; if (e.button == 1) //== MouseButtons.Left) { if (isMeasure) { GISHandler.GISTools.CreatLine(this.axMapControl1); isMeasure = false; } if (areaMeasure) { GISHandler.GISTools.MeasureArea(this.axMapControl1); // areaMeasure = false; } if (polygonSt) { GISHandler.GISTools.FreePolygonSt(this.axMapControl1, SystemSet.Base_Map + "\\处理数据库\\图层数据"); polygonSt = false; } if (attribute) { // GISHandler.GISTools.IdentifyTool(this.axMapControl1); if (identifyDialog.IsDisposed) { ShowIdentifyDialog(); } identifyDialog.OnMouseDown(e.button, e.mapX, e.mapY); //attribute = false; } if (edit) { Edit et = new Edit(this.axMapControl1); et.Show(); et.TopMost = true; edit = false; } } if (e.button == 2) { GISHandler.GISTools.setNull(this.axMapControl1); //弹出右键菜单 IMapControl3 m_mapControl = (IMapControl3)this.axMapControl1.Object; m_menuMap.PopupMenu(e.x, e.y, m_mapControl.hWnd); } }
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(); } }
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); } }
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); } } }
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 axMapControl1_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e) { if (e.button == 2) { m_toolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd); } }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (e.button == 2) { //Popup the menu m_navigationMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd); } }
private void axPageLayoutControl1_OnMouseDown(object sender, IPageLayoutControlEvents_OnMouseDownEvent e) { //Popup the ToolbarMenu if (e.button == 2) { m_ToolbarMenu.PopupMenu(e.x, e.y, axPageLayoutControl1.hWnd); } }
private void axGlobeControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IGlobeControlEvents_OnMouseDownEvent e) { //Popup menu if (e.button == 2) { m_ToolbarMenu2.PopupMenu(e.x, e.y, axGlobeControl1.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; //判断所选菜单的类型 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); } }
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); } } }
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { if (e.button == 2)//右健弹出快捷键 { m_ToolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd); } // axMapControl1.Pan(); // axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerCrosshair; // axMapControl1.Extent = axMapControl1.TrackRectangle(); // axMapControl1.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography, null, null); }
public bool OnContextMenu(int x, int y) { ESRI.ArcGIS.Geometry.IPoint point = this.hk.PageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IElement mapSurroundElement = ElementPropetyImp.GetElementFromPage(this.hk.PageLayoutControl, (int)point.X, (int)point.Y); _rightMenu1.SetCurrentElement(mapSurroundElement); _rightMenu2.SetCurrentElement(mapSurroundElement); _layerMenu.PopupMenu(x, y, this.hk.PageLayoutControl.hWnd); return(false); }
private void axPageLayoutControl1_OnMouseDown(object sender, IPageLayoutControlEvents_OnMouseDownEvent e) { if (e.button == 1) { } if (e.button == 2) { //Open the palette. // m_ToolbarPalette.PopupPalette(e.x, e.y, axPageLayoutControl1.hWnd); m_toolbarMenu2.PopupMenu(e.x, e.y, axPageLayoutControl1.hWnd); } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { //如果不是右键按下直接返回 if (e.button != 2) { return; } esriTOCControlItem itemType = esriTOCControlItem.esriTOCControlItemNone; IBasicMap basicMap = null; ILayer layer = null; object other = null; object data = null; //判断所选菜单的类型 m_tocControl.HitTest(e.x, e.y, ref itemType, ref basicMap, ref layer, ref other, ref data); //确定选定的菜单类型, Map 或是图层菜单 if (itemType == esriTOCControlItem.esriTOCControlItemMap) { m_tocControl.SelectItem(basicMap, null); } else { m_tocControl.SelectItem(layer, null); } //设置 CustomProperty 为 layer ( 用于自定义的 Layer 命令) m_mapControl.CustomProperty = layer; //弹出右键菜单 if (itemType == esriTOCControlItem.esriTOCControlItemMap) { m_menuMap.PopupMenu(e.x, e.y, m_tocControl.hWnd); } if (itemType == esriTOCControlItem.esriTOCControlItemLayer) { m_menuLayer.PopupMenu(e.x, e.y, m_tocControl.hWnd); } }
private void axPageLayoutControl1_OnMouseDown(object sender, IPageLayoutControlEvents_OnMouseDownEvent e) { if (e.button == 1) { // if() //GISHandler.GISTools.addNorthArrow(this.axPageLayoutControl1, axPageLayoutControl1.ActiveView.FocusMap); } if (e.button == 2) { IPageLayoutControl p_mapControl = (IPageLayoutControl)this.axPageLayoutControl1.Object; p_menuLayer.PopupMenu(e.x, e.y, p_mapControl.hWnd); } }
/// <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; * } * } * */ }
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); } } }
//TOCControl打开属性表 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; try { axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index); } catch (Exception) { throw; } switch (e.button) { case 2: if (pItem == esriTOCControlItem.esriTOCControlItemMap) { axTOCControl1.SelectItem(axMapControl1, null); } else { axTOCControl1.SelectItem(pLayer, null); } //将该图层设置为地图控件的自定义属性; axMapControl1.CustomProperty = pLayer; //弹出右键菜单 if (pItem == esriTOCControlItem.esriTOCControlItemMap) { m_pMenuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } if (pItem == esriTOCControlItem.esriTOCControlItemLayer) { m_pMenuMap = new ToolbarMenuClass(); m_pMenuMap.AddItem(new OpenAttribute(pLayer), -1, 0, true, esriCommandStyles.esriCommandStyleTextOnly); m_pMenuMap.SetHook(axMapControl1); m_pMenuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } break; } }
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; //Determine what kind of item is selected axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //Ensure the item gets selected if (item == esriTOCControlItem.esriTOCControlItemMap) { axTOCControl1.SelectItem(map, null); } else if (item == esriTOCControlItem.esriTOCControlItemLayer) { axTOCControl1.SelectItem(layer, null); } else { return; } //Set the layer into the CustomProperty (this is used by the custom layer commands) m_mapControl.CustomProperty = layer; if (e.button != 2) { return; } //Popup the correct context menu-- if (item == esriTOCControlItem.esriTOCControlItemMap) { m_pTOCMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } if (item == esriTOCControlItem.esriTOCControlItemLayer) { m_pTOCLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.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; //判断所选菜单的类型 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); } }
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); } } }
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); } } }
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); // 确保已被选中 if (item == esriTOCControlItem.esriTOCControlItemMap) { axTOCControl1.SelectItem(map, null); } else { axTOCControl1.SelectItem(layer, null); } // 把CustomProperty设置成对应图层 (this is used by the custom layer commands) axMapControl1.CustomProperty = layer; // if (item == esriTOCControlItem.esriTOCControlItemMap) { mMapMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } if (item == esriTOCControlItem.esriTOCControlItemLayer) { mLayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } }
//缩放到图层 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; //Hittest axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //选择物件 if (item == esriTOCControlItem.esriTOCControlItemLayer) { axTOCControl1.SelectItem(layer, null); axMapControl1.CustomProperty = layer; LayerMenu.PopupMenu(e.x, e.y, axTOCControl1.hWnd); axTOCControl1.Update(); } } }
// Show the TOC context menu when an NALayer is right-clicked on private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.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 has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); // Only implemented a context menu for NALayers. Exit if the layer is anything else. if ((layer as INALayer) == null) { return; } axTOCControl1.SelectItem(layer); // Set the layer into the CustomProperty. // This is used by the other commands to know what layer was right-clicked on // in the table of contents. axMapControl1.CustomProperty = layer; //Popup the correct context menu and update the TOC when it's done. if (item == esriTOCControlItem.esriTOCControlItemLayer) { m_menuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd); ITOCControl toc = axTOCControl1.Object as ITOCControl; toc.Update(); } }
//TOCControl1鼠标点击事件,左键 符号变更,右键菜单 private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e) { this.axTOCControl1.HitTest(e.x, e.y, ref pTocItem, ref pBasicMap, ref pLayer, ref oLegendGroup, ref oIndex); axMapControl1.CustomProperty = pLayer; if (e.button == 1) //符号变更 { if (pTocItem == esriTOCControlItem.esriTOCControlItemLegendClass) { ILegendClass pLegend = new LegendClassClass(); //首先获取图例,然后赋值过去 ISymbol symbol = null; //新建 symbol,从符号窗体中最后就是获得这个东西 if (oLegendGroup is ILegendGroup && (int)oIndex != -1) { pLegend = ((ILegendGroup)oLegendGroup).get_Class((int)oIndex) as ILegendClass; } //给上面建的图例类赋值 FormSymbology frm = new FormSymbology(pLegend, pLayer); //新建符号窗体,并将该赋值的赋值过去 frm.ShowDialog(); //显示对话框,之后就获得了 symbol 了 symbol = frm.pStyleGalleryItem.Item as ISymbol; //调用窗体的 public 字段 pLegend.Symbol = symbol; //将 symbol 赋值给图例 axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); //刷新地图 } } else if (e.button == 2) //加载右键菜单 { if (pTocItem == esriTOCControlItem.esriTOCControlItemMap) { } else if (pTocItem == esriTOCControlItem.esriTOCControlItemLayer) { pToolMenuLayer.PopupMenu(e.x, e.y, pTocControl.hWnd); ITOCControl toc = axTOCControl1.Object as ITOCControl; toc.Update(); } } }
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; } } } }