Class ProgressBar
A control that fills an area (vertical or horizontal) according to a value.
Inherited Members
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.dll
Syntax
[DataContract]
public class ProgressBar : ControlBase
Constructors
ProgressBar(int, int, HorizontalAlignment)
Creates a new horizontal progress bar.
Declaration
public ProgressBar(int width, int height, HorizontalAlignment horizontalAlignment)
Parameters
Type | Name | Description |
---|---|---|
int | width | Width of the control. |
int | height | Height of the control. |
HorizontalAlignment | horizontalAlignment | Sets the control to be horizontal, starting from the specified side. Center/Stretch is invalid. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when |
ProgressBar(int, int, VerticalAlignment)
Creates a new vertical progress bar.
Declaration
public ProgressBar(int width, int height, VerticalAlignment verticalAlignment)
Parameters
Type | Name | Description |
---|---|---|
int | width | Width of the control. |
int | height | Height of the control. |
VerticalAlignment | verticalAlignment | Sets the control to be vertical, starting from the specified side. Center/Stretch is invalid. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when |
Fields
controlSize
The size of the bar.
Declaration
[DataMember]
protected int controlSize
Field Value
Type | Description |
---|---|
int |
fillSize
For theme use only. The size of the bar currently filled based on the Progress property.
Declaration
[DataMember]
public int fillSize
Field Value
Type | Description |
---|---|
int |
horizontalAlignment
The alignment if the bar is horizontal.
Declaration
[DataMember]
protected HorizontalAlignment horizontalAlignment
Field Value
Type | Description |
---|---|
HorizontalAlignment |
isHorizontal
Flag to indicate this bar was created horizontal.
Declaration
[DataMember]
protected bool isHorizontal
Field Value
Type | Description |
---|---|
bool |
progressValue
The progress bar fill value. Between 0f and 1f.
Declaration
[DataMember]
protected float progressValue
Field Value
Type | Description |
---|---|
float |
verticalAlignment
The alignment if the bar is vertical.
Declaration
[DataMember]
protected VerticalAlignment verticalAlignment
Field Value
Type | Description |
---|---|
VerticalAlignment |
Properties
BackgroundGlyph
The glyph to use when drawing the unfilled part of the bar.
Declaration
[DataMember]
public int BackgroundGlyph { get; set; }
Property Value
Type | Description |
---|---|
int |
BarColor
The color to print the filled part of the progress bar.
Declaration
[DataMember]
public Color? BarColor { get; set; }
Property Value
Type | Description |
---|---|
Color? |
BarGlyph
The glyph to use when drawing the filled part of the bar.
Declaration
[DataMember]
public int BarGlyph { get; set; }
Property Value
Type | Description |
---|---|
int |
DisplayText
An optional text to display on the bar. If set to "%"
, displays the percentage of the progress.
Declaration
[DataMember]
public string DisplayText { get; set; }
Property Value
Type | Description |
---|---|
string |
DisplayTextAlignment
Alignment to print the DisplayText. Stretch is invalid for the property.
Declaration
[DataMember]
public HorizontalAlignment DisplayTextAlignment { get; set; }
Property Value
Type | Description |
---|---|
HorizontalAlignment |
DisplayTextColor
The color to print the DisplayText string.
Declaration
[DataMember]
public Color? DisplayTextColor { get; set; }
Property Value
Type | Description |
---|---|
Color? |
DisplayTextStates
The theme of the text displayed on the bar.
Declaration
[DataMember]
public ThemeStates DisplayTextStates { get; protected set; }
Property Value
Type | Description |
---|---|
ThemeStates |
HorizontalAlignment
The horizontal orientation used when IsHorizontal is set to true.
Declaration
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
Type | Description |
---|---|
HorizontalAlignment |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
IsHorizontal
When true, the progress bar uses the HorizontalAlignment property to determine the starting fill direction. When false, uses the VerticalAlignment property.
Declaration
public bool IsHorizontal { get; set; }
Property Value
Type | Description |
---|---|
bool |
PrintDisplayAsDecorator
When true, prints the DisplayText on the control in decorators instead of replacing the portation of the bar that overlaps the text.
Declaration
[DataMember]
public bool PrintDisplayAsDecorator { get; set; }
Property Value
Type | Description |
---|---|
bool |
Progress
Gets or sets the value of the scrollbar between the minimum and maximum values.
Declaration
public float Progress { get; set; }
Property Value
Type | Description |
---|---|
float |
ThemeStateBar
The theme of the progressed part of the bar.
Declaration
[DataMember]
public ThemeStates ThemeStateBar { get; protected set; }
Property Value
Type | Description |
---|---|
ThemeStates |
VerticalAlignment
The vertical orientation used when IsHorizontal is set to false.
Declaration
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
Type | Description |
---|---|
VerticalAlignment |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
Methods
ProcessKeyboard(Keyboard)
Called when the control should process keyboard information.
Declaration
public override bool ProcessKeyboard(Keyboard info)
Parameters
Type | Name | Description |
---|---|---|
Keyboard | info | The keyboard information. |
Returns
Type | Description |
---|---|
bool | True if the keyboard was handled by this control. |
Overrides
RefreshThemeStateColors(Colors)
Updates the ThemeState by calling RefreshTheme(Colors) with the provided colors. Override this method to adjust how colors are used by the ThemeState.
Declaration
protected override void RefreshThemeStateColors(Colors colors)
Parameters
Type | Name | Description |
---|---|---|
Colors | colors | The colors to apply to the theme state. |
Overrides
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
ProgressChanged
Called when the Progress property value changes.
Declaration
public event EventHandler? ProgressChanged
Event Type
Type | Description |
---|---|
EventHandler |