43 lines
919 B
C#
43 lines
919 B
C#
|
|
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();
|
||
|
|
}
|