namespace NeoUI.Controls;
///
/// 提供静态方法用于显示模态对话框,包括确认对话框和信息对话框。
///
public static class Modal
{
///
/// 显示一个确认对话框
///
/// 父窗口
/// 标题
/// 信息
/// 点击确定按钮时执行的异步委托
/// 如果用户点击OK并异步操作成功,则返回true,否则返回false
public static bool? Confirm(Window owner, string title, string message, Func>? onOkAsync = null)
{
var modal = new ModalWindow(title, message)
{
Owner = owner,
OnOkAsync = onOkAsync
};
return modal.ShowDialog();
}
///
/// 显示一个信息对话框
///
/// 父窗口
/// 标题
/// 信息
public static void Info(Window owner, string title, string message)
{
var modal = new ModalWindow(title, message)
{
Owner = owner
};
// 隐藏取消按钮
modal.CancelButton.Visibility = Visibility.Collapsed;
modal.ShowDialog();
}
}