You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/AI/Models/SpecialMessages/WorkflowStatusMessage.cs

71 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace AI.Models.SpecialMessages
{
/// <summary>
/// 工作流状态特殊消息 - 在聊天流中显示工作流进度
/// </summary>
public class WorkflowStatusMessage : ISpecialMessage, INotifyPropertyChanged
{
private string _title = "工作流进度";
private ObservableCollection<WorkflowStepModel> _steps = new();
/// <summary>
/// 消息唯一标识符
/// </summary>
public string Id { get; set; } = Guid.NewGuid().ToString();
/// <summary>
/// 类型名称
/// </summary>
public string TypeName => "WorkflowStatus";
/// <summary>
/// 需要实时更新
/// </summary>
public bool IsLive => true;
/// <summary>
/// 工作流标题
/// </summary>
public string Title
{
get => _title;
set => SetProperty(ref _title, value);
}
/// <summary>
/// 工作流步骤列表
/// </summary>
public ObservableCollection<WorkflowStepModel> Steps
{
get => _steps;
set => SetProperty(ref _steps, value);
}
public event PropertyChangedEventHandler? PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
{
return false;
}
field = value;
OnPropertyChanged(propertyName);
return true;
}
}
}