Layer Routines LayerAction Property            Table of Contents

Layers Overview


 

This page discusses the following topics:

Layer Defined
Layer Attributes
Information Returned by a Layer
Opening and Closing Layers
The Buffer Layer
 

 

Layer Defined

The control is made up of one or more drawing layers. A layer is what shapes are drawn on, and has several attributes. Only one layer is the current drawing layer at any time. When the control is first initialized at run-time, two layers are opened, the Buffer Layer and Layer 1. More will be said about the buffer layer later on.

Layers are the same as the control view. Layers are transparently stacked on top of one another, with shapes in the bottommost layer drawn first, and the topmost layer (highest in number) drawn last.

The idea behind multiple layers is that shapes with similar meaning and attributes can be kept on the same layer. Then that layer can be manipulated without affecting shapes on other layers.

For instance, say we had one layer with rectangles, another with circles, and a third with triangles. Looking at each layer separately:



Layer 1 images/layer1.gif Layer 2 images/layer2.gif Layer 3 images/layer3.gif

 


When viewed on the control, it would look like this, with the bottommost layer drawn first:

images/layers_all.gif
 

 

Layer Attributes

Name and Number
A layer has a string (LayerName) and number (LayerNumber) associated with it. LayerNumber reflects the current drawing layer, and can be used in calls to methods and when referencing properties. LayerName can be used as an identifier, as well as to return the LayerNumber it represents with LayerFindByName.

Colors
A layer has a color state, with pen and brush settings. When shapes are added to a layer, they take on the layer's color state if there is no cad level color state. The initial setting is a solid black pen with a transparent brush.

Below we see two layers with their own color states. The first has a green fill with diagonal lines, the second has a blue fill with horizontal lines. Notice that the blue shapes are 'on top of' the green shapes, because the drawing order is from the smallest layer number to the largest.

images/twolayers.gif

Action
A layer has a LayerAction property that defines how shapes on that layer interact with the control. LayerAction sets whether or not shapes can be found with the mouse, moved, or displayed at all.

Search Method
Shapes can be selected by the mouse depending on the search method. By default, most shapes are set so that they can only be selected by clicking their border. This can be changed so that clicking the inside of the shape will select it. The property for doing this is called LayerSearchMethod. Note that changing this property only affects shapes drawn after the change.
 

 

Information Returned by a Layer

The number of shapes on a layer is returned by LayerShapeCount.

The numbers of the shapes on a layer can be returned in an array via LayerShapeNumbers.

 


Opening and Closing Layers

A layer is opened with the LayerOpen method. When a layer is opened, it becomes the current drawing layer.

A layer is closed with the LayerClose method. Closing a layer completely deletes all shapes on the layer. Closing a layer also affects any existing layer numbers. If existing layer numbers are higher than the one deleted, then they are changed to be one less than before. For instance, if we had five layers numbered 0 through 4, and layer 2 was deleted, layers 3 and 4 would be renumbered to 2 and 3, respectively. Use LayerFindByName when necessary to find a layer's number with respect to its name.

 

 

The Buffer Layer

The buffer layer is provided as a means for hiding shapes in the control. It always has a LayerNumber of 0, with a LayerName of "Buffer Layer". The buffer layer cannot be deleted. Its LayerAction property is set so that shapes on it are not shown.

Some uses for this layer are:

 

 

See Also

Layer Routines



Layer Routines LayerAction Property

 

Last modified on: Tuesday, February 04, 2003