Mapinfo.windows.dialogs namespace – Pitney Bowes MapXtreme User Manual

Page 134

Advertising
background image

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

MapInfo.Windows.Dialogs Namespace

MapXtreme v7.1

134

Developer Guide

Customizing Context Menus

You can create customized context menu items for your Layer Control that appear when the user
right-clicks a node in the layer tree. Use the ContextMenuTargetObject property to return the object
that the user right-clicked.

A code sample has been provided that shows how to define a LayerControlEnhancer class that
allows a user to add custom items to the Layer Control's context menu. This example can be found
in the LayerControl sample application located in the
..\MapInfo\MapXtreme\7.x.x\Samples\Desktop\Features\LayerControl directory.

Keyboard Shortcut Programmability

You can create keyboard shortcuts to access everything on the LayerControl toolbar. The
PerformDown, PerformUp, and PerformRemove methods already provide programmatic access to
the Down, Up, and Remove buttons.

The AddMenuMnemonic property provides programmatic access to the key associated with
displaying the Add menu. The syntax for the AddMenuMnemonic property is:

public System.Windows.Forms.Keys AddMenuMnemonic {get; set;}

MapInfo.Windows.Dialogs Namespace

The MapInfo.Windows.Dialogs namespace contains classes that create dialog boxes with specific
functions. Contrary to controls, dialog boxes are not visible during design-time and can only be
created and configured in code. You can create your own customized dialog boxes using classes
from the MapInfo.Windows.Dialogs namespace and then utilize them by calling the
System.Windows.Forms.Form.ShowDialog() method.

The stock dialogs are built from the MapXtreme object model’s public API. There are no hidden
internal fields or anything private. You can use these dialogs or customize them for your needs, or
write your own from scratch. You may wish to provide fewer controls on a stock dialog so that your
users are restricted from changing some behavior.

To use a particular dialog box in your application, add the MapInfo.Windows.Dialogs namespace to
your code as follows:

using MapInfo.Windows.Dialogs

private void DoLayerControl()
{

LayerControlDlg layerControl = new LayerControlDlg();
layerControl.Map = mapControl1.Map;
layerControl.ShowDialog(this);

}

The code above displays the LayerControl dialog box when the DoLayerControl() method is called.

Advertising