The function of the system itself for zooming in and out is a separate rewrite, but if you add a toolbar with the same functionality, there will be some conflicts between the two, in order to resolve the conflict can rewrite the Onitemclick event of the tool bar
The toolbar is named Axtool
I am writing in the mouse click event of the map itself
The code is as follows:
Private voidAxmap_onmousedown (Objectsender, ESRI. ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)//Manipulating AE surfaces{Ienvelope penv; Axmap.mousepointer=Esricontrolsmousepointer.esripointercrosshair; Igeometry Geometry=NULL; ESRI. ArcGIS.Geometry.Point Point=NewESRI. ArcGIS.Geometry.PointClass (); Igraphicscontainer PGC= Axmap.activeview asIgraphicscontainer; AxMap.ActiveView.PartialRefresh (Esriviewdrawphase.esriviewgeography,NULL,NULL);//Refresh All Layers Switch(flag) { Case 1://Map ZoomPenv =Axmap.trackrectangle (); Penv.expand (0.5,0.5,true); Axmap.extent=penv; Break; Case 2://View Zoom outPenv =axmap.extent; Penv.expand (2,2,true); Axmap.extent=penv; Break; Case 3://View PanningAxmap.pan (); Break;}
To add an event for Axtool to resolve conflicts:
Private voidAxtool_onitemclick (Objectsender, Itoolbarcontrolevents_onitemclickevent e)//resolve the conflict after the toolbar is clicked and used by other tools { //First reset Map current toolFlag =-1;//Invalid setting current map ClickAxmap.currenttool =NULL;//set the current map tool to be empty intToolnum = E.index;//get the index of the Click Tool on the tool barICommand _command = AxTool.CommandPool.get_Command (toolnum);//get the Click Command based on the following flagAxmap.currenttool = _command asItool;//set the command for the current map for the command_command. OnClick ();//The response should be ordered}
This will resolve the conflict successfully.
Conflicts that are used by custom tools and self-contained toolbars (ICommand) in Arcengine and other tools