Class IntegerProperty
- Namespace
- CADability.UserInterface
- Assembly
- CADability.dll
Display an editable integer value in the property grid.
public class IntegerProperty : EditableProperty<int>, IPropertyEntry, IShowProperty, IConstructProperty, ISerializable, ICommandHandler, IDeserializationCallback, IJsonSerialize, IJsonSerializeDone
- Inheritance
-
IntegerProperty
- Implements
- Inherited Members
Constructors
IntegerProperty()
Parameterless constructor for the JSON deserialization (IJsonSerialize); the state is restored by SetObjectData(IJsonReadData).
protected IntegerProperty()
IntegerProperty(int, string)
Creates an entry that holds the value itself; it is accessed through IntegerValue, or through GetIntEvent and SetIntEvent when handlers are attached.
public IntegerProperty(int initialValue, string resourceId)
Parameters
initialValueintThe initial value of the entry
resourceIdstringResource id of the label text and the tooltip, or null to keep the default
IntegerProperty(object, string, string)
Creates an entry that reads and writes the value through reflection on a property of the owning object. When no property with
exactly that name exists, the first property whose name ends with propertyName (ignoring case) is used.
public IntegerProperty(object objectWithInt, string propertyName, string resourceId)
Parameters
objectWithIntobjectThe object that owns the value
propertyNamestringName of a public property of type int on
objectWithIntresourceIdstringResource id of the label text and the tooltip, or null to keep the default
IntegerProperty(SerializationInfo, StreamingContext)
Constructor required by deserialization
protected IntegerProperty(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerializationInfo
contextStreamingContextStreamingContext
IntegerProperty(string, string)
Creates an entry for a value of the Settings: the value is held in IntegerValue and saved together with the setting name.
public IntegerProperty(string resourceId, string settingName)
Parameters
resourceIdstringResource id of the label text and the tooltip
settingNamestringThe name under which the value is addressed in the settings
Properties
ContextMenu
Must be overridden, when Flags contains PropertyEntryType.ContextMenu. See ContextMenu
public override MenuWithHandler[] ContextMenu { get; }
Property Value
Flags
Override for more functionality. Only returns PropertyEntryType.ValueEditable and PropertyEntryType.LabelEditable if apropriate
public override PropertyEntryType Flags { get; }
Property Value
IntegerValue
The value held by the entry itself: it is the value displayed when no object and no GetIntEvent is connected, and the value saved when the entry is a setting. Setting it updates the display but does not notify an owner; use SetInt(int) for that.
public int IntegerValue { get; set; }
Property Value
NotifyOnLostFocusOnly
Without functionality: set to false by every constructor and never evaluated, the value is transferred with every change.
public bool NotifyOnLostFocusOnly { get; set; }
Property Value
UpDownOnly
Without functionality: was meant to restrict the input to the spin button, always returns false.
public bool UpDownOnly { get; set; }
Property Value
Value
Must be overridden, when Flags contains PropertyEntryType.ValueEditable
public override string Value { get; }
Property Value
Methods
AddSpecialValue(int, string)
Defines a special value that is displayed by a text instead of the number (e.g. "automatic" for 0). All special values are offered in the context menu of the entry; selecting one sets the value.
public void AddSpecialValue(int val, string resourceId)
Parameters
valintThe value
resourceIdstringResource id of the text displayed for
val; a leading "!" of the string resource is removed
EditTextChanged(string)
May be overridden when Flags contains PropertyEntryType.ValueEditable. See EditTextChanged(string),
public override 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 override void EndEdit(bool aborted, bool modified, string newValue)
Parameters
GetObjectData(IJsonWriteData)
Writes the value, the resource id, the setting name and the special values for the JSON serialization (IJsonSerialize); used when this entry is part of the settings.
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
IntChanged()
Must be called by the owner of this property when the integer value has been changed from outside (not by the user editing this property) to update the displayed value.
public void IntChanged()
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 override void Refresh()
SetInt(int)
Transfers a new value to the owner: raises SetIntEvent or, when no handler is attached, sets the reflected property of the connected object. Does nothing when the value equals the current one. The displayed text is not updated here but by the following Refresh() or IntChanged(). Called when the user edits the value and by the settings.
public void SetInt(int d)
Parameters
dintThe new value
SetMinMax(int, int, bool)
Defines the range of the value and whether a spin button (up/down arrows) is displayed next to the value. The range is stored but currently not enforced when a value is entered.
public void SetMinMax(int min, int max, bool showupdown)
Parameters
minintSmallest allowed value
maxintLargest allowed value
showupdownbooltrue to display the spin button
SetObjectData(IJsonReadData)
Restores the value, the resource id, the setting name and the special values from the JSON serialization (IJsonSerialize) and registers for the IJsonSerializeDone callback, which reconnects the entry to its own IntegerValue.
public void SetObjectData(IJsonReadData data)
Parameters
dataIJsonReadDataThe data to read from
StartEdit(bool)
Only handles value editing. If the label may also be edited, override this method and call this base implementation;
public override void StartEdit(bool editValue)
Parameters
editValuebool
TextToValue(string, out int)
Converts the text to a value. Returns true if possible, false otherwise (maybe invalid characters or outside the limit)
protected override bool TextToValue(string input, out int val)
Parameters
Returns
ValueToText(int)
Returns the text representation of the value.
protected override string ValueToText(int val)
Parameters
valint
Returns
Events
GetIntEvent
When a handler is attached, the entry asks it for the current value instead of reading the reflected property of the connected object or the internal IntegerValue. Called whenever the display is refreshed (IntChanged(), Refresh()) and before a new value is set.
public event IntegerProperty.GetIntDelegate GetIntEvent
Event Type
SetIntEvent
Raised by SetInt(int) with the new value when the user has changed it (by typing, with the spin button or from the context menu of the special values), so that the owner can take it over. When a handler is attached, the reflected property of the connected object is not set.
public event IntegerProperty.SetIntDelegate SetIntEvent
Event Type
Operators
explicit operator int(IntegerProperty)
Converts the entry to its IntegerValue.
public static explicit operator int(IntegerProperty ip)
Parameters
ipIntegerPropertyThe entry
Returns
- int
The value held by the entry