Table of Contents

Class ColorSelectionProperty

Namespace
CADability.UserInterface
Assembly
CADability.dll

Property page entry to choose a ColorDef from a ColorList in a drop down list which shows a color box next to each name. It either controls the color of an IColorDef object (the object is updated when the selection changes and the entry follows changes of the object), accesses a ColorDef property of an arbitrary object via reflection, or only reports the selection via ColorDefChangedEvent. The ColorList.StaticFlags decide whether an "undefined" entry and the colors "from parent" and "from style" are offered.

public class ColorSelectionProperty : MultipleChoiceProperty, IPropertyEntry, IShowProperty
Inheritance
ColorSelectionProperty
Implements
Inherited Members

Constructors

ColorSelectionProperty(IColorDef, string, ColorList, StaticFlags)

Creates an entry which controls the color of iColorDef. The current color of the object is preselected; if the object is an IGeoObject, the entry follows changes of its color.

public ColorSelectionProperty(IColorDef iColorDef, string resourceId, ColorList clrTable, ColorList.StaticFlags flags)

Parameters

iColorDef IColorDef

The object whose color is edited

resourceId string

Resource id of the label text

clrTable ColorList

The list providing the choices

flags ColorList.StaticFlags

Which special colors are offered, see ColorList.StaticFlags

ColorSelectionProperty(object, string, string, ColorList, StaticFlags)

Creates an entry which edits a property of type ColorDef of an arbitrary object via reflection. The current value of the property is preselected; if the object is an IGeoObject, the entry follows changes of its color.

public ColorSelectionProperty(object go, string propertyName, string resourceId, ColorList clrTable, ColorList.StaticFlags flags)

Parameters

go object

The object holding the property

propertyName string

Name of the ColorDef property of that object

resourceId string

Resource id of the label text

clrTable ColorList

The list providing the choices

flags ColorList.StaticFlags

Which special colors are offered, see ColorList.StaticFlags

ColorSelectionProperty(string, ColorList, ColorDef, StaticFlags)

Creates an entry which is not connected to an object: the selection is reported via ColorDefChangedEvent.

public ColorSelectionProperty(string resourceId, ColorList clrTable, ColorDef select, ColorList.StaticFlags flags)

Parameters

resourceId string

Resource id of the label text

clrTable ColorList

The list providing the choices

select ColorDef

The initially selected color, or null for "undefined"

flags ColorList.StaticFlags

Which special colors are offered, see ColorList.StaticFlags

Properties

Connected

The IGeoObject whose color is controlled by this entry. Setting it connects the entry to the new object (which must implement IColorDef): its color is changed when the user selects an entry, and the entry is refreshed when the color of the object changes.

public IGeoObject Connected { get; set; }

Property Value

IGeoObject

ShowAllowUndefinedGray

Whether the "undefined" entry should be displayed in gray. The value is only stored; the current implementation does not evaluate it.

public bool ShowAllowUndefinedGray { get; set; }

Property Value

bool

Value

Must be overridden, when Flags contains PropertyEntryType.ValueEditable

public override string Value { get; }

Property Value

string

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

GetDropDownList()

Must be overridden when Flags contains PropertyEntryType.DropDown, See GetDropDownList()

public override string[] GetDropDownList()

Returns

string[]

ListBoxSelected(int)

Must be overridden when Flags contains PropertyEntryType.DropDown

public override void ListBoxSelected(int selectedIndex)

Parameters

selectedIndex int

OnSelectionChanged(string)

Called when the user has picked a choice. Raises SelectionChangedEvent, stores the text in SelectedText and raises ValueChangedEvent. Derived classes override it to pass the selection on to the object they represent.

protected override void OnSelectionChanged(string selected)

Parameters

selected string

The selected text

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

Parameters

propertyTreeView IPropertyPage

SetSelection(int)

Sets the current selection by index without raising the events. Used to synchronize the entry with the object it represents.

public override void SetSelection(int toSelect)

Parameters

toSelect int

Index into Choices; a negative or invalid index clears the selection

Events

ColorDefChangedEvent

Raised when the user selects a color and the entry is neither connected to an IColorDef object nor to a property via reflection.

public event ColorSelectionProperty.ColorDefChangedDelegate ColorDefChangedEvent

Event Type

ColorSelectionProperty.ColorDefChangedDelegate