You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
59 lines
1.6 KiB
using System.Threading;
|
|
using AIK.Common.Enum;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AIK.Views.UIViewModels
|
|
{
|
|
public partial class DialogMessageViewModel : ObservableObject
|
|
{
|
|
private readonly CancellationTokenSource _cts = new();
|
|
|
|
public CancellationToken CancellationToken => _cts.Token;
|
|
[ObservableProperty]
|
|
private string _title = "请稍候";
|
|
|
|
[ObservableProperty]
|
|
private string _message = "处理中...";
|
|
|
|
[ObservableProperty]
|
|
private MessageTypeEnum _messageType;
|
|
|
|
[ObservableProperty]
|
|
private string _iconPath = "\ue601";
|
|
|
|
[ObservableProperty]
|
|
private string _iconForeground = "white";
|
|
|
|
[ObservableProperty]
|
|
private bool _isCancelButtonVisible = true;
|
|
|
|
public DialogMessageViewModel(
|
|
string title = "处理中",
|
|
string message = "处理中...",
|
|
MessageTypeEnum typeEnum = MessageTypeEnum.Info,
|
|
bool showCancel = true)
|
|
{
|
|
Title = title;
|
|
Message = message;
|
|
IsCancelButtonVisible = showCancel;
|
|
MessageType = typeEnum;
|
|
var (icon, color) = Common.IconString.MessageStyle.GetByType(typeEnum);
|
|
IconPath = icon;
|
|
IconForeground = color;
|
|
}
|
|
|
|
|
|
[RelayCommand]
|
|
private void Cancel()
|
|
{
|
|
_cts.Cancel();
|
|
}
|
|
}
|
|
}
|
|
|