mirror of
https://github.com/4sval/FModel.git
synced 2026-12-04 23:02:22 -06:00
50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System;
|
|
|
|
namespace FModel.Framework;
|
|
|
|
public class FStatus : ViewModel, IProgress<string>
|
|
{
|
|
private bool _isReady;
|
|
public bool IsReady
|
|
{
|
|
get => _isReady;
|
|
private set => SetProperty(ref _isReady, value);
|
|
}
|
|
|
|
private EStatusKind _kind;
|
|
public EStatusKind Kind
|
|
{
|
|
get => _kind;
|
|
private set
|
|
{
|
|
SetProperty(ref _kind, value);
|
|
IsReady = Kind != EStatusKind.Loading && Kind != EStatusKind.Stopping;
|
|
}
|
|
}
|
|
|
|
private string _label;
|
|
public string Label
|
|
{
|
|
get => _label;
|
|
private set => SetProperty(ref _label, value);
|
|
}
|
|
|
|
public FStatus()
|
|
{
|
|
SetStatus(EStatusKind.Loading);
|
|
}
|
|
|
|
public void SetStatus(EStatusKind kind, string label = "")
|
|
{
|
|
Kind = kind;
|
|
UpdateStatusLabel(label);
|
|
}
|
|
|
|
public void UpdateStatusLabel(string label, string prefix = null)
|
|
{
|
|
Label = Kind == EStatusKind.Loading ? $"{prefix ?? Kind.ToString()} {label}".Trim() : Kind.ToString();
|
|
}
|
|
|
|
public void Report(string value) => UpdateStatusLabel(value);
|
|
}
|