31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using Avalonia;
|
|||
|
|
using Avalonia.Controls;
|
||
|
|
using Avalonia.Layout;
|
||
|
|
|
||
|
|
namespace AgentWikiUi.Gui;
|
||
|
|
|
||
|
|
static class ConfirmDialog
|
||
|
|
{
|
||
|
|
public static Task<bool> Ask(Window owner, string question)
|
||
|
|
{
|
||
|
|
var yes = new Button { Content = "Elimina", MinWidth = 90 };
|
||
|
|
var no = new Button { Content = "Annulla", MinWidth = 90 };
|
||
|
|
var dlg = new Window
|
||
|
|
{
|
||
|
|
Title = question, Width = 340, SizeToContent = SizeToContent.Height, CanResize = false,
|
||
|
|
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||
|
|
Content = new StackPanel
|
||
|
|
{
|
||
|
|
Margin = new(20), Spacing = 18,
|
||
|
|
Children =
|
||
|
|
{
|
||
|
|
new TextBlock { Text = question, TextWrapping = Avalonia.Media.TextWrapping.Wrap },
|
||
|
|
new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, HorizontalAlignment = HorizontalAlignment.Right, Children = { no, yes } },
|
||
|
|
},
|
||
|
|
},
|
||
|
|
};
|
||
|
|
yes.Click += (_, _) => dlg.Close(true);
|
||
|
|
no.Click += (_, _) => dlg.Close(false);
|
||
|
|
return dlg.ShowDialog<bool>(owner);
|
||
|
|
}
|
||
|
|
}
|