|
@@ -39,7 +39,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int Query (int width, int height, ustring title, ustring message, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (false, width, height, title, message, 0, buttons);
|
|
|
+ return QueryFull (false, width, height, title, message, 0, null, buttons);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -55,7 +55,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int Query (ustring title, ustring message, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (false, 0, 0, title, message, 0, buttons);
|
|
|
+ return QueryFull (false, 0, 0, title, message, 0, null, buttons);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -72,7 +72,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int ErrorQuery (int width, int height, ustring title, ustring message, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (true, width, height, title, message, 0, buttons);
|
|
|
+ return QueryFull (true, width, height, title, message, 0, null, buttons);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -88,7 +88,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int ErrorQuery (ustring title, ustring message, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (true, 0, 0, title, message, 0, buttons);
|
|
|
+ return QueryFull (true, 0, 0, title, message, 0, null, buttons);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -106,7 +106,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (false, width, height, title, message, defaultButton, buttons);
|
|
|
+ return QueryFull (false, width, height, title, message, defaultButton, null, buttons);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -123,9 +123,47 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int Query (ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (false, 0, 0, title, message, defaultButton, buttons);
|
|
|
+ return QueryFull (false, 0, 0, title, message, defaultButton, null, buttons);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Presents a normal <see cref="MessageBox"/> with the specified title and message and a list of buttons to show to the user.
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
|
|
|
+ /// <param name="width">Width for the window.</param>
|
|
|
+ /// <param name="height">Height for the window.</param>
|
|
|
+ /// <param name="title">Title for the query.</param>
|
|
|
+ /// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
+ /// <param name="defaultButton">Index of the default button.</param>
|
|
|
+ /// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="buttons">Array of buttons to add.</param>
|
|
|
+ /// <remarks>
|
|
|
+ /// Use <see cref="Query(ustring, ustring, ustring[])"/> instead; it automatically sizes the MessageBox based on the contents.
|
|
|
+ /// </remarks>
|
|
|
+ public static int Query (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons)
|
|
|
+ {
|
|
|
+ return QueryFull (false, width, height, title, message, defaultButton, border, buttons);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show to the user.
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
|
|
|
+ /// <param name="title">Title for the query.</param>
|
|
|
+ /// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
+ /// <param name="defaultButton">Index of the default button.</param>
|
|
|
+ /// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="buttons">Array of buttons to add.</param>
|
|
|
+ /// <remarks>
|
|
|
+ /// The message box will be vertically and horizontally centered in the container and the size will be automatically determined
|
|
|
+ /// from the size of the message and buttons.
|
|
|
+ /// </remarks>
|
|
|
+ public static int Query (ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons)
|
|
|
+ {
|
|
|
+ return QueryFull (false, 0, 0, title, message, defaultButton, border, buttons);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show to the user.
|
|
|
/// </summary>
|
|
@@ -141,7 +179,7 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (true, width, height, title, message, defaultButton, buttons);
|
|
|
+ return QueryFull (true, width, height, title, message, defaultButton, null, buttons);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -158,10 +196,48 @@ namespace Terminal.Gui {
|
|
|
/// </remarks>
|
|
|
public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
|
|
|
{
|
|
|
- return QueryFull (true, 0, 0, title, message, defaultButton, buttons);
|
|
|
+ return QueryFull (true, 0, 0, title, message, defaultButton, null, buttons);
|
|
|
}
|
|
|
|
|
|
- static int QueryFull (bool useErrorColors, int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring [] buttons)
|
|
|
+ /// <summary>
|
|
|
+ /// Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show to the user.
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
|
|
|
+ /// <param name="width">Width for the window.</param>
|
|
|
+ /// <param name="height">Height for the window.</param>
|
|
|
+ /// <param name="title">Title for the query.</param>
|
|
|
+ /// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
+ /// <param name="defaultButton">Index of the default button.</param>
|
|
|
+ /// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="buttons">Array of buttons to add.</param>
|
|
|
+ /// <remarks>
|
|
|
+ /// Use <see cref="ErrorQuery(ustring, ustring, ustring[])"/> instead; it automatically sizes the MessageBox based on the contents.
|
|
|
+ /// </remarks>
|
|
|
+ public static int ErrorQuery (int width, int height, ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons)
|
|
|
+ {
|
|
|
+ return QueryFull (true, width, height, title, message, defaultButton, border, buttons);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Presents an error <see cref="MessageBox"/> with the specified title and message and a list of buttons to show to the user.
|
|
|
+ /// </summary>
|
|
|
+ /// <returns>The index of the selected button, or -1 if the user pressed ESC to close the dialog.</returns>
|
|
|
+ /// <param name="title">Title for the query.</param>
|
|
|
+ /// <param name="message">Message to display, might contain multiple lines.</param>
|
|
|
+ /// <param name="defaultButton">Index of the default button.</param>
|
|
|
+ /// <param name="border">The border settings.</param>
|
|
|
+ /// <param name="buttons">Array of buttons to add.</param>
|
|
|
+ /// <remarks>
|
|
|
+ /// The message box will be vertically and horizontally centered in the container and the size will be automatically determined
|
|
|
+ /// from the size of the title, message. and buttons.
|
|
|
+ /// </remarks>
|
|
|
+ public static int ErrorQuery (ustring title, ustring message, int defaultButton = 0, Border border = null, params ustring [] buttons)
|
|
|
+ {
|
|
|
+ return QueryFull (true, 0, 0, title, message, defaultButton, border, buttons);
|
|
|
+ }
|
|
|
+
|
|
|
+ static int QueryFull (bool useErrorColors, int width, int height, ustring title, ustring message,
|
|
|
+ int defaultButton = 0, Border border = null, params ustring [] buttons)
|
|
|
{
|
|
|
const int defaultWidth = 50;
|
|
|
int textWidth = TextFormatter.MaxWidth (message, width == 0 ? defaultWidth : width);
|
|
@@ -192,6 +268,10 @@ namespace Terminal.Gui {
|
|
|
d = new Dialog (title, Math.Max (width, textWidth) + 4, height, buttonList.ToArray ());
|
|
|
}
|
|
|
|
|
|
+ if (border != null) {
|
|
|
+ d.Border = border;
|
|
|
+ }
|
|
|
+
|
|
|
if (useErrorColors) {
|
|
|
d.ColorScheme = Colors.Error;
|
|
|
}
|