30 lines
921 B
C#
30 lines
921 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Harmonia.WinUI.Messaging;
|
|
|
|
public class WindowsMessageService : IMessageService
|
|
{
|
|
private static MainWindow MainWindow => App.ServiceProvider.GetRequiredService<MainWindow>();
|
|
|
|
public async Task<bool> ConfirmAsync(string title, string message)
|
|
{
|
|
ContentDialog dialog = new()
|
|
{
|
|
XamlRoot = MainWindow.Content.XamlRoot,
|
|
Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style,
|
|
Title = title,
|
|
Content = message,
|
|
PrimaryButtonText = "Yes",
|
|
CloseButtonText = "No",
|
|
DefaultButton = ContentDialogButton.Primary
|
|
};
|
|
|
|
var result = await dialog.ShowAsync();
|
|
|
|
return result == ContentDialogResult.Primary;
|
|
}
|
|
} |