Table of Contents

Class MultipleChoiceProperty

Namespace
CADability.UserInterface
Assembly
CADability.dll

Property page entry which shows one text out of a fixed set of choices and lets the user pick another one from a drop down list. It is the base class of the attribute selection entries (ColorSelectionProperty, LayerSelectionProperty, LinePatternSelectionProperty etc.), of BooleanProperty and of MultipleChoiceSetting. A selection by the user is reported through SelectionChangedEvent and ValueChangedEvent; derived classes override OnSelectionChanged(string) to apply it to the object they represent.

public class MultipleChoiceProperty : PropertyEntryImpl, IPropertyEntry, IShowProperty
Inheritance
MultipleChoiceProperty
Implements
Derived
Inherited Members

Constructors

MultipleChoiceProperty()

Empty constructor for the use by derived classes. The derived class has to set at least propertyLabelText and choices.

public MultipleChoiceProperty()

MultipleChoiceProperty(string, int)

Creates the entry with the choices taken from the string table: the entry resourceId + ".Values" must contain all choices separated by its first character (see GetSplittedStrings(string)).

public MultipleChoiceProperty(string resourceId, int InitialSelection)

Parameters

resourceId string

Resource id of the label; resourceId + ".Values" provides the choices

InitialSelection int

Index of the initially selected choice; 0 is used when it is out of range

MultipleChoiceProperty(string, string[], string)

Constructor with initialization.

public MultipleChoiceProperty(string resourceId, string[] Choices, string InitialSelection)

Parameters

resourceId string

Resource id of the text displayed on the left side

Choices string[]

The choices

InitialSelection string

The initially selected text (one of the choices)

Fields

propertyLabelText

The text of the label (left side of the entry), set by some derived classes from their resource id. The label displayed by the property page is taken from the resource id, not from this field.

protected string propertyLabelText

Field Value

string

unselectedText

The text shown (in gray) when no choice is selected, see SetUnselectedText(string). null: the value is shown empty.

protected string unselectedText

Field Value

string

user

Back reference to any user item. Not used by the MultipleChoiceProperty object itself.

public object user

Field Value

object

An arbitrary object supplied by the user of this property entry, or null

Properties

Choices

The texts the user can choose from, in the order of the drop down list. Getting and setting work on a copy of the array; setting does not change the current selection.

public string[] Choices { get; set; }

Property Value

string[]

CurrentIndex

The index of SelectedText in Choices, or -1 when nothing is selected.

public int CurrentIndex { get; }

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

SelectedText

The currently selected choice, or null when nothing is selected.

public string SelectedText { get; protected set; }

Property Value

string

Value

Must be overridden, when Flags contains PropertyEntryType.ValueEditable

public override string Value { get; }

Property Value

string

Methods

ChoiceIndex(string)

Returns the index of the given text in Choices.

public int ChoiceIndex(string choice)

Parameters

choice string

The text to look for

Returns

int

The index, or -1 when the text is not one of the choices

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 virtual void OnSelectionChanged(string selected)

Parameters

selected string

The selected text

SetSelection(int)

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

public virtual void SetSelection(int toSelect)

Parameters

toSelect int

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

SetUnselectedText(string)

Sets the text which is shown (in gray) when nothing is selected, e.g. "multiple values" when the entry represents several objects with different attributes.

public void SetUnselectedText(string ResourceID)

Parameters

ResourceID string

Resource id of the text in the string table

Events

SelectionChangedEvent

Raised when the user picks a choice from the drop down list (or a derived class reports a new selection).

public event MultipleChoiceProperty.SelectionChangedDelegate SelectionChangedEvent

Event Type

MultipleChoiceProperty.SelectionChangedDelegate

ValueChangedEvent

Raised after SelectionChangedEvent, with the newly selected text as the value.

public event ValueChangedDelegate ValueChangedEvent

Event Type

ValueChangedDelegate