18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH THE ARCGIS CONTROLS<br />

another ToolbarMenu as a submenu, or appear as a popup menu and be<br />

used for a right-click context menu. Refer to the ‘Building applications’<br />

scenarios in Chapter 6, ‘<strong>Developer</strong> scenarios’, to see how to build a<br />

popup menu hosting some control commands that work with the<br />

PageLayoutControl.<br />

Hosting theToolbarMenu as a submenu<br />

Hosting the ToolbarMenu as a popup<br />

CommandPool<br />

Each ToolbarControl and ToolbarMenu has a CommandPool that is used to<br />

manage the collection of Command objects that it is using. Normally, you<br />

will not interact with the CommandPool. When a command is added to<br />

the ToolbarControl either through the property pages of the ToolbarControl<br />

or programmatically, the command is automatically added to the<br />

CommandPool. Command objects are added to the CommandPool either as a<br />

UID object that uniquely identifies the command—using a GUID—or<br />

as an existing instance of a Command object.<br />

If an existing instance of a Command object is added, there is no unique<br />

identifier for the command, and multiple instances of the same command<br />

can exist in the CommandPool. If a UID object is supplied, the<br />

CommandPool can identify whether the command already exists in the<br />

CommandPool and, if so, can reuse the previous instance of the command.<br />

The CommandPool manages this by tracking whether the OnCreate method<br />

of a command has been called. If the OnCreate method has been called,<br />

it will reuse the command and increment its UsageCount.<br />

For example, if a Zoom In tool is added to a ToolbarControl twice, with<br />

the UID supplied, when one of the Zoom In items on the ToolbarControl<br />

is selected and appears “pressed”, the other Zoom In item will also<br />

appear pressed because they are both using the same Command object.<br />

When an application contains multiple ToolbarControls or ToolbarMenus,<br />

you should ensure each ToolbarControl and ToolbarMenu uses the same<br />

CommandPool so only one instance of a command is created in the application.<br />

Customize<br />

The ToolbarControl has a Customize property that can be set to put the<br />

ToolbarControl into customize mode. This changes the behavior of the<br />

ToolbarControl and allows the end user to rearrange, remove, and add items as well<br />

as change their appearance.<br />

• Use the left mouse button to select an item on the ToolbarControl, then either<br />

drag the selected item to a new position or drag and drop the item off the<br />

ToolbarControl to remove it.<br />

• Right-click to select an item and display a customize menu. The customize<br />

menu can be used to remove the item or change the Style (bitmap, caption, or<br />

both) and Grouping of the ToolbarItem.<br />

While the ToolbarControl is in customize mode, you can programmatically launch<br />

the modeless CustomizeDialog. The CustomizeDialog lists all of the control<br />

commands, together with any custom commands, toolsets, and menus. It does<br />

this by reading entries from the ESRI Controls Commands, ESRI Controls<br />

Chapter 3 • Developing with <strong>ArcGIS</strong> controls • 53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!