Class StyleList
- Namespace
- CADability.Attribute
- Assembly
- CADability.dll
List of Style objects. The Project and the Settings each own one (StyleList, StyleList); the list of the project is shown in the control center, where styles can be added, renamed and marked as the default for a kind of object. The names of the styles are unique within the list and the entries are ordered alphabetically.
public class StyleList : PropertyEntryImpl, IPropertyEntry, IShowProperty, ICloneable, ISerializable, IAttributeList, ICommandHandler, IDeserializationCallback, IJsonSerialize, IJsonSerializeDone
- Inheritance
-
StyleList
- Implements
- Inherited Members
Constructors
StyleList()
Creates an empty style list that is not owned by a project or the settings.
public StyleList()
StyleList(SerializationInfo, StreamingContext)
Constructor required by deserialization
protected StyleList(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerializationInfo
contextStreamingContextStreamingContext
Fields
styles
The entries, keyed by name and ordered alphabetically. Internal state of the list.
protected SortedList styles
Field Value
Properties
ColorList
public ColorList ColorList { get; }
Property Value
ContextMenu
Must be overridden, when Flags contains PropertyEntryType.ContextMenu. See ContextMenu
public override MenuWithHandler[] ContextMenu { get; }
Property Value
Current
The current style of the list, shown in bold in the control center. The construct actions set it to the style the user chooses for the object under construction, and objects dropped into a view that carry the internal edge style get it. Setting a style whose name is not in the list adds it; setting null throws.
public Style Current { get; set; }
Property Value
DimensionStyleList
The DimensionStyleList of the Owner, or null when the list has no owner.
public DimensionStyleList DimensionStyleList { get; }
Property Value
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
HatchStyleList
The HatchStyleList of the Owner, or null when the list has no owner.
public HatchStyleList HatchStyleList { get; }
Property Value
LayerList
public LayerList LayerList { get; }
Property Value
Names
The names of all styles in the list in alphabetical order. The selection properties use them as choices.
public string[] Names { get; }
Property Value
- string[]
Owner
The Project or Settings that holds this list, or null. The container sets it when the list is added. The styles resolve their attributes in the lists of the owner, changes of a style are reported to it and it is asked before a style is removed (RemovingItem(IAttributeList, INamedAttribute, string)).
public IAttributeListContainer Owner { get; set; }
Property Value
SubItems
Must be overridden, when Flags contains PropertyEntryType.HasSubEntries. See SubItems
public override IPropertyEntry[] SubItems { get; }
Property Value
Methods
Add(Style)
Adds a style to the list and makes this list its Parent. The first style added becomes the Current one. Throws an ArgumentException when a style with the same name is already in the list. The control center is not refreshed.
public void Add(Style ToAdd)
Parameters
Clone()
public StyleList Clone()
Returns
Find(string)
public Style Find(string Name)
Parameters
Namestring
Returns
FindIndex(Style)
Returns the index of the style with the name of the given style in the alphabetical order of the list, as used by the property entries of the control center.
public int FindIndex(Style style)
Parameters
styleStylethe style to look for; only its name is compared
Returns
- int
the index, or -1 when no style with that name is in the list
GetDefault(IAttributeListContainer)
Creates a style list from the "StyleList.Default" entry of the string table, which (in the English version) defines the styles "2D", "3D", "Text" and "Dimension" by the names of a layer, a colour, a line width and a line pattern. These are looked up in the lists of the container, a name without a match gives a null attribute. The four styles become the defaults for Curves, Solids, Text and Dimension in this order. Used when neither the project nor the global settings provide a style list.
public static StyleList GetDefault(IAttributeListContainer container)
Parameters
containerIAttributeListContainerprovides the layer, colour, line width and line pattern lists
Returns
- StyleList
the default style list, not yet owned by the container
GetDefault(EDefaultFor)
Returns the style that is the default for the given category of objects (see DefaultFor). SetDefaults(IGeoObject) uses it with the PreferredStyle of a new object.
public Style GetDefault(Style.EDefaultFor defaultFor)
Parameters
defaultForStyle.EDefaultForthe category; when several are combined, the first style that is default for any of them is returned
Returns
- Style
the default style, or null when no style is marked as default for the category
GetObjectData(IJsonWriteData)
Writes the styles and the Current style for the JSON serialization (IJsonSerialize).
public void GetObjectData(IJsonWriteData data)
Parameters
dataIJsonWriteDatareceives 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
infoSerializationInforeceives the data
contextStreamingContextthe destination of the serialization
Remove(Style)
Removes a style from the list and refreshes the control center. Before removing, the Owner is asked (RemovingItem(IAttributeList, INamedAttribute, string)): it refuses to remove the last style and lets the user confirm when the style is still used by objects. Does nothing when the style is not in the list.
public void Remove(Style toRemove)
Parameters
toRemoveStylethe style to remove
SetObjectData(IJsonReadData)
Reads the data written by GetObjectData(IJsonWriteData) for the JSON deserialization (IJsonSerialize). The styles are sorted into the list and connected to it when all objects have been read (IJsonSerializeDone).
public void SetObjectData(IJsonReadData data)
Parameters
dataIJsonReadDataprovides the data