mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2024-11-25 05:42:45 +01:00
75 lines
2.0 KiB
C#
75 lines
2.0 KiB
C#
using System.Threading.Tasks;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Threading;
|
|
|
|
namespace DHT.Desktop.Dialogs.Message;
|
|
|
|
static class Dialog {
|
|
public static async Task ShowOk(Window owner, string title, string message) {
|
|
if (!Dispatcher.UIThread.CheckAccess()) {
|
|
await Dispatcher.UIThread.InvokeAsync(() => ShowOk(owner, title, message));
|
|
return;
|
|
}
|
|
|
|
await new MessageDialog {
|
|
DataContext = new MessageDialogModel {
|
|
Title = title,
|
|
Message = message,
|
|
IsOkVisible = true
|
|
}
|
|
}.ShowDialog<DialogResult.All>(owner);
|
|
}
|
|
|
|
public static async Task<DialogResult.OkCancel> ShowOkCancel(Window owner, string title, string message) {
|
|
if (!Dispatcher.UIThread.CheckAccess()) {
|
|
return await Dispatcher.UIThread.InvokeAsync(() => ShowOkCancel(owner, title, message));
|
|
}
|
|
|
|
var result = await new MessageDialog {
|
|
DataContext = new MessageDialogModel {
|
|
Title = title,
|
|
Message = message,
|
|
IsOkVisible = true,
|
|
IsCancelVisible = true
|
|
}
|
|
}.ShowDialog<DialogResult.All?>(owner);
|
|
|
|
return result.ToOkCancel();
|
|
}
|
|
|
|
public static async Task<DialogResult.YesNo> ShowYesNo(Window owner, string title, string message) {
|
|
if (!Dispatcher.UIThread.CheckAccess()) {
|
|
return await Dispatcher.UIThread.InvokeAsync(() => ShowYesNo(owner, title, message));
|
|
}
|
|
|
|
var result = await new MessageDialog {
|
|
DataContext = new MessageDialogModel {
|
|
Title = title,
|
|
Message = message,
|
|
IsYesVisible = true,
|
|
IsNoVisible = true
|
|
}
|
|
}.ShowDialog<DialogResult.All?>(owner);
|
|
|
|
return result.ToYesNo();
|
|
}
|
|
|
|
public static async Task<DialogResult.YesNoCancel> ShowYesNoCancel(Window owner, string title, string message) {
|
|
if (!Dispatcher.UIThread.CheckAccess()) {
|
|
return await Dispatcher.UIThread.InvokeAsync(() => ShowYesNoCancel(owner, title, message));
|
|
}
|
|
|
|
var result = await new MessageDialog {
|
|
DataContext = new MessageDialogModel {
|
|
Title = title,
|
|
Message = message,
|
|
IsYesVisible = true,
|
|
IsNoVisible = true,
|
|
IsCancelVisible = true
|
|
}
|
|
}.ShowDialog<DialogResult.All?>(owner);
|
|
|
|
return result.ToYesNoCancel();
|
|
}
|
|
}
|