-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageBoxExtensions.cs
More file actions
29 lines (24 loc) · 1.43 KB
/
Copy pathMessageBoxExtensions.cs
File metadata and controls
29 lines (24 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Terminal.Gui.App;
using Terminal.Gui.Views;
namespace TerminalGui.Extensions.Extensions;
public static class MessageBoxExtensions
{
extension(MessageBox)
{
public static bool Confirm(IApplication application, string message, string title = "Confirm", string yesText = "Yes", string noText = "No")
=> MessageBox.Query(application, title, message, yesText, noText) == 0;
/// <summary>
/// Displays an error <see cref="MessageBox" /> with the specified values
/// </summary>
/// <param name="application"></param>
/// <param name="message">The error message to display. if <see langword="null" />, "An error has occured" is displayed.</param>
/// <param name="title"></param>
/// <param name="okText"></param>
public static void Error(IApplication application, string? message = null, string title = "Error", string okText = "OK")
=> MessageBox.ErrorQuery(application, title, message ?? "An error has occured", okText);
public static void Error(IApplication application, Exception exception, string title = "Error", string okText = "OK")
=> MessageBox.Error(application, exception.Message, okText);
public static void Info(IApplication application, string message, string title = "Info", string okText = "OK")
=> MessageBox.Query(application, title, message, okText);
}
}