Conflicts between custom tools and built-in tool bar (ICommand) in arcengine and use of other tools.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.