Conflicts between custom tools and built-in tool bar (ICommand) in arcengine and use of other tools.
In your system, the zoom-in and zoom-out functions are directly rewritten. However, if you add a toolbar with the same function, there will be some conflicts between the two, to solve this conflict, You can override the OnItemClick event of the toolbar.
This toolbar is named axTool.
I wrote it in the map mouse click event.
The Code is as follows:
Private void axMap_OnMouseDown (object sender, ESRI. arcGIS. controls. IMapControlEvents2_OnMouseDownEvent e) // manipulate the AE drawing {IEnvelope pEnv; axMap. mousePointer = esriControlsMousePointer. esriPointerCrosshair; IGeometry geometry = null; ESRI. arcGIS. geometry. point point = new ESRI. arcGIS. geometry. pointClass (); IGraphicsContainer pGC = axMap. activeView as IGraphicsContainer; axMap. activeView. partialRefresh (esriViewDrawPhase. esriViewGeography, null, null); // refresh all layers switch (flag) {case 1: // map zoom in pEnv = axMap. trackRectangle (); pEnv. expand (0.5, 0.5, true); axMap. extent = pEnv; break; case 2: // view zoom out pEnv = axMap. extent; pEnv. expand (2, 2, true); axMap. extent = pEnv; break; case 3: // view translation axMap. pan (); break ;}
Add an event for axTool to resolve the conflict:
Private void axTool_OnItemClick (object sender, IToolbarControlEvents_OnItemClickEvent e) // solves conflicts with other tools after the toolbar is clicked {// reset the current map tool flag =-1 first; // set the current map and click "invalid axMap. currentTool = null; // set the current map tool to null int toolnum = e. index; // obtain the index ICommand _ command = axTool. commandPool. get_Command (toolnum); // obtain the command axMap according to the flag. currentTool = _ command as ITool; // set the current map command to this command _ command. onClick (); // response to this command}
In this way, the conflict can be solved successfully.