using Microsoft.UI.Dispatching; using System.Collections.ObjectModel; namespace XFEExtension.NetCore.WinUIHelper.Interface.Services; /// /// 全局消息显示服务 /// public interface IMessageService : IGlobalService { /// /// 消息堆栈 /// ReadOnlyDictionary MessageStack { get; } /// /// 显示一条消息 /// /// 消息文本 /// 消息标题(可选) /// 是否显示成功 bool ShowMessage(string message, string title = ""); /// /// 显示一条消息 /// /// 消息文本 /// 消息标题 /// 消息的提示等级 /// 是否显示成功 bool ShowMessage(string message, string title, InfoBarSeverity severity); /// /// 显示一条带按钮的消息 /// /// 消息文本 /// 消息标题 /// 按钮文本 /// 按钮回调方法 /// 提示等级 /// 是否可以被关闭 /// 是否显示成功 bool ShowButtonMessage(string message, string title, string buttonText, Action callBackAction, InfoBarSeverity severity = InfoBarSeverity.Informational, bool canClose = true); /// /// 显示一条消息 /// /// 消息文本 /// 消息标题 /// 消息自定义内容 /// 消息的提示等级 /// 消息持续时间 /// 是否可被关闭 /// 按钮文本 /// 按钮回调方法 /// 消息的ID /// 是否显示成功 bool ShowMessage(string message, string title = "", object? content = null, InfoBarSeverity severity = InfoBarSeverity.Informational, double time = 5, bool canClose = true, string buttonText = "", Action? callBackAction = null, string messageId = ""); /// /// 显示一条消息,使用指定ID /// /// 消息ID /// 消息文本 /// 消息标题 /// 消息的提示等级 /// 消息的持续时间 /// 是否显示成功 bool ShowMessageWithId(string messageId, string message, string title = "", InfoBarSeverity severity = InfoBarSeverity.Informational, double time = 5); /// /// 显示一条消息,使用自定义InfoBar控件 /// /// 自定义InfoBar控件 /// 消息的持续时间 /// 消息ID /// 是否显示成功 bool ShowMessage(InfoBar infoBar, double time = -1, string messageId = ""); /// /// 根据消息ID获取一条消息 /// /// 消息ID /// InfoBar控件 InfoBar? GetMessage(string messageId); /// /// 移除一条消息 /// /// 消息ID /// 是否移除成功 bool RemoveMessage(string messageId); /// /// 清除所有消息列表 /// void Clear(); /// /// 初始化消息显示服务 /// /// 需要显示的消息的StackPanel控件 /// 目标DispatcherQueue void Initialize(StackPanel stackPanel, DispatcherQueue dispatcherQueue); }