Class ScrollBar
Represents a scrollbar control.
Inherited Members
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.dll
Syntax
[DataContract]
public class ScrollBar : ControlBase
Constructors
ScrollBar(Orientation, int)
Creates a new Slider control
Declaration
public ScrollBar(Orientation orientation, int size)
Parameters
Type | Name | Description |
---|---|---|
Orientation | orientation | Sets the control to either horizontal or vertical. |
int | size | The height or width of the control, based on the |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Size of the control must be 2 or more |
ScrollBar(Orientation, int, int)
Creates a new Slider control with the specified width and height.
Declaration
public ScrollBar(Orientation orientation, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Orientation | orientation | Sets the control to either horizontal or vertical. |
int | width | The width the control. |
int | height | The height of the control. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | With a horizontal Slider, width must be 2 or more. With a vertical Slider, height must be 2 or more. |
Properties
ArrowStep
Gets or sets the amount of values to add or subtract to the Value when the up or down arrows are used.
Declaration
[DataMember]
public int ArrowStep { get; set; }
Property Value
Type | Description |
---|---|
int |
ArrowsMoveGrip
When true, the arrow buttons simply move the grip instead of using the ArrowStep value to adjust the value.
Declaration
[DataMember]
public bool ArrowsMoveGrip { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsGripped
When true, indicates that the mouse is gripping the slider to scroll.
Declaration
public bool IsGripped { get; }
Property Value
Type | Description |
---|---|
bool |
MaximumValue
Gets or sets the maximum value for the scrollbar.
Declaration
[DataMember]
public int MaximumValue { get; set; }
Property Value
Type | Description |
---|---|
int |
MouseWheelMovesGrip
When true, the mouse wheelsimply moves the grip instead of using the MouseWheelStep value to adjust the value.
Declaration
[DataMember]
public bool MouseWheelMovesGrip { get; set; }
Property Value
Type | Description |
---|---|
bool |
MouseWheelStep
Gets or sets the amount of values to add or subtract to the Value when the up or down arrows are used.
Declaration
[DataMember]
public int MouseWheelStep { get; set; }
Property Value
Type | Description |
---|---|
int |
Orientation
Indicates if the slider is horizontal or vertical.
Declaration
[DataMember]
public Orientation Orientation { get; }
Property Value
Type | Description |
---|---|
Orientation |
Style
The style applied to drawing the control.
Declaration
[DataMember]
public ScrollBar.ThemeStyle Style { get; set; }
Property Value
Type | Description |
---|---|
ScrollBar.ThemeStyle |
Value
Gets or sets the value of the slider between the minimum and maximum values.
Declaration
[DataMember]
public int Value { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
CalculateGripSize()
Sets the bar and grip sizes of the control.
Declaration
protected void CalculateGripSize()
DecreaseGripByOne()
Decreases the grip position by one and sets the value.
Declaration
public void DecreaseGripByOne()
DecreaseValue(int)
Decreases the value by the specified amount.
Declaration
public void DecreaseValue(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to subract from Value. |
IncreaseGripByOne()
Increases the grip position by one and sets the value.
Declaration
public void IncreaseGripByOne()
IncreaseValue(int)
Increases the value by the specified amount.
Declaration
public void IncreaseValue(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to add to Value. |
OnResized()
Resizes the control and recalculates the grip size.
Declaration
protected override void OnResized()
Overrides
OnValueChanged()
Invokes the ValueChanged event.
Declaration
protected void OnValueChanged()
ProcessMouse(MouseScreenObjectState)
Checks if the mouse is the control and calls the appropriate mouse methods.
Declaration
public override bool ProcessMouse(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | Mouse information. |
Returns
Type | Description |
---|---|
bool | True when the control is enabled, set to use the mouse and the mouse is over it, otherwise false. |
Overrides
ProcessMouseWheel(MouseScreenObjectState)
Processes the mouse wheel values regardless of if the mouse is over the scrollbar or not.
Declaration
public bool ProcessMouseWheel(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | The mouse state. |
Returns
Type | Description |
---|---|
bool | True if the mouse wheel was processed. |
SetGripToValue()
Moves the grip position based on the Value property.
Declaration
protected void SetGripToValue()
SetValue(int, bool)
Sets the value of the control without using the Value property. Optionally calls SetGripToValue().
Declaration
protected void SetValue(int value, bool setGrip = true)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to set. |
bool | setGrip | Moves the grip when true. |
UpdateAndRedraw(TimeSpan)
Redraws the control if applicable.
Declaration
public override void UpdateAndRedraw(TimeSpan time)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | time | The duration of thecurrent frame. |
Overrides
Events
ValueChanged
Raised when the Value property changes.
Declaration
public event EventHandler? ValueChanged
Event Type
Type | Description |
---|---|
EventHandler |