Class LinearRangeViewBase<TOption, TValue>
Abstract base for linear range views (LinearSelector<T>, LinearMultiSelector<T>, LinearRange<T>) that present a list of typed options navigable by keyboard or mouse, and expose the current selection as a strongly-typed value via IValue<TValue>.
public abstract class LinearRangeViewBase<TOption, TValue> : View, IDisposable, ISupportInitializeNotification, ISupportInitialize, IOrientation, IValue<TValue>, IValue
Type Parameters
TOptionThe data type carried by each LinearRangeOption<T>.
TValueThe shape of Value; defined by the concrete subclass.
- Inheritance
-
LinearRangeViewBase<TOption, TValue>
- Implements
-
IValue<TValue>
- Derived
-
LinearRange<T>
- Inherited Members
- Extension Methods
Remarks
Default key bindings (when Orientation is Horizontal):
| Key | Action |
|---|---|
| Left / Right | Moves to the previous or next option. |
| Ctrl+Left / Ctrl+Right | Moves by a larger step. |
Default key bindings (when Orientation is Vertical):
| Key | Action |
|---|---|
| Up / Down | Moves to the previous or next option. |
| Ctrl+Up / Ctrl+Down | Moves by a larger step. |
Common key bindings (both orientations):
| Key | Action |
|---|---|
| Home / End | Moves to the first or last option. |
| Enter | Accepts the current selection (Accept). |
| Space | Activates the current selection (Activate). |
Common bindings (Home, End, Enter, Space) are configurable via DefaultKeyBindings and DefaultKeyBindings. Orientation-dependent cursor bindings are set dynamically and cannot be reconfigured.
Constructors
- LinearRangeViewBase(List<TOption>?, Orientation, LinearRangeRenderMode)
Initializes a new instance of the LinearRangeViewBase<TOption, TValue> class.
- LinearRangeViewBase(LinearRangeRenderMode)
Initializes a new instance of the LinearRangeViewBase<TOption, TValue> class.
Properties
- AllowEmpty
Allow no selection.
- DefaultKeyBindings
Gets or sets the view-specific default key bindings shared by all linear range views. Contains only bindings unique to this family; shared bindings come from DefaultKeyBindings.
IMPORTANT: This is a process-wide static property. Change with care. Do not set in parallelizable unit tests.
- FocusedOption
The focused option (has the cursor).
- LegendsOrientation
Legends Orientation. Orientation
- MinimumInnerSpacing
Gets or sets the minimum number of rows/columns between Options. The default is 1.
- Options
Set the linear range options. When the new options no longer contain the previously selected value(s), the selection is dropped (event semantics depend on the concrete subclass).
- Orientation
Gets or sets the Orientation. The default is Horizontal.
- SelectedIndices
Gets the currently selected option indices, in selection order, as a read-only snapshot.
- ShowEndSpacing
Show/Hide spacing before and after the first and last option.
- ShowLegends
Show/Hide the options legends.
- Style
LinearRange styles. LinearRangeStyle
- Text
Setting the Text of a linear range is a shortcut to setting options. The text is a CSV string of the options.
- UseMinimumSize
Gets or sets whether the minimum or ideal size will be used when calculating the size of the linear range.
- Value
Gets or sets the value.
Methods
- ApplySelectedIndices(IReadOnlyList<int>)
Replaces the selected indices without raising ValueChanged. Used by concrete subclass Value setters to apply their value back to the index model.
- GetIdealHeight()
Gets the ideal height of the linear range. The ideal height is the minimum height required to display all options and inner spacing.
- GetIdealWidth()
Gets the ideal width of the linear range. The ideal width is the minimum width required to display all options and inner spacing.
- IndexOfData(TOption?)
Finds the first option whose Data equals
datausing the default equality comparer forTOption.
- OnAccepting(CommandEventArgs)
Called when the user is accepting the state of the View and the Accept has been invoked. Set CommandEventArgs.Handled to true and return true to indicate the event was handled and processing should stop.
- OnActivated(ICommandContext?)
Called when the View has been activated. This is called after Accepting has been raised and not cancelled.
- OnDrawingContent(DrawContext?)
Called when the View's content is to be drawn. The default implementation does nothing.
- OnLegendsOrientationChanged(ValueChangedEventArgs<Orientation>)
Called after LegendsOrientation has changed.
- OnLegendsOrientationChanging(ValueChangingEventArgs<Orientation>)
Called before LegendsOrientation changes. Return true to cancel the change.
- OnMinimumInnerSpacingChanged(ValueChangedEventArgs<int>)
Called after MinimumInnerSpacing has changed.
- OnMinimumInnerSpacingChanging(ValueChangingEventArgs<int>)
Called before MinimumInnerSpacing changes. Return true to cancel the change.
- OnMouseEvent(Mouse)
Called when a mouse event occurs within the view's Viewport.
- OnOptionFocused(int, LinearRangeEventArgs<TOption>)
Overridable function that fires the OptionFocused event.
- OnOrientationChanged(Orientation)
Called when Orientation has been changed.
- OnSelectionChanged()
Called by the base when the selected indices have changed due to user input. Concrete subclasses must compute their Value from the current selection and raise ValueChanged / ValueChangedUntyped.
- OnShowEndSpacingChanged(ValueChangedEventArgs<bool>)
Called after ShowEndSpacing has changed.
- OnShowEndSpacingChanging(ValueChangingEventArgs<bool>)
Called before ShowEndSpacing changes. Return true to cancel the change.
- OnShowLegendsChanged(ValueChangedEventArgs<bool>)
Called after ShowLegends has changed.
- OnShowLegendsChanging(ValueChangingEventArgs<bool>)
Called before ShowLegends changes. Return true to cancel the change.
- OnUseMinimumSizeChanged(ValueChangedEventArgs<bool>)
Called after UseMinimumSize has changed.
- OnUseMinimumSizeChanging(ValueChangingEventArgs<bool>)
Called before UseMinimumSize changes. Return true to cancel the change.
- RaiseValueChanging(TValue?, TValue?)
Raises ValueChanging. Returns true if cancelled.
Events
- LegendsOrientationChanged
Event raised after the LegendsOrientation property has changed.
- LegendsOrientationChanging
Event raised before the LegendsOrientation property changes. Can be cancelled.
- MinimumInnerSpacingChanged
Event raised after the MinimumInnerSpacing property has changed.
- MinimumInnerSpacingChanging
Event raised before the MinimumInnerSpacing property changes. Can be cancelled.
- OptionFocused
Event raised When the option is hovered with the keys or the mouse.
- OrientationChanged
Raised when Orientation has changed.
- OrientationChanging
Raised when Orientation is changing. Can be cancelled.
- ShowEndSpacingChanged
Event raised after the ShowEndSpacing property has changed.
- ShowEndSpacingChanging
Event raised before the ShowEndSpacing property changes. Can be cancelled.
- ShowLegendsChanged
Event raised after the ShowLegends property has changed.
- ShowLegendsChanging
Event raised before the ShowLegends property changes. Can be cancelled.
- UseMinimumSizeChanged
Event raised after the UseMinimumSize property has changed.
- UseMinimumSizeChanging
Event raised before the UseMinimumSize property changes. Can be cancelled.
- ValueChanged
Raised when Value has changed.
- ValueChangedUntyped
Raised when Value has changed, providing the value as an un-typed object.
- ValueChanging
Raised when Value is about to change. Set Handled to true to cancel the change.