Add tools, Custom tools, Add tools custom tools – Pitney Bowes MapXtreme User Manual
Page 143

Chapter 7: Desktop Applications, Controls, Dialogs, and Tools
MapXtreme Desktop Tools API
MapXtreme v7.1
143
Developer Guide
Dynamic Selection shows what objects can be in the selection as the mouse is being moved when
using the SelectRectMapTool, SelectRadiusMapTool, and the SelectPolygonMapTool.
The selection map tools have properties to set various options, including which layers are
selectable. These default tool properties can be set on the MapTools collection which can be found
in MapInfo.Windows.Controls.MapControl.Tools. Optionally, each tool can set its own overriding
properties and specify to use the default value on the MapTools collection or its overriding value.
To set the default list of selectable layers, create an IMapLayerFilter which specifies which layers are
selectable. Then set the default property on the MapTools for the SelectableLayerFilter.
For example, to set the default list of selectable layers to work on all vector layers:
// select from all vector layers
IMapLayerFilter selectableLayerFilter =
MapLayerFilterFactory.FilterAnd(MapLayerFilterFactory.FilterVisibleLayers
(true), MapLayerFilterFactory.FilterByLayerType(LayerType.Normal));
mapControl1.Tools.SelectMapToolProperties.SelectableLayerFilter =
selectableLayerFilter;
For more information on Select tool properties see
MapInfo.Tools.MapTool.ISelectMapToolProperties in the MapXtreme Developer Reference.
Add Tools
The Add family of tools (AddArcMapTool, AddCircleMapTool, AddEllipseMapTool, AddLineMapTool,
AddPointMapTool, AddPolygonMapTool, AddPolylineMapTool, and AddRectangleMapTool) are all
based on the AddMapTool class. The Add tools allows you to draw a particular geometric object on
your map. In order to add an object to a map, you must have an active insertion layer in your map
where the object resides after it is created. The size and shape of the particular object depends on
the tool used and can be constrained through the use of the modifier keys (Shift and Ctrl) while the
tool is being used.
For more information on Add tool properties see MapInfo.Tools.MapTool.IAddMapToolProperties in
the MapXtreme Developer Reference Help.
Custom Tools
The Custom tools (CustomArcMapTool, CustomCircleMapTool, CustomEllipseMapTool,
CustomLineMapTool, CustomPointMapTool, CustomPolygonMapTool, CustomPolylineMapTool, and
CustomRectangleMapTool) are very basic tools that only fire events. Use these classes to design
custom behaviors for specific tools. For example, you can use the CustomEllipseMapTool to draw
green Ellipses with a red outline every time the tools is used. Use the various tool events (see
Tool
Events on page 155
) to specify particular behaviors to respond to specific events generated by the
tools.
Custom tools are not included in the default tools collection. If you wish to assign a custom tool to a
mouse button, you may provide any string you wish to identify the tool.
For more on customizing tools, see
Customizing Tools on page 154
.