Table of Contents

Class LineWidth

Namespace
CADability.Attribute
Assembly
CADability.dll

Describes a line width. The "onedimensional" GeoObjects (e.g. Line, Ellipse, BSpline) have a line with as an attribute. The main propertie of the line width are the width and the scaling system (LineWidth.Scaling), which defines how to interpret the width.

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

Constructors

LineWidth()

Creates an empty and unnamed LineWidth

public LineWidth()

LineWidth(SerializationInfo, StreamingContext)

Constructor required by deserialization

protected LineWidth(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

LineWidth(string, double)

Creates a line width with the given name and width. The Scale is Device (the default value of the enumeration); set it explicitly when the width is meant in world or layout units. The object does not belong to a list yet, see Add(LineWidth).

public LineWidth(string name, double width)

Parameters

name string

the name, unique within the LineWidthList it is added to

width double

the width, interpreted according to Scale

Fields

ThinLine

A line width of 0, which is the thinnest line the output device can draw (one pixel on the screen, 0.1 mm when printed). It is a shared instance without a name that does not belong to any list; CADability itself no longer uses it.

public static LineWidth ThinLine

Field Value

LineWidth

Properties

ContextMenu

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

public override MenuWithHandler[] ContextMenu { get; }

Property Value

MenuWithHandler[]

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; set; }

Property Value

string

Name

The name of the line width, unique within its LineWidthList and shown in the control center. Setting a name that is already used by another entry of the list throws a NameAlreadyExistsException; otherwise 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

Parent

The LineWidthList this line width belongs to, or null (Parent). It is set by the list when the line width is added or removed; the line width forwards its changes to it. Hides Parent, the parent of the entry in the control center.

public IAttributeList Parent { get; set; }

Property Value

IAttributeList

Scale

Gets or sets the LineWidth.Scaling of this LineWidth.

public LineWidth.Scaling Scale { get; set; }

Property Value

LineWidth.Scaling

SubItems

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

public override IPropertyEntry[] SubItems { get; }

Property Value

IPropertyEntry[]

Width

Gets or sets the line width of this object.

public double Width { get; set; }

Property Value

double

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 pp)

Parameters

pp IPropertyPage

the property page the entry was added to

Clone()

Returns a clone of this LineWidth

public LineWidth Clone()

Returns

LineWidth

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, width and scaling of this line width 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

Read(string, SerializationInfo, StreamingContext)

Reads the LineWidth stored under the given name from the legacy binary serialization data (ISerializable). For use in the deserialization constructors of objects that have a line width; missing or incompatible entries yield null instead of an exception, so that older files can be read.

public static LineWidth Read(string name, SerializationInfo info, StreamingContext context)

Parameters

name string

the name the LineWidth was stored under

info SerializationInfo

the serialization data

context StreamingContext

the source of the serialization

Returns

LineWidth

the LineWidth, or null when there is no entry with that name or it is not a LineWidth

Removed(IPropertyPage)

Implementation of Removed(IPropertyPage): closes the undo context of the project (an edit may have been interrupted by removing the entry), reports Removed and forgets the page. Override it to unsubscribe from events, and call the base implementation.

public override void Removed(IPropertyPage pp)

Parameters

pp IPropertyPage

the property page the entry was removed from

SetObjectData(IJsonReadData)

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

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

the data to read from