Windows.controls – Pitney Bowes MapXtreme User Manual

Page 474

Advertising
background image

Appendix B: Customizing MapXtreme

Customizable Classes

MapXtreme v7.1

481

Developer Guide

public MyUserDrawLayer(string Name, string Alias) : base(Name, Alias)
{}

// Override the abstract Draw method to draw a rectangle.
public override void Draw(System.Drawing.Rectangle ClientRect,
System.Drawing.Rectangle
UpdateRect, Graphics graphics) {
// Create a pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create location and size of rectangle.
float x = 10.0F;
float y = 10.0F;
float width = 200.0F;
float height = 200.0F;
// Draw rectangle to screen.
graphics.DrawRectangle(blackPen, x, y, width, height);
}
}

A VB UserDrawLayer sample application is provided with MapXtreme in the
..\MapInfo\MapXtreme\7.x.x\Samples\Desktop\Features folder.

Windows.Controls

Many of the classes in the Windows.Controls namespace can be sub-classed to implement custom
behavior. Below are two examples of customizing the LayerControl using this approach.

MapInfo.Windows.Controls.PropertiesUserControl

If you want to add your own custom tabs to the LayerControl, create a class that subclasses
PropertiesUserControl. Then add your class to the collection of other tab classes by calling the
LayerControl's GetLayerTypeControls() and SetLayerTypeControls() methods. For an example of
how this works, refer to the sample application included in your Samples\Features directory of your
MapXtreme installation. Look in the MapBackgroundControl.cs file in the LayerControl sample
application for the class MapBackgroundControl which subclasses PropertiesUserControl.

MapInfo.Windows.Controls.LayerNodeHelper and all of its subclasses

LayerNodeHelper classes control the appearance and behavior of nodes in the LayerControl's layer
tree. For example, these helper classes dictate which layers the user is allowed to remove. If the
properties of the ILayerNodeHelper interface do not give you enough control over the appearance or
behavior of layer nodes—for example, if you want to apply per-table logic, where the user is allowed
to remove some map layers, but not others—you can subclass any of these helper classes, override
the appropriate method, and perform your per-layer logic in your overridden method. Then put your
new helper class to use by calling the LayerControl.SetLayerTypeHelper method.

By default, when the user removes a GroupLayer, a confirmation dialog appears, except in cases
when the GroupLayer is completely empty—in that case, the empty GroupLayer is simply removed
with no confirmation prompt (LabelLayers work similarly). To force the Layer Control to always

Advertising