Overview of the mapinfo.tools namespace, Mapinfo.tools namespace, Overview – Pitney Bowes MapXtreme User Manual

Page 140: Of the mapinfo.tools namespace

Advertising
background image

Chapter 7: Desktop Applications, Controls, Dialogs, and Tools

Overview of the MapInfo.Tools Namespace

MapXtreme v7.1

140

Developer Guide

An example of customizing a dialog box is as follows: The LineStyleDlg class creates a Line Style
Dialog Box. This dialog box can be created in either a sparse style mode (where nothing is selected
when opened), or in a mode where some choices are visible but not enabled (grayed out).

The customization provided by setting property values is obviously limited to the specific dialog
object being modified. To create a new dialog box based upon a design of an established one is
done by adding some controls to a new form at design time. For example, to create a modified
LineStyle Dialog Box, you can drop a LineStyle Control on a new form and then add other controls to
that form, making, in effect, a modified LineStyle Dialog Box.

Overview of the MapInfo.Tools Namespace

MapTool Object Model

The MapTools are the objects you use to interact with the map. These tools implement the basic
behaviors you expect of a map. There are view-based tools, zooming and panning, tools for creating
geometries on a specific layers, and tools for generating selections based on an area of the map.
Each tool is customizable using events to capture pre- and post-process events.

Properties of the methods associated with the tools are on the tool and not the layer. For example,
the selectability of a layer is specified on the tool and not the layer. In this way, you can use one tool
to select an object on one layer and use another tool to select from a second layer. This gives much
more freedom in the tools but also enables you to emulate the properties on layers. The Layer
Control operates on the entire tools collection of the map, when selectability or other properties are
changed via its UI.

This design also allows you to create tools that insert into specific layers. For example, a city planner
may want the application to insert manholes on the water layer only, but to insert trees on the
vegetation layer. You could create a custom tool that when selected, inserts only the specified
symbol or geometry on the appropriate layer. This also works for the stock tools, so that drawing a
polygon will always be on the specified layer. Again the stock Layer Control manipulates the tools
collection to make it seem as if the insertion is on a single layer.

The MapInfo.Tools namespace contains all the classes that allow you to create basic and
customizable tools for your MapXtreme application.

You can customize new instances of these stock tools with event code, or write your own tool
classes that derive from stock tools but override specific methods. See

Customizing Tools on

page 154

.

Tools can be assigned to a particular mouse button (left, right, or middle). Use the following string
tool names for the appropriate mouse button property: "Arrow", "ZoomIn", "ZoomOut", "Center",
"Pan", "SelectPoint", "SelectRect", "SelectRadius", "SelectPolygon", "SelectRegion", "AddPoint",
"AddLine", "AddPolyline", "AddPolygon", "AddRectangle", "AddCircle", "AddEllipse", "AddText",
"Label".

For example, the code below sets the left mouse button to the ZoomIn tool:

mapControl1.Tools.LeftButtonTool = "ZoomIn"

Advertising