Other Controls
This page documents other UI controls, such as progress bars and timers
Progress Bar Methods
StartProgressBar
Initializes and displays a progress bar for tracking operations.
public void StartProgressBar(int totalOperations, string itemTypeText = "items", bool showCancelButton = true)
Parameters:
totalOperations: Total number of operations to be performed.
itemTypeText: Optional. Text describing the type of items being processed. Default is "items".
showCancelButton: Optional. Indicates whether to show a cancel button on the progress bar. Default is true.
UpdateProgressBar
Updates the current progress in an active progress bar.
public void UpdateProgressBar(int currentOperation, string message = null)
Parameters:
currentOperation: Current operation number (should be between 0 and totalOperations).
message: Optional. Message to display in the progress bar. Default is null.
Closes and disposes the progress bar.
IsProgressCancelled
Checks if the progress operation was cancelled by the user.
Returns:
true if the operation was cancelled; false otherwise or if no progress bar exists.
Initializes and starts a timer for measuring operation duration.
Stops the timer and optionally outputs the elapsed time to the console.
Parameters:
description: Optional. Description of the operation being timed. Default is "Operation".
outputToConsole: Optional. Indicates whether to output the elapsed time to the console. Default is true.
Returns:
A TimeSpan representing the elapsed time.
Gets the current elapsed time without stopping the timer.
Returns:
A TimeSpan representing the elapsed time, or TimeSpan.Zero if no timer is running.
Formats a TimeSpan into a human-readable string.
Parameters:
time: The TimeSpan to format.
Returns:
A formatted string representation of the time span (e.g., "1h 30m 45.123s", "2m 30.456s", or "10.789s").
Last updated