Class SpinnerTextAnimator
- Namespace
- SharpConsoleUI.Helpers
- Assembly
- SharpConsoleUI.dll
Drives an arbitrary text setter from a looping spinner frame cycle, using the window system's animation manager. Useful for animating a status-bar label or window title without a dedicated control. Dispose or Stop to end the animation.
public sealed class SpinnerTextAnimator : IDisposable
- Inheritance
-
SpinnerTextAnimator
- Implements
- Inherited Members
- Extension Methods
Constructors
SpinnerTextAnimator(ConsoleWindowSystem, SpinnerStyle, Action<string>, int?)
Creates an animator using a preset style. When intervalMs is null,
the style's per-style default interval is used.
public SpinnerTextAnimator(ConsoleWindowSystem system, SpinnerStyle style, Action<string> setter, int? intervalMs = null)
Parameters
systemConsoleWindowSystemstyleSpinnerStylesetterAction<string>intervalMsint?
SpinnerTextAnimator(ConsoleWindowSystem, IReadOnlyList<string>, Action<string>, int?)
Creates an animator using custom frames (may contain markup).
public SpinnerTextAnimator(ConsoleWindowSystem system, IReadOnlyList<string> frames, Action<string> setter, int? intervalMs = null)
Parameters
systemConsoleWindowSystemframesIReadOnlyList<string>setterAction<string>intervalMsint?
Properties
FrameWidth
Gets the display width (in columns) of the widest frame, with any markup stripped. Use this to pad the target to a fixed width so that toggling Visible (or showing an empty placeholder) does not shift the surrounding layout. For example:
<pre><code class="lang-csharp">if (!animator.Visible) label.Label = new string(' ', animator.FrameWidth);</code></pre>
public int FrameWidth { get; }
Property Value
IntervalMs
Gets the resolved per-frame interval in milliseconds.
public int IntervalMs { get; }
Property Value
Visible
Gets or sets whether the spinner is shown. When false, the animation is cancelled and the target setter receives an empty string; setting true resumes if the animator was started. Independent of Start()/Stop() — toggling visibility preserves started state.
public bool Visible { get; set; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Start()
Starts the animation. Idempotent. No visible effect while Visible is false; the animation begins when the animator is next shown.
public void Start()
Remarks
Has no effect when the window system's animations are disabled or the concurrent-animation pool is full; in those cases the setter is never invoked.
Stop()
Stops the animation and clears the started state. Safe to call when not started (idempotent).
public void Stop()