using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CapMachine.Wpf.Services
{
///
/// 会话窗口扩展服务
///
public static class DialogExtensions
{
///
/// 询问窗口
///
///
/// 提示消息
/// 会话ID
///
public static async Task Question(this IHostDialogService hostDialogService,
string message,
string IdentifierName)
{
return await Question(hostDialogService, "确定", message, IdentifierName);
}
///
/// 询问窗口-指定标题
///
///
/// 标题
/// 提示消息
/// 会话ID
///
public static async Task Question(this IHostDialogService hostDialogService,
string title,
string message,
string IdentifierName)
{
DialogParameters param = new DialogParameters();
param.Add("Title", title);
param.Add("Message", message);
var dialogResult = await hostDialogService.ShowDialogAsync("AppViews.HostMessageBox", param, IdentifierName);
return dialogResult.Result == ButtonResult.OK;
}
///
/// 询问窗口
///
///
/// 标题
/// 提示消息
///
public static bool Question(this IDialogService dialogService, string title, string message)
{
if (string.IsNullOrWhiteSpace(title))
title = "确定";
DialogParameters parameters = new DialogParameters();
parameters.Add("Title", title);
parameters.Add("Message", message);
bool dialogResult = false;
dialogService.ShowDialog("AppViews.MessageBox", parameters, callback =>
{
dialogResult = callback.Result == ButtonResult.OK;
});
return dialogResult;
}
}
}