Table of Contents

Class Style

Namespace
CADability.Attribute
Assembly
CADability.dll

A Style is a collection of several attributes like Layer, LineWidth that can be collectively set to an GeoObject.

[ComVisible(true)]
[Guid("5FC3B97D-716E-496B-AAB6-2891ABF1F248")]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Style : PropertyEntryImpl, IPropertyEntry, IShowProperty, ICloneable, ISerializable, INamedAttribute, IColorDef, ILayer, ILineWidth, ILinePattern, IHatchStyle, IDimensionStyle, ICommandHandler, IJsonSerialize
Inheritance
Style
Implements
Inherited Members

Constructors

Style()

Creates a style without a name and without any attribute. Such a style changes nothing when applied; it is used by Clone() and by the deserialization. Use Style(string) or GetDefault() to create a usable style.

public Style()

Style(SerializationInfo, StreamingContext)

Constructor required by deserialization

protected Style(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Style(string)

Creates a style with the given name whose attributes are all null, i.e. applying it changes nothing until attributes like Layer or ColorDef are set.

public Style(string name)

Parameters

name string

the name of the style; must be unique in the StyleList it is added to

Properties

ColorDef

The colour this style applies (Apply(IGeoObject)) to objects that implement IColorDef, or null when the style leaves the colour of an object unchanged. Setting it notifies the containing StyleList and its owner (undo, modified flag); objects that already have this style are not changed.

public ColorDef ColorDef { get; set; }

Property Value

ColorDef

ContextMenu

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

public override MenuWithHandler[] ContextMenu { get; }

Property Value

MenuWithHandler[]

DefaultFor

The categories of objects (a combination of Style.EDefaultFor flags) for which this style is the default: SetDefaults(IGeoObject) applies the style that GetDefault(EDefaultFor) returns for the PreferredStyle of a new object. Setting it does not clear the same category on the other styles of the list; the context menu of the style in the control center does that.

public Style.EDefaultFor DefaultFor { get; set; }

Property Value

Style.EDefaultFor

DimensionStyle

The dimension style this style applies (Apply(IGeoObject)) to objects that implement IDimensionStyle, or null when the style leaves the dimension style of an object unchanged. Setting it notifies the containing StyleList and its owner (undo, modified flag); objects that already have this style are not changed.

public DimensionStyle DimensionStyle { get; set; }

Property Value

DimensionStyle

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

HatchStyle

The hatch style this style applies (Apply(IGeoObject)) to objects that implement IHatchStyle, or null when the style leaves the hatch style of an object unchanged. Setting it notifies the containing StyleList and its owner (undo, modified flag); objects that already have this style are not changed.

public HatchStyle HatchStyle { get; set; }

Property Value

HatchStyle

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

Layer

The layer this style applies (Apply(IGeoObject)) to an object, or null when the style leaves the layer of an object unchanged. Setting it notifies the containing StyleList and its owner (undo, modified flag); objects that already have this style are not changed.

public Layer Layer { get; set; }

Property Value

Layer

LinePattern

The line pattern this style applies (Apply(IGeoObject)) to objects that implement ILinePattern, or null when the style leaves the line pattern of an object unchanged. Setting it notifies the containing StyleList and its owner (undo, modified flag); objects that already have this style are not changed.

public LinePattern LinePattern { get; set; }

Property Value

LinePattern

LineWidth

The line width this style applies (Apply(IGeoObject)) to objects that implement ILineWidth, or null when the style leaves the line width of an object unchanged. Setting it notifies the containing StyleList and its owner (undo, modified flag); objects that already have this style are not changed.

public LineWidth LineWidth { get; set; }

Property Value

LineWidth

Name

The name of the Style. Different Styles in the same list must have different names.

public string Name { get; set; }

Property Value

string

Parent

The StyleList that contains this Style. May be null.

public StyleList Parent { get; set; }

Property Value

StyleList

SubItems

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

public override IPropertyEntry[] SubItems { get; }

Property Value

IPropertyEntry[]

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

Apply(IGeoObject)

Applies this style to the given GeoObject. Since the style knows better about the different kinds of interfaces and attributes, this is implemented in the Style class not in IGeoObjectImpl.

public void Apply(IGeoObject go)

Parameters

go IGeoObject

the GeoObject which is to be modified

Check(IGeoObject)

Checks whether the given GeoObject accords to this style

public bool Check(IGeoObject go)

Parameters

go IGeoObject

the GeoObject to check

Returns

bool

true, if all attributes are the same as given in the style

Clone()

Creates a copy of this style with the same name, the same DefaultFor categories and references to the same attribute objects (layer, colour, line width, line pattern, hatch style, dimension style). The copy is not contained in a StyleList.

public Style Clone()

Returns

Style

the copy

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

GetDefault()

Returns a default (empty) Style. Use this function if you need a Style and dont have access to a StyleList.

public static Style GetDefault()

Returns

Style

The default Stalye

GetObjectData(IJsonWriteData)

Writes the name, the attributes, the containing list and DefaultFor for the JSON serialization (IJsonSerialize). Attributes that are null are left out.

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

IsDefaultFor(EDefaultFor)

Checks whether this style is the default for at least one of the given categories.

public bool IsDefaultFor(Style.EDefaultFor toTest)

Parameters

toTest Style.EDefaultFor

the categories to test, several may be combined

Returns

bool

true when DefaultFor contains any of the categories

RemoveDefaultFor(EDefaultFor)

Removes the given categories from DefaultFor.

public void RemoveDefaultFor(Style.EDefaultFor toRemove)

Parameters

toRemove Style.EDefaultFor

the categories to remove

SetDefaultFor(EDefaultFor)

Adds the given categories to DefaultFor, keeping the ones already set.

public void SetDefaultFor(Style.EDefaultFor toSet)

Parameters

toSet Style.EDefaultFor

the categories to add

SetObjectData(IJsonReadData)

Reads the data written by GetObjectData(IJsonWriteData) for the JSON deserialization (IJsonSerialize). Attributes that were not written stay null.

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

provides the data