55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
using WPFluent.Controls;
|
|
|
|
|
|
namespace WPFluent.Extensions;
|
|
|
|
public static class MessageExtensions
|
|
{
|
|
private static readonly ContentDialogService ContentDialogService = new ContentDialogService();
|
|
|
|
public static async void ShowMessage(string content = "内容...", string title = "消息")
|
|
{
|
|
Controls.MessageWindow uiMessageBox = new()
|
|
{
|
|
Title = title,
|
|
Content = content,
|
|
MinWidth = 200,
|
|
//PrimaryButtonIcon = SymbolRegular.Button16,
|
|
//PrimaryButtonAppearance = ControlAppearance.Primary,
|
|
//PrimaryButtonText = "确定",
|
|
//SecondaryButtonIcon = SymbolRegular.Button20,
|
|
//SecondaryButtonAppearance = ControlAppearance.Secondary,
|
|
//SecondaryButtonText = "取消",
|
|
CloseButtonAppearance = ControlAppearance.Primary,
|
|
//CloseButtonIcon = SymbolRegular.CalendarCancel16,
|
|
CloseButtonText = "确定",
|
|
WindowStartupLocation = System.Windows.WindowStartupLocation.Manual,
|
|
};
|
|
await uiMessageBox.ShowDialogAsync();
|
|
}
|
|
|
|
public static async Task<ContentDialogResult> ShowTaskDialog(
|
|
string title,
|
|
object content,
|
|
string primaryButtonText = "确定",
|
|
string secondaryButtonText = "取消",
|
|
string closeButtonText = "关闭")
|
|
{
|
|
return await ContentDialogService.ShowSimpleDialogAsync(
|
|
new SimpleContentDialogOptions()
|
|
{
|
|
Title = title,
|
|
Content = content,
|
|
PrimaryButtonText = primaryButtonText,
|
|
SecondaryButtonText = secondaryButtonText,
|
|
CloseButtonText = closeButtonText,
|
|
});
|
|
//result switch
|
|
//{
|
|
// ContentDialogResult.Primary => "User saved their work",
|
|
// ContentDialogResult.Secondary => "User did not save their work",
|
|
// _ => "User cancelled the dialog"
|
|
//};
|
|
}
|
|
}
|