diff --git a/Terminal.Gui/Windows/Dialog.cs b/Terminal.Gui/Windows/Dialog.cs
index f1ff80a69..42b7c23a2 100644
--- a/Terminal.Gui/Windows/Dialog.cs
+++ b/Terminal.Gui/Windows/Dialog.cs
@@ -62,7 +62,7 @@ namespace Terminal.Gui {
///
/// Use the constructor that does not take a width and height instead.
///
- public Dialog (ustring title, int width, int height, params Button [] buttons) : base (title, padding: padding)
+ public Dialog (ustring title, int width, int height, params Button [] buttons) : base (title: title, padding: padding)
{
X = Pos.Center ();
Y = Pos.Center ();
@@ -119,6 +119,42 @@ namespace Terminal.Gui {
///
public Dialog (ustring title, params Button [] buttons) : this (title: title, width: 0, height: 0, buttons: buttons) { }
+ ///
+ /// Initializes a new instance of the class using positioning,
+ /// with a and with an optional set of s to display
+ ///
+ /// Title for the dialog.
+ /// The border.
+ /// Optional buttons to lay out at the bottom of the dialog.
+ public Dialog (ustring title, Border border, params Button [] buttons)
+ : this (title: title, width: 0, height: 0, buttons: buttons)
+ {
+ Initialize (title, border);
+ }
+
+ ///
+ /// Initializes a new instance of the class using positioning,
+ /// with a and with an optional set of s to display
+ ///
+ /// Title for the dialog.
+ /// Width for the dialog.
+ /// Height for the dialog.
+ /// The border.
+ /// Optional buttons to lay out at the bottom of the dialog.
+ public Dialog (ustring title, int width, int height, Border border, params Button [] buttons)
+ : this (title: title, width: width, height: height, buttons: buttons)
+ {
+ Initialize (title, border);
+ }
+
+ void Initialize (ustring title, Border border)
+ {
+ if (border != null) {
+ Border = border;
+ Border.Title = title;
+ }
+ }
+
///
/// Adds a to the , its layout will be controlled by the
///
diff --git a/Terminal.Gui/Windows/MessageBox.cs b/Terminal.Gui/Windows/MessageBox.cs
index bbf64337d..a50a71f65 100644
--- a/Terminal.Gui/Windows/MessageBox.cs
+++ b/Terminal.Gui/Windows/MessageBox.cs
@@ -281,15 +281,11 @@ namespace Terminal.Gui {
// Create Dialog (retain backwards compat by supporting specifying height/width)
Dialog d;
if (width == 0 & height == 0) {
- d = new Dialog (title, buttonList.ToArray ()) {
+ d = new Dialog (title, border, buttonList.ToArray ()) {
Height = msgboxHeight
};
} else {
- d = new Dialog (title, width, Math.Max (height, 4), buttonList.ToArray ());
- }
-
- if (border != null) {
- d.Border = border;
+ d = new Dialog (title, width, Math.Max (height, 4), border, buttonList.ToArray ());
}
if (useErrorColors) {
diff --git a/UICatalog/Scenarios/MessageBoxes.cs b/UICatalog/Scenarios/MessageBoxes.cs
index 60ac78928..3ba0f500f 100644
--- a/UICatalog/Scenarios/MessageBoxes.cs
+++ b/UICatalog/Scenarios/MessageBoxes.cs
@@ -125,6 +125,11 @@ namespace UICatalog.Scenarios {
};
frame.Add (defaultButtonEdit);
+ var border = new Border () {
+ Effect3D = true,
+ BorderStyle = BorderStyle.Single
+ };
+
label = new Label ("Style:") {
X = 0,
Y = Pos.Bottom (label),
@@ -133,16 +138,25 @@ namespace UICatalog.Scenarios {
TextAlignment = Terminal.Gui.TextAlignment.Right,
};
frame.Add (label);
+
var styleRadioGroup = new RadioGroup (new ustring [] { "_Query", "_Error" }) {
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
};
+ styleRadioGroup.SelectedItemChanged += e => {
+ switch (e.SelectedItem) {
+ case 0:
+ border.BorderBrush = Colors.Dialog.Normal.Foreground;
+ border.Background = Colors.Dialog.Normal.Background;
+ break;
+ case 1:
+ border.BorderBrush = Colors.Error.Normal.Foreground;
+ border.Background = Colors.Error.Normal.Background;
+ break;
+ }
+ };
frame.Add (styleRadioGroup);
- var border = new Border () {
- Effect3D = true,
- BorderStyle = BorderStyle.Single
- };
var ckbEffect3D = new CheckBox ("Effect3D", true) {
X = Pos.Right (label) + 1,
Y = Pos.Top (label) + 2
diff --git a/UnitTests/TopLevels/MessageBoxTests.cs b/UnitTests/TopLevels/MessageBoxTests.cs
index 8a569702f..dbf5c2bc5 100644
--- a/UnitTests/TopLevels/MessageBoxTests.cs
+++ b/UnitTests/TopLevels/MessageBoxTests.cs
@@ -319,5 +319,38 @@ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Application.Run ();
}
+
+ [Theory, AutoInitShutdown]
+ [InlineData ("", true)]
+ [InlineData ("", false)]
+ [InlineData ("\n", true)]
+ [InlineData ("\n", false)]
+ public void MessageBox_With_A_Empty_Message_Or_A_NewLline_WrapMessagge_True_Or_False (string message, bool wrapMessage)
+ {
+ var iterations = -1;
+ Application.Begin (Application.Top);
+
+ Application.Iteration += () => {
+ iterations++;
+
+ if (iterations == 0) {
+ MessageBox.Query ("mywindow", message, 0, null, wrapMessage, "ok");
+
+ Application.RequestStop ();
+ } else if (iterations == 1) {
+ Application.Refresh ();
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
+ ┌ mywindow ────────────────────────────────────┐
+ │ │
+ │ │
+ │ [◦ ok ◦] │
+ └──────────────────────────────────────────────┘", output);
+
+ Application.RequestStop ();
+ }
+ };
+
+ Application.Run ();
+ }
}
}
\ No newline at end of file