Class PropertyEntryImpl
- Namespace
- CADability.UserInterface
- Assembly
- CADability.dll
The base class for entries of the property page (IPropertyEntry): it keeps the property page, the parent, the index and the open state of the entry, raises PropertyEntryChangedStateEvent and provides a default (mostly empty or throwing) implementation of the notifications. A derived class provides Flags and a label (LabelText or a resource id) and overrides what its flags announce: Value and the edit methods for an editable value, SubItems for sub entries, ContextMenu, GetDropDownList() and so on. The entries of CADability (e.g. GeoPointProperty, MultipleChoiceProperty, ShowPropertyGroup) derive from it. It replaces the older IShowPropertyImpl and implements IShowProperty only as far as the property page still needs it.
public abstract class PropertyEntryImpl : IPropertyEntry, IShowProperty
- Inheritance
-
PropertyEntryImpl
- Implements
- Derived
- Inherited Members
Constructors
PropertyEntryImpl()
Creates the entry without a frame and without a resource id; the derived class sets resourceIdInternal or LabelText itself.
public PropertyEntryImpl()
PropertyEntryImpl(IFrame)
Creates the entry with the frame it belongs to, which Frame returns even while the entry is not shown in a property page.
public PropertyEntryImpl(IFrame Frame)
Parameters
FrameIFramethe frame
PropertyEntryImpl(string)
Provides the resource id for the label text
public PropertyEntryImpl(string resourceId)
Parameters
resourceIdstring
Fields
propertyPage
The property page the entry is currently shown in, set by Added(IPropertyPage) and cleared by Removed(IPropertyPage). Null while the entry is not shown.
protected IPropertyPage propertyPage
Field Value
resourceIdInternal
The resource id of the entry: Label looks it up in the StringTable when no LabelText is set, and ResourceId returns it. Set by the constructor PropertyEntryImpl(string) or by the derived class.
protected string resourceIdInternal
Field Value
Properties
ContextMenu
Must be overridden, when Flags contains PropertyEntryType.ContextMenu. See ContextMenu
public virtual MenuWithHandler[] ContextMenu { get; }
Property Value
DeferUpdate
Only meaningful when ValueEditable is set. In this case the changes by typing do not notify the system until the text-box is closed (i.e. the focus leaves the text box)
public virtual bool DeferUpdate { get; set; }
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 abstract PropertyEntryType Flags { get; }
Property Value
Frame
The frame the entry belongs to: the frame given to the constructor, otherwise the frame of the property page the entry is shown in, otherwise the frame of its parent entry or page, and as a last resort the active frame (Frame). Setting it overrides this lookup.
protected IFrame Frame { get; set; }
Property Value
IndentLevel
The indentation of this entry (according to it's position int the property tree). The implementer must simply keep this value
public int IndentLevel { get; set; }
Property Value
Index
The line number of this entry in the property page. The implementer must simply keep this value
public int Index { get; set; }
Property Value
IsLocked
Implementation of IsLocked: by default the entry is never locked, and setting it throws a NotImplementedException. An entry with Lockable in its Flags overrides it (see EditableProperty<T>).
public virtual bool IsLocked { get; set; }
Property Value
IsOpen
Implementation of IsOpen. Setting it calls Opened(bool); the property page sets it (via OpenOrCloseSubEntries()) when the user opens or closes the entry.
public bool IsOpen { get; set; }
Property Value
Label
Implementation of Label: returns LabelText when it is set, otherwise the string of the StringTable for resourceIdInternal. Throws a NotImplementedException when neither is set.
public string Label { get; }
Property Value
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 virtual string LabelText { get; set; }
Property Value
Parent
Gets or sets the parent. The implementer must simply keep this reference, it is either a IPropertyEntry or a IPropertyPage for the root objects
public object Parent { get; set; }
Property Value
ReadOnly
Implementation of ReadOnly. When the entry is opened, a read only entry makes its SubItems read only as well.
public virtual bool ReadOnly { get; set; }
Property Value
ResourceId
Implementation of ResourceId: returns resourceIdInternal. The property page looks up the tool tip of the entry in the StringTable with it, hides entries by it (HideEntry(string, bool)) and FindSubItem(string) identifies the entry by it.
public virtual string ResourceId { get; }
Property Value
SubEntries
Implementation of SubEntries: the SubItems as IShowProperty objects (null for an item that does not implement it). SubItems must not be null.
public IShowProperty[] SubEntries { get; }
Property Value
SubEntriesCount
Implementation of SubEntriesCount: the number of SubItems, which must not be null.
public int SubEntriesCount { get; }
Property Value
SubItems
Must be overridden, when Flags contains PropertyEntryType.HasSubEntries. See SubItems
public virtual IPropertyEntry[] SubItems { get; }
Property Value
Value
Must be overridden, when Flags contains PropertyEntryType.ValueEditable
public virtual string Value { get; }
Property Value
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 virtual void Added(IPropertyPage pp)
Parameters
ppIPropertyPagethe property page the entry was added to
ButtonClicked(PropertyEntryButton)
Must be overridden, when Flags contains PropertyEntryType.HasSpinButton or CancelButton or OKButton
public virtual void ButtonClicked(PropertyEntryButton button)
Parameters
buttonPropertyEntryButton
Concat(IPropertyEntry[], IPropertyEntry[])
Concatenates two arrays of entries, e.g. the geometric properties of an object and its attribute properties, into one array to return from SubItems.
public static IPropertyEntry[] Concat(IPropertyEntry[] left, IPropertyEntry[] right)
Parameters
leftIPropertyEntry[]the first entries
rightIPropertyEntry[]the entries that follow
Returns
- IPropertyEntry[]
a new array with the entries of
leftfollowed by those ofright
EditTextChanged(string)
May be overridden when Flags contains PropertyEntryType.ValueEditable. See EditTextChanged(string),
public virtual bool EditTextChanged(string newValue)
Parameters
newValuestring
Returns
EndEdit(bool, bool, string)
Must be overridden when Flags contains PropertyEntryType.ValueEditable. See EndEdit(bool, bool, string)
public virtual void EndEdit(bool aborted, bool modified, string newValue)
Parameters
FindSubItem(string)
Implementation of FindSubItem(string): returns this entry when its ResourceId
(or, when it has none, its LabelText) equals helpResourceID, otherwise
searches the SubItems recursively, whether they are open or not, setting their parent on the way.
public virtual IPropertyEntry FindSubItem(string helpResourceID)
Parameters
helpResourceIDstringthe resource id (or label text) to look for
Returns
- IPropertyEntry
the entry found, or null
GetDropDownList()
Must be overridden when Flags contains PropertyEntryType.DropDown, See GetDropDownList()
public virtual string[] GetDropDownList()
Returns
- string[]
GetErrorText()
Implementation of GetErrorText(): returns an empty string. Override it together with EditTextChanged(string) to explain why a text was rejected.
public virtual string GetErrorText()
Returns
- string
the error text, empty by default
ListBoxSelected(int)
Must be overridden when Flags contains PropertyEntryType.DropDown
public virtual void ListBoxSelected(int selectedIndex)
Parameters
selectedIndexint
OpenOrCloseSubEntries()
Implementation of OpenOrCloseSubEntries(): toggles IsOpen, which notifies the entry via Opened(bool). Requires SubItems to be non-null.
public virtual int OpenOrCloseSubEntries()
Returns
- int
the number of sub items that became visible, or the negative number of sub items that were hidden
Opened(bool)
Implementation of Opened(bool): reports OpenSubEntries or CollapseSubEntries and, when the entry was opened, makes it the Parent of its SubItems and passes ReadOnly on to them.
public virtual void Opened(bool isOpen)
Parameters
isOpenbooltrue: the entry was opened, false: it was closed
PropertyEntryChangedState(StateChangedArgs)
Raises PropertyEntryChangedStateEvent with the given arguments. The notifications of this class (Added(IPropertyPage), Removed(IPropertyPage), Opened(bool), Selected(IPropertyEntry), UnSelected(IPropertyEntry)) use it; a derived class may report further changes, e.g. EditEnded.
protected void PropertyEntryChangedState(StateChangedArgs args)
Parameters
argsStateChangedArgsthe change to report
Refresh()
Asks the property page to redisplay this entry (see Refresh(IPropertyEntry)); call it after the label, the value or the sub entries changed. Does nothing while the entry is not shown.
public virtual void Refresh()
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 virtual void Removed(IPropertyPage pp)
Parameters
ppIPropertyPagethe property page the entry was removed from
Select()
Implementation of Select(): selects this entry in its property page. Does nothing while the entry is not shown; the entry must be displayed, i.e. its parents must be open.
public virtual void Select()
Selected(IPropertyEntry)
Implementation of Selected(IPropertyEntry): reports Selected.
public virtual void Selected(IPropertyEntry previousSelected)
Parameters
previousSelectedIPropertyEntrythe entry that was selected before, may be null
StartEdit(bool)
May be overridden, when Flags contains PropertyEntryType.ValueEditable or PropertyEntryType.LabelEditable to handle which part is being edited
public virtual void StartEdit(bool editValue)
Parameters
editValuebool
UnSelected(IPropertyEntry)
Implementation of UnSelected(IPropertyEntry): reports UnSelected.
public virtual void UnSelected(IPropertyEntry nowSelected)
Parameters
nowSelectedIPropertyEntrythe entry that is selected instead, may be null
Events
PropertyEntryChangedStateEvent
Raised when the state of the entry changes: it was added to or removed from a property page, selected or unselected, opened or closed, or an edit of its value ended. The argument tells which (see StateChangedArgs.State). The owner of an entry uses it e.g. to show feedback in the view while the entry is selected.
public event PropertyEntryChangedStateDelegate PropertyEntryChangedStateEvent
Event Type
StateChangedEvent
Implementation of StateChangedEvent for code that still uses the older interface: a handler added here is called whenever PropertyEntryChangedStateEvent is raised, and removing the handler removes the forwarder that was added for it.
public event StateChangedDelegate StateChangedEvent