AuthorBuddy/Services/OperationState.cs

43 lines
919 B
C#
Raw Normal View History

2026-05-31 19:31:27 +02:00
namespace AuthorBuddy.Web.Services;
public class OperationState
{
public string StatusText { get; private set; } = "Bereit";
public bool IsBusy { get; private set; }
public double Progress { get; private set; }
public string ThoughtText { get; private set; } = "";
public event Action? OnChange;
public void SetStatus(string text, bool busy = false, double progress = 0)
{
StatusText = text;
IsBusy = busy;
Progress = progress;
Notify();
}
public void SetThought(string text)
{
ThoughtText = text;
Notify();
}
public void AppendThought(string text)
{
ThoughtText += text;
Notify();
}
public void Reset()
{
StatusText = "Bereit";
IsBusy = false;
Progress = 0;
ThoughtText = "";
Notify();
}
private void Notify() => OnChange?.Invoke();
}