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); } }
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); } }
private void axPageLayoutControl1_OnMouseUp(object sender, IPageLayoutControlEvents_OnMouseUpEvent e) { //Display the Popup Menu so that it appears to the right of the mouse click if (e.button == 2) { //Cast to the IToolbarMenu2 interface of the m_pToolbarMenu IToolbarMenu2 m_pToolbarMenu2 = (IToolbarMenu2)m_pToolbarMenu; //Align the Menu so that it appears to the right of the user mouse click m_pToolbarMenu2.AlignLeft = true; //Popup the menu m_pToolbarMenu.PopupMenu(e.x, e.y, axPageLayoutControl1.hWnd); } }
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { IBasicMap pMap = null; ILayer pLayer = null; object unk = null, data = null; ESRI.ArcGIS.Controls.esriTOCControlItem pItem = ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemNone; try { axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data); } catch (Exception) { throw; } switch (e.button) { case 2: //右键 if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemMap) { axTOCControl1.SelectItem(pMap, null); } else if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemLayer) { axTOCControl1.SelectItem(pLayer, null); } axMapControl1.CustomProperty = pLayer; if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemMap) { // } if (pItem == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemLayer) { var m_pMenuLayer = new ToolbarMenu(); m_pMenuLayer.AddItem(new BuildLineBuffer(), -1, 0, false, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly); m_pMenuLayer.AddItem(new ShowAttribute(), 1, 1, false, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly); m_pMenuLayer.SetHook(axMapControl1); m_pMenuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } break; default: break; } }
private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap pMap = null; ILayer pLayer = null; object legendgp = null; object index = null; ToolbarMenu m_pMenuLayer = new ToolbarMenu(); 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(pMap, null); } else { axTOCControl1.SelectItem(pLayer, null); } axMapControl1.CustomProperty = pLayer; if (pItem == esriTOCControlItem.esriTOCControlItemMap) { //.............右键map时 } if (pItem == esriTOCControlItem.esriTOCControlItemLayer) { m_pMenuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_pMenuLayer.AddItem(new ZoomToLayer(), -1, 1, false, esriCommandStyles.esriCommandStyleTextOnly); m_pMenuLayer.AddItem(new LayerVisibility(), 1, 2, true, esriCommandStyles.esriCommandStyleTextOnly); m_pMenuLayer.AddItem(new LayerVisibility(), 2, 3, false, esriCommandStyles.esriCommandStyleTextOnly); m_pMenuLayer.AddItem(new OpenAttribute(pLayer), -1, 4, true, esriCommandStyles.esriCommandStyleTextOnly); m_pMenuLayer.SetHook(axMapControl1); m_pMenuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd); } break; } }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { #region 主窗体右键 /////地图视窗鼠标事件 IToolbarMenu mapPopMenu = null; mapPopMenu = new ToolbarMenu(); if (e.button == 2) { /* IMap pMap = axMapControl1.Map; IActiveView pActiveView = pMap as IActiveView; IEnvelope pEnv = axMapControl1.TrackRectangle(); pActiveView.Extent = pEnv; pActiveView.Refresh();*/ //地图视窗右键菜单功能 mapPopMenu.AddItem(new ControlsSelectTool(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapPanTool(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapFullExtentCommand(), -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapIdentifyTool(), -1, 3, false, esriCommandStyles.esriCommandStyleIconAndText);//识别工具 mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 4, false, esriCommandStyles.esriCommandStyleIconAndText);// mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 5, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsSelectFeaturesTool(), -1, 6, false, esriCommandStyles.esriCommandStyleIconAndText);//选择要素工具 mapPopMenu.AddItem(new ControlsClearSelectionCommand(), -1, 7, false, esriCommandStyles.esriCommandStyleIconAndText);//缩放所选要素 mapPopMenu.AddItem(new ControlsZoomToSelectedCommand(), -1, 8, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapZoomToLastExtentBackCommand(), -1, 9, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapZoomToLastExtentForwardCommand(), -1, 10, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.SetHook(axMapControl1);//// 得到地图视窗右键菜单 mapPopMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);//弹出显示菜单 } /* if (e.button == 1)//左键因为右键要取消 { IMap pMap = axMapControl1.Map; IActiveView pActiveView = pMap as IActiveView; IEnvelope pEnv = axMapControl1.TrackRectangle(); pActiveView.Extent = pEnv; pActiveView.Refresh(); } * */ //此事件不会触发 if (e.button == 3)//如果鼠标中间改为ControlsMapPanTool会更好 { IMap pMap = axMapControl1.Map; IActiveView pActiveView = pMap as IActiveView; IEnvelope pEnv = axMapControl1.TrackRectangle(); pActiveView.Extent = pEnv; pActiveView.Refresh(); } #endregion //if (e.button == 2) //{ // IMap pMap = axMapControl1.Map; // IActiveView pActiveView = pMap as IActiveView; // IEnvelope pEnv = axMapControl1.TrackRectangle(); // pActiveView.Extent = pEnv; // pActiveView.Refresh(); //} //网络分析 if (clicked != true) return; IPoint ipNew; if (m_ipPoints == null) { m_ipPoints = new MultipointClass(); } ipNew = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); object o = Type.Missing; m_ipPoints.AddPoint(ipNew, ref o, ref o); IElement element; ITextElement textelement = new TextElementClass(); element = textelement as IElement; clickedcount++; textelement.Text = clickedcount.ToString(); element.Geometry = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); pGC.AddElement(element, 0); m_ipActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { #region 主窗体右键 /////地图视窗鼠标事件 IToolbarMenu mapPopMenu = null; mapPopMenu = new ToolbarMenu(); if (e.button == 2) { /* IMap pMap = axMapControl1.Map; * IActiveView pActiveView = pMap as IActiveView; * IEnvelope pEnv = axMapControl1.TrackRectangle(); * pActiveView.Extent = pEnv; * pActiveView.Refresh();*/ //地图视窗右键菜单功能 mapPopMenu.AddItem(new ControlsSelectTool(), -1, 0, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapPanTool(), -1, 1, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapFullExtentCommand(), -1, 2, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapIdentifyTool(), -1, 3, false, esriCommandStyles.esriCommandStyleIconAndText); //识别工具 mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 4, false, esriCommandStyles.esriCommandStyleIconAndText); // mapPopMenu.AddItem(new ControlsMapZoomInFixedCommand(), -1, 5, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsSelectFeaturesTool(), -1, 6, false, esriCommandStyles.esriCommandStyleIconAndText); //选择要素工具 mapPopMenu.AddItem(new ControlsClearSelectionCommand(), -1, 7, false, esriCommandStyles.esriCommandStyleIconAndText); //缩放所选要素 mapPopMenu.AddItem(new ControlsZoomToSelectedCommand(), -1, 8, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapZoomToLastExtentBackCommand(), -1, 9, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.AddItem(new ControlsMapZoomToLastExtentForwardCommand(), -1, 10, false, esriCommandStyles.esriCommandStyleIconAndText); mapPopMenu.SetHook(axMapControl1); //// 得到地图视窗右键菜单 mapPopMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd); //弹出显示菜单 } /* if (e.button == 1)//左键因为右键要取消 * { * IMap pMap = axMapControl1.Map; * IActiveView pActiveView = pMap as IActiveView; * IEnvelope pEnv = axMapControl1.TrackRectangle(); * pActiveView.Extent = pEnv; * pActiveView.Refresh(); * } * */ //此事件不会触发 if (e.button == 3)//如果鼠标中间改为ControlsMapPanTool会更好 { IMap pMap = axMapControl1.Map; IActiveView pActiveView = pMap as IActiveView; IEnvelope pEnv = axMapControl1.TrackRectangle(); pActiveView.Extent = pEnv; pActiveView.Refresh(); } #endregion //if (e.button == 2) //{ // IMap pMap = axMapControl1.Map; // IActiveView pActiveView = pMap as IActiveView; // IEnvelope pEnv = axMapControl1.TrackRectangle(); // pActiveView.Extent = pEnv; // pActiveView.Refresh(); //} //网络分析 if (clicked != true) { return; } IPoint ipNew; if (m_ipPoints == null) { m_ipPoints = new MultipointClass(); } ipNew = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); object o = Type.Missing; m_ipPoints.AddPoint(ipNew, ref o, ref o); IElement element; ITextElement textelement = new TextElementClass(); element = textelement as IElement; clickedcount++; textelement.Text = clickedcount.ToString(); element.Geometry = m_ipActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); pGC.AddElement(element, 0); m_ipActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }