Table of Contents

Class Layer

Namespace
CADability.Attribute
Assembly
CADability.dll

A Layer is an attribute to IGeoObject objects. With several layers you can group the GeoObjects in a Model. In a ModelView you can select which layers are visible. In a Filter you can select which layers are be pickable The property DisplayOrder affects the order of display or printing if the according feature is enabled in a ModelView or Layout. Layer implements the IShowProperty interface to present ist properties.

public class Layer : PropertyEntryImpl, IPropertyEntry, IShowProperty, ISerializable, INamedAttribute, ICommandHandler, IJsonSerialize
Inheritance
Layer
Implements
Inherited Members

Constructors

Layer()

Creates a layer without a name, with DisplayOrder and Transparency set to 0. Used by the JSON deserialization and by Clone(); set Name before adding the layer to a LayerList.

public Layer()

Layer(SerializationInfo, StreamingContext)

Constructor required by deserialization

protected Layer(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Layer(string)

Creates a layer with the given name. The layer does not belong to a list yet; add it to the LayerList of the project (or use CreateOrFind(string)) before assigning it to objects.

public Layer(string Name)

Parameters

Name string

the name of the layer, must be unique within the list it is added to

Fields

LayerComparer

A shared instance of LayerComparer, which compares layers by name only.

public static LayerComparer LayerComparer

Field Value

LayerComparer

Properties

ContextMenu

Must be overridden, when Flags contains PropertyEntryType.ContextMenu. See ContextMenu

public override MenuWithHandler[] ContextMenu { get; }

Property Value

MenuWithHandler[]

DisplayOrder

The z-index of the layer: when a view or a print-out is set to use the display order (e.g. UseDisplayOrder), the objects are painted in ascending order of the display order of their layers, so objects on a layer with a higher value cover objects on a layer with a lower value. Layers without special needs keep the default 0. Setting the value does not raise change notifications.

public int DisplayOrder { get; set; }

Property Value

int

Flags

Implementation of Flags: the derived class states what the entry is and what the user can do with it. The flags must match the overridden members, e.g. HasSubEntries requires SubItems, ValueEditable requires Value and EndEdit(bool, bool, string), DropDown requires GetDropDownList() and ListBoxSelected(int).

public override PropertyEntryType Flags { get; }

Property Value

PropertyEntryType

LabelText

An explicit label text. When set (not null) it is shown instead of the text from the StringTable; use it for entries whose label is not a fixed resource string, e.g. the name of an item. Call Refresh() after changing it while the entry is displayed.

public override string LabelText { get; }

Property Value

string

Name

The name of the layer, which identifies it within its LayerList and is shown in the control center. Setting a name that is already used by another layer of the list throws a NameAlreadyExistsException. Otherwise the list is re-sorted and the change is forwarded to the owner of the list (the project), which records it for undo.

public string Name { get; set; }

Property Value

string

SubItems

Must be overridden, when Flags contains PropertyEntryType.HasSubEntries. See SubItems

public override IPropertyEntry[] SubItems { get; }

Property Value

IPropertyEntry[]

Transparency

Gets or sets the transparency of this layer: 0 is not transparent, 255 is totally transparent

public int Transparency { get; set; }

Property Value

int

Methods

Added(IPropertyPage)

Implementation of Added(IPropertyPage): memorizes the page in propertyPage and reports Added. Override it to subscribe to events while the entry is displayed, and call the base implementation.

public override void Added(IPropertyPage propertyPage)

Parameters

propertyPage IPropertyPage

Clone()

Creates a copy of this layer with the same name, DisplayOrder and Transparency. The copy does not belong to any LayerList.

public Layer Clone()

Returns

Layer

the copy

EditTextChanged(string)

May be overridden when Flags contains PropertyEntryType.ValueEditable. See EditTextChanged(string),

public override bool EditTextChanged(string newValue)

Parameters

newValue string

Returns

bool

EndEdit(bool, bool, string)

Must be overridden when Flags contains PropertyEntryType.ValueEditable. See EndEdit(bool, bool, string)

public override void EndEdit(bool aborted, bool modified, string newValue)

Parameters

aborted bool
modified bool
newValue string

GetObjectData(IJsonWriteData)

Writes the name, display order and transparency of this layer for the JSON serialization (IJsonSerialize).

public void GetObjectData(IJsonWriteData data)

Parameters

data IJsonWriteData

receives the data

GetObjectData(SerializationInfo, StreamingContext)

Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.

public void GetObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

receives the data

context StreamingContext

the destination of the serialization

SetObjectData(IJsonReadData)

Restores this layer from the JSON data written by GetObjectData(IJsonWriteData) (IJsonSerialize).

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

the data to read from