Control commands


The Control Commands are commands, tools, toolcontrols, toolsets, menus and palettes that work with the ArcGIS Engine Controls to perform some specific action. For example, there is a suite of map navigation, map inquiry, feature selection, graphic element, feature editing and ink commands that work with the MapControl and PageLayoutControl; a suite of globe commands that work with the GlobeControl; a suite of scene commands that work with the SceneControl; and a suite of network and schematics commands that work with the Network Analyst and Schematics extensions respectively. You can extend this suite of control commands by creating your own customized commands that perform some specific piece of work.
For a full list of the control commands, including a description of each, its associated GUID, the ArcGIS Engine Controls the command works with, and any extension required, see the article Built-in commands, menus, palettes, multi-items and toolsets.

Control Commands with the ToolbarControl

For applications using the ToolbarControl in conjunction with a buddy control, these commands can be added to the ToolbarControl in one of three ways:
  • Through the ToolbarControl property pages at design-time
  • Programmatically using the AddItem, AddMenuItem, and AddToolbarDef methods. The commands can be added to a ToolbarMenu using the AddItem and AddSubMenu methods, and the commands can be added to a ToolbarPalette using the AddItem method.
  • By the end user if the ToolbarControl is in customize mode.

Control Commands without the ToolbarControl

While building applications with the ToolbarControl can quickly provide pieces of a framework similar to the ArcGIS for Desktop application framework, there are times when the ToolbarControl is not required for an application: the visual appearance of the ToolbarControl may not match that of the application; the overhead of implementing Command objects for the ToolbarControl is not required; or there is an existing application framework present in the application.
The Control Commands can work directly with the MapControl, PageLayoutControl, GlobeControl and SceneControl by programmatically creating a new instance of a Command and passing either the MapControl, PageLayoutControl, GlobeControl and SceneControl to the ICommand::OnCreate method. The developer becomes responsible for calling ICommand::OnCreate and ICommand::OnClick methods at the appropriate times and reading properties on the ICommand interface to build up the user interface as follows:
  • A new instance of a Command is created programmatically and the individual ArcGIS Control is passed to the OnCreate event. For example, if the Zoom FullExtent command is to work with the MapControl, the MapControl must be passed as the hook to the OnCreate method.
  • A developer can use the CommandPool object without the ToolbarControl in order to manage the commands used by an application. The CommandPool will provide support for calling the OnCreate method of each command based on its Hook property.
  • If the command only implements the ICommand interface you can call the OnClick method at the appropriate time to perform the specific action. If the command is a tool that implements both the ICommand and ITool interfaces you must set the tool to be the CurrentTool in the ArcGIS Control. The ArcGIS Control will send any keyboard and mouse events to the tool.
  • A command’s Enabled, Caption, and Bitmap properties can be read and set into the properties of a command button supplied by the development environment to build up the user interface of the application.

Creating custom commands

To extend the suite of control commands, you can create custom commands, tools, menus and palettes to work with the ArcGIS Engine Controls. The HookHelper, GlobeHookHelper and SceneHookHelper objects can be used to simplify this development. The HookHelper object makes it straightforward to create a command that works with the MapControl, PageLayoutControl, ToolbarControl, and the ArcMap application; the GlobeHookHelper to create a command that works with the GlobeControl, ToolbarControl, and the ArcGlobe application; and the SceneHookHelper to create a command that works with the SceneControl, ToolbarControl, and the ArcScene application.
Rather than adding code into an ICommand::OnCreate method to determine the type of hook passed to the command, the HookHelper, GlobeHookHelper and SceneHookHelper objects handles this.
  • The HookHelper object is used to hold onto the hook and the IHookHelper interface it implements can return the ActiveView, PageLayout, and Map regardless of the type of hook that is passed.
  • The GlobeHookHelper object is used to hold onto the hook and the IGlobeHookHelper interface it implements can return the Camera, Globe, GlobeDisplay and ActiveViewer regardless of the type of hook that is passed.
  • The SceneHookHelper object is used to hold onto the hook and the ISceneHookHelper interface it implements can return the SceneViewer, Scene, SceneGraph and Camera regardless of the type of hook that is passed.
When a change is made to the HookHelper, GlobeHookHelper and SceneHookHelper objects the IHookHelperEvents::OnHookUpdated event is fired. For example, the event is fired in repsonse to the IToolbarControlEvents::OnBuddyChanged event and the IPageLayoutControlEvents::OnPageLayoutReplaced event. Use the event to re-synch any member variables storing IHookHelper, IGlobeHookHelper, and ISceneHookHelper properties, and to re-synch any event listeners such as IActiveViewEvents.
The HookHelper and GlobeHookHelper both implement the IHookActions interface, which provides methods to flash, pan or zoom, and create graphics, labels and callouts on the specified IPoint, IEnvelope, IPolyline and IPolygon objects. For example, the DoActionOnMultiple method could be used to zoom to the extent of the selected features in the Map.

Singleton Objects

The are several singleton objects that only support one instance of the object per process that are used by the Control Commands. You can make use of these objects in your own custom commands too.
  • The CommandEnvironment object implements the IGraphicProperties and ILayerEffectProperties interfaces. The members of IGraphicProperties manage the default MarkerSymbol, LineSymbol and FillSymbol used by the Control Commands.
  • The EngineEditor object implements the IEngineEditProperties, IEngineEditProperties2 and IEngineSnapEnvironment interfaces. The members of these interfaces manage the properties of edit sessions and snap agents.
  • The EngineInkEnvironment object implements the IEngineInkEnvironment and IEngineInkEnvironmentEvents interfaces. The members of these interfaces manage the ink collection and tablet properties.
  • The EngineNetworkAnalystEnvironment object implements the IEngineNetworkAnalystEnvironment, IEngineNetworkAnalystEnvironmentEvents and IEngineNetworkAnalystHelper interfaces. The members of these interfaces manage the collection of network layers, the current network layer, solving and getting directions.
  • The MyPlaceCollection object implements the IEnumPlace and IPlaceCollection interfaces. The members of these interfaces manage the addition and removal of Place objects to the place collection.