Forráskód Böngészése

Fixes #2486 - Removes old `Border` and fixes a litany of related things (#2525)

* Added View.BorderStyle and renamed BorderStyle enum to LineStyle

* Fixed a lot of things and broke everything else

* Fixed things

* Updated DialogTests

* Updates including Rect unit tests

* Fixed Dialog & MessagBox tests

* Fixed AllviewsTester bug

* Fixed AllviewsTester bug

* Removed Border class

* Renamed View privates with _

* Removed comments in MessageBox.cs
Tig 2 éve
szülő
commit
a637f8a29c
78 módosított fájl, 5035 hozzáadás és 2619 törlés
  1. 3 3
      ReactiveExample/LoginView.cs
  2. 1 1
      Terminal.Gui/Configuration/ConfigurationManager.cs
  3. 10 9
      Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
  4. 35 12
      Terminal.Gui/Drawing/LineCanvas.cs
  5. 1 1
      Terminal.Gui/Drawing/Thickness.cs
  6. 2 1
      Terminal.Gui/FileServices/DefaultFileOperations.cs
  7. 1 27
      Terminal.Gui/Resources/config.json
  8. 437 339
      Terminal.Gui/Text/TextFormatter.cs
  9. 1 111
      Terminal.Gui/View/Border.cs
  10. 7 4
      Terminal.Gui/View/Frame.cs
  11. 217 203
      Terminal.Gui/View/View.cs
  12. 7 0
      Terminal.Gui/Views/Button.cs
  13. 37 58
      Terminal.Gui/Views/Dialog.cs
  14. 9 23
      Terminal.Gui/Views/FrameView.cs
  15. 4 0
      Terminal.Gui/Views/Label.cs
  16. 2 2
      Terminal.Gui/Views/Menu.cs
  17. 62 73
      Terminal.Gui/Views/MessageBox.cs
  18. 12 12
      Terminal.Gui/Views/TileView.cs
  19. 82 78
      Terminal.Gui/Views/Toplevel.cs
  20. 26 94
      Terminal.Gui/Views/Window.cs
  21. 5 23
      Terminal.Gui/Views/Wizard/Wizard.cs
  22. 6 3
      UICatalog/KeyBindingsDialog.cs
  23. 2 1
      UICatalog/Scenario.cs
  24. 10 12
      UICatalog/Scenarios/AllViewsTester.cs
  25. 3 3
      UICatalog/Scenarios/BackgroundWorkerCollection.cs
  26. 5 15
      UICatalog/Scenarios/BordersComparisons.cs
  27. 49 134
      UICatalog/Scenarios/BordersOnContainers.cs
  28. 6 3
      UICatalog/Scenarios/Clipping.cs
  29. 1 1
      UICatalog/Scenarios/ConfigurationEditor.cs
  30. 7 7
      UICatalog/Scenarios/CsvEditor.cs
  31. 6 2
      UICatalog/Scenarios/Dialogs.cs
  32. 3 3
      UICatalog/Scenarios/DynamicMenuBar.cs
  33. 3 3
      UICatalog/Scenarios/DynamicStatusBar.cs
  34. 4 3
      UICatalog/Scenarios/Editor.cs
  35. 2 2
      UICatalog/Scenarios/Frames.cs
  36. 1 1
      UICatalog/Scenarios/InteractiveTree.cs
  37. 2 17
      UICatalog/Scenarios/Keys.cs
  38. 12 14
      UICatalog/Scenarios/LineDrawing.cs
  39. 1 1
      UICatalog/Scenarios/MultiColouredTable.cs
  40. 1 1
      UICatalog/Scenarios/Notepad.cs
  41. 6 34
      UICatalog/Scenarios/RuneWidthGreaterThanOne.cs
  42. 1 1
      UICatalog/Scenarios/SingleBackgroundWorker.cs
  43. 5 5
      UICatalog/Scenarios/Snake.cs
  44. 2 2
      UICatalog/Scenarios/TableEditor.cs
  45. 4 10
      UICatalog/Scenarios/TileViewExperiment.cs
  46. 1 1
      UICatalog/Scenarios/TileViewNesting.cs
  47. 7 7
      UICatalog/Scenarios/ViewExperiments.cs
  48. 16 8
      UICatalog/Scenarios/WindowsAndFrameViews.cs
  49. 2 1
      UICatalog/Scenarios/Wizards.cs
  50. 2 2
      UICatalog/UICatalog.cs
  51. 4 4
      UnitTests/Application/ApplicationTests.cs
  52. 5 6
      UnitTests/Configuration/ThemeTests.cs
  53. 3 3
      UnitTests/ConsoleDrivers/ConsoleDriverTests.cs
  54. 218 66
      UnitTests/Dialogs/DialogTests.cs
  55. 322 107
      UnitTests/Dialogs/MessageBoxTests.cs
  56. 4 4
      UnitTests/Dialogs/WizardTests.cs
  57. 74 74
      UnitTests/Drawing/LineCanvasTests.cs
  58. 935 208
      UnitTests/Text/TextFormatterTests.cs
  59. 4 4
      UnitTests/Text/UnicodeTests.cs
  60. 10 13
      UnitTests/UICatalog/ScenarioTests.cs
  61. 23 615
      UnitTests/View/BorderTests.cs
  62. 340 0
      UnitTests/View/DrawTests.cs
  63. 29 2
      UnitTests/View/FrameTests.cs
  64. 838 0
      UnitTests/View/Layout/AutoSizeTests.cs
  65. 18 18
      UnitTests/View/Layout/DimTests.cs
  66. 63 8
      UnitTests/View/Layout/LayoutTests.cs
  67. 14 14
      UnitTests/View/Layout/PosTests.cs
  68. 14 14
      UnitTests/View/NavigationTests.cs
  69. 8 8
      UnitTests/View/ViewTests.cs
  70. 10 14
      UnitTests/Views/ButtonTests.cs
  71. 2 2
      UnitTests/Views/ContextMenuTests.cs
  72. 3 4
      UnitTests/Views/FrameViewTests.cs
  73. 912 0
      UnitTests/Views/LabelTests.cs
  74. 1 1
      UnitTests/Views/MenuTests.cs
  75. 4 4
      UnitTests/Views/ScrollBarViewTests.cs
  76. 3 3
      UnitTests/Views/ScrollViewTests.cs
  77. 40 49
      UnitTests/Views/ToplevelTests.cs
  78. 3 3
      UnitTests/Views/WindowTests.cs

+ 3 - 3
ReactiveExample/LoginView.cs

@@ -9,10 +9,10 @@ namespace ReactiveExample {
 	public class LoginView : Window, IViewFor<LoginViewModel> {
 		readonly CompositeDisposable _disposable = new CompositeDisposable();
 		
-		public LoginView (LoginViewModel viewModel) : base("Reactive Extensions Example") {
+		public LoginView (LoginViewModel viewModel) : base() {
+			Title = "Reactive Extensions Example";
 			ViewModel = viewModel;
-			var title = TitleLabel ();
-			var usernameLengthLabel = UsernameLengthLabel (title);
+			var usernameLengthLabel = UsernameLengthLabel (TitleLabel ());
 			var usernameInput = UsernameInput (usernameLengthLabel);
 			var passwordLengthLabel = PasswordLengthLabel (usernameInput);
 			var passwordInput = PasswordInput (passwordLengthLabel);

+ 1 - 1
Terminal.Gui/Configuration/ConfigurationManager.cs

@@ -73,7 +73,7 @@ namespace Terminal.Gui {
 		/// </summary>
 		/// <example>
 		/// 	[SerializableConfigurationProperty(Scope = typeof(Configuration.ThemeManager.ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
-		///	public static BorderStyle DefaultBorderStyle {
+		///	public static LineStyle DefaultBorderStyle {
 		///	...
 		/// </example>
 		[AttributeUsage (AttributeTargets.Property, AllowMultiple = false, Inherited = false)]

+ 10 - 9
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs

@@ -951,12 +951,12 @@ namespace Terminal.Gui {
 			/// </summary>
 			Off = 0b_0000_0000,
 			/// <summary>
-			/// When enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/> will draw a 
+			/// When enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, LineStyle)"/> will draw a 
 			/// ruler in the frame for any side with a padding value greater than 0.
 			/// </summary>
 			FrameRuler = 0b_0000_0001,
 			/// <summary>
-			/// When Enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, Border)"/> will use
+			/// When Enabled, <see cref="DrawWindowFrame(Rect, int, int, int, int, bool, bool, LineStyle)"/> will use
 			/// 'L', 'R', 'T', and 'B' for padding instead of ' '.
 			/// </summary>
 			FramePadding = 0b_0000_0010,
@@ -977,9 +977,10 @@ namespace Terminal.Gui {
 		/// <param name="paddingBottom">Number of rows to pad on the bottom (if 0 the border will not appear on the bottom).</param>
 		/// <param name="border">If set to <c>true</c> and any padding dimension is > 0 the border will be drawn.</param>
 		/// <param name="fill">If set to <c>true</c> it will clear the content area (the area inside the padding) with the current color, otherwise the content area will be left untouched.</param>
-		/// <param name="borderContent">The <see cref="Border"/> to be used if defined.</param>
+		/// <param name="lineStyle">The line style to be used.</param>
+		[ObsoleteAttribute ("This method is obsolete in v2. Use use LineCanvas or Frame instead.", false)]
 		public virtual void DrawWindowFrame (Rect region, int paddingLeft = 0, int paddingTop = 0, int paddingRight = 0,
-			int paddingBottom = 0, bool border = true, bool fill = false, Border borderContent = null)
+			int paddingBottom = 0, bool border = true, bool fill = false, LineStyle lineStyle = LineStyle.Single)
 		{
 			char clearChar = ' ';
 			char leftChar = clearChar;
@@ -1019,16 +1020,16 @@ namespace Terminal.Gui {
 			// fbottom is location of bottom frame line
 			int fbottom = ftop + fheight + 1;
 
-			var borderStyle = borderContent == null ? BorderStyle.Single : borderContent.BorderStyle;
+			var borderStyle = lineStyle;
 
 			Rune hLine = default, vLine = default,
 				uRCorner = default, uLCorner = default, lLCorner = default, lRCorner = default;
 
 			if (border) {
 				switch (borderStyle) {
-				case BorderStyle.None:
+				case LineStyle.None:
 					break;
-				case BorderStyle.Single:
+				case LineStyle.Single:
 					hLine = HLine;
 					vLine = VLine;
 					uRCorner = URCorner;
@@ -1036,7 +1037,7 @@ namespace Terminal.Gui {
 					lLCorner = LLCorner;
 					lRCorner = LRCorner;
 					break;
-				case BorderStyle.Double:
+				case LineStyle.Double:
 					hLine = HDLine;
 					vLine = VDLine;
 					uRCorner = URDCorner;
@@ -1044,7 +1045,7 @@ namespace Terminal.Gui {
 					lLCorner = LLDCorner;
 					lRCorner = LRDCorner;
 					break;
-				case BorderStyle.Rounded:
+				case LineStyle.Rounded:
 					hLine = HRLine;
 					vLine = VRLine;
 					uRCorner = URRCorner;

+ 35 - 12
Terminal.Gui/Drawing/LineCanvas.cs

@@ -4,15 +4,38 @@ using System.Linq;
 
 namespace Terminal.Gui {
 
+	/// <summary>
+	/// Defines the style of lines for a <see cref="LineCanvas"/>.
+	/// </summary>
+	public enum LineStyle {
+		/// <summary>
+		/// No border is drawn.
+		/// </summary>
+		None,
+		/// <summary>
+		/// The border is drawn using single-width line glyphs.
+		/// </summary>
+		Single,
+		/// <summary>
+		/// The border is drawn using double-width line glyphs.
+		/// </summary>
+		Double,
+		/// <summary>
+		/// The border is drawn using single-width line glyphs with rounded corners.
+		/// </summary>
+		Rounded,
+		// TODO: Support Ruler
+		///// <summary> 
+		///// The border is drawn as a diagnostic ruler ("|123456789...").
+		///// </summary>
+		//Ruler
+	}
 
 	/// <summary>
 	/// Facilitates box drawing and line intersection detection
 	/// and rendering.  Does not support diagonal lines.
 	/// </summary>
 	public class LineCanvas {
-
-
-
 		private List<StraightLine> lines = new List<StraightLine> ();
 
 		Dictionary<IntersectionRuneType, IntersectionRuneResolver> runeResolvers = new Dictionary<IntersectionRuneType, IntersectionRuneResolver> {
@@ -43,7 +66,7 @@ namespace Terminal.Gui {
 		/// Positive for Down/Right.  Negative for Up/Left.</param>
 		/// <param name="orientation">Direction of the line.</param>
 		/// <param name="style">The style of line to use</param>
-		public void AddLine (Point from, int length, Orientation orientation, BorderStyle style)
+		public void AddLine (Point from, int length, Orientation orientation, LineStyle style)
 		{
 			lines.Add (new StraightLine (from, length, orientation, style));
 		}
@@ -102,10 +125,10 @@ namespace Terminal.Gui {
 
 			public Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects)
 			{
-				var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded && i.Line.Length != 0);
+				var useRounded = intersects.Any (i => i.Line.Style == LineStyle.Rounded && i.Line.Length != 0);
 
-				bool doubleHorizontal = intersects.Any (l => l.Line.Orientation == Orientation.Horizontal && l.Line.Style == BorderStyle.Double);
-				bool doubleVertical = intersects.Any (l => l.Line.Orientation == Orientation.Vertical && l.Line.Style == BorderStyle.Double);
+				bool doubleHorizontal = intersects.Any (l => l.Line.Orientation == Orientation.Horizontal && l.Line.Style == LineStyle.Double);
+				bool doubleVertical = intersects.Any (l => l.Line.Orientation == Orientation.Vertical && l.Line.Style == LineStyle.Double);
 
 
 				if (doubleHorizontal) {
@@ -199,10 +222,10 @@ namespace Terminal.Gui {
 			}
 
 			// TODO: Remove these two once we have all of the below ported to IntersectionRuneResolvers
-			var useDouble = intersects.Any (i => i.Line.Style == BorderStyle.Double);
-			var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded);
+			var useDouble = intersects.Any (i => i.Line.Style == LineStyle.Double);
+			var useRounded = intersects.Any (i => i.Line.Style == LineStyle.Rounded);
 			// TODO: Support ruler
-			//var useRuler = intersects.Any (i => i.Line.Style == BorderStyle.Ruler && i.Line.Length != 0);
+			//var useRuler = intersects.Any (i => i.Line.Style == LineStyle.Ruler && i.Line.Length != 0);
 
 			// TODO: maybe make these resolvers to for simplicity?
 			// or for dotted lines later on or that kind of thing?
@@ -470,9 +493,9 @@ namespace Terminal.Gui {
 			public Point Start { get; }
 			public int Length { get; }
 			public Orientation Orientation { get; }
-			public BorderStyle Style { get; }
+			public LineStyle Style { get; }
 
-			public StraightLine (Point start, int length, Orientation orientation, BorderStyle style)
+			public StraightLine (Point start, int length, Orientation orientation, LineStyle style)
 			{
 				this.Start = start;
 				this.Length = length;

+ 1 - 1
Terminal.Gui/Drawing/Thickness.cs

@@ -179,7 +179,7 @@ namespace Terminal.Gui {
 				Application.Driver.FillRect (new Rect (rect.X, rect.Y + Math.Max (0, rect.Height - Bottom), rect.Width, Bottom), bottomChar);
 			}
 
-			// TODO: This should be moved to LineCanvas as a new BorderStyle.Ruler
+			// TODO: This should be moved to LineCanvas as a new LineStyle.Ruler
 			if ((ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FrameRuler) == ConsoleDriver.DiagnosticFlags.FrameRuler) {
 				// Top
 				var hruler = new Ruler () { Length = rect.Width, Orientation = Orientation.Horizontal };

+ 2 - 1
Terminal.Gui/FileServices/DefaultFileOperations.cs

@@ -67,7 +67,8 @@ namespace Terminal.Gui {
 			};
 			tf.SelectAll ();
 
-			var dlg = new Dialog (title) {
+			var dlg = new Dialog () {
+				Title = title,
 				Width = Dim.Percent (50),
 				Height = 4
 			};

+ 1 - 27
Terminal.Gui/Resources/config.json

@@ -36,35 +36,9 @@
   "Themes": [
     {
       "Default": {
-        "Dialog.DefaultBorder": {
-          "BorderStyle": "Single",
-          "DrawMarginFrame": true,
-          "BorderThickness": {
-            "Left": 0,
-            "Top": 0,
-            "Right": 0,
-            "Bottom": 0
-          },
-          "BorderBrush": "Black",
-          "Background": "Black",
-          "Padding": {
-            "Left": 0,
-            "Top": 0,
-            "Right": 0,
-            "Bottom": 0
-          },
-          "Effect3D": true,
-          "Effect3DOffset": {
-            "X": 1,
-            "Y": 1
-          },
-          "Effect3DBrush": {
-            "Foreground": "Gray",
-            "Background": "DarkGray"
-          }
-        },
         "Dialog.DefaultButtonAlignment": "Center",
         "FrameView.DefaultBorderStyle": "Single",
+        "Window.DefaultBorderStyle": "Single",
         "ColorSchemes": [
           {
             "TopLevel": {

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 437 - 339
Terminal.Gui/Text/TextFormatter.cs


+ 1 - 111
Terminal.Gui/View/Border.cs

@@ -6,115 +6,5 @@ using System.Text;
 using System.Collections.Generic;
 
 namespace Terminal.Gui {
-	/// <summary>
-	/// Specifies the border style for a <see cref="View"/> and to be used by the <see cref="Border"/> class.
-	/// </summary>
-	public enum BorderStyle {
-		/// <summary>
-		/// No border is drawn.
-		/// </summary>
-		None,
-		/// <summary>
-		/// The border is drawn using single-width line glyphs.
-		/// </summary>
-		Single,
-		/// <summary>
-		/// The border is drawn using double-width line glyphs.
-		/// </summary>
-		Double,
-		/// <summary>
-		/// The border is drawn using single-width line glyphs with rounded corners.
-		/// </summary>
-		Rounded,
-		// TODO: Support Ruler
-		///// <summary> 
-		///// The border is drawn as a diagnostic ruler ("|123456789...").
-		///// </summary>
-		//Ruler
-	}
-
-	/// <summary>
-	/// Defines the visual border for a <see cref="Frame"/>. Also provides helper APIS for rendering the border.
-	/// </summary>
-	public class Border {
-
-		/// <summary>
-		/// Raised if any of the properties that define the border are changed.
-		/// </summary>
-		public event Action<Border> BorderChanged;
-
-		private BorderStyle _style;
-		private Color _forgroundColor;
-		private Color _backgroundColor;
-
-		/// <summary>
-		/// Specifies the <see cref="Gui.BorderStyle"/> for a view.
-		/// </summary>
-		[JsonInclude, JsonConverter (typeof (JsonStringEnumConverter))]
-		public BorderStyle BorderStyle {
-			get => _style;
-			set {
-				_style = value;
-				OnBorderChanged ();
-			}
-		}
-
-		/// <summary>
-		/// Gets or sets the <see cref="Color"/> that draws the outer border color.
-		/// </summary>
-		[JsonInclude, JsonConverter (typeof (ColorJsonConverter))]
-		public Color ForgroundColor {
-			get => _forgroundColor;
-			set {
-				_forgroundColor = value;
-				OnBorderChanged ();
-			}
-		}
-
-		/// <summary>
-		/// Gets or sets the <see cref="Color"/> that fills the area between the bounds of a <see cref="Border"/>.
-		/// </summary>
-		[JsonInclude, JsonConverter (typeof (ColorJsonConverter))]
-		public Color BackgroundColor {
-			get => _backgroundColor;
-			set {
-				_backgroundColor = value;
-				OnBorderChanged ();
-			}
-		}
-
-		// TODO: These are all temporary to keep code compiling
-		/// <summary>
-		/// 
-		/// </summary>
-		public bool DrawMarginFrame { get; set; }
-		/// <summary>
-		/// 
-		/// </summary>
-		public Point Effect3DOffset { get; set; } = new Point (1, 1);
-		/// <summary>
-		/// 
-		/// </summary>
-		public bool Effect3D { get; set; }
-		/// <summary>
-		/// 
-		/// </summary>
-		public Thickness BorderThickness { get; set; } = new Thickness (0);
-		/// <summary>
-		/// 
-		/// </summary>
-		public object Effect3DBrush { get; set; }
-		/// <summary>
-		/// 
-		/// </summary>
-		public Thickness PaddingThickness { get; set; } = new Thickness (0);
-
-		/// <summary>
-		/// Invoke the <see cref="BorderChanged"/> event.
-		/// </summary>
-		public virtual void OnBorderChanged ()
-		{
-			BorderChanged?.Invoke (this);
-		}
-	}
+	
 }

+ 7 - 4
Terminal.Gui/View/Frame.cs

@@ -10,6 +10,7 @@ namespace Terminal.Gui {
 	// TODO: v2 - If a Frame has focus, navigation keys (e.g Command.NextView) should cycle through SubViews of the Frame
 	// QUESTION: How does a user navigate out of a Frame to another Frame, or back into the Parent's SubViews?
 
+	
 	/// <summary>
 	/// Frames are a special form of <see cref="View"/> that act as adornments; they appear outside of the <see cref="View.Bounds"/>
 	/// enabling borders, menus, etc... 
@@ -111,7 +112,7 @@ namespace Terminal.Gui {
 				Driver.SetAttribute (prevAttr);
 			}
 
-			if (Id == "BorderFrame" && BorderStyle != BorderStyle.None) {
+			if (Id == "BorderFrame" && BorderStyle != LineStyle.None) {
 				var lc = new LineCanvas ();
 				
 				var drawTop = Thickness.Top > 0 && Frame.Width > 1 && Frame.Height > 1;
@@ -131,9 +132,9 @@ namespace Terminal.Gui {
 						// Add a short horiz line for ╔╡
 						lc.AddLine (screenBounds.Location, 1, Orientation.Horizontal, BorderStyle);
 						// Add a short vert line for ╔╡
-						lc.AddLine (new Point (screenBounds.X + 1, screenBounds.Location.Y), 0, Orientation.Vertical, BorderStyle.Single);
+						lc.AddLine (new Point (screenBounds.X + 1, screenBounds.Location.Y), 0, Orientation.Vertical, LineStyle.Single);
 						// Add a short vert line for ╞
-						lc.AddLine (new Point (screenBounds.X + 1 + (titleWidth + 1), screenBounds.Location.Y), 0, Orientation.Vertical, BorderStyle.Single);
+						lc.AddLine (new Point (screenBounds.X + 1 + (titleWidth + 1), screenBounds.Location.Y), 0, Orientation.Vertical, LineStyle.Single);
 						// Add the right hand line for ╞═════╗
 						lc.AddLine (new Point (screenBounds.X + 1 + (titleWidth + 1), screenBounds.Location.Y), Frame.Width - (titleWidth + 3), Orientation.Horizontal, BorderStyle);
 					}
@@ -195,7 +196,7 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// 
 		/// </summary>
-		public BorderStyle BorderStyle { get; set; } = BorderStyle.None;
+		public new LineStyle BorderStyle { get; set; } = LineStyle.None;
 
 		/// <summary>
 		/// Defines the rectangle that the <see cref="Frame"/> will use to draw its content. 
@@ -206,6 +207,8 @@ namespace Terminal.Gui {
 				var prev = _thickness;
 				_thickness = value;
 				if (prev != _thickness) {
+
+					Parent?.LayoutFrames ();
 					OnThicknessChanged ();
 				}
 

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 217 - 203
Terminal.Gui/View/View.cs


+ 7 - 0
Terminal.Gui/Views/Button.cs

@@ -163,7 +163,14 @@ namespace Terminal.Gui {
 			}
 		}
 
+		/// <summary>
+		/// 
+		/// </summary>
 		public bool NoDecorations {get;set;}
+
+		/// <summary>
+		/// 
+		/// </summary>
 		public bool NoPadding {get;set;}
 
 		/// <inheritdoc/>

+ 37 - 58
Terminal.Gui/Views/Dialog.cs

@@ -32,91 +32,66 @@ namespace Terminal.Gui {
 		[SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
 		public static ButtonAlignments DefaultButtonAlignment { get; set; } = ButtonAlignments.Center;
 
+		// TODO: Reenable once border/borderframe design is settled
 		/// <summary>
 		/// Defines the default border styling for <see cref="Dialog"/>. Can be configured via <see cref="ConfigurationManager"/>.
 		/// </summary>
-		[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
-		public static Border DefaultBorder { get; set; } = new Border () {
-			BorderStyle = BorderStyle.Single,
-		};
+		//[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
+		//public static Border DefaultBorder { get; set; } = new Border () {
+		//	LineStyle = LineStyle.Single,
+		//};
 
 		internal List<Button> buttons = new List<Button> ();
 
 		/// <summary>
 		/// Initializes a new instance of the <see cref="Dialog"/> class using <see cref="LayoutStyle.Computed"/> positioning 
-		/// and an optional set of <see cref="Button"/>s to display
+		/// with no <see cref="Button"/>s.
 		/// </summary>
-		/// <param name="title">Title for the dialog.</param>
-		/// <param name="width">Width for the dialog.</param>
-		/// <param name="height">Height for the dialog.</param>
-		/// <param name="buttons">Optional buttons to lay out at the bottom of the dialog.</param>
 		/// <remarks>
-		/// if <c>width</c> and <c>height</c> are both 0, the Dialog will be vertically and horizontally centered in the
-		/// container and the size will be 85% of the container. 
-		/// After initialization use <c>X</c>, <c>Y</c>, <c>Width</c>, and <c>Height</c> to override this with a location or size.
+		/// By default, <see cref="View.X"/> and <see cref="View.Y"/> are set to <c>Pos.Center ()</c> and <see cref="View.Width"/> and <see cref="View.Height"/> are set 
+		/// to <c>Width = Dim.Percent (85)</c>, centering the Dialog vertically and horizontally. 
 		/// </remarks>
+		public Dialog () : this (null) { }
+
+		/// <summary>
+		/// Initializes a new instance of the <see cref="Dialog"/> class using <see cref="LayoutStyle.Computed"/> positioning 
+		/// and an optional set of <see cref="Button"/>s to display
+		/// </summary>
+		/// <param name="buttons">Optional buttons to lay out at the bottom of the dialog.</param>
 		/// <remarks>
-		/// Use the constructor that does not take a <c>width</c> and <c>height</c> instead.
+		/// By default, <see cref="View.X"/> and <see cref="View.Y"/> are set to <c>Pos.Center ()</c> and <see cref="View.Width"/> and <see cref="View.Height"/> are set 
+		/// to <c>Width = Dim.Percent (85)</c>, centering the Dialog vertically and horizontally. 
 		/// </remarks>
-		public Dialog (ustring title, int width, int height, params Button [] buttons) : base (title: title, padding: 0, border: DefaultBorder)
+		public Dialog (params Button [] buttons) : base ()
 		{
-			SetInitialProperties (width, height, buttons);
+			SetInitialProperties (buttons);
 		}
 
-		private void SetInitialProperties (int width, int height, Button [] buttons)
+		private void SetInitialProperties (Button [] buttons)
 		{
 			X = Pos.Center ();
 			Y = Pos.Center ();
 
-			if (width == 0 & height == 0) {
-				Width = Dim.Percent (85);
-				Height = Dim.Percent (85);
-			} else {
-				Width = width;
-				Height = height;
-			}
+			Width = Dim.Percent (85);
+			Height = Dim.Percent (85);
 
 			ColorScheme = Colors.Dialog;
+
 			Modal = true;
 			ButtonAlignment = DefaultButtonAlignment;
 
 			if (buttons != null) {
 				foreach (var b in buttons) {
-					this.buttons.Add (b);
-					Add (b);
+					AddButton (b);
 				}
 			}
 
-			LayoutStarted += (s, args) => {
-				LayoutStartedHandler ();
+			LayoutComplete += (s, args) => {
+				LayoutButtons ();
 			};
-		}
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Dialog"/> class using <see cref="LayoutStyle.Computed"/>.
-		/// </summary>
-		/// <remarks>
-		/// <para>
-		/// Te Dialog will be vertically and horizontally centered in the container and the size will be 85% of the container. 
-		/// After initialization use <c>X</c>, <c>Y</c>, <c>Width</c>, and <c>Height</c> to override this with a location or size.
-		/// </para>
-		/// <para>
-		/// Use <see cref="AddButton(Button)"/> to add buttons to the dialog.
-		/// </para>
-		/// </remarks>
-		public Dialog () : this (title: ustring.Empty, width: 0, height: 0, buttons: null) { }
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Dialog"/> class using <see cref="LayoutStyle.Computed"/> positioning 
-		/// and with an optional set of <see cref="Button"/>s to display
-		/// </summary>
-		/// <param name="title">Title for the dialog.</param>
-		/// <param name="buttons">Optional buttons to lay out at the bottom of the dialog.</param>
-		/// <remarks>
-		/// Te Dialog will be vertically and horizontally centered in the container and the size will be 85% of the container. 
-		/// After initialization use <c>X</c>, <c>Y</c>, <c>Width</c>, and <c>Height</c> to override this with a location or size.
-		/// </remarks>
-		public Dialog (ustring title, params Button [] buttons) : this (title: title, width: 0, height: 0, buttons: buttons) { }
+		}
 
 		/// <summary>
 		/// Adds a <see cref="Button"/> to the <see cref="Dialog"/>, its layout will be controlled by the <see cref="Dialog"/>
@@ -124,22 +99,26 @@ namespace Terminal.Gui {
 		/// <param name="button">Button to add.</param>
 		public void AddButton (Button button)
 		{
-			if (button == null)
+			if (button == null) {
 				return;
+			}
 
+			//button.AutoSize = false; // BUGBUG: v2 - Hack to get around autosize not accounting for Margin?
 			buttons.Add (button);
 			Add (button);
 			SetNeedsDisplay ();
 			LayoutSubviews ();
 		}
 
-		// Get the width of all buttons, not including any spacing
+		// Get the width of all buttons, not including any Margin.
 		internal int GetButtonsWidth ()
 		{
 			if (buttons.Count == 0) {
 				return 0;
 			}
-			return buttons.Select (b => b.Frame.Width).Sum ();
+			//var widths = buttons.Select (b => b.TextFormatter.GetFormattedSize ().Width + b.BorderFrame.Thickness.Horizontal + b.Padding.Thickness.Horizontal);
+			var widths = buttons.Select (b => b.Frame.Width);
+			return widths.Sum ();
 		}
 
 		/// <summary>
@@ -174,7 +153,7 @@ namespace Terminal.Gui {
 		/// </summary>
 		public ButtonAlignments ButtonAlignment { get; set; }
 
-		void LayoutStartedHandler ()
+		void LayoutButtons ()
 		{
 			if (buttons.Count == 0 || !IsInitialized) return;
 
@@ -209,8 +188,8 @@ namespace Terminal.Gui {
 						button.X = Pos.AnchorEnd (shiftLeft);
 					} else {
 						if (i == 0) {
-							// first (leftmost) button - always hard flush left
-							var left = Bounds.Width + Border.BorderThickness.Horizontal;
+							// first (leftmost) button 
+							var left = Bounds.Width;
 							button.X = Pos.AnchorEnd (left);
 						} else {
 							shiftLeft += button.Frame.Width + (spacing);

+ 9 - 23
Terminal.Gui/Views/FrameView.cs

@@ -16,20 +16,18 @@ namespace Terminal.Gui {
 		/// <param name="frame">Frame.</param>
 		/// <param name="title">Title.</param>
 		/// <param name="views">Views.</param>
-		/// <param name="border">The <see cref="Border"/>.</param>
-		public FrameView (Rect frame, ustring title = null, View [] views = null, Border border = null) : base (frame)
+		public FrameView (Rect frame, ustring title = null, View [] views = null) : base (frame)
 		{
-			SetInitialProperties (frame, title, views, border);
+			SetInitialProperties (frame, title, views);
 		}
 
 		/// <summary>
 		/// Initializes a new instance of the <see cref="Gui.FrameView"/> class using <see cref="LayoutStyle.Computed"/> layout.
 		/// </summary>
 		/// <param name="title">Title.</param>
-		/// <param name="border">The <see cref="Border"/>.</param>
-		public FrameView (ustring title, Border border = null)
+		public FrameView (ustring title)
 		{
-			SetInitialProperties (Rect.Empty, title, null, border);
+			SetInitialProperties (Rect.Empty, title, null);
 		}
 
 		/// <summary>
@@ -40,31 +38,19 @@ namespace Terminal.Gui {
 		}
 
 		/// <summary>
-		/// The default <see cref="BorderStyle"/> for <see cref="FrameView"/>. The default is <see cref="BorderStyle.Single"/>.
+		/// The default <see cref="LineStyle"/> for <see cref="FrameView"/>'s border. The default is <see cref="LineStyle.Single"/>.
 		/// </summary>
 		/// <remarks>
-		/// This property can be set in a Theme to change the default <see cref="BorderStyle"/> for all <see cref="FrameView"/>s. 
+		/// This property can be set in a Theme to change the default <see cref="LineStyle"/> for all <see cref="FrameView"/>s. 
 		/// </remarks>
 		[SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
-		public static BorderStyle DefaultBorderStyle { get; set; } = BorderStyle.Single;
+		public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
 
-		void SetInitialProperties (Rect frame, ustring title, View [] views = null, Border border = null)
+		void SetInitialProperties (Rect frame, ustring title, View [] views = null)
 		{
 			this.Title = title;
-			if (border == null) {
-				Border = new Border () {
-					BorderStyle = DefaultBorderStyle,
-					//DrawMarginFrame = true
-					//Title = title
-				};
-			} else {
-				Border = border;
-				//if (ustring.IsNullOrEmpty (border.Title)) {
-				//	border.Title = title;
-				//}
-			}
 			BorderFrame.Thickness = new Thickness (1);
-			BorderFrame.BorderStyle = Border.BorderStyle;
+			BorderFrame.BorderStyle = DefaultBorderStyle;
 			//BorderFrame.ColorScheme = ColorScheme;
 			BorderFrame.Data = "BorderFrame";
 		}

+ 4 - 0
Terminal.Gui/Views/Label.cs

@@ -58,6 +58,10 @@ namespace Terminal.Gui {
 		{
 			Height = 1;
 			AutoSize = autosize;
+			//HotKeySpecifier = new Rune ('_');
+			//if (HotKey != Key.Null) {
+			//	AddKeyBinding (Key.Space | HotKey, Command.Accept);
+			//}
 		}
 
 		/// <summary>

+ 2 - 2
Terminal.Gui/Views/Menu.cs

@@ -1374,12 +1374,12 @@ namespace Terminal.Gui {
 				}
 
 				// This positions the submenu horizontally aligned with the first character of the
-				// menu it belongs to's text
+				// text belonging to the menu 
 				for (int i = 0; i < index; i++)
 					pos += Menus [i].TitleLength + (Menus [i].Help.ConsoleWidth > 0 ? Menus [i].Help.ConsoleWidth + 2 : 0) + leftPadding + rightPadding;
 				var superView = SuperView == null ? Application.Top : SuperView;
 				Point locationOffset;
-				if (superView.Border != null && superView.Border.BorderStyle != BorderStyle.None) {
+				if (superView.BorderStyle != LineStyle.None) {
 					locationOffset = new Point (superView.Frame.X + 1, superView.Frame.Y + 1);
 				} else {
 					locationOffset = new Point (superView.Frame.X, superView.Frame.Y);

+ 62 - 73
Terminal.Gui/Views/MessageBox.cs

@@ -153,15 +153,15 @@ namespace Terminal.Gui {
 		/// <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="wrapMessagge">If wrap the message or not.</param>
+		/// <param name="wrapMessage">If wrap the message or not.</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, bool wrapMessagge = true, params ustring [] buttons)
+		public static int Query (ustring title, ustring message, int defaultButton = 0, bool wrapMessage = true, params ustring [] buttons)
 		{
-			return QueryFull (false, 0, 0, title, message, defaultButton, wrapMessagge, buttons);
+			return QueryFull (false, 0, 0, title, message, defaultButton, wrapMessage, buttons);
 		}
 
 
@@ -241,94 +241,83 @@ namespace Terminal.Gui {
 		/// Defines the default border styling for <see cref="Dialog"/>. Can be configured via <see cref="ConfigurationManager"/>.
 		/// </summary>
 		[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
-		public static Border DefaultBorder { get; set; } = new Border () {
-			BorderStyle = BorderStyle.Single,
-		};
+		public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
 
 		static int QueryFull (bool useErrorColors, int width, int height, ustring title, ustring message,
-			int defaultButton = 0, bool wrapMessagge = true, params ustring [] buttons)
+			int defaultButton = 0, bool wrapMessage = true, params ustring [] buttons)
 		{
-			int defaultWidth = 50;
-			if (defaultWidth > Application.Driver.Cols / 2) {
-				defaultWidth = (int)(Application.Driver.Cols * 0.60f);
-			}
-			int maxWidthLine = TextFormatter.MaxWidthLine (message);
-			if (wrapMessagge && maxWidthLine > Application.Driver.Cols) {
-				maxWidthLine = Application.Driver.Cols;
-			}
-			if (width == 0) {
-				maxWidthLine = Math.Max (maxWidthLine, defaultWidth);
-			} else {
-				maxWidthLine = width;
-			}
-			int textWidth = TextFormatter.MaxWidth (message, maxWidthLine);
-			int textHeight = TextFormatter.MaxLines (message, textWidth); // message.Count (ustring.Make ('\n')) + 1;
-			int msgboxHeight = Math.Max (1, textHeight) + 4; // textHeight + (top + top padding + buttons + bottom)
-
-			if (wrapMessagge) {
-				textWidth = Math.Min (textWidth, Application.Driver.Cols);
-				msgboxHeight = Math.Min (msgboxHeight, Application.Driver.Rows);
-			}
 			// Create button array for Dialog
 			int count = 0;
 			List<Button> buttonList = new List<Button> ();
-			if (buttons != null && defaultButton > buttons.Length - 1) {
-				defaultButton = buttons.Length - 1;
-			}
-			foreach (var s in buttons) {
-				var b = new Button (s);
-				if (count == defaultButton) {
-					b.IsDefault = true;
+			if (buttons != null) {
+				if (defaultButton > buttons.Length - 1) {
+					defaultButton = buttons.Length - 1;
+				}
+				foreach (var s in buttons) {
+					var b = new Button (s);
+					if (count == defaultButton) {
+						b.IsDefault = true;
+					}
+					buttonList.Add (b);
+					count++;
 				}
-				buttonList.Add (b);
-				count++;
-			}
 
-			// Create Dialog (retain backwards compat by supporting specifying height/width)
-			Dialog d;
-			if (width == 0 & height == 0) {
-				d = new Dialog (title, buttonList.ToArray ()) {
-					Height = msgboxHeight,
-					Border = DefaultBorder
-				};
-			} else {
-				d = new Dialog (title, width, Math.Max (height, 4), buttonList.ToArray ()) {
-					Border = DefaultBorder
-				};
 			}
+			
+			Dialog d;
+			d = new Dialog (buttonList.ToArray ()) {
+				Title = title,
+				BorderStyle = DefaultBorderStyle,
+				Width = Dim.Percent (60),
+				Height = 5 // Border + one line of text + vspace + buttons
+			};
 
+			if (width != 0) {
+				d.Width = width;
+			} 
+			
+			if (height != 0) {
+				d.Height = height;
+			}
+		
 			if (useErrorColors) {
 				d.ColorScheme = Colors.Error;
-				//d.Border.ForgroundColor = Colors.Error.Normal.Foreground;
-				//d.Border.BackgroundColor = Colors.Error.Normal.Background;
 			} else {
 				d.ColorScheme = Colors.Dialog;
-				//d.Border.ForgroundColor = Colors.Dialog.Normal.Foreground;
-				//d.Border.BackgroundColor = Colors.Dialog.Normal.Background;
 			}
 
-			if (!ustring.IsNullOrEmpty (message)) {
-				var l = new Label (message) {
-					LayoutStyle = LayoutStyle.Computed,
-					TextAlignment = TextAlignment.Centered,
-					X = Pos.Center (),
-					Y = Pos.Center (),
-					Width = Dim.Fill (),
-					Height = Dim.Fill (1),
-					AutoSize = false
-				};
-				d.Add (l);
-			}
+			var messageLabel = new Label () {
+				AutoSize = false,
+				Text = message,
+				TextAlignment = TextAlignment.Centered,
+				X = 0,
+				Y = 0,
+				Width = Dim.Fill (0),
+				Height = Dim.Fill (1)
+			};
+			messageLabel.TextFormatter.WordWrap = wrapMessage; // BUGBUG: This does nothing as it's not implemented by TextFormatter!
+			d.Add (messageLabel);
+			
+			d.Loaded += (s, e) => {
+				if (width != 0 || height != 0) {
+					return;
+				}
+				// TODO: replace with Dim.Fit when implemented
+				var maxBounds = d.SuperView?.Bounds ?? Application.Top.Bounds;
+				messageLabel.TextFormatter.Size = new Size (maxBounds.Size.Width - d.GetFramesThickness ().Horizontal, maxBounds.Size.Height - d.GetFramesThickness ().Vertical);
+				var msg = messageLabel.TextFormatter.Format ();
+				var messageSize = messageLabel.TextFormatter.GetFormattedSize ();
 
-			if (width == 0 & height == 0) {
-				// Dynamically size Width
-				var dWidth = Math.Max (maxWidthLine, Math.Max (title.ConsoleWidth, Math.Max (textWidth + 2, d.GetButtonsWidth () + d.buttons.Count + 2))); // textWidth + (left + padding + padding + right)
-				if (wrapMessagge) {
-					d.Width = Math.Min (dWidth, Application.Driver.Cols);
-				} else {
-					d.Width = dWidth;
+				// Ensure the width fits the text + buttons
+				var newWidth = Math.Max (width, Math.Max (messageSize.Width + d.GetFramesThickness ().Horizontal,
+								d.GetButtonsWidth () + d.buttons.Count + d.GetFramesThickness ().Horizontal));
+				if (newWidth > d.Frame.Width) {
+					d.Width = newWidth;
 				}
-			}
+				// Ensure height fits the text + vspace + buttons
+				d.Height = Math.Max (height, messageSize.Height + 2 + d.GetFramesThickness ().Vertical);
+				d.SetRelativeLayout (d.SuperView?.Frame ?? Application.Top.Frame);
+			};
 
 			// Setup actions
 			Clicked = -1;

+ 12 - 12
Terminal.Gui/Views/TileView.cs

@@ -9,7 +9,7 @@ namespace Terminal.Gui {
 	/// A <see cref="View"/> consisting of a moveable bar that divides
 	/// the display area into resizeable <see cref="Tiles"/>.
 	/// </summary>
-	public partial class TileView : View {
+	public class TileView : View {
 		TileView parentTileView;
 
 		/// <summary>
@@ -23,7 +23,7 @@ namespace Terminal.Gui {
 		/// new instances use <see cref="TileView.RebuildForTileCount(int)"/> 
 		/// or <see cref="TileView.InsertTile(int)"/>.
 		/// </summary>
-		public partial class Tile {
+		public class Tile {
 			/// <summary>
 			/// The <see cref="ContentView"/> that is contained in this <see cref="TileView"/>.
 			/// Add new child views to this member for multiple 
@@ -43,7 +43,7 @@ namespace Terminal.Gui {
 			/// </summary>
 			/// <remarks>
 			/// Title are not rendered for root level tiles 
-			/// <see cref="BorderStyle"/> is <see cref="BorderStyle.None"/>.
+			/// <see cref="Gui.LineStyle"/> is <see cref="LineStyle.None"/>.
 			///</remarks>
 			public string Title {
 				get => _title;
@@ -373,12 +373,12 @@ namespace Terminal.Gui {
 		}
 
 		/// <summary>
-		/// BUGBUG: v2 Temporary for now
+		/// The line style to use when drawing the splitter lines.
 		/// </summary>
-		public BorderStyle BorderStyle { get; set; } = BorderStyle.None;
+		public LineStyle LineStyle { get; set; } = LineStyle.None;
 
 		/// <summary>
-		/// Overriden so no Frames get drawn (BUGBUG: v2 fix this hack)
+		/// Overridden so no Frames get drawn (BUGBUG: v2 fix this hack)
 		/// </summary>
 		/// <param name="bounds"></param>
 		/// <returns></returns>
@@ -403,11 +403,11 @@ namespace Terminal.Gui {
 			if (IsRootTileView ()) {
 				if (HasBorder ()) {
 
-					lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, BorderStyle);
-					lc.AddLine (new Point (0, 0), bounds.Height - 1, Orientation.Vertical, BorderStyle);
+					lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, LineStyle);
+					lc.AddLine (new Point (0, 0), bounds.Height - 1, Orientation.Vertical, LineStyle);
 
-					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Width + 1, Orientation.Horizontal, BorderStyle);
-					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, BorderStyle);
+					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Width + 1, Orientation.Horizontal, LineStyle);
+					lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, LineStyle);
 				}
 
 				foreach (var line in allLines) {
@@ -428,7 +428,7 @@ namespace Terminal.Gui {
 						length += 2;
 					}
 
-					lc.AddLine (origin, length, line.Orientation, BorderStyle);
+					lc.AddLine (origin, length, line.Orientation, LineStyle);
 				}
 			}
 
@@ -1070,7 +1070,7 @@ namespace Terminal.Gui {
 
 		private bool HasBorder ()
 		{
-			return BorderStyle != BorderStyle.None;
+			return LineStyle != LineStyle.None;
 		}
 
 		/// <inheritdoc/>

+ 82 - 78
Terminal.Gui/Views/Toplevel.cs

@@ -615,78 +615,88 @@ namespace Terminal.Gui {
 		}
 
 		/// <summary>
-		///  Ensures the new position of the <see cref="Toplevel"/> is within the bounds of the screen (e.g. for dragging a Window).
+		///  Gets a new location of the <see cref="Toplevel"/> that is within the Bounds of the <paramref name="top"/>'s 
+		///  <see cref="View.SuperView"/> (e.g. for dragging a Window).
 		///  The `out` parameters are the new X and Y coordinates.
 		/// </summary>
+		/// <remarks>
+		/// If <paramref name="top"/> does not have a <see cref="View.SuperView"/> or it's SuperView is not <see cref="Application.Top"/>
+		/// the position will be bound by the <see cref="ConsoleDriver.Cols"/> and <see cref="ConsoleDriver.Rows"/>.
+		/// </remarks>
 		/// <param name="top">The Toplevel that is to be moved.</param>
-		/// <param name="x">The target x location.</param>
-		/// <param name="y">The target y location.</param>
-		/// <param name="nx">The x location after ensuring <paramref name="top"/> will remain visible.</param>
-		/// <param name="ny">The y location after ensuring <paramref name="top"/> will remain visible.</param>
-		/// <param name="mb">The new top most menuBar</param>
-		/// <param name="sb">The new top most statusBar</param>
-		/// <returns>The <see cref="Toplevel"/> that is Application.Top</returns>
-		internal View EnsureVisibleBounds (Toplevel top, int x, int y,
-					out int nx, out int ny, out MenuBar mb, out StatusBar sb)
+		/// <param name="targetX">The target x location.</param>
+		/// <param name="targetY">The target y location.</param>
+		/// <param name="nx">The x location that will ensure <paramref name="top"/> will be visible.</param>
+		/// <param name="ny">The y location that will ensure <paramref name="top"/> will be visible.</param>
+		/// <param name="menuBar">The new top most menuBar</param>
+		/// <param name="statusBar">The new top most statusBar</param>
+		/// <returns>
+		///  Either <see cref="Application.Top"/> (if <paramref name="top"/> does not have a Super View) or
+		///  <paramref name="top"/>'s SuperView. This can be used to ensure LayoutSubviews is called on the correct View.
+		///  </returns>
+		internal View GetLocationThatFits (Toplevel top, int targetX, int targetY,
+					out int nx, out int ny, out MenuBar menuBar, out StatusBar statusBar)
 		{
-			int l;
+			int maxWidth;
 			View superView;
 			if (top?.SuperView == null || top == Application.Top || top?.SuperView == Application.Top) {
-				l = Driver.Cols;
+				maxWidth = Driver.Cols;
 				superView = Application.Top;
 			} else {
-				l = top.SuperView.Frame.Width;
+				// Use the SuperView's Bounds, not Frame
+				maxWidth = top.SuperView.Bounds.Width;
 				superView = top.SuperView;
 			}
+
 			// BUGBUG: v2 hack for now
 			var mfLength = top.BorderFrame.Thickness.Top > 0 ? 2 : 1;
-			if (top.Frame.Width <= l) {
-				nx = Math.Max (x, 0);
-				nx = nx + top.Frame.Width > l ? Math.Max (l - top.Frame.Width, 0) : nx;
+			if (top.Frame.Width <= maxWidth) {
+				nx = Math.Max (targetX, 0);
+				nx = nx + top.Frame.Width > maxWidth ? Math.Max (maxWidth - top.Frame.Width, 0) : nx;
 				if (nx + mfLength > top.Frame.X + top.Frame.Width) {
 					nx = Math.Max (top.Frame.Right - mfLength, 0);
 				}
 			} else {
-				nx = x;
+				nx = targetX;
 			}
 			//System.Diagnostics.Debug.WriteLine ($"nx:{nx}, rWidth:{rWidth}");
-			bool m, s;
+			bool menuVisible, statusVisible;
 			if (top?.SuperView == null || top == Application.Top || top?.SuperView == Application.Top) {
-				m = Application.Top.MenuBar?.Visible == true;
-				mb = Application.Top.MenuBar;
+				menuVisible = Application.Top.MenuBar?.Visible == true;
+				menuBar = Application.Top.MenuBar;
 			} else {
 				var t = top.SuperView;
 				while (t is not Toplevel) {
 					t = t.SuperView;
 				}
-				m = ((Toplevel)t).MenuBar?.Visible == true;
-				mb = ((Toplevel)t).MenuBar;
+				menuVisible = ((Toplevel)t).MenuBar?.Visible == true;
+				menuBar = ((Toplevel)t).MenuBar;
 			}
 			if (top?.SuperView == null || top == Application.Top || top?.SuperView == Application.Top) {
-				l = m ? 1 : 0;
+				maxWidth = menuVisible ? 1 : 0;
 			} else {
-				l = 0;
+				maxWidth = 0;
 			}
-			ny = Math.Max (y, l);
+			ny = Math.Max (targetY, maxWidth);
 			if (top?.SuperView == null || top == Application.Top || top?.SuperView == Application.Top) {
-				s = Application.Top.StatusBar?.Visible == true;
-				sb = Application.Top.StatusBar;
+				statusVisible = Application.Top.StatusBar?.Visible == true;
+				statusBar = Application.Top.StatusBar;
 			} else {
 				var t = top.SuperView;
 				while (t is not Toplevel) {
 					t = t.SuperView;
 				}
-				s = ((Toplevel)t).StatusBar?.Visible == true;
-				sb = ((Toplevel)t).StatusBar;
+				statusVisible = ((Toplevel)t).StatusBar?.Visible == true;
+				statusBar = ((Toplevel)t).StatusBar;
 			}
 			if (top?.SuperView == null || top == Application.Top || top?.SuperView == Application.Top) {
-				l = s ? Driver.Rows - 1 : Driver.Rows;
+				maxWidth = statusVisible ? Driver.Rows - 1 : Driver.Rows;
 			} else {
-				l = s ? top.SuperView.Frame.Height - 1 : top.SuperView.Frame.Height;
+				maxWidth = statusVisible ? top.SuperView.Frame.Height - 1 : top.SuperView.Frame.Height;
 			}
-			ny = Math.Min (ny, l);
-			if (top.Frame.Height <= l) {
-				ny = ny + top.Frame.Height >= l ? Math.Max (l - top.Frame.Height, m ? 1 : 0) : ny;
+			ny = Math.Min (ny, maxWidth);
+			if (top.Frame.Height <= maxWidth) {
+				ny = ny + top.Frame.Height >= maxWidth ? Math.Max (maxWidth - top.Frame.Height, menuVisible ? 1 : 0) : ny;
 				if (ny + mfLength > top.Frame.Y + top.Frame.Height) {
 					ny = Math.Max (top.Frame.Bottom - mfLength, 0);
 				}
@@ -714,7 +724,7 @@ namespace Terminal.Gui {
 		/// <param name="top">The Toplevel to adjust.</param>
 		public virtual void PositionToplevel (Toplevel top)
 		{
-			var superView = EnsureVisibleBounds (top, top.Frame.X, top.Frame.Y,
+			var superView = GetLocationThatFits (top, top.Frame.X, top.Frame.Y,
 				out int nx, out int ny, out _, out StatusBar sb);
 			bool layoutSubviews = false;
 			if ((superView != top || top?.SuperView != null || (top != Application.Top && top.Modal)
@@ -739,53 +749,47 @@ namespace Terminal.Gui {
 				layoutSubviews = true;
 			}
 
-			if (layoutSubviews) {
+			if (superView.LayoutNeeded || layoutSubviews) {
 				superView.LayoutSubviews ();
 			}
+			if (LayoutNeeded) {
+				LayoutSubviews ();
+			}
 		}
 
 		///<inheritdoc/>
-		//public override void Redraw (Rect bounds)
-		//{
-		//	if (!Visible) {
-		//		return;
-		//	}
-
-		//	if (!_needsDisplay.IsEmpty || _childNeedsDisplay || LayoutNeeded) {
-		//		Driver.SetAttribute (GetNormalColor ());
-
-		//		// This is the Application.Top. Clear just the region we're being asked to redraw 
-		//		// (the bounds passed to us).
-		//		Clear ();
-		//		Driver.SetAttribute (Enabled ? Colors.Base.Normal : Colors.Base.Disabled);
-
-		//		LayoutSubviews ();
-		//		PositionToplevels ();
-
-		//		if (this == Application.MdiTop) {
-		//			foreach (var top in Application.MdiChildes.AsEnumerable ().Reverse ()) {
-		//				if (top.Frame.IntersectsWith (bounds)) {
-		//					if (top != this && !top.IsCurrentTop && !OutsideTopFrame (top) && top.Visible) {
-		//						top.SetNeedsLayout ();
-		//						top.SetNeedsDisplay (top.Bounds);
-		//						top.Redraw (top.Bounds);
-		//					}
-		//				}
-		//			}
-		//		}
-
-		//		foreach (var view in Subviews) {
-		//			if (view.Frame.IntersectsWith (bounds) && !OutsideTopFrame (this)) {
-		//				view.SetNeedsLayout ();
-		//				view.SetNeedsDisplay (view.Bounds);
-		//			}
-		//		}
-
-		//		// BUGBUG: shouldn't we just return here? the call to base.Redraw below is redundant
-		//	}
-
-		//	base.Redraw (Bounds);
-		//}
+		public override void Redraw (Rect bounds)
+		{
+			if (!Visible) {
+				return;
+			}
+
+			if (!_needsDisplay.IsEmpty || _childNeedsDisplay || LayoutNeeded) {
+				Driver.SetAttribute (Enabled ? Colors.Base.Normal : Colors.Base.Disabled);
+				LayoutSubviews ();
+				PositionToplevels ();
+
+				if (this == Application.MdiTop) {
+					foreach (var top in Application.MdiChildes.AsEnumerable ().Reverse ()) {
+						if (top.Frame.IntersectsWith (bounds)) {
+							if (top != this && !top.IsCurrentTop && !OutsideTopFrame (top) && top.Visible) {
+								top.SetNeedsLayout ();
+								top.SetNeedsDisplay (top.Bounds);
+								top.Redraw (top.Bounds);
+							}
+						}
+					}
+				}
+
+				foreach (var view in Subviews) {
+					if (view.Frame.IntersectsWith (bounds) && !OutsideTopFrame (this)) {
+						view.SetNeedsLayout ();
+						view.SetNeedsDisplay (view.Bounds);
+					}
+				}
+			}
+			base.Redraw (Bounds);
+		}
 
 		bool OutsideTopFrame (Toplevel top)
 		{
@@ -840,7 +844,7 @@ namespace Terminal.Gui {
 					} else {
 						SuperView.SetNeedsDisplay ();
 					}
-					EnsureVisibleBounds (this, mouseEvent.X + (SuperView == null ? mouseEvent.OfX - start.X : Frame.X - start.X),
+					GetLocationThatFits (this, mouseEvent.X + (SuperView == null ? mouseEvent.OfX - start.X : Frame.X - start.X),
 						mouseEvent.Y + (SuperView == null ? mouseEvent.OfY - start.Y : Frame.Y - start.Y),
 						out nx, out ny, out _, out _);
 

+ 26 - 94
Terminal.Gui/Views/Window.cs

@@ -8,124 +8,56 @@ using static Terminal.Gui.ConfigurationManager;
 namespace Terminal.Gui {
 
 	/// <summary>
-	/// A <see cref="Toplevel"/> <see cref="View"/> that draws a border around its <see cref="View.Frame"/> with a Title at the top.
+	/// A <see cref="Toplevel"/> <see cref="View"/> with <see cref="View.BorderStyle"/> set to <see cref="LineStyle.Single"/>. 
 	/// </summary>
 	/// <remarks>
-	/// The 'client area' of a <see cref="Window"/> is a rectangle deflated by one or more rows/columns from <see cref="View.Bounds"/>. A this time there is no
-	/// API to determine this rectangle.
+	/// <para>
+	/// This is a helper class to simplify creating a <see cref="Toplevel"/> with a border.
+	/// </para>
 	/// </remarks>
 	public class Window : Toplevel {
 		/// <summary>
-		/// Initializes a new instance of the <see cref="Gui.Window"/> class with an optional title using <see cref="LayoutStyle.Absolute"/> positioning.
-		/// </summary>
-		/// <param name="frame">Superview-relative rectangle specifying the location and size</param>
-		/// <param name="title">Title</param>
-		/// <remarks>
-		/// This constructor initializes a Window with a <see cref="LayoutStyle"/> of <see cref="LayoutStyle.Absolute"/>. Use constructors
-		/// that do not take <c>Rect</c> parameters to initialize a Window with <see cref="LayoutStyle.Computed"/>. 
-		/// </remarks>
-		public Window (Rect frame, ustring title = null) : this (frame, title, padding: 0, border: null)
-		{
-		}
-
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Window"/> class with an optional title using <see cref="LayoutStyle.Computed"/> positioning.
+		/// Initializes a new instance of the <see cref="Window"/> class using <see cref="LayoutStyle.Computed"/> positioning.
 		/// </summary>
-		/// <param name="title">Title.</param>
-		/// <remarks>
-		///   This constructor initializes a View with a <see cref="LayoutStyle"/> of <see cref="LayoutStyle.Computed"/>. 
-		///   Use <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and <see cref="View.Height"/> properties to dynamically control the size and location of the view.
-		/// </remarks>
-		public Window (ustring title = null) : this (title, padding: 0, border: null)
-		{
+		public Window () : base () {
+			SetInitialProperties ();
 		}
 
 		/// <summary>
 		/// Initializes a new instance of the <see cref="Window"/> class using <see cref="LayoutStyle.Computed"/> positioning.
 		/// </summary>
-		public Window () : this (title: null) { }
-
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Window"/> using <see cref="LayoutStyle.Absolute"/> positioning with the specified frame for its location, with the specified frame padding,
-		/// and an optional title.
-		/// </summary>
-		/// <param name="frame">Superview-relative rectangle specifying the location and size</param>
-		/// <param name="title">Title</param>
-		/// <param name="padding">Number of characters to use for padding of the drawn frame.</param>
-		/// <param name="border">The <see cref="Border"/>.</param>
-		/// <remarks>
-		/// This constructor initializes a Window with a <see cref="LayoutStyle"/> of <see cref="LayoutStyle.Absolute"/>. Use constructors
-		/// that do not take <c>Rect</c> parameters to initialize a Window with  <see cref="LayoutStyle"/> of <see cref="LayoutStyle.Computed"/> 
-		/// </remarks>
-		public Window (Rect frame, ustring title = null, int padding = 0, Border border = null) : base (frame)
+		public Window (Rect frame) : base (frame)
 		{
-			SetInitialProperties (title, frame, padding, border);
+			SetInitialProperties ();
 		}
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Window"/> using <see cref="LayoutStyle.Computed"/> positioning,
-		/// and an optional title.
-		/// </summary>
-		/// <param name="title">Title.</param>
-		/// <param name="padding">Number of characters to use for padding of the drawn frame.</param>
-		/// <param name="border">The <see cref="Border"/>.</param>
-		/// <remarks>
-		///   This constructor initializes a View with a <see cref="LayoutStyle"/> of <see cref="LayoutStyle.Computed"/>. 
-		///   Use <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and <see cref="View.Height"/> properties to dynamically control the size and location of the view.
-		/// </remarks>
-		public Window (ustring title = null, int padding = 0, Border border = null) : base ()
-		{
-			SetInitialProperties (title, Rect.Empty, padding, border);
-		}
+		// TODO: enable this
+		///// <summary>
+		///// The default <see cref="LineStyle"/> for <see cref="Window"/>'s border. The default is <see cref="LineStyle.Single"/>.
+		///// </summary>
+		///// <remarks>
+		///// This property can be set in a Theme to change the default <see cref="LineStyle"/> for all <see cref="Window"/>s. 
+		///// </remarks>
+		/////[SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
+		////public static ColorScheme DefaultColorScheme { get; set; } = Colors.Base;
 
 		/// <summary>
-		/// The default <see cref="BorderStyle"/> for <see cref="FrameView"/>. The default is <see cref="BorderStyle.Single"/>.
+		/// The default <see cref="LineStyle"/> for <see cref="Window"/>'s border. The default is <see cref="LineStyle.Single"/>.
 		/// </summary>
 		/// <remarks>
-		/// This property can be set in a Theme to change the default <see cref="BorderStyle"/> for all <see cref="Window"/>s. 
+		/// This property can be set in a Theme to change the default <see cref="LineStyle"/> for all <see cref="Window"/>s. 
 		/// </remarks>
-		///[SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
-		public static BorderStyle DefaultBorderStyle { get; set; } = BorderStyle.Single;
+		[SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
+		public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
 
-		void SetInitialProperties (ustring title, Rect frame, int padding = 0, Border border = null)
+		void SetInitialProperties ()
 		{
 			CanFocus = true;
-			ColorScheme = Colors.Base;
-			if (title == null) title = ustring.Empty;
-			Title = title;
-
-			if (border == null) {
-				// TODO: v2 this is a hack until Border gets refactored
-				Border = new Border () {
-					BorderStyle = DefaultBorderStyle,
-					PaddingThickness = new Thickness (padding),
-				};
-			} else {
-				Border = border;
-			}
-			BorderFrame.Thickness = new Thickness (1);
-			BorderFrame.BorderStyle = Border.BorderStyle;
-			//BorderFrame.ColorScheme = ColorScheme;
-			BorderFrame.Data = "BorderFrame";
-
-			// TODO: Hack until Border is refactored
-			Padding.Thickness = Border.PaddingThickness ?? Padding.Thickness;
-
-			if (frame.IsEmpty) {
-				// Make it bigger to fit the margin, border, & padding
-				frame = new Rect (frame.Location, new Size (Margin.Thickness.Horizontal + BorderFrame.Thickness.Horizontal + Padding.Thickness.Horizontal + 1, Margin.Thickness.Vertical + BorderFrame.Thickness.Vertical + Padding.Thickness.Vertical + 1));
-			}
+			ColorScheme = Colors.Base; // TODO: make this a theme property
+			BorderStyle = DefaultBorderStyle;
 		}
 
-		///// <summary>
-		///// Enumerates the various <see cref="View"/>s in the embedded <see cref="ContentView"/>.
-		///// </summary>
-		///// <returns>The enumerator.</returns>
-		//public new IEnumerator GetEnumerator ()
-		//{
-		//	return contentView.GetEnumerator ();
-		//}
-
+		// TODO: Are these overrides really needed? 
 		/// <inheritdoc/>
 		public override void Add (View view)
 		{

+ 5 - 23
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -134,7 +134,7 @@ namespace Terminal.Gui {
 			public WizardStep (ustring title)
 			{
 				this.Title = title; // this.Title holds just the "Wizard Title"; base.Title holds "Wizard Title - Step Title"
-				this.Border.BorderStyle = BorderStyle.Rounded;
+				this.BorderStyle = LineStyle.Rounded;
 				base.Add (contentView);
 
 				helpTextView.ReadOnly = true;
@@ -274,26 +274,12 @@ namespace Terminal.Gui {
 		/// The Wizard will be vertically and horizontally centered in the container.
 		/// After initialization use <c>X</c>, <c>Y</c>, <c>Width</c>, and <c>Height</c> change size and position.
 		/// </remarks>
-		public Wizard () : this (ustring.Empty)
-		{
-		}
+		public Wizard () : base () { 
 
-		/// <summary>
-		/// Initializes a new instance of the <see cref="Wizard"/> class using <see cref="LayoutStyle.Computed"/> positioning.
-		/// </summary>
-		/// <param name="title">Sets the <see cref="Title"/> for the Wizard.</param>
-		/// <remarks>
-		/// The Wizard will be vertically and horizontally centered in the container.
-		/// After initialization use <c>X</c>, <c>Y</c>, <c>Width</c>, and <c>Height</c> change size and position.
-		/// </remarks>
-		public Wizard (ustring title) : base (title)
-		{
-			wizardTitle = title;
 			// Using Justify causes the Back and Next buttons to be hard justified against
 			// the left and right edge
 			ButtonAlignment = ButtonAlignments.Justify;
-			this.Border.BorderStyle = BorderStyle.Double;
-			this.Border.PaddingThickness = new Thickness (0);
+			BorderStyle = LineStyle.Double;
 
 			//// Add a horiz separator
 			//var separator = new LineView (Graphs.Orientation.Horizontal) {
@@ -736,9 +722,7 @@ namespace Terminal.Gui {
 				}
 				if (base.Modal) {
 					ColorScheme = Colors.Dialog;
-					Border.BorderStyle = BorderStyle.Rounded;
-//					Border.Effect3D = true;
-//					Border.DrawMarginFrame = true;
+					BorderStyle = LineStyle.Rounded;
 				} else {
 					if (SuperView != null) {
 						ColorScheme = SuperView.ColorScheme;
@@ -746,9 +730,7 @@ namespace Terminal.Gui {
 						ColorScheme = Colors.Base;
 					}
 					CanFocus = true;
-//					Border.Effect3D = false;
-					Border.BorderStyle = BorderStyle.None;
-//					Border.DrawMarginFrame = false;
+					BorderStyle = LineStyle.None;
 				}
 			}
 		}

+ 6 - 3
UICatalog/KeyBindingsDialog.cs

@@ -122,9 +122,12 @@ namespace UICatalog {
 			}
 		}
 
-		public KeyBindingsDialog () : base("Keybindings", 50,10)
+		public KeyBindingsDialog () : base()
 		{
-			if(ViewTracker.Instance == null) {
+			Title = "Keybindings";
+			Height = 50;
+			Width = 10;
+			if (ViewTracker.Instance == null) {
 				ViewTracker.Initialize ();
 			}
 			
@@ -178,7 +181,7 @@ namespace UICatalog {
 			Key? key = null;
 
 			// prompt user to hit a key
-			var dlg = new Dialog ("Enter Key");
+			var dlg = new Dialog () { Title = "Enter Key" };
 			dlg.KeyPress += (s, k) => {
 				key = k.KeyEvent.Key;
 				Application.RequestStop ();

+ 2 - 1
UICatalog/Scenario.cs

@@ -78,7 +78,8 @@ namespace UICatalog {
 			ConfigurationManager.Themes.Theme = Theme;
 			ConfigurationManager.Apply ();
 
-			Win = new Window ($"{Application.QuitKey} to Quit - Scenario: {GetName ()}") {
+			Win = new Window () {
+				Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}",
 				X = 0,
 				Y = 0,
 				Width = Dim.Fill (),

+ 10 - 12
UICatalog/Scenarios/AllViewsTester.cs

@@ -91,7 +91,14 @@ namespace UICatalog.Scenarios {
 				_settingsPane.SetFocus ();
 			};
 			_classListView.SelectedItemChanged += (s,args) => {
-				ClearClass (_curView);
+				// Remove existing class, if any
+				if (_curView != null) {
+					_curView.LayoutComplete -= LayoutCompleteHandler;
+					_hostPane.Remove (_curView);
+					_curView.Dispose ();
+					_curView = null;
+					_hostPane.Clear ();
+				}
 				_curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
 			};
 			_leftPane.Add (_classListView);
@@ -347,19 +354,10 @@ namespace UICatalog.Scenarios {
 			 .Where (myType => myType.IsClass && !myType.IsAbstract && myType.IsPublic && myType.IsSubclassOf (typeof (View)))) {
 				types.Add (type);
 			}
+			types.Add (typeof (View));
 			return types;
 		}
-
-		void ClearClass (View view)
-		{
-			// Remove existing class, if any
-			if (view != null) {
-				view.LayoutComplete -= LayoutCompleteHandler;
-				_hostPane.Remove (view);
-				view.Dispose ();
-				_hostPane.Clear ();
-			}
-		}
+		
 
 		View CreateClass (Type type)
 		{

+ 3 - 3
UICatalog/Scenarios/BackgroundWorkerCollection.cs

@@ -345,14 +345,14 @@ namespace UICatalog.Scenarios {
 				};
 
 				LayoutStarted += (s,e) => {
-					var btnsWidth = start.Bounds.Width + close.Bounds.Width + 2 - 1;
+					var btnsWidth = start.Frame.Width + close.Frame.Width + 2 - 1;
 					var shiftLeft = Math.Max ((Bounds.Width - btnsWidth) / 2 - 2, 0);
 
-					shiftLeft += close.Bounds.Width + 1;
+					shiftLeft += close.Frame.Width + 1;
 					close.X = Pos.AnchorEnd (shiftLeft);
 					close.Y = Pos.AnchorEnd (1);
 
-					shiftLeft += start.Bounds.Width + 1;
+					shiftLeft += start.Frame.Width + 1;
 					start.X = Pos.AnchorEnd (shiftLeft);
 					start.Y = Pos.AnchorEnd (1);
 				};

+ 5 - 15
UICatalog/Scenarios/BordersComparisons.cs

@@ -9,18 +9,13 @@ namespace UICatalog.Scenarios {
 		{
 			Application.Init ();
 
-			var borderStyle = BorderStyle.Double;
+			var borderStyle = LineStyle.Double;
 			var borderThickness = new Thickness (1, 2, 3, 4);
 			var padding = 1;
 
 			Application.Top.Text = $"Border Thickness: {borderThickness}\nPadding: {padding}";
 
-			var win = new Window (new Rect (5, 5, 40, 20), "Window",
-				padding: padding,
-				border: new Border () {
-					BorderStyle = borderStyle,
-					BorderThickness = borderThickness
-				});
+			var win = new Window (new Rect (5, 5, 40, 20)) { Title = "Window" };
 
 			var tf1 = new TextField ("1234567890") { Width = 10 };
 
@@ -77,14 +72,9 @@ namespace UICatalog.Scenarios {
 			topLevel.Add (tf3, button2, label2, tv2, tf4);
 			Application.Top.Add (topLevel);
 
-			var frameView = new FrameView (new Rect (95, 5, 40, 20), "FrameView", null,
-				border: new Border () {
-					BorderStyle = borderStyle,
-					BorderThickness = borderThickness
-				}
-			);
-			//frameView.BorderFrame.Thickness = borderThickness;
-			//frameView.BorderFrame.BorderStyle = borderStyle;
+			var frameView = new FrameView (new Rect (95, 5, 40, 20), "FrameView", null);
+			frameView.BorderFrame.Thickness = borderThickness;
+			frameView.BorderFrame.BorderStyle = borderStyle;
 			//frameView.Padding.Thickness = paddingThickness;
 
 			var tf5 = new TextField ("1234567890") { Width = 10 };

+ 49 - 134
UICatalog/Scenarios/BordersOnContainers.cs

@@ -7,28 +7,18 @@ namespace UICatalog.Scenarios {
 	public class BordersOnContainers : Window {
 		public BordersOnContainers (NStack.ustring title, string typeName, View smartView)
 		{
-			var borderStyle = BorderStyle.Double;
-			var drawMarginFrame = false;
+			var borderStyle = LineStyle.Double;
 			var borderThickness = new Thickness (1, 2, 3, 4);
 			var borderBrush = Colors.Base.HotFocus.Foreground;
 			var padding = new Thickness (1, 2, 3, 4);
 			var background = Colors.Base.HotNormal.Foreground;
-			var effect3D = true;
 
 			smartView.X = Pos.Center ();
 			smartView.Y = 0;
 			smartView.Width = 40;
 			smartView.Height = 20;
-			smartView.Border = new Border () {
-				BorderStyle = borderStyle,
-				DrawMarginFrame = drawMarginFrame,
-				BorderThickness = borderThickness,
-				ForgroundColor = borderBrush,
-				PaddingThickness = padding,
-				BackgroundColor = background,
-				Effect3D = effect3D,
-				//Title = typeName
-			};
+			smartView.BorderStyle = borderStyle;
+			
 			smartView.ColorScheme = Colors.TopLevel;
 
 			var tf1 = new TextField ("1234567890") { Width = 10 };
@@ -66,16 +56,16 @@ namespace UICatalog.Scenarios {
 			};
 			paddingTopEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Left,
-						int.Parse (e.NewText.ToString ()), smartView.Border.PaddingThickness.Right,
-						smartView.Border.PaddingThickness.Bottom);
+					smartView.Padding.Thickness = new Thickness (smartView.Padding.Thickness.Left,
+						int.Parse (e.NewText.ToString ()), smartView.Padding.Thickness.Right,
+						smartView.Padding.Thickness.Bottom);
 				} catch {
 					if (!e.NewText.IsEmpty) {
 						e.Cancel = true;
 					}
 				}
 			};
-			paddingTopEdit.Text = $"{smartView.Border.PaddingThickness.Top}";
+			paddingTopEdit.Text = $"{smartView.Padding.Thickness.Top}";
 
 			Add (paddingTopEdit);
 
@@ -86,16 +76,16 @@ namespace UICatalog.Scenarios {
 			};
 			paddingLeftEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.PaddingThickness = new Thickness (int.Parse (e.NewText.ToString ()),
-						smartView.Border.PaddingThickness.Top, smartView.Border.PaddingThickness.Right,
-						smartView.Border.PaddingThickness.Bottom);
+					smartView.Padding.Thickness = new Thickness (int.Parse (e.NewText.ToString ()),
+						smartView.Padding.Thickness.Top, smartView.Padding.Thickness.Right,
+						smartView.Padding.Thickness.Bottom);
 				} catch {
 					if (!e.NewText.IsEmpty) {
 						e.Cancel = true;
 					}
 				}
 			};
-			paddingLeftEdit.Text = $"{smartView.Border.PaddingThickness.Left}";
+			paddingLeftEdit.Text = $"{smartView.Padding.Thickness.Left}";
 			Add (paddingLeftEdit);
 
 			var paddingRightEdit = new TextField ("") {
@@ -105,16 +95,16 @@ namespace UICatalog.Scenarios {
 			};
 			paddingRightEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Left,
-						smartView.Border.PaddingThickness.Top, int.Parse (e.NewText.ToString ()),
-						smartView.Border.PaddingThickness.Bottom);
+					smartView.Padding.Thickness = new Thickness (smartView.Padding.Thickness.Left,
+						smartView.Padding.Thickness.Top, int.Parse (e.NewText.ToString ()),
+						smartView.Padding.Thickness.Bottom);
 				} catch {
 					if (!e.NewText.IsEmpty) {
 						e.Cancel = true;
 					}
 				}
 			};
-			paddingRightEdit.Text = $"{smartView.Border.PaddingThickness.Right}";
+			paddingRightEdit.Text = $"{smartView.Padding.Thickness.Right}";
 			Add (paddingRightEdit);
 
 			var paddingBottomEdit = new TextField ("") {
@@ -124,8 +114,8 @@ namespace UICatalog.Scenarios {
 			};
 			paddingBottomEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Left,
-						smartView.Border.PaddingThickness.Top, smartView.Border.PaddingThickness.Right,
+					smartView.Padding.Thickness = new Thickness (smartView.Padding.Thickness.Left,
+						smartView.Padding.Thickness.Top, smartView.Padding.Thickness.Right,
 						int.Parse (e.NewText.ToString ()));
 				} catch {
 					if (!e.NewText.IsEmpty) {
@@ -133,7 +123,7 @@ namespace UICatalog.Scenarios {
 					}
 				}
 			};
-			paddingBottomEdit.Text = $"{smartView.Border.PaddingThickness.Bottom}";
+			paddingBottomEdit.Text = $"{smartView.Padding.Thickness.Bottom}";
 			Add (paddingBottomEdit);
 
 			var replacePadding = new Button ("Replace all based on top") {
@@ -141,7 +131,7 @@ namespace UICatalog.Scenarios {
 				Y = 5
 			};
 			replacePadding.Clicked += (s, e) => {
-				smartView.Border.PaddingThickness = new Thickness (smartView.Border.PaddingThickness.Top);
+				smartView.Padding.Thickness = new Thickness (smartView.Padding.Thickness.Top);
 				if (paddingTopEdit.Text.IsEmpty) {
 					paddingTopEdit.Text = "0";
 				}
@@ -160,16 +150,16 @@ namespace UICatalog.Scenarios {
 			};
 			borderTopEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Left,
-						int.Parse (e.NewText.ToString ()), smartView.Border.BorderThickness.Right,
-						smartView.Border.BorderThickness.Bottom);
+					smartView.BorderFrame.Thickness = new Thickness (smartView.BorderFrame.Thickness.Left,
+						int.Parse (e.NewText.ToString ()), smartView.BorderFrame.Thickness.Right,
+						smartView.BorderFrame.Thickness.Bottom);
 				} catch {
 					if (!e.NewText.IsEmpty) {
 						e.Cancel = true;
 					}
 				}
 			};
-			borderTopEdit.Text = $"{smartView.Border.BorderThickness.Top}";
+			borderTopEdit.Text = $"{smartView.BorderFrame.Thickness.Top}";
 
 			Add (borderTopEdit);
 
@@ -180,16 +170,16 @@ namespace UICatalog.Scenarios {
 			};
 			borderLeftEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.BorderThickness = new Thickness (int.Parse (e.NewText.ToString ()),
-						smartView.Border.BorderThickness.Top, smartView.Border.BorderThickness.Right,
-						smartView.Border.BorderThickness.Bottom);
+					smartView.BorderFrame.Thickness = new Thickness (int.Parse (e.NewText.ToString ()),
+						smartView.BorderFrame.Thickness.Top, smartView.BorderFrame.Thickness.Right,
+						smartView.BorderFrame.Thickness.Bottom);
 				} catch {
 					if (!e.NewText.IsEmpty) {
 						e.Cancel = true;
 					}
 				}
 			};
-			borderLeftEdit.Text = $"{smartView.Border.BorderThickness.Left}";
+			borderLeftEdit.Text = $"{smartView.BorderFrame.Thickness.Left}";
 			Add (borderLeftEdit);
 
 			var borderRightEdit = new TextField ("") {
@@ -199,16 +189,16 @@ namespace UICatalog.Scenarios {
 			};
 			borderRightEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Left,
-						smartView.Border.BorderThickness.Top, int.Parse (e.NewText.ToString ()),
-						smartView.Border.BorderThickness.Bottom);
+					smartView.BorderFrame.Thickness = new Thickness (smartView.BorderFrame.Thickness.Left,
+						smartView.BorderFrame.Thickness.Top, int.Parse (e.NewText.ToString ()),
+						smartView.BorderFrame.Thickness.Bottom);
 				} catch {
 					if (!e.NewText.IsEmpty) {
 						e.Cancel = true;
 					}
 				}
 			};
-			borderRightEdit.Text = $"{smartView.Border.BorderThickness.Right}";
+			borderRightEdit.Text = $"{smartView.BorderFrame.Thickness.Right}";
 			Add (borderRightEdit);
 
 			var borderBottomEdit = new TextField ("") {
@@ -218,8 +208,8 @@ namespace UICatalog.Scenarios {
 			};
 			borderBottomEdit.TextChanging += (s, e) => {
 				try {
-					smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Left,
-						smartView.Border.BorderThickness.Top, smartView.Border.BorderThickness.Right,
+					smartView.BorderFrame.Thickness = new Thickness (smartView.BorderFrame.Thickness.Left,
+						smartView.BorderFrame.Thickness.Top, smartView.BorderFrame.Thickness.Right,
 						int.Parse (e.NewText.ToString ()));
 				} catch {
 					if (!e.NewText.IsEmpty) {
@@ -227,7 +217,7 @@ namespace UICatalog.Scenarios {
 					}
 				}
 			};
-			borderBottomEdit.Text = $"{smartView.Border.BorderThickness.Bottom}";
+			borderBottomEdit.Text = $"{smartView.BorderFrame.Thickness.Bottom}";
 			Add (borderBottomEdit);
 
 			var replaceBorder = new Button ("Replace all based on top") {
@@ -235,7 +225,7 @@ namespace UICatalog.Scenarios {
 				Y = 5
 			};
 			replaceBorder.Clicked += (s, e) => {
-				smartView.Border.BorderThickness = new Thickness (smartView.Border.BorderThickness.Top);
+				smartView.BorderFrame.Thickness = new Thickness (smartView.BorderFrame.Thickness.Top);
 				if (borderTopEdit.Text.IsEmpty) {
 					borderTopEdit.Text = "0";
 				}
@@ -247,101 +237,19 @@ namespace UICatalog.Scenarios {
 
 			Add (new Label ("BorderStyle:"));
 
-			var borderStyleEnum = Enum.GetValues (typeof (BorderStyle)).Cast<BorderStyle> ().ToList ();
+			var borderStyleEnum = Enum.GetValues (typeof (LineStyle)).Cast<LineStyle> ().ToList ();
 			var rbBorderStyle = new RadioGroup (borderStyleEnum.Select (
 				e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
 
 				X = 2,
 				Y = 1,
-				SelectedItem = (int)smartView.Border.BorderStyle
+				SelectedItem = (int)smartView.BorderStyle
 			};
 			Add (rbBorderStyle);
 
-			var cbDrawMarginFrame = new CheckBox ("Draw Margin Frame", smartView.Border.DrawMarginFrame) {
-				X = Pos.AnchorEnd (20),
-				Y = 0,
-				Width = 5
-			};
-			cbDrawMarginFrame.Toggled += (s, e) => {
-				try {
-					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
-					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
-						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
-					}
-				} catch { }
-			};
-			Add (cbDrawMarginFrame);
-
 			rbBorderStyle.SelectedItemChanged += (s, e) => {
-				smartView.Border.BorderStyle = (BorderStyle)e.SelectedItem;
+				smartView.BorderStyle = (LineStyle)e.SelectedItem;
 				smartView.SetNeedsDisplay ();
-				if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
-					cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
-				}
-			};
-
-			var cbEffect3D = new CheckBox ("Draw 3D effects", smartView.Border.Effect3D) {
-				X = Pos.AnchorEnd (20),
-				Y = 1,
-				Width = 5
-			};
-			Add (cbEffect3D);
-
-			Add (new Label ("Effect3D Offset:") {
-				X = Pos.AnchorEnd (20),
-				Y = 2
-			});
-			Add (new Label ("X:") {
-				X = Pos.AnchorEnd (19),
-				Y = 3
-			});
-
-			var effect3DOffsetX = new TextField ("") {
-				X = Pos.AnchorEnd (16),
-				Y = 3,
-				Width = 5
-			};
-			effect3DOffsetX.TextChanging += (s, e) => {
-				try {
-					smartView.Border.Effect3DOffset = new Point (int.Parse (e.NewText.ToString ()),
-						smartView.Border.Effect3DOffset.Y);
-				} catch {
-					if (!e.NewText.IsEmpty && e.NewText != CultureInfo.CurrentCulture.NumberFormat.NegativeSign) {
-						e.Cancel = true;
-					}
-				}
-			};
-			effect3DOffsetX.Text = $"{smartView.Border.Effect3DOffset.X}";
-			Add (effect3DOffsetX);
-
-			Add (new Label ("Y:") {
-				X = Pos.AnchorEnd (10),
-				Y = 3
-			});
-
-			var effect3DOffsetY = new TextField ("") {
-				X = Pos.AnchorEnd (7),
-				Y = 3,
-				Width = 5
-			};
-			effect3DOffsetY.TextChanging += (s, e) => {
-				try {
-					smartView.Border.Effect3DOffset = new Point (smartView.Border.Effect3DOffset.X,
-						int.Parse (e.NewText.ToString ()));
-				} catch {
-					if (!e.NewText.IsEmpty && e.NewText != CultureInfo.CurrentCulture.NumberFormat.NegativeSign) {
-						e.Cancel = true;
-					}
-				}
-			};
-			effect3DOffsetY.Text = $"{smartView.Border.Effect3DOffset.Y}";
-			Add (effect3DOffsetY);
-
-			cbEffect3D.Toggled += (s, e) => {
-				try {
-					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
-						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;
-				} catch { }
 			};
 
 			Add (new Label ("Background:") {
@@ -354,10 +262,17 @@ namespace UICatalog.Scenarios {
 
 				X = 2,
 				Y = 6,
-				SelectedItem = (int)smartView.Border.BackgroundColor
+				//SelectedItem = (int)smartView.BorderFrame.BackgroundColor
 			};
 			rbBackground.SelectedItemChanged += (s, e) => {
-				smartView.Border.BackgroundColor = (Color)e.SelectedItem;
+//				smartView.Border.BackgroundColor = (Color)e.SelectedItem;
+				smartView.BorderFrame.ColorScheme = new ColorScheme() { 
+					Normal = new Terminal.Gui.Attribute(Color.Red, Color.White),
+					HotNormal = new Terminal.Gui.Attribute (Color.Magenta, Color.White),
+					Disabled = new Terminal.Gui.Attribute (Color.Gray, Color.White),
+					Focus = new Terminal.Gui.Attribute (Color.Blue, Color.White),
+					HotFocus = new Terminal.Gui.Attribute (Color.BrightBlue, Color.White),	
+				};
 			};
 			Add (rbBackground);
 
@@ -371,10 +286,10 @@ namespace UICatalog.Scenarios {
 
 				X = Pos.AnchorEnd (18),
 				Y = 6,
-				SelectedItem = (int)smartView.Border.ForgroundColor
+				//SelectedItem = (int)smartView.Border.ForgroundColor
 			};
 			rbBorderBrush.SelectedItemChanged += (s, e) => {
-				smartView.Border.ForgroundColor = (Color)e.SelectedItem;
+				//smartView.Border.ForgroundColor = (Color)e.SelectedItem;
 			};
 			Add (rbBorderBrush);
 

+ 6 - 3
UICatalog/Scenarios/Clipping.cs

@@ -32,7 +32,8 @@ namespace UICatalog.Scenarios {
 			//scrollView.ShowVerticalScrollIndicator = true;
 			//scrollView.ShowHorizontalScrollIndicator = true;
 
-			var embedded1 = new Window ("1") {
+			var embedded1 = new Window () {
+				Title = "1",
 				X = 3,
 				Y = 3,
 				Width = Dim.Fill (3),
@@ -41,7 +42,8 @@ namespace UICatalog.Scenarios {
 				Id = "1"
 			};
 
-			var embedded2 = new Window ("2") {
+			var embedded2 = new Window () {
+				Title = "1",
 				X = 3,
 				Y = 3,
 				Width = Dim.Fill (3),
@@ -51,7 +53,8 @@ namespace UICatalog.Scenarios {
 			};
 			embedded1.Add (embedded2);
 
-			var embedded3 = new Window ("3") {
+			var embedded3 = new Window () {
+				Title = "3",
 				X = 3,
 				Y = 3,
 				Width = Dim.Fill (3),

+ 1 - 1
UICatalog/Scenarios/ConfigurationEditor.cs

@@ -46,7 +46,7 @@ namespace UICatalog.Scenarios {
 				Width = Dim.Fill (),
 				Height = Dim.Fill (1),
 				Orientation = Orientation.Vertical,
-				Border = new Border () { BorderStyle = BorderStyle.Single }
+				LineStyle = LineStyle.Single
 			};
 
 			Application.Top.Add (_tileView);

+ 7 - 7
UICatalog/Scenarios/CsvEditor.cs

@@ -388,7 +388,7 @@ namespace UICatalog.Scenarios {
 			}
 
 		}
-
+		
 		private void Open ()
 		{
 			var ofd = new FileDialog () {
@@ -436,7 +436,7 @@ namespace UICatalog.Scenarios {
 
 				// Only set the current filename if we successfully loaded the entire file
 				currentFile = filename;
-				Win.Title = $"{this.GetName ()} - {Path.GetFileName(currentFile)}";
+				Win.Title = $"{this.GetName ()} - {Path.GetFileName (currentFile)}";
 
 			} catch (Exception ex) {
 				MessageBox.ErrorQuery ("Open Failed", $"Error on line {lineNumber}{Environment.NewLine}{ex.Message}", "Ok");
@@ -446,7 +446,7 @@ namespace UICatalog.Scenarios {
 		{
 			var _scrollBar = new ScrollBarView (tableView, true);
 
-			_scrollBar.ChangedPosition += (s,e) => {
+			_scrollBar.ChangedPosition += (s, e) => {
 				tableView.RowOffset = _scrollBar.Position;
 				if (tableView.RowOffset != _scrollBar.Position) {
 					_scrollBar.Position = tableView.RowOffset;
@@ -462,7 +462,7 @@ namespace UICatalog.Scenarios {
 				_listView.SetNeedsDisplay ();
 			};*/
 
-			tableView.DrawContent += (s,e) => {
+			tableView.DrawContent += (s, e) => {
 				_scrollBar.Size = tableView.Table?.Rows?.Count ?? 0;
 				_scrollBar.Position = tableView.RowOffset;
 				//	_scrollBar.OtherScrollBarView.Size = _listView.Maxlength - 1;
@@ -514,10 +514,10 @@ namespace UICatalog.Scenarios {
 			bool okPressed = false;
 
 			var ok = new Button ("Ok", is_default: true);
-			ok.Clicked += (s,e) => { okPressed = true; Application.RequestStop (); };
+			ok.Clicked += (s, e) => { okPressed = true; Application.RequestStop (); };
 			var cancel = new Button ("Cancel");
-			cancel.Clicked += (s,e) => { Application.RequestStop (); };
-			var d = new Dialog (title, 60, 20, ok, cancel);
+			cancel.Clicked += (s, e) => { Application.RequestStop (); };
+			var d = new Dialog (ok, cancel) { Title = title };
 
 			var lbl = new Label () {
 				X = 0,

+ 6 - 2
UICatalog/Scenarios/Dialogs.cs

@@ -197,10 +197,14 @@ namespace UICatalog.Scenarios {
 
 					// This tests dynamically adding buttons; ensuring the dialog resizes if needed and 
 					// the buttons are laid out correctly
-					dialog = new Dialog (titleEdit.Text, width, height,
-						buttons.ToArray ()) {
+					dialog = new Dialog (buttons.ToArray ()) {
+						Title = titleEdit.Text,
 						ButtonAlignment = (Dialog.ButtonAlignments)styleRadioGroup.SelectedItem
 					};
+					if (height != 0 || width != 0) {
+						dialog.Height = height;
+						dialog.Width = width;
+					}
 
 					var add = new Button ("Add a button") {
 						X = Pos.Center (),

+ 3 - 3
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -16,7 +16,7 @@ namespace UICatalog.Scenarios {
 		public override void Init ()
 		{
 			Application.Init ();
-			Application.Top.Add (new DynamicMenuBarSample ($"{Application.QuitKey} to Quit - Scenario: {GetName ()}"));
+			Application.Top.Add (new DynamicMenuBarSample () { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" });
 		}
 
 		public class DynamicMenuItemList {
@@ -74,7 +74,7 @@ namespace UICatalog.Scenarios {
 
 			public DynamicMenuItemModel DataContext { get; set; }
 
-			public DynamicMenuBarSample (ustring title) : base (title)
+			public DynamicMenuBarSample () : base ()
 			{
 				DataContext = new DynamicMenuItemModel ();
 
@@ -881,7 +881,7 @@ namespace UICatalog.Scenarios {
 					_txtTitle.Text = ustring.Empty;
 					Application.RequestStop ();
 				};
-				var _dialog = new Dialog ("Please enter the menu details.", _btnOk, _btnCancel);
+				var _dialog = new Dialog (_btnOk, _btnCancel) { Title = "Enter the menu details." };
 
 				Width = Dim.Fill ();
 				Height = Dim.Fill () - 1;

+ 3 - 3
UICatalog/Scenarios/DynamicStatusBar.cs

@@ -15,7 +15,7 @@ namespace UICatalog.Scenarios {
 		public override void Init ()
 		{
 			Application.Init ();
-			Application.Top.Add (new DynamicStatusBarSample ($"{Application.QuitKey} to Quit - Scenario: {GetName ()}"));
+			Application.Top.Add (new DynamicStatusBarSample () { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" });
 		}
 
 		public class DynamicStatusItemList {
@@ -62,7 +62,7 @@ namespace UICatalog.Scenarios {
 
 			public DynamicStatusItemModel DataContext { get; set; }
 
-			public DynamicStatusBarSample (ustring title) : base (title)
+			public DynamicStatusBarSample () : base ()
 			{
 				DataContext = new DynamicStatusItemModel ();
 
@@ -496,7 +496,7 @@ namespace UICatalog.Scenarios {
 					_txtTitle.Text = ustring.Empty;
 					Application.RequestStop ();
 				};
-				var _dialog = new Dialog ("Please enter the item details.", _btnOk, _btnCancel);
+				var _dialog = new Dialog (_btnOk, _btnCancel) { Title = "Enter the menu details." };
 
 				Width = Dim.Fill ();
 				Height = Dim.Fill () - 1;

+ 4 - 3
UICatalog/Scenarios/Editor.cs

@@ -39,7 +39,8 @@ namespace UICatalog.Scenarios {
 			ConfigurationManager.Themes.Theme = Theme;
 			ConfigurationManager.Apply ();
 			
-			Win = new Window (_fileName ?? "Untitled") {
+			Win = new Window () {
+				Title = _fileName ?? "Untitled",
 				X = 0,
 				Y = 1,
 				Width = Dim.Fill (),
@@ -736,12 +737,12 @@ namespace UICatalog.Scenarios {
 				return;
 			}
 
-			_winDialog = new Window (isFind ? "Find" : "Replace") {
+			_winDialog = new Window () {
+				Title = isFind ? "Find" : "Replace",
 				X = Win.Bounds.Width / 2 - 30,
 				Y = Win.Bounds.Height / 2 - 10,
 				ColorScheme = Colors.TopLevel
 			};
-			_winDialog.Border.Effect3D = true;
 
 			_tabView = new TabView () {
 				X = 0,

+ 2 - 2
UICatalog/Scenarios/Frames.cs

@@ -170,7 +170,7 @@ namespace UICatalog.Scenarios {
 
 				Add (new Label ("BorderStyle:"));
 
-				var borderStyleEnum = Enum.GetValues (typeof (BorderStyle)).Cast<BorderStyle> ().ToList ();
+				var borderStyleEnum = Enum.GetValues (typeof (LineStyle)).Cast<LineStyle> ().ToList ();
 				var rbBorderStyle = new RadioGroup (borderStyleEnum.Select (
 					e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
 
@@ -181,7 +181,7 @@ namespace UICatalog.Scenarios {
 				Add (rbBorderStyle);
 
 				rbBorderStyle.SelectedItemChanged += (s, e) => {
-					viewToEdit.BorderFrame.BorderStyle = (BorderStyle)e.SelectedItem;
+					viewToEdit.BorderFrame.BorderStyle = (LineStyle)e.SelectedItem;
 					viewToEdit.SetNeedsDisplay ();
 				};
 

+ 1 - 1
UICatalog/Scenarios/InteractiveTree.cs

@@ -114,7 +114,7 @@ namespace UICatalog.Scenarios {
 			ok.Clicked += (s,e) => { okPressed = true; Application.RequestStop (); };
 			var cancel = new Button ("Cancel");
 			cancel.Clicked += (s,e) => { Application.RequestStop (); };
-			var d = new Dialog (title, 60, 20, ok, cancel);
+			var d = new Dialog (ok, cancel) { Title = title };
 
 			var lbl = new Label () {
 				X = 0,

+ 2 - 17
UICatalog/Scenarios/Keys.cs

@@ -12,22 +12,6 @@ namespace UICatalog.Scenarios {
 			public List<string> _processHotKeyList = new List<string> ();
 			public List<string> _processColdKeyList = new List<string> ();
 
-			public TestWindow (ustring title = null) : base (title)
-			{
-			}
-
-			public TestWindow (Rect frame, ustring title = null) : base (frame, title)
-			{
-			}
-
-			public TestWindow (ustring title = null, int padding = 0) : base (title, padding)
-			{
-			}
-
-			public TestWindow (Rect frame, ustring title = null, int padding = 0) : base (frame, title, padding)
-			{
-			}
-
 			public override bool ProcessKey (KeyEvent keyEvent)
 			{
 				_processKeyList.Add (keyEvent.ToString ());
@@ -54,7 +38,8 @@ namespace UICatalog.Scenarios {
 			ConfigurationManager.Themes.Theme = Theme;
 			ConfigurationManager.Apply ();
 			
-			Win = new TestWindow ($"{Application.QuitKey} to Quit - Scenario: {GetName ()}") {
+			Win = new TestWindow () {
+				Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}",
 				X = 0,
 				Y = 0,
 				Width = Dim.Fill (),

+ 12 - 14
UICatalog/Scenarios/LineDrawing.cs

@@ -39,7 +39,7 @@ namespace UICatalog.Scenarios {
 
 			LineCanvas grid;
 			public event Action<Color> ColorChanged;
-			public event Action<BorderStyle> SetStyle;
+			public event Action<LineStyle> SetStyle;
 
 			Dictionary<Point, Color> swatches = new Dictionary<Point, Color> {
 				{ new Point(1,1),Color.Red},
@@ -53,17 +53,17 @@ namespace UICatalog.Scenarios {
 			{
 				grid = new LineCanvas ();
 
-				grid.AddLine (new Point (0, 0), int.MaxValue, Orientation.Vertical, BorderStyle.Single);
-				grid.AddLine (new Point (0, 0), width, Orientation.Horizontal, BorderStyle.Single);
-				grid.AddLine (new Point (width, 0), int.MaxValue, Orientation.Vertical, BorderStyle.Single);
+				grid.AddLine (new Point (0, 0), int.MaxValue, Orientation.Vertical, LineStyle.Single);
+				grid.AddLine (new Point (0, 0), width, Orientation.Horizontal, LineStyle.Single);
+				grid.AddLine (new Point (width, 0), int.MaxValue, Orientation.Vertical, LineStyle.Single);
 
-				grid.AddLine (new Point (0, 2), width, Orientation.Horizontal, BorderStyle.Single);
+				grid.AddLine (new Point (0, 2), width, Orientation.Horizontal, LineStyle.Single);
 
-				grid.AddLine (new Point (2, 0), int.MaxValue, Orientation.Vertical, BorderStyle.Single);
-				grid.AddLine (new Point (4, 0), int.MaxValue, Orientation.Vertical, BorderStyle.Single);
-				grid.AddLine (new Point (6, 0), int.MaxValue, Orientation.Vertical, BorderStyle.Single);
+				grid.AddLine (new Point (2, 0), int.MaxValue, Orientation.Vertical, LineStyle.Single);
+				grid.AddLine (new Point (4, 0), int.MaxValue, Orientation.Vertical, LineStyle.Single);
+				grid.AddLine (new Point (6, 0), int.MaxValue, Orientation.Vertical, LineStyle.Single);
 
-				grid.AddLine (new Point (0, 4), width, Orientation.Horizontal, BorderStyle.Single);
+				grid.AddLine (new Point (0, 4), width, Orientation.Horizontal, LineStyle.Single);
 			}
 			public override void Redraw (Rect bounds)
 			{
@@ -101,17 +101,17 @@ namespace UICatalog.Scenarios {
 
 					if (mouseEvent.X == 3 && mouseEvent.Y == 3) {
 
-						SetStyle?.Invoke (BorderStyle.Double);
+						SetStyle?.Invoke (LineStyle.Double);
 						return true;
 					}
 					if (mouseEvent.X == 5 && mouseEvent.Y == 3) {
 
-						SetStyle?.Invoke (BorderStyle.Single);
+						SetStyle?.Invoke (LineStyle.Single);
 						return true;
 					}
 					if (mouseEvent.X == 7 && mouseEvent.Y == 3) {
 
-						SetStyle?.Invoke (BorderStyle.Rounded);
+						SetStyle?.Invoke (LineStyle.Rounded);
 						return true;
 					}
 				}
@@ -130,8 +130,6 @@ namespace UICatalog.Scenarios {
 
 			Point? currentLineStart = null;
 
-			public BorderStyle BorderStyle { get; internal set; }
-
 			public DrawingArea ()
 			{
 				AddCanvas (Color.White);

+ 1 - 1
UICatalog/Scenarios/MultiColouredTable.cs

@@ -75,7 +75,7 @@ namespace UICatalog.Scenarios {
 			ok.Clicked += (s,e) => { okPressed = true; Application.RequestStop (); };
 			var cancel = new Button ("Cancel");
 			cancel.Clicked += (s,e) => { Application.RequestStop (); };
-			var d = new Dialog (title, 60, 20, ok, cancel);
+			var d = new Dialog (ok, cancel) { Title = title };
 
 			var lbl = new Label () {
 				X = 0,

+ 1 - 1
UICatalog/Scenarios/Notepad.cs

@@ -48,7 +48,7 @@ namespace UICatalog.Scenarios {
 				Height = Dim.Fill (1),
 			};
 			split.Tiles.ElementAt(0).ContentView.Add (tabView);
-			split.BorderStyle = BorderStyle.None;
+			split.LineStyle = LineStyle.None;
 
 			Application.Top.Add (split);
 

+ 6 - 34
UICatalog/Scenarios/RuneWidthGreaterThanOne.cs

@@ -21,13 +21,13 @@ namespace UICatalog.Scenarios {
 			Application.Init ();
 
 			var menu = new MenuBar (new MenuBarItem [] {
-				new MenuBarItem ("Margin", new MenuItem [] {
-					new MenuItem ("With margin", "", WithMargin),
-					new MenuItem ("Without margin", "", WithoutMargin)
+				new MenuBarItem ("Padding", new MenuItem [] {
+					new MenuItem ("With Padding", "", () => _win.Padding.Thickness = new Thickness (1)),
+					new MenuItem ("Without Padding", "", () =>_win.Padding.Thickness = new Thickness (0))
 				}),
-				new MenuBarItem ("Draw Margin Frame", new MenuItem [] {
-					new MenuItem ("With draw", "", WithDrawMargin),
-					new MenuItem ("Without draw", "", WithoutDrawMargin)
+				new MenuBarItem ("BorderStyle", new MenuItem [] {
+					new MenuItem ("Single", "", () => _win.BorderStyle = LineStyle.Single),
+					new MenuItem ("None", "", () => _win.BorderStyle = LineStyle.None)
 				}),
 				new MenuBarItem ("Runes length", new MenuItem [] {
 					new MenuItem ("Wide", "", WideRunes),
@@ -160,34 +160,6 @@ namespace UICatalog.Scenarios {
 			Application.Refresh ();
 		}
 
-		private void WithoutDrawMargin ()
-		{
-			_win.Border.BorderStyle = BorderStyle.None;
-			_win.Border.DrawMarginFrame = false;
-		}
-
-		private void WithDrawMargin ()
-		{
-			_win.Border.DrawMarginFrame = true;
-			_win.Border.BorderStyle = BorderStyle.Single;
-		}
-
-		private void WithoutMargin ()
-		{
-			_win.X = 0;
-			_win.Y = 0;
-			_win.Width = Dim.Fill ();
-			_win.Height = Dim.Fill ();
-		}
-
-		private void WithMargin ()
-		{
-			_win.X = 5;
-			_win.Y = 5;
-			_win.Width = Dim.Fill (22);
-			_win.Height = Dim.Fill (5);
-		}
-
 		public override void Run ()
 		{
 		}

+ 1 - 1
UICatalog/Scenarios/SingleBackgroundWorker.cs

@@ -79,7 +79,7 @@ namespace UICatalog.Scenarios {
 				log.Add ($"Worker is started at {startStaging}.{startStaging:fff}");
 				listLog.SetNeedsDisplay ();
 
-				var md = new Dialog ($"Running Worker started at {startStaging}.{startStaging:fff}", cancel);
+				var md = new Dialog (cancel) { Title = $"Running Worker started at {startStaging}.{startStaging:fff}" };
 				md.Add (new Label ("Wait for worker to finish...") {
 					X = Pos.Center (),
 					Y = Pos.Center ()

+ 5 - 5
UICatalog/Scenarios/Snake.cs

@@ -88,10 +88,10 @@ namespace UICatalog.Scenarios {
 
 				var canvas = new LineCanvas ();
 
-				canvas.AddLine (new Point (0, 0), State.Width - 1, Orientation.Horizontal, BorderStyle.Double);
-				canvas.AddLine (new Point (0, 0), State.Height - 1, Orientation.Vertical, BorderStyle.Double);
-				canvas.AddLine (new Point (0, State.Height - 1), State.Width - 1, Orientation.Horizontal, BorderStyle.Double);
-				canvas.AddLine (new Point (State.Width - 1, 0), State.Height - 1, Orientation.Vertical, BorderStyle.Double);
+				canvas.AddLine (new Point (0, 0), State.Width - 1, Orientation.Horizontal, LineStyle.Double);
+				canvas.AddLine (new Point (0, 0), State.Height - 1, Orientation.Vertical, LineStyle.Double);
+				canvas.AddLine (new Point (0, State.Height - 1), State.Width - 1, Orientation.Horizontal, LineStyle.Double);
+				canvas.AddLine (new Point (State.Width - 1, 0), State.Height - 1, Orientation.Vertical, LineStyle.Double);
 
 				for (int i = 1; i < State.Snake.Count; i++) {
 
@@ -107,7 +107,7 @@ namespace UICatalog.Scenarios {
 						pt2,
 						length,
 						orientation,
-						BorderStyle.Single);
+						LineStyle.Single);
 
 				}
 

+ 2 - 2
UICatalog/Scenarios/TableEditor.cs

@@ -281,7 +281,7 @@ namespace UICatalog.Scenarios {
 			ok.Clicked += (s,e) => { accepted = true; Application.RequestStop (); };
 			var cancel = new Button ("Cancel");
 			cancel.Clicked += (s,e) => { Application.RequestStop (); };
-			var d = new Dialog (prompt, 60, 20, ok, cancel);
+			var d = new Dialog (ok, cancel) { Title = prompt };
 
 			var style = tableView.Style.GetOrCreateColumnStyle (col);
 
@@ -763,7 +763,7 @@ namespace UICatalog.Scenarios {
 			ok.Clicked += (s,e) => { okPressed = true; Application.RequestStop (); };
 			var cancel = new Button ("Cancel");
 			cancel.Clicked += (s,e) => { Application.RequestStop (); };
-			var d = new Dialog (title, 60, 20, ok, cancel);
+			var d = new Dialog (ok, cancel) { Title = title };
 
 			var lbl = new Label () {
 				X = 0,

+ 4 - 10
UICatalog/Scenarios/TileViewExperiment.cs

@@ -35,7 +35,7 @@ namespace UICatalog.Scenarios {
 					     //IgnoreBorderPropertyOnRedraw = true
 
 			};
-			frame1.Border.BorderStyle = BorderStyle.Double;
+			frame1.BorderStyle = LineStyle.Double;
 
 			//var frame2 = new FrameView () {
 			//	Title = "frame2",
@@ -62,14 +62,9 @@ namespace UICatalog.Scenarios {
 				Width = 30, //Dim.Percent (30) - 5,
 				Height = 10, //Dim.Percent (50) - 5,
 				ColorScheme = Colors.ColorSchemes ["Dialog"],
-				Border = new Border () {
-					BorderStyle = BorderStyle.Single,
-					BorderThickness = new Thickness (1), 
-					DrawMarginFrame = true,
-					PaddingThickness = new Thickness(1),
-					ForgroundColor = Color.BrightMagenta,
-				}
+				BorderStyle = LineStyle.Single,
 			};
+			view1.Padding.Thickness = new Thickness (1);
 
 			frame1.Add (view1);
 
@@ -82,8 +77,7 @@ namespace UICatalog.Scenarios {
 				Y = 0,
 				Width = Dim.Percent (30),
 				Height = Dim.Percent (70),
-				ColorScheme = Colors.ColorSchemes ["Error"],
-				Border = new Border () { BorderStyle = BorderStyle.Single }
+				ColorScheme = Colors.ColorSchemes ["Error"]
 			};
 
 			frame1.Add (view2);

+ 1 - 1
UICatalog/Scenarios/TileViewNesting.cs

@@ -112,7 +112,7 @@ namespace UICatalog.Scenarios {
 			root.Tiles.ElementAt (1).Title = (bool)cbTitles.Checked ? $"View 2" : string.Empty;
 
 
-			root.BorderStyle = (bool)border ? BorderStyle.Rounded : BorderStyle.None;
+			root.LineStyle = (bool)border ? LineStyle.Rounded : LineStyle.None;
 
 
 			workArea.Add (root);

+ 7 - 7
UICatalog/Scenarios/ViewExperiments.cs

@@ -161,7 +161,7 @@ namespace UICatalog.Scenarios {
 				};
 				Add (styleLabel);
 
-				var borderStyleEnum = Enum.GetValues (typeof (BorderStyle)).Cast<BorderStyle> ().ToList ();
+				var borderStyleEnum = Enum.GetValues (typeof (LineStyle)).Cast<LineStyle> ().ToList ();
 				var rbBorderStyle = new RadioGroup (borderStyleEnum.Select (
 					e => NStack.ustring.Make (e.ToString ())).ToArray ()) {
 					X = Pos.Left (styleLabel),
@@ -170,7 +170,7 @@ namespace UICatalog.Scenarios {
 				};
 
 				rbBorderStyle.SelectedItemChanged += (s, e) => {
-					viewToEdit.BorderFrame.BorderStyle = (BorderStyle)e.SelectedItem;
+					viewToEdit.BorderFrame.BorderStyle = (LineStyle)e.SelectedItem;
 					viewToEdit.SetNeedsDisplay ();
 				};
 				Add (rbBorderStyle);
@@ -276,7 +276,7 @@ namespace UICatalog.Scenarios {
 			view.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
 			view.Margin.Data = "Margin";
 			view.BorderFrame.Thickness = new Thickness (2);
-			view.BorderFrame.BorderStyle = BorderStyle.Single;
+			view.BorderFrame.BorderStyle = LineStyle.Single;
 			view.BorderFrame.ColorScheme = view.ColorScheme;
 			view.BorderFrame.Data = "BorderFrame";
 			view.Padding.Thickness = new Thickness (2);
@@ -298,7 +298,7 @@ namespace UICatalog.Scenarios {
 			view2.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
 			view2.Margin.Data = "Margin";
 			view2.BorderFrame.Thickness = new Thickness (1);
-			view2.BorderFrame.BorderStyle = BorderStyle.Single;
+			view2.BorderFrame.BorderStyle = LineStyle.Single;
 			view2.BorderFrame.ColorScheme = view.ColorScheme;
 			view2.BorderFrame.Data = "BorderFrame";
 			view2.Padding.Thickness = new Thickness (1);
@@ -322,7 +322,7 @@ namespace UICatalog.Scenarios {
 			view3.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
 			view3.Margin.Data = "Margin";
 			view3.BorderFrame.Thickness = new Thickness (1, 1, 1, 1);
-			view3.BorderFrame.BorderStyle = BorderStyle.Single;
+			view3.BorderFrame.BorderStyle = LineStyle.Single;
 			view3.BorderFrame.ColorScheme = view.ColorScheme;
 			view3.BorderFrame.Data = "BorderFrame";
 			view3.Padding.Thickness = new Thickness (1, 1, 0, 0);
@@ -346,7 +346,7 @@ namespace UICatalog.Scenarios {
 			view4.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
 			view4.Margin.Data = "Margin";
 			view4.BorderFrame.Thickness = new Thickness (1, 1, 1, 1);
-			view4.BorderFrame.BorderStyle = BorderStyle.Single;
+			view4.BorderFrame.BorderStyle = LineStyle.Single;
 			view4.BorderFrame.ColorScheme = view.ColorScheme;
 			view4.BorderFrame.Data = "BorderFrame";
 			view4.Padding.Thickness = new Thickness (0, 0, 1, 1);
@@ -369,7 +369,7 @@ namespace UICatalog.Scenarios {
 			view5.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"];
 			view5.Margin.Data = "Margin";
 			view5.BorderFrame.Thickness = new Thickness (1, 1, 1, 1);
-			view5.BorderFrame.BorderStyle = BorderStyle.Single;
+			view5.BorderFrame.BorderStyle = LineStyle.Single;
 			view5.BorderFrame.ColorScheme = view.ColorScheme;
 			view5.BorderFrame.Data = "BorderFrame";
 			view5.Padding.Thickness = new Thickness (0, 0, 0, 0);

+ 16 - 8
UICatalog/Scenarios/WindowsAndFrameViews.cs

@@ -25,14 +25,17 @@ namespace UICatalog.Scenarios {
 			Application.Top.Remove (Win);
 			Win?.Dispose ();
 
-			Win = new Window ($"{listWin.Count} - Scenario: {GetName ()}", padding) {
+			Win = new Window () {
+				Title = $"{listWin.Count} - Scenario: {GetName ()}",
 				X = Pos.Center (),
 				Y = 1,
 				Width = Dim.Fill (15),
-				Height = 10
+				Height = 10,
+				ColorScheme = Colors.Dialog
 			};
+			Win.Padding.Thickness = new Thickness (padding);
+			Win.Margin.Thickness = new Thickness (margin);
 
-			Win.ColorScheme = Colors.Dialog;
 			var paddingButton = new Button ($"Padding of container is {padding}") {
 				X = Pos.Center (),
 				Y = 0,
@@ -57,14 +60,17 @@ namespace UICatalog.Scenarios {
 			//		TextField
 			//	sub FrameView with
 			// 
-			for (var i = 0; i < 3; i++) {
+			for (var pad = 0; pad < 3; pad++) {
 				Window win = null;
-				win = new Window ($"{listWin.Count} - Window Loop - padding = {i}", i) {
+				win = new Window () {
+					Title = $"{listWin.Count} - Window Loop - padding = {pad}",
 					X = margin,
 					Y = Pos.Bottom (listWin.Last ()) + (margin),
 					Width = Dim.Fill (margin),
-					Height = contentHeight + (i * 2) + 2,
+					Height = contentHeight + (pad * 2) + 2,
 				};
+				win.Padding.Thickness = new Thickness (pad);
+				
 				win.ColorScheme = Colors.Dialog;
 				var pressMeButton = new Button ("Press me! (Y = 0)") {
 					X = Pos.Center (),
@@ -74,7 +80,8 @@ namespace UICatalog.Scenarios {
 				pressMeButton.Clicked += (s,e) =>
 					MessageBox.ErrorQuery (win.Title.ToString (), "Neat?", "Yes", "No");
 				win.Add (pressMeButton);
-				var subWin = new Window ("Sub Window") {
+				var subWin = new Window () {
+					Title = "Sub Window",
 					X = Pos.Percent (0),
 					Y = 1,
 					Width = Dim.Percent (50),
@@ -131,7 +138,8 @@ namespace UICatalog.Scenarios {
 				ColorScheme = Colors.Error,
 				//Clicked = () => MessageBox.ErrorQuery (frame.Title.ToString (), "Neat?", "Yes", "No")
 			});
-			var subWinofFV = new Window ("this is a Sub-Window") {
+			var subWinofFV = new Window () {
+				Title = "This is a Sub-Window",
 				X = Pos.Percent (0),
 				Y = 1,
 				Width = Dim.Percent (50),

+ 2 - 1
UICatalog/Scenarios/Wizards.cs

@@ -111,7 +111,8 @@ namespace UICatalog.Scenarios {
 
 					actionLabel.Text = ustring.Empty;
 
-					var wizard = new Wizard (titleEdit.Text) {
+					var wizard = new Wizard () {
+						Title = titleEdit.Text,
 						Width = width,
 						Height = height
 					};

+ 2 - 2
UICatalog/UICatalog.cs

@@ -317,7 +317,7 @@ namespace UICatalog {
 					CanFocus = true,
 					Shortcut = Key.CtrlMask | Key.C,
 				};
-				ContentPane.BorderStyle = BorderStyle.Single;
+				ContentPane.LineStyle = LineStyle.Single;
 				ContentPane.SetSplitterPos (0, 25);
 				ContentPane.ShortcutAction = () => ContentPane.SetFocus ();
 
@@ -655,7 +655,7 @@ namespace UICatalog {
 
 				ColorScheme = Colors.ColorSchemes [_topLevelColorScheme];
 
-				ContentPane.BorderStyle = FrameView.DefaultBorderStyle;
+				ContentPane.LineStyle = FrameView.DefaultBorderStyle;
 
 				MenuBar.Menus [0].Children [0].Shortcut = Application.QuitKey;
 				StatusBar.Items [0].Shortcut = Application.QuitKey;

+ 4 - 4
UnitTests/Application/ApplicationTests.cs

@@ -772,10 +772,10 @@ namespace Terminal.Gui.ApplicationTests {
 		public void EnsuresTopOnFront_CanFocus_True_By_Keyboard_And_Mouse ()
 		{
 			var top = Application.Top;
-			var win = new Window ("win") { X = 0, Y = 0, Width = 20, Height = 10 };
+			var win = new Window () { Title = "win", X = 0, Y = 0, Width = 20, Height = 10 };
 			var tf = new TextField () { Width = 10 };
 			win.Add (tf);
-			var win2 = new Window ("win2") { X = 22, Y = 0, Width = 20, Height = 10 };
+			var win2 = new Window () { Title = "win2", X = 22, Y = 0, Width = 20, Height = 10 };
 			var tf2 = new TextField () { Width = 10 };
 			win2.Add (tf2);
 			top.Add (win, win2);
@@ -817,10 +817,10 @@ namespace Terminal.Gui.ApplicationTests {
 		public void EnsuresTopOnFront_CanFocus_False_By_Keyboard_And_Mouse ()
 		{
 			var top = Application.Top;
-			var win = new Window ("win") { X = 0, Y = 0, Width = 20, Height = 10 };
+			var win = new Window () { Title = "win", X = 0, Y = 0, Width = 20, Height = 10 };
 			var tf = new TextField () { Width = 10 };
 			win.Add (tf);
-			var win2 = new Window ("win2") { X = 22, Y = 0, Width = 20, Height = 10 };
+			var win2 = new Window () { Title = "win2", X = 22, Y = 0, Width = 20, Height = 10 };
 			var tf2 = new TextField () { Width = 10 };
 			win2.Add (tf2);
 			top.Add (win, win2);

+ 5 - 6
UnitTests/Configuration/ThemeTests.cs

@@ -55,20 +55,19 @@ namespace Terminal.Gui.ConfigurationTests {
 		public void TestApply ()
 		{
 			ConfigurationManager.Reset ();
-
+			
 			var theme = new ThemeScope ();
 			Assert.NotEmpty (theme);
-
+			
 			Themes.Add ("testTheme", theme);
 
-			Assert.True (Dialog.DefaultBorder.Effect3D);
-			Assert.Equal (typeof (Border), theme ["Dialog.DefaultBorder"].PropertyInfo.PropertyType);
-			theme ["Dialog.DefaultBorder"].PropertyValue = new Border () { Effect3D = false }; // default is true
+			Assert.Equal (LineStyle.Single, FrameView.DefaultBorderStyle);
+			theme ["FrameView.DefaultBorderStyle"].PropertyValue = LineStyle.Double; // default is Single
 
 			Themes.Theme = "testTheme";
 			Themes! [ThemeManager.SelectedTheme]!.Apply ();
 
-			Assert.False (Dialog.DefaultBorder.Effect3D);
+			Assert.Equal (LineStyle.Double, FrameView.DefaultBorderStyle);
 		}
 
 		[Fact]

+ 3 - 3
UnitTests/ConsoleDrivers/ConsoleDriverTests.cs

@@ -252,13 +252,13 @@ namespace Terminal.Gui.DriverTests {
 				System.Threading.Tasks.Task.Delay (500).Wait ();
 				Application.MainLoop.Invoke (() => {
 					var lbl = new Label ("Hello World") { X = Pos.Center () };
-					var dlg = new Dialog ("Test", new Button ("Ok"));
+					var dlg = new Dialog (new Button ("Ok"));
 					dlg.Add (lbl);
 					Application.Begin (dlg);
 
 					var expected = @"
 ┌──────────────────┐
-│┌┤Test├─────────┐ │
+│┌───────────────┐ │
 ││  Hello World  │ │
 ││               │ │
 ││               │ │
@@ -275,7 +275,7 @@ namespace Terminal.Gui.DriverTests {
 
 					expected = @"
 ┌──────────────────┐
-│┌┤Test├─────────┐ │
+│┌───────────────┐ │
 ││  Hello World  │ │
 ││               │ │
 ││               │ │

+ 218 - 66
UnitTests/Dialogs/DialogTests.cs

@@ -44,7 +44,12 @@ namespace Terminal.Gui.DialogTests {
 
 		private (Application.RunState, Dialog) RunButtonTestDialog (string title, int width, Dialog.ButtonAlignments align, params Button [] btns)
 		{
-			var dlg = new Dialog (title, width, 1, btns) {
+			var dlg = new Dialog (btns) {
+				Title = title,
+				X = 0,
+				Y = 0,
+				Width = width,
+				Height = 1,
 				ButtonAlignment = align,
 			};
 			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -52,6 +57,155 @@ namespace Terminal.Gui.DialogTests {
 			return (Application.Begin (dlg), dlg);
 		}
 
+		[Fact]
+		[AutoInitShutdown]
+		public void Size_Default ()
+		{
+			var d = new Dialog () {
+			};
+			Application.Begin (d);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			// Default size is Percent(85) 
+			Assert.Equal (new Size ((int)(100 * .85), (int)(100 * .85)), d.Frame.Size);
+		}
+
+		[Fact]
+		[AutoInitShutdown]
+		public void Location_Default ()
+		{
+			var d = new Dialog () {
+			};
+			Application.Begin (d);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			// Default location is centered, so 100 / 2 - 85 / 2 = 7
+			var expected = 7;
+			Assert.Equal (new Point (expected, expected), d.Frame.Location);
+		}
+
+
+		[Fact]
+		[AutoInitShutdown]
+		public void Size_Not_Default ()
+		{
+			var d = new Dialog () {
+				Width = 50,
+				Height = 50,
+			};
+
+			Application.Begin (d);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			// Default size is Percent(85) 
+			Assert.Equal (new Size (50, 50), d.Frame.Size);
+		}
+
+		[Fact]
+		[AutoInitShutdown]
+		public void Location_Not_Default ()
+		{
+			var d = new Dialog () {
+				X = 1,
+				Y = 1,
+			};
+			Application.Begin (d);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			// Default location is centered, so 100 / 2 - 85 / 2 = 7
+			var expected = 1;
+			Assert.Equal (new Point (expected, expected), d.Frame.Location);
+		}
+
+
+		[Fact]
+		[AutoInitShutdown]
+		public void Location_When_Application_Top_Not_Default ()
+		{
+			var expected = 5;
+			var d = new Dialog () {
+				X = expected,
+				Y = expected,
+				Height = 5,
+				Width = 5
+			};
+			Application.Begin (d);
+			((FakeDriver)Application.Driver).SetBufferSize (20, 10);
+
+			// Default location is centered, so 100 / 2 - 85 / 2 = 7
+			Assert.Equal (new Point (expected, expected), d.Frame.Location);
+
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+     ┌───┐
+     │   │
+     │   │
+     │   │
+     └───┘", output);
+		}
+
+		[Fact]
+		[AutoInitShutdown]
+		public void Location_When_Not_Application_Top_Not_Default ()
+		{
+			Application.Top.BorderStyle = LineStyle.Double;
+
+			var iterations = -1;
+			Application.Iteration += () => {
+				iterations++;
+				
+				if (iterations == 0) {
+					var d = new Dialog () {
+						X = 5,
+						Y = 5,
+						Height = 3,
+						Width = 5
+					};
+					Application.Begin (d);
+
+					Assert.Equal (new Point (5, 5), d.Frame.Location);
+					TestHelpers.AssertDriverContentsWithFrameAre (@"
+╔══════════════════╗
+║                  ║
+║                  ║
+║                  ║
+║                  ║
+║    ┌───┐         ║
+║    │   │         ║
+║    └───┘         ║
+║                  ║
+╚══════════════════╝", output);
+
+					d = new Dialog () {
+						X = 5,
+						Y = 5,
+					};
+					Application.Begin (d);
+
+					// This is because of PostionTopLevels and EnsureVisibleBounds
+					Assert.Equal (new Point (3, 2), d.Frame.Location);
+					TestHelpers.AssertDriverContentsWithFrameAre (@"
+╔══════════════════╗
+║                  ║
+║  ┌───────────────┐
+║  │               │
+║  │               │
+║  │               │
+║  │               │
+║  │               │
+║  │               │
+╚══└───────────────┘", output);
+
+
+				} else if (iterations > 0) {
+					Application.RequestStop ();
+				}
+			};
+			
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (20, 10);
+			Application.Run ();
+		}
+		
 		[Fact]
 		[AutoInitShutdown]
 		public void ButtonAlignment_One ()
@@ -68,10 +222,11 @@ namespace Terminal.Gui.DialogTests {
 			d.SetBufferSize (width, 1);
 
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btnText));
+			// Center
 			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
-			// Justify
+			// Justify 
 			buttonRow = $"{d.VLine}    {d.LeftBracket} {btnText} {d.RightBracket}{d.VLine}";
 			Assert.Equal (width, buttonRow.Length);
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btnText));
@@ -338,7 +493,7 @@ namespace Terminal.Gui.DialogTests {
 
 		[Fact]
 		[AutoInitShutdown]
-		public void ButtonAlignment_Four_On_Smaller_Width ()
+		public void ButtonAlignment_Four_On_Too_Small_Width ()
 		{
 			Application.RunState runstate = null;
 
@@ -355,33 +510,30 @@ namespace Terminal.Gui.DialogTests {
 			var btn3 = $"{d.LeftBracket} {btn3Text} {d.RightBracket}";
 			var btn4Text = "never";
 			var btn4 = $"{d.LeftBracket} {btn4Text} {d.RightBracket}";
-
-			var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}";
-			var width = buttonRow.Length;
-			d.SetBufferSize (30, 1);
-
+			var buttonRow = string.Empty;
+			
+			var width = 30;
+			d.SetBufferSize (width, 1);
+			
 			// Default - Center
-			buttonRow = $"yes ] {btn2} {btn3} [ never";
-			Assert.NotEqual (width, buttonRow.Length);
-			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
+			buttonRow = $"{d.VLine}es ] {btn2} {btn3} [ neve{d.VLine}";
+			(runstate, var dlg) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
+			Assert.Equal (new Size (width, 1), dlg.Frame.Size);
 			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
-			buttonRow = $"es ] {btn2}  {btn3}  [ neve";
-			Assert.NotEqual (width, buttonRow.Length);
+			buttonRow = $"{d.VLine}[ yes [ no [ maybe [ never ]{d.VLine}";
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Justify, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
 			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); Application.End (runstate);
 
 			// Right
-			buttonRow = $" yes ] {btn2} {btn3} [ neve";
-			Assert.NotEqual (width, buttonRow.Length);
+			buttonRow = $"{d.VLine}] {btn2} {btn3} {btn4}{d.VLine}";
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Right, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
 			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); Application.End (runstate);
 
 			// Left
-			buttonRow = $"es ] {btn2} {btn3} [ never";
-			Assert.NotEqual (width, buttonRow.Length);
+			buttonRow = $"{d.VLine}{btn1} {btn2} {btn3} [ n{d.VLine}";
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Left, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
 			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); Application.End (runstate);
 		}
@@ -468,7 +620,7 @@ namespace Terminal.Gui.DialogTests {
 
 			// Default - Center
 			(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btn1Text), new Button (btn2Text), new Button (btn3Text), new Button (btn4Text));
-			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output); 
+			TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", output);
 			Application.End (runstate);
 
 			// Justify
@@ -552,7 +704,7 @@ namespace Terminal.Gui.DialogTests {
 			d.SetBufferSize (width, 1);
 
 			// Default (center)
-			var dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Center };
+			var dlg = new Dialog (new Button (btn1Text)) { Title = title, Width = width, Height = 1, ButtonAlignment = Dialog.ButtonAlignments.Center };
 			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
 			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
@@ -568,7 +720,7 @@ namespace Terminal.Gui.DialogTests {
 			Application.End (runstate);
 
 			// Justify
-			dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Justify };
+			dlg = new Dialog (new Button (btn1Text)) { Title = title, Width = width, Height = 1, ButtonAlignment = Dialog.ButtonAlignments.Justify };
 			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
 			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
@@ -584,7 +736,7 @@ namespace Terminal.Gui.DialogTests {
 			Application.End (runstate);
 
 			// Right
-			dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Right };
+			dlg = new Dialog (new Button (btn1Text)) { Title = title, Width = width, Height = 1, ButtonAlignment = Dialog.ButtonAlignments.Right };
 			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
 			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
@@ -600,7 +752,7 @@ namespace Terminal.Gui.DialogTests {
 			Application.End (runstate);
 
 			// Left
-			dlg = new Dialog (title, width, 1, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Left };
+			dlg = new Dialog (new Button (btn1Text)) { Title = title, Width = width, Height = 1, ButtonAlignment = Dialog.ButtonAlignments.Left };
 			// Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
 			dlg.BorderFrame.Thickness = new Thickness (1, 0, 1, 0);
 			runstate = Application.Begin (dlg);
@@ -638,8 +790,8 @@ namespace Terminal.Gui.DialogTests {
 				btn2 = new Button ("Show Sub");
 				btn3 = new Button ("Close");
 				btn3.Clicked += (s, e) => Application.RequestStop ();
-				btn2.Clicked += (s, e) => { MessageBox.Query ("hey", "ya", "ok"); };
-				var dlg = new Dialog ("Hey", btn2, btn3);
+				btn2.Clicked += (s, e) => { MessageBox.Query (string.Empty, "ya", "ok"); };
+				var dlg = new Dialog (btn2, btn3);
 
 				Application.Run (dlg);
 			};
@@ -651,7 +803,7 @@ namespace Terminal.Gui.DialogTests {
 					Assert.True (btn1.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ())));
 				} else if (iterations == 1) {
 					expected = @"
-      ┌┤Hey├─────────────────────────────────────────────────────────────┐
+      ┌──────────────────────────────────────────────────────────────────┐
       │                                                                  │
       │                                                                  │
       │                                                                  │
@@ -677,7 +829,7 @@ namespace Terminal.Gui.DialogTests {
 					Assert.True (btn2.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ())));
 				} else if (iterations == 2) {
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-      ┌┤Hey├─────────────────────────────────────────────────────────────┐
+      ┌──────────────────────────────────────────────────────────────────┐
       │                                                                  │
       │                                                                  │
       │                                                                  │
@@ -685,7 +837,7 @@ namespace Terminal.Gui.DialogTests {
       │                                                                  │
       │                                                                  │
       │                                                                  │
-      │         ┌┤hey├─────────────────────────────────────────┐         │
+      │         ┌──────────────────────────────────────────────┐         │
       │         │                      ya                      │         │
       │         │                                              │         │
       │         │                   [◦ ok ◦]                   │         │
@@ -730,15 +882,15 @@ namespace Terminal.Gui.DialogTests {
 					Application.RequestStop ();
 				}
 			};
-			
+
 			win.Loaded += (s, a) => {
-				var dlg = new Dialog ("Test", 18, 3, new Button ("Ok"));
+				var dlg = new Dialog (new Button ("Ok")) { Width = 18, Height = 3 };
 
 				dlg.Loaded += (s, a) => {
 					Application.Refresh ();
 					var expected = @"
 ┌──────────────────┐
-│┌┤Test├──────────┐│
+│┌────────────────┐│
 ││     [ Ok ]     ││
 │└────────────────┘│
 └──────────────────┘";
@@ -749,42 +901,42 @@ namespace Terminal.Gui.DialogTests {
 			};
 			Application.Run (win);
 		}
-		
-//		[Theory, AutoInitShutdown]
-//		[InlineData (5)]
-//		//[InlineData (6)]
-//		//[InlineData (7)]
-//		//[InlineData (8)]
-//		//[InlineData (9)]
-//		public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height)
-//		{
-//			((FakeDriver)Application.Driver).SetBufferSize (20, height);
-//			var win = new Window ();
-
-//			Application.Iteration += () => {
-//				var dlg = new Dialog ("Test", new Button ("Ok"));
-
-//				dlg.LayoutComplete += (s, a) => {
-//					Application.Refresh ();
-//					// BUGBUG: This seems wrong; is it a bug in Dim.Percent(85)??
-//					var expected = @"
-//┌┌┤Test├─────────┐─┐
-//││               │ │
-//││     [ Ok ]    │ │
-//│└───────────────┘ │
-//└──────────────────┘";
-//					_ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
-
-//					dlg.RequestStop ();
-//					win.RequestStop ();
-//				};
-
-//				Application.Run (dlg);
-//			};
-
-//			Application.Run (win);
-//			Application.Shutdown ();
-//		}
+
+		//		[Theory, AutoInitShutdown]
+		//		[InlineData (5)]
+		//		//[InlineData (6)]
+		//		//[InlineData (7)]
+		//		//[InlineData (8)]
+		//		//[InlineData (9)]
+		//		public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height)
+		//		{
+		//			((FakeDriver)Application.Driver).SetBufferSize (20, height);
+		//			var win = new Window ();
+
+		//			Application.Iteration += () => {
+		//				var dlg = new Dialog ("Test", new Button ("Ok"));
+
+		//				dlg.LayoutComplete += (s, a) => {
+		//					Application.Refresh ();
+		//					// BUGBUG: This seems wrong; is it a bug in Dim.Percent(85)??
+		//					var expected = @"
+		//┌┌┤Test├─────────┐─┐
+		//││               │ │
+		//││     [ Ok ]    │ │
+		//│└───────────────┘ │
+		//└──────────────────┘";
+		//					_ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+
+		//					dlg.RequestStop ();
+		//					win.RequestStop ();
+		//				};
+
+		//				Application.Run (dlg);
+		//			};
+
+		//			Application.Run (win);
+		//			Application.Shutdown ();
+		//		}
 	}
 
 }

+ 322 - 107
UnitTests/Dialogs/MessageBoxTests.cs

@@ -3,6 +3,7 @@ using Xunit;
 using Xunit.Abstractions;
 using System.Text;
 using Terminal.Gui;
+using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
 
 namespace Terminal.Gui.DialogTests {
 
@@ -14,8 +15,166 @@ namespace Terminal.Gui.DialogTests {
 			this.output = output;
 		}
 
+		[Fact]
+		[AutoInitShutdown]
+		public void Size_Default ()
+		{
+			var iterations = -1;
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			Application.Iteration += () => {
+				iterations++;
+
+				if (iterations == 0) {
+					MessageBox.Query (string.Empty, string.Empty, null);
+
+					Application.RequestStop ();
+				} else if (iterations == 1) {
+					Application.Refresh ();
+
+					Assert.IsType<Dialog> (Application.Current);
+					// Default size is Percent(60) 
+					Assert.Equal (new Size ((int)(100 * .60), 5), Application.Current.Frame.Size);
+
+					Application.RequestStop ();
+				}
+			};
+
+			Application.Run ();
+		}
+
+		[Fact]
+		[AutoInitShutdown]
+		public void Location_Default ()
+		{
+			var iterations = -1;
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			Application.Iteration += () => {
+				iterations++;
+
+				if (iterations == 0) {
+					MessageBox.Query (string.Empty, string.Empty, null);
+
+					Application.RequestStop ();
+				} else if (iterations == 1) {
+					Application.Refresh ();
+
+					Assert.IsType<Dialog> (Application.Current);
+					// Default location is centered, so
+					// X = (100 / 2) - (60 / 2) = 20
+					// Y = (100 / 2) - (5 / 2) = 47
+					Assert.Equal (new Point (20, 47), Application.Current.Frame.Location);
+
+					Application.RequestStop ();
+				}
+			};
+
+			Application.Run ();
+		}
+
+		[Theory]
+		[InlineData (0, 0)]
+		[InlineData (1, 1)]
+		[InlineData (7, 5)]
+		[InlineData (50, 50)]
+		[AutoInitShutdown]
+		public void Size_Not_Default_No_Message (int height, int width)
+		{
+			var iterations = -1;
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			Application.Iteration += () => {
+				iterations++;
+
+				if (iterations == 0) {
+					MessageBox.Query (height, width, string.Empty, string.Empty, null);
+
+					Application.RequestStop ();
+				} else if (iterations == 1) {
+					Application.Refresh ();
+
+					Assert.IsType<Dialog> (Application.Current);
+					Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
+
+					Application.RequestStop ();
+				}
+			};
+		}
+
+		[Theory]
+		[InlineData (0, 0, "1")]
+		[InlineData (1, 1, "1")]
+		[InlineData (7, 5, "1")]
+		[InlineData (50, 50, "1")]
+		[InlineData (0, 0, "message")]
+		[InlineData (1, 1, "message")]
+		[InlineData (7, 5, "message")]
+		[InlineData (50, 50, "message")]
+		[AutoInitShutdown]
+		public void Size_Not_Default_Message (int height, int width, string message)
+		{
+			var iterations = -1;
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			Application.Iteration += () => {
+				iterations++;
+
+				if (iterations == 0) {
+					MessageBox.Query (height, width, string.Empty, message, null);
+
+					Application.RequestStop ();
+				} else if (iterations == 1) {
+					Application.Refresh ();
+
+					Assert.IsType<Dialog> (Application.Current);
+					Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
+
+					Application.RequestStop ();
+				}
+			};
+		}
+
+		[Theory]
+		[InlineData (0, 0, "1")]
+		[InlineData (1, 1, "1")]
+		[InlineData (7, 5, "1")]
+		[InlineData (50, 50, "1")]
+		[InlineData (0, 0, "message")]
+		[InlineData (1, 1, "message")]
+		[InlineData (7, 5, "message")]
+		[InlineData (50, 50, "message")]
+		[AutoInitShutdown]
+		public void Size_Not_Default_Message_Button (int height, int width, string message)
+		{
+			var iterations = -1;
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (100, 100);
+
+			Application.Iteration += () => {
+				iterations++;
+
+				if (iterations == 0) {
+					MessageBox.Query (height, width, string.Empty, message, "_Ok");
+
+					Application.RequestStop ();
+				} else if (iterations == 1) {
+					Application.Refresh ();
+
+					Assert.IsType<Dialog> (Application.Current);
+					Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
+
+					Application.RequestStop ();
+				}
+			};
+		}
+
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_Empty_Size_Without_Buttons ()
+		public void Size_None_No_Buttons ()
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
@@ -46,47 +205,39 @@ namespace Terminal.Gui.DialogTests {
 		}
 
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_Empty_Size_With_Button ()
+		public void Size_No_With_Button ()
 		{
+			Application.Top.BorderStyle = LineStyle.Double;
 			var iterations = -1;
 			Application.Begin (Application.Top);
 
+			var aboutMessage = new StringBuilder ();
+			aboutMessage.AppendLine (@"0123456789012345678901234567890123456789");
+			aboutMessage.AppendLine (@"https://github.com/gui-cs/Terminal.Gui");
+			var message = aboutMessage.ToString ();
+
+			((FakeDriver)Application.Driver).SetBufferSize (40 + 4, 8);
+
 			Application.Iteration += () => {
 				iterations++;
 
 				if (iterations == 0) {
-					var aboutMessage = new StringBuilder ();
-					aboutMessage.AppendLine (@"A comprehensive sample library for");
-					aboutMessage.AppendLine (@"");
-					aboutMessage.AppendLine (@"  _______                  _             _   _____       _  ");
-					aboutMessage.AppendLine (@" |__   __|                (_)           | | / ____|     (_) ");
-					aboutMessage.AppendLine (@"    | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ");
-					aboutMessage.AppendLine (@"    | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ");
-					aboutMessage.AppendLine (@"    | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | ");
-					aboutMessage.AppendLine (@"    |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| ");
-					aboutMessage.AppendLine (@"");
-					aboutMessage.AppendLine (@"https://github.com/gui-cs/Terminal.Gui");
 
-					MessageBox.Query ("About UI Catalog", aboutMessage.ToString (), "_Ok");
+
+					MessageBox.Query (string.Empty, message, "_Ok");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-         ┌┤About UI Catalog├──────────────────────────────────────────┐
-         │             A comprehensive sample library for             │
-         │                                                            │
-         │  _______                  _             _   _____       _  │
-         │ |__   __|                (_)           | | / ____|     (_) │
-         │    | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  │
-         │    | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | │
-         │    | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | │
-         │    |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| │
-         │                                                            │
-         │           https://github.com/gui-cs/Terminal.Gui           │
-         │                                                            │
-         │                          [◦ Ok ◦]                          │
-         └────────────────────────────────────────────────────────────┘
+╔══════════════════════════════════════════╗
+║┌────────────────────────────────────────┐║
+║│0123456789012345678901234567890123456789│║
+║│ https://github.com/gui-cs/Terminal.Gui │║
+║│                                        │║
+║│                [◦ Ok ◦]                │║
+║└────────────────────────────────────────┘║
+╚══════════════════════════════════════════╝
 ", output);
 
 					Application.RequestStop ();
@@ -97,7 +248,7 @@ namespace Terminal.Gui.DialogTests {
 		}
 
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_A_Smaller_Fixed_Size ()
+		public void Size_Tiny_Fixed_Size ()
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
@@ -106,13 +257,16 @@ namespace Terminal.Gui.DialogTests {
 				iterations++;
 
 				if (iterations == 0) {
-					MessageBox.Query (7, 5, "Title", "Message", "_Ok");
+					MessageBox.Query (7, 5, string.Empty, "Message", "_Ok");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
+
+					Assert.Equal (new Size (7, 5), Application.Current.Frame.Size);
+
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-                                    ┌┤Tit├┐
+                                    ┌─────
                                     │Messa│
                                     │ ge  │
                                     │ Ok ◦│
@@ -127,7 +281,7 @@ namespace Terminal.Gui.DialogTests {
 		}
 
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_A_Enough_Fixed_Size ()
+		public void Size_JustBigEnough_Fixed_Size ()
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
@@ -136,13 +290,13 @@ namespace Terminal.Gui.DialogTests {
 				iterations++;
 
 				if (iterations == 0) {
-					MessageBox.Query (11, 5, "Title", "Message", "_Ok");
+					MessageBox.Query (11, 5, string.Empty, "Message", "_Ok");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-                                  ┌┤Title├──┐
+                                  ┌─────────┐
                                   │ Message │
                                   │         │
                                   │[◦ Ok ◦] │
@@ -157,47 +311,53 @@ namespace Terminal.Gui.DialogTests {
 		}
 
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_A_Label_Without_Spaces_WrapMessagge_True ()
+		public void Message_Long_Without_Spaces_WrapMessage_True ()
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
+			Application.Top.BorderStyle = LineStyle.Double;
+			((FakeDriver)Application.Driver).SetBufferSize (20, 10);
 
 			Application.Iteration += () => {
 				iterations++;
 
 				if (iterations == 0) {
-					MessageBox.Query ("mywindow", new string ('f', 2000), "ok");
+					// 50 characters should make the height of the wrapped text 7
+					MessageBox.Query (string.Empty, new string ('f', 50), defaultButton: 0, wrapMessage: true, "btn");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
+
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-┌┤mywindow├────────────────────────────────────────────────────────────────────┐
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff│
-│                                   [◦ ok ◦]                                   │
-└──────────────────────────────────────────────────────────────────────────────┘", output);
+╔══════════════════╗
+║┌────────────────┐║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│       ff       │║
+║│                │║
+║│    [◦ btn ◦]   │║
+║└────────────────┘║
+╚══════════════════╝", output);
+					Assert.Equal (new Size (20 - 2, 10 - 2), Application.Current.Frame.Size);
+					Application.RequestStop ();
 
+					// Really long text
+					MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: true, "btn");
+				} else if (iterations == 2) {
+					Application.Refresh ();
+					TestHelpers.AssertDriverContentsWithFrameAre (@"
+╔┌────────────────┐╗
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│    [◦ btn ◦]   │║
+╚└────────────────┘╝", output);
 					Application.RequestStop ();
 				}
 			};
@@ -206,51 +366,54 @@ namespace Terminal.Gui.DialogTests {
 		}
 
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_A_Label_With_Spaces_WrapMessagge_True ()
+		public void Message_With_Spaces_WrapMessage_True ()
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
+			Application.Top.BorderStyle = LineStyle.Double;
+			((FakeDriver)Application.Driver).SetBufferSize (20, 10);
 
 			Application.Iteration += () => {
 				iterations++;
 
 				if (iterations == 0) {
 					var sb = new StringBuilder ();
-					for (int i = 0; i < 1000; i++)
+					for (int i = 0; i < 17; i++)
 						sb.Append ("ff ");
 
-					MessageBox.Query ("mywindow", sb.ToString (), "ok");
+					MessageBox.Query (string.Empty, sb.ToString (), defaultButton: 0, wrapMessage: true, "btn");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-┌┤mywindow├────────────────────────────────────────────────────────────────────┐
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff │
-│                                   [◦ ok ◦]                                   │
-└──────────────────────────────────────────────────────────────────────────────┘", output);
+╔══════════════════╗
+║ ┌──────────────┐ ║
+║ │ff ff ff ff ff│ ║
+║ │ff ff ff ff ff│ ║
+║ │ff ff ff ff ff│ ║
+║ │    ff ff     │ ║
+║ │              │ ║
+║ │   [◦ btn ◦]  │ ║
+║ └──────────────┘ ║
+╚══════════════════╝", output);
+					Application.RequestStop ();
 
+					// Really long text
+					MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: true, "btn");
+				} else if (iterations == 2) {
+					Application.Refresh ();
+					TestHelpers.AssertDriverContentsWithFrameAre (@"
+╔┌────────────────┐╗
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│    [◦ btn ◦]   │║
+╚└────────────────┘╝", output);
 					Application.RequestStop ();
 				}
 			};
@@ -259,26 +422,51 @@ namespace Terminal.Gui.DialogTests {
 		}
 
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_A_Label_Without_Spaces_WrapMessagge_False ()
+		public void Message_Without_Spaces_WrapMessage_False ()
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
+			Application.Top.BorderStyle = LineStyle.Double;
+			((FakeDriver)Application.Driver).SetBufferSize (20, 10);
 
 			Application.Iteration += () => {
 				iterations++;
 
 				if (iterations == 0) {
-					MessageBox.Query ("mywindow", new string ('f', 2000), 0,  false, "ok");
+					MessageBox.Query (string.Empty, new string ('f', 50), defaultButton: 0, wrapMessage: true, "btn");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-────────────────────────────────────────────────────────────────────────────────
-ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-                                                                                
-                                    [◦ ok ◦]                                    
-────────────────────────────────────────────────────────────────────────────────", output);
+╔══════════════════╗
+║┌────────────────┐║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│       ff       │║
+║│                │║
+║│    [◦ btn ◦]   │║
+║└────────────────┘║
+╚══════════════════╝", output);
+
+					Application.RequestStop ();
+
+					// Really long text
+					MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: true, "btn");
+				} else if (iterations == 2) {
+					Application.Refresh ();
+					TestHelpers.AssertDriverContentsWithFrameAre (@"
+╔┌────────────────┐╗
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│    [◦ btn ◦]   │║
+╚└────────────────┘╝", output);
 
 					Application.RequestStop ();
 				}
@@ -288,31 +476,54 @@ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
 		}
 
 		[Fact, AutoInitShutdown]
-		public void MessageBox_With_A_Label_With_Spaces_WrapMessagge_False ()
+		public void Message_With_Spaces_WrapMessage_False ()
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
+			Application.Top.BorderStyle = LineStyle.Double;
+			((FakeDriver)Application.Driver).SetBufferSize (20, 10);
 
 			Application.Iteration += () => {
 				iterations++;
 
 				if (iterations == 0) {
 					var sb = new StringBuilder ();
-					for (int i = 0; i < 1000; i++)
+					for (int i = 0; i < 17; i++)
 						sb.Append ("ff ");
 
-					MessageBox.Query ("mywindow", sb.ToString (), 0,  false, "ok");
+					MessageBox.Query (string.Empty, sb.ToString (), defaultButton: 0, wrapMessage: false, "btn");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-────────────────────────────────────────────────────────────────────────────────
- ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff f
-                                                                                
-                                    [◦ ok ◦]                                    
-────────────────────────────────────────────────────────────────────────────────", output);
+╔══════════════════╗
+║ ┌──────────────┐ ║
+║ │ff ff ff ff ff│ ║
+║ │ff ff ff ff ff│ ║
+║ │ff ff ff ff ff│ ║
+║ │    ff ff     │ ║
+║ │              │ ║
+║ │   [◦ btn ◦]  │ ║
+║ └──────────────┘ ║
+╚══════════════════╝", output);
+					Application.RequestStop ();
 
+					// Really long text
+					MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: false, "btn");
+				} else if (iterations == 2) {
+					Application.Refresh ();
+					TestHelpers.AssertDriverContentsWithFrameAre (@"
+╔┌────────────────┐╗
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│ffffffffffffffff│║
+║│    [◦ btn ◦]   │║
+╚└────────────────┘╝", output);
 					Application.RequestStop ();
 				}
 			};
@@ -321,11 +532,15 @@ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
 		}
 
 		[Theory, AutoInitShutdown]
+		[InlineData (" ", true)]
+		[InlineData (" ", false)]
 		[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)
+		[InlineData (" \n", true)]
+		[InlineData (" \n", false)]
+		public void Message_Empty_Or_A_NewLline_WrapMessagge_True_Or_False (string message, bool wrapMessage)
 		{
 			var iterations = -1;
 			Application.Begin (Application.Top);
@@ -334,13 +549,13 @@ ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
 				iterations++;
 
 				if (iterations == 0) {
-					MessageBox.Query ("mywindow", message, 0, wrapMessage, "ok");
+					MessageBox.Query (string.Empty, message, 0, wrapMessage, "ok");
 
 					Application.RequestStop ();
 				} else if (iterations == 1) {
 					Application.Refresh ();
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-                ┌┤mywindow├────────────────────────────────────┐
+                ┌──────────────────────────────────────────────┐
                 │                                              │
                 │                                              │
                 │                   [◦ ok ◦]                   │

+ 4 - 4
UnitTests/Dialogs/WizardTests.cs

@@ -22,7 +22,7 @@ namespace Terminal.Gui.DialogTests {
 
 		private void RunButtonTestWizard (string title, int width, int height)
 		{
-			var wizard = new Wizard (title) { Width = width, Height = height };
+			var wizard = new Wizard () { Title = title, Width = width, Height = height };
 			Application.End (Application.Begin (wizard));
 		}
 
@@ -126,7 +126,7 @@ namespace Terminal.Gui.DialogTests {
 			var buttonRow = $"{d.VDLine}{btnBack}{new string (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{d.VDLine}";
 			var bottomRow = $"{d.LLDCorner}{new string (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}";
 
-			var wizard = new Wizard (title) { Width = width, Height = height };
+			var wizard = new Wizard () { Title = title, Width = width, Height = height };
 			var runstate = Application.Begin (wizard);
 			TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}", output);
 			Application.End (runstate);
@@ -159,7 +159,7 @@ namespace Terminal.Gui.DialogTests {
 			var buttonRow = $"{d.VDLine}{btnBack}{new string (' ', width - btnBack.Length - btnNext.Length - 2)}{btnNext}{d.VDLine}";
 			var bottomRow = $"{d.LLDCorner}{new string (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}";
 
-			var wizard = new Wizard (title) { Width = width, Height = height };
+			var wizard = new Wizard () { Title = title, Width = width, Height = height };
 			wizard.AddStep (new Wizard.WizardStep (stepTitle));
 			//wizard.LayoutSubviews ();
 			var firstIteration = false;
@@ -229,7 +229,7 @@ namespace Terminal.Gui.DialogTests {
 			//var buttonRow = $"{d.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{d.VDLine}";
 			var bottomRow = $"{d.LLDCorner}{new string (d.HDLine.ToString () [0], width - 2)}{d.LRDCorner}";
 
-			var wizard = new Wizard (title) { Width = width, Height = height };
+			var wizard = new Wizard () { Title = title, Width = width, Height = height };
 			wizard.AddStep (new Wizard.WizardStep ("ABCD"));
 
 			Application.End (Application.Begin (wizard));

+ 74 - 74
UnitTests/Drawing/LineCanvasTests.cs

@@ -14,10 +14,10 @@ namespace Terminal.Gui.DrawingTests {
 			this.output = output;
 		}
 
-		[InlineData (BorderStyle.Single)]
-		[InlineData (BorderStyle.Rounded)]
+		[InlineData (LineStyle.Single)]
+		[InlineData (LineStyle.Rounded)]
 		[Theory, AutoInitShutdown]
-		public void TestLineCanvas_Horizontal (BorderStyle style)
+		public void TestLineCanvas_Horizontal (LineStyle style)
 		{
 			var v = GetCanvas (out var canvas);
 			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, style);
@@ -34,7 +34,7 @@ namespace Terminal.Gui.DrawingTests {
 		public void TestLineCanvas_Horizontal_Double ()
 		{
 			var v = GetCanvas (out var canvas);
-			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, BorderStyle.Double);
+			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Double);
 
 			v.Redraw (v.Bounds);
 
@@ -44,10 +44,10 @@ namespace Terminal.Gui.DrawingTests {
 			TestHelpers.AssertDriverContentsAre (looksLike, output);
 		}
 
-		[InlineData (BorderStyle.Single)]
-		[InlineData (BorderStyle.Rounded)]
+		[InlineData (LineStyle.Single)]
+		[InlineData (LineStyle.Rounded)]
 		[Theory, AutoInitShutdown]
-		public void TestLineCanvas_Vertical (BorderStyle style)
+		public void TestLineCanvas_Vertical (LineStyle style)
 		{
 			var v = GetCanvas (out var canvas);
 			canvas.AddLine (new Point (0, 0), 1, Orientation.Vertical, style);
@@ -65,7 +65,7 @@ namespace Terminal.Gui.DrawingTests {
 		public void TestLineCanvas_Vertical_Double ()
 		{
 			var v = GetCanvas (out var canvas);
-			canvas.AddLine (new Point (0, 0), 1, Orientation.Vertical, BorderStyle.Double);
+			canvas.AddLine (new Point (0, 0), 1, Orientation.Vertical, LineStyle.Double);
 
 			v.Redraw (v.Bounds);
 
@@ -84,8 +84,8 @@ namespace Terminal.Gui.DrawingTests {
 		public void TestLineCanvas_Corner_NoOverlap ()
 		{
 			var v = GetCanvas (out var canvas);
-			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, BorderStyle.Single);
-			canvas.AddLine (new Point (0, 1), 1, Orientation.Vertical, BorderStyle.Single);
+			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Single);
+			canvas.AddLine (new Point (0, 1), 1, Orientation.Vertical, LineStyle.Single);
 
 			v.Redraw (v.Bounds);
 
@@ -104,8 +104,8 @@ namespace Terminal.Gui.DrawingTests {
 		public void TestLineCanvas_Corner_Correct ()
 		{
 			var v = GetCanvas (out var canvas);
-			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, BorderStyle.Single);
-			canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, BorderStyle.Single);
+			canvas.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Single);
+			canvas.AddLine (new Point (0, 0), 2, Orientation.Vertical, LineStyle.Single);
 
 			v.Redraw (v.Bounds);
 
@@ -124,14 +124,14 @@ namespace Terminal.Gui.DrawingTests {
 			var v = GetCanvas (out var canvas);
 
 			// outer box
-			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, BorderStyle.Single);
-			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Single);
-			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, BorderStyle.Single);
-			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, BorderStyle.Single);
+			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Single);
+			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Single);
+			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Single);
+			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Single);
 
 
-			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Single);
-			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Single);
+			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Single);
+			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Single);
 
 			v.Redraw (v.Bounds);
 
@@ -146,7 +146,7 @@ namespace Terminal.Gui.DrawingTests {
 		}
 
 		/// <summary>
-		/// Demonstrates when <see cref="BorderStyle.Rounded"/> corners are used. Notice how
+		/// Demonstrates when <see cref="LineStyle.Rounded"/> corners are used. Notice how
 		/// not all lines declare rounded.  If there are 1+ lines intersecting and a corner is
 		/// to be used then if any of them are rounded a rounded corner is used.
 		/// </summary>
@@ -156,17 +156,17 @@ namespace Terminal.Gui.DrawingTests {
 			var v = GetCanvas (out var canvas);
 
 			// outer box
-			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, BorderStyle.Rounded);
+			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Rounded);
 
 			// BorderStyle.Single is ignored because corner overlaps with the above line which is Rounded
 			// this results in a rounded corner being used.
-			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Single);
-			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, BorderStyle.Rounded);
-			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, BorderStyle.Single);
+			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Single);
+			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Rounded);
+			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Single);
 
 			// These lines say rounded but they will result in the T sections which are never rounded.
-			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Rounded);
-			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Rounded);
+			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Rounded);
+			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Rounded);
 
 			v.Redraw (v.Bounds);
 
@@ -186,14 +186,14 @@ namespace Terminal.Gui.DrawingTests {
 			var v = GetCanvas (out var canvas);
 
 			// outer box
-			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, BorderStyle.Double);
-			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Double);
-			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, BorderStyle.Double);
-			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, BorderStyle.Double);
+			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Double);
+			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Double);
+			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Double);
+			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Double);
 
 
-			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Double);
-			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Double);
+			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Double);
+			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Double);
 
 			v.Redraw (v.Bounds);
 
@@ -209,21 +209,21 @@ namespace Terminal.Gui.DrawingTests {
 
 
 		[Theory, AutoInitShutdown]
-		[InlineData (BorderStyle.Single)]
-		[InlineData (BorderStyle.Rounded)]
-		public void TestLineCanvas_Window_DoubleTop_SingleSides (BorderStyle thinStyle)
+		[InlineData (LineStyle.Single)]
+		[InlineData (LineStyle.Rounded)]
+		public void TestLineCanvas_Window_DoubleTop_SingleSides (LineStyle thinStyle)
 		{
 			var v = GetCanvas (out var canvas);
 
 			// outer box
-			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, BorderStyle.Double);
+			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, LineStyle.Double);
 			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, thinStyle);
-			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, BorderStyle.Double);
+			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, LineStyle.Double);
 			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, thinStyle);
 
 
 			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, thinStyle);
-			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, BorderStyle.Double);
+			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, LineStyle.Double);
 
 			v.Redraw (v.Bounds);
 
@@ -239,20 +239,20 @@ namespace Terminal.Gui.DrawingTests {
 		}
 
 		[Theory, AutoInitShutdown]
-		[InlineData (BorderStyle.Single)]
-		[InlineData (BorderStyle.Rounded)]
-		public void TestLineCanvas_Window_SingleTop_DoubleSides (BorderStyle thinStyle)
+		[InlineData (LineStyle.Single)]
+		[InlineData (LineStyle.Rounded)]
+		public void TestLineCanvas_Window_SingleTop_DoubleSides (LineStyle thinStyle)
 		{
 			var v = GetCanvas (out var canvas);
 
 			// outer box
 			canvas.AddLine (new Point (0, 0), 9, Orientation.Horizontal, thinStyle);
-			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, BorderStyle.Double);
+			canvas.AddLine (new Point (9, 0), 4, Orientation.Vertical, LineStyle.Double);
 			canvas.AddLine (new Point (9, 4), -9, Orientation.Horizontal, thinStyle);
-			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, BorderStyle.Double);
+			canvas.AddLine (new Point (0, 4), -4, Orientation.Vertical, LineStyle.Double);
 
 
-			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, BorderStyle.Double);
+			canvas.AddLine (new Point (5, 0), 4, Orientation.Vertical, LineStyle.Double);
 			canvas.AddLine (new Point (0, 2), 9, Orientation.Horizontal, thinStyle);
 
 			v.Redraw (v.Bounds);
@@ -276,14 +276,14 @@ namespace Terminal.Gui.DrawingTests {
 			var v = GetCanvas (out var canvas, 1, 1);
 
 			// outer box
-			canvas.AddLine (new Point (0, 0), 8, Orientation.Horizontal, BorderStyle.Single);
-			canvas.AddLine (new Point (8, 0), 3, Orientation.Vertical, BorderStyle.Single);
-			canvas.AddLine (new Point (8, 3), -8, Orientation.Horizontal, BorderStyle.Single);
-			canvas.AddLine (new Point (0, 3), -3, Orientation.Vertical, BorderStyle.Single);
+			canvas.AddLine (new Point (0, 0), 8, Orientation.Horizontal, LineStyle.Single);
+			canvas.AddLine (new Point (8, 0), 3, Orientation.Vertical, LineStyle.Single);
+			canvas.AddLine (new Point (8, 3), -8, Orientation.Horizontal, LineStyle.Single);
+			canvas.AddLine (new Point (0, 3), -3, Orientation.Vertical, LineStyle.Single);
 
 
-			canvas.AddLine (new Point (5, 0), 3, Orientation.Vertical, BorderStyle.Single);
-			canvas.AddLine (new Point (0, 2), 8, Orientation.Horizontal, BorderStyle.Single);
+			canvas.AddLine (new Point (5, 0), 3, Orientation.Vertical, LineStyle.Single);
+			canvas.AddLine (new Point (0, 2), 8, Orientation.Horizontal, LineStyle.Single);
 
 			v.Redraw (v.Bounds);
 
@@ -307,19 +307,19 @@ namespace Terminal.Gui.DrawingTests {
 
 			// ╔╡ Title ╞═════╗
 			// Add a short horiz line for ╔╡
-			lc.AddLine (new Point (0, 0), 1, Orientation.Horizontal, BorderStyle.Double);
+			lc.AddLine (new Point (0, 0), 1, Orientation.Horizontal, LineStyle.Double);
 			//LHS line down
-			lc.AddLine (new Point (0, 0), 5, Orientation.Vertical, BorderStyle.Double);
+			lc.AddLine (new Point (0, 0), 5, Orientation.Vertical, LineStyle.Double);
 
 			//Vertical line before Title, results in a ╡
-			lc.AddLine (new Point (1, 0), 0, Orientation.Vertical, BorderStyle.Single);
+			lc.AddLine (new Point (1, 0), 0, Orientation.Vertical, LineStyle.Single);
 			//Vertical line after Title, results in a ╞
-			lc.AddLine (new Point (6, 0), 0, Orientation.Vertical, BorderStyle.Single);
+			lc.AddLine (new Point (6, 0), 0, Orientation.Vertical, LineStyle.Single);
 
 			// remainder of title
-			lc.AddLine (new Point (6, 0), 3, Orientation.Horizontal, BorderStyle.Double);
+			lc.AddLine (new Point (6, 0), 3, Orientation.Horizontal, LineStyle.Double);
 			//RHS line down
-			lc.AddLine (new Point (9, 0), 5, Orientation.Vertical, BorderStyle.Double);
+			lc.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Double);
 
 			v.Redraw (v.Bounds);
 
@@ -330,13 +330,13 @@ namespace Terminal.Gui.DrawingTests {
 			TestHelpers.AssertDriverContentsAre (looksLike, output);
 		}
 
-		[InlineData(0,0,0, Orientation.Horizontal,BorderStyle.Double,"═")]
-		[InlineData(0,0,0, Orientation.Vertical,BorderStyle.Double,"║")]
-		[InlineData(0,0,0, Orientation.Horizontal,BorderStyle.Single,"─")]
-		[InlineData(0,0,0, Orientation.Vertical,BorderStyle.Single,"│")]
+		[InlineData(0,0,0, Orientation.Horizontal,LineStyle.Double,"═")]
+		[InlineData(0,0,0, Orientation.Vertical,LineStyle.Double,"║")]
+		[InlineData(0,0,0, Orientation.Horizontal,LineStyle.Single,"─")]
+		[InlineData(0,0,0, Orientation.Vertical,LineStyle.Single,"│")]
 		[AutoInitShutdown, Theory]
 		public void TestLineCanvas_1LineTests(
-			int x1, int y1,int l1, Orientation o1, BorderStyle s1,
+			int x1, int y1,int l1, Orientation o1, LineStyle s1,
 			string expected
 		)
 		{
@@ -355,44 +355,44 @@ namespace Terminal.Gui.DrawingTests {
 
 		[Theory, AutoInitShutdown]
 		[InlineData(
-			0,0,1,Orientation.Horizontal,BorderStyle.Double,
-			1,0,0, Orientation.Vertical,BorderStyle.Single, "═╡"
+			0,0,1,Orientation.Horizontal,LineStyle.Double,
+			1,0,0, Orientation.Vertical,LineStyle.Single, "═╡"
 		)]
 		[InlineData(
-			0,0,0, Orientation.Vertical,BorderStyle.Single,
-			0,0,1,Orientation.Horizontal,BorderStyle.Double,
+			0,0,0, Orientation.Vertical,LineStyle.Single,
+			0,0,1,Orientation.Horizontal,LineStyle.Double,
 			 "╞═"
 		)]
 		[InlineData(
-			0,0,1, Orientation.Vertical,BorderStyle.Single,
-			0,0,0,Orientation.Horizontal,BorderStyle.Double,
+			0,0,1, Orientation.Vertical,LineStyle.Single,
+			0,0,0,Orientation.Horizontal,LineStyle.Double,
 @"
 │"
 		)]
 		[InlineData(
-			0,0,1, Orientation.Vertical,BorderStyle.Single,
-			0,1,0,Orientation.Horizontal,BorderStyle.Double,
+			0,0,1, Orientation.Vertical,LineStyle.Single,
+			0,1,0,Orientation.Horizontal,LineStyle.Double,
 			@"
 "
 		)]
 		[InlineData(
-			0,0,0, Orientation.Vertical,BorderStyle.Single,
-			0,0,0,Orientation.Horizontal,BorderStyle.Single,
+			0,0,0, Orientation.Vertical,LineStyle.Single,
+			0,0,0,Orientation.Horizontal,LineStyle.Single,
 			@"┼
 "
 		)]
 		[InlineData(
-			0,0,0, Orientation.Vertical,BorderStyle.Double,
-			0,0,0,Orientation.Horizontal,BorderStyle.Double,
+			0,0,0, Orientation.Vertical,LineStyle.Double,
+			0,0,0,Orientation.Horizontal,LineStyle.Double,
 			@"╬
 "
 		)]
 		public void TestLineCanvas_2LineTests(
-			int x1, int y1,int l1, Orientation o1, BorderStyle s1,
-			int x2, int y2, int l2, Orientation o2, BorderStyle s2,
+			int x1, int y1,int l1, Orientation o1, LineStyle s1,
+			int x2, int y2, int l2, Orientation o2, LineStyle s2,
 			string expected
 		)
 		{

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 935 - 208
UnitTests/Text/TextFormatterTests.cs


+ 4 - 4
UnitTests/Text/UnicodeTests.cs

@@ -57,21 +57,21 @@ namespace Terminal.Gui.TextTests {
 これは広いルーンラインです。
 これは広いルーンラインです。"
 			};
-			var win = new Window ("ワイドルーン") { Width = Dim.Fill (), Height = Dim.Fill () };
+			var win = new Window () { Width = Dim.Fill (), Height = Dim.Fill () };
 			win.Add (tv);
 			Application.Top.Add (win);
 			var lbl = new Label ("ワイドルーン。");
-			var dg = new Dialog ("テスト", 14, 4, new Button ("選ぶ"));
+			var dg = new Dialog (new Button ("選ぶ")) { Width = 14, Height = 4 };
 			dg.Add (lbl);
 			Application.Begin (Application.Top);
 			Application.Begin (dg);
 			((FakeDriver)Application.Driver).SetBufferSize (30, 10);
 
 			var expected = @"
-┌┤ワイドルーン├──────────────┐
+┌────────────────────────────┐
 │これは広いルーンラインです。│
 │これは広いルーンラインです。│
-│これは ┌┤テスト├────┐ です。│
+│これは ┌────────────┐ です。│
 │これは │ワイドルーン│ です。│
 │これは │  [ 選ぶ ]  │ です。│
 │これは └────────────┘ です。│

+ 10 - 13
UnitTests/UICatalog/ScenarioTests.cs

@@ -222,7 +222,8 @@ namespace UICatalog.Tests {
 				.Select (t => new KeyValuePair<string, Type> (t.Name, t))
 				.ToDictionary (t => t.Key, t => t.Value);
 
-			_leftPane = new Window ("Classes") {
+			_leftPane = new Window () {
+				Title = "Classes",
 				X = 0,
 				Y = 0,
 				Width = 15,
@@ -327,7 +328,14 @@ namespace UICatalog.Tests {
 				_settingsPane.SetFocus ();
 			};
 			_classListView.SelectedItemChanged += (s, args) => {
-				ClearClass (_curView);
+				// Remove existing class, if any
+				if (_curView != null) {
+					_curView.LayoutComplete -= LayoutCompleteHandler;
+					_hostPane.Remove (_curView);
+					_curView.Dispose ();
+					_curView = null;
+					_hostPane.Clear ();
+				}
 				_curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
 			};
 
@@ -513,17 +521,6 @@ namespace UICatalog.Tests {
 				return types;
 			}
 
-			void ClearClass (View view)
-			{
-				// Remove existing class, if any
-				if (view != null) {
-					view.LayoutComplete -= LayoutCompleteHandler;
-					_hostPane.Remove (view);
-					view.Dispose ();
-					_hostPane.Clear ();
-				}
-			}
-
 			View CreateClass (Type type)
 			{
 				// If we are to create a generic Type

+ 23 - 615
UnitTests/View/BorderTests.cs

@@ -1,8 +1,5 @@
-using System;
-using System.Reflection.Emit;
-using Xunit;
+using Xunit;
 using Xunit.Abstractions;
-using Rune = System.Rune;
 
 namespace Terminal.Gui.ViewTests {
 	public class BorderTests {
@@ -13,623 +10,34 @@ namespace Terminal.Gui.ViewTests {
 			this.output = output;
 		}
 
-		[Fact, AutoInitShutdown]
-		public void Constructor_Defaults ()
+		[Fact]
+		public void View_BorderStyle_Defaults ()
 		{
-			var b = new Border ();
-			Assert.Equal (BorderStyle.None, b.BorderStyle);
-			Assert.False (b.DrawMarginFrame);
-			Assert.Equal (Thickness.Empty, b.BorderThickness);
-			Assert.Equal (Color.Black, b.ForgroundColor);
-			Assert.Equal (Color.Black, b.BackgroundColor);
-			Assert.Equal (Thickness.Empty, b.PaddingThickness);
-			Assert.False (b.Effect3D);
-			Assert.Equal (new Point (1, 1), b.Effect3DOffset);
-			Assert.Null (b.Effect3DBrush);
+			var view = new View ();
+			Assert.Equal (LineStyle.None, view.BorderStyle);
+			Assert.Equal (Thickness.Empty, view.BorderFrame.Thickness);
 		}
 
-		//[Fact]
-		//public void BorderStyle_Different_None_Ensures_DrawMarginFrame_To_True ()
-		//{
-		//	var b = new Border () {
-		//		BorderStyle = BorderStyle.Single,
-		//		DrawMarginFrame = false
-		//	};
-
-		//	Assert.True (b.DrawMarginFrame);
-
-		//	b.BorderStyle = BorderStyle.None;
-		//	Assert.True (b.DrawMarginFrame);
-		//	b.DrawMarginFrame = false;
-		//	Assert.False (b.DrawMarginFrame);
-		//}
-
-		//[Fact, AutoInitShutdown]
-		// public void ActualWidth_ActualHeight ()
-		// {
-		// 	var v = new View (new Rect (5, 10, 60, 20), "", new Border ());
-
-		//[Fact]
-		//public void ToplevelContainer_LayoutStyle_Computed_Constuctor_ ()
-		//{
-		//	var tc = new Border.ToplevelContainer (new Border ());
-
-		//	Assert.Equal (LayoutStyle.Computed, tc.LayoutStyle);
-		//}
-
-		//[Fact]
-		//public void ToplevelContainer_LayoutStyle_Absolute_Constuctor_ ()
-		//{
-		//	var tc = new Border.ToplevelContainer (new Rect (1, 2, 3, 4), new Border ());
-
-		//	Assert.Equal (LayoutStyle.Absolute, tc.LayoutStyle);
-		//}
-
-		//[Fact]
-		//public void GetSumThickness_Test ()
-		//{
-		//	var b = new Border () {
-		//		BorderThickness = new Thickness (1, 2, 3, 4),
-		//		Padding = new Thickness (4, 3, 2, 1)
-		//	};
-		//	Assert.Equal (new Thickness (5, 5, 5, 5), b.GetSumThickness ());
-		//}
-
-		//[Fact]
-		//[AutoInitShutdown]
-		//public void DrawContent_With_Child_Border ()
-		//{
-		//	var top = Application.Top;
-		//	var driver = (FakeDriver)Application.Driver;
-
-		// [Fact]
-		// [AutoInitShutdown]
-		// public void DrawContent_With_Child_Border ()
-		// {
-		// 	var top = Application.Top;
-		// 	var driver = (FakeDriver)Application.Driver;
-
-		//	top.LayoutSubviews ();
-		//	label.Redraw (label.Bounds);
-
-		//	var frame = label.Frame;
-		//	var drawMarginFrame = label.Border.DrawMarginFrame ? 1 : 0;
-		//	var sumThickness = label.Border.GetSumThickness ();
-		//	var padding = label.Border.Padding;
-		//	var effect3DOffset = label.Border.Effect3DOffset;
-		//	var borderStyle = label.Border.BorderStyle;
-
-		//	// Check the upper BorderThickness
-		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top;
-		//		r < frame.Y - drawMarginFrame - padding.Top; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the left BorderThickness
-		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
-		//		r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-		//			c < frame.X - drawMarginFrame - padding.Left; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the right BorderThickness
-		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
-		//		r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
-		//		for (int c = frame.Right + drawMarginFrame + padding.Right;
-		//			c < frame.Right + drawMarginFrame - sumThickness.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the lower BorderThickness
-		//	for (int r = frame.Bottom + drawMarginFrame + padding.Bottom;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the upper Padding
-		//	for (int r = frame.Y - drawMarginFrame - padding.Top;
-		//		r < frame.Y - drawMarginFrame; r++) {
-		//		for (int c = frame.X - drawMarginFrame - padding.Left;
-		//			c < frame.Right + drawMarginFrame + padding.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	// Check the left Padding
-		//	for (int r = frame.Y - drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame; r++) {
-		//		for (int c = frame.X - drawMarginFrame - padding.Left;
-		//			c < frame.X - drawMarginFrame; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	// Check the right Padding
-		//	for (int r = frame.Y - drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame; r++) {
-		//		for (int c = frame.Right + drawMarginFrame;
-		//			c < frame.Right + drawMarginFrame - padding.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	// Check the lower Padding
-		//	for (int r = frame.Bottom + drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
-		//		for (int c = frame.X - drawMarginFrame - padding.Left;
-		//			c < frame.Right + drawMarginFrame + padding.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Background);
-		//		}
-		//	}
-
-		//	Rune hLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.HLine : (borderStyle == BorderStyle.Double ? driver.HDLine : ' ')) : ' ';
-		//	Rune vLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.VLine : (borderStyle == BorderStyle.Double ? driver.VDLine : ' ')) : ' ';
-		//	Rune uRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.URCorner : (borderStyle == BorderStyle.Double ? driver.URDCorner : ' ')) : ' ';
-		//	Rune uLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.ULCorner : (borderStyle == BorderStyle.Double ? driver.ULDCorner : ' ')) : ' ';
-		//	Rune lLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.LLCorner : (borderStyle == BorderStyle.Double ? driver.LLDCorner : ' ')) : ' ';
-		//	Rune lRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.LRCorner : (borderStyle == BorderStyle.Double ? driver.LRDCorner : ' ')) : ' ';
-
-		//	var text = "";
-		//	// Check the MarginFrame
-		//	for (int r = frame.Y - drawMarginFrame;
-		//		r < frame.Bottom + drawMarginFrame; r++) {
-		//		for (int c = frame.X - drawMarginFrame;
-		//			c <= frame.Right + drawMarginFrame - 1; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			var rune = (Rune)driver.Contents [r, c, 0];
-		//			Assert.Equal (Color.Black, color.Background);
-		//			if (c == frame.X - drawMarginFrame && r == frame.Y - drawMarginFrame) {
-		//				Assert.Equal (uLCorner, rune);
-		//			} else if (c == frame.Right && r == frame.Y - drawMarginFrame) {
-		//				Assert.Equal (uRCorner, rune);
-		//			} else if (c == frame.X - drawMarginFrame && r == frame.Bottom) {
-		//				Assert.Equal (lLCorner, rune);
-		//			} else if (c == frame.Right && r == frame.Bottom) {
-		//				Assert.Equal (lRCorner, rune);
-		//			} else if (c >= frame.X && (r == frame.Y - drawMarginFrame
-		//				|| r == frame.Bottom)) {
-		//				Assert.Equal (hLine, rune);
-		//			} else if ((c == frame.X - drawMarginFrame || c == frame.Right)
-		//				&& r >= frame.Y && r <= frame.Bottom - drawMarginFrame) {
-		//				Assert.Equal (vLine, rune);
-		//			} else {
-		//				text += rune.ToString ();
-		//			}
-		//		}
-		//	}
-		//	Assert.Equal ("This is a test", text.Trim ());
-
-			// 		var color = (Attribute)driver.Contents [r, c, 1];
-			// 		var rune = (Rune)driver.Contents [r, c, 0];
-			// 		if (r == frame.Y - drawMarginFrame || r == frame.Bottom + drawMarginFrame - 1
-			// 			|| c == frame.X - drawMarginFrame || c == frame.Right + drawMarginFrame - 1) {
-			// 			Assert.Equal (Color.BrightGreen, color.Background);
-			// 		} else {
-			// 			Assert.Equal (Color.Black, color.Background);
-			// 		}
-			// 		if (c == frame.X - drawMarginFrame && r == frame.Y - drawMarginFrame) {
-			// 			Assert.Equal (uLCorner, rune);
-			// 		} else if (c == frame.Right && r == frame.Y - drawMarginFrame) {
-			// 			Assert.Equal (uRCorner, rune);
-			// 		} else if (c == frame.X - drawMarginFrame && r == frame.Bottom) {
-			// 			Assert.Equal (lLCorner, rune);
-			// 		} else if (c == frame.Right && r == frame.Bottom) {
-			// 			Assert.Equal (lRCorner, rune);
-			// 		} else if (c >= frame.X && (r == frame.Y - drawMarginFrame
-			// 			|| r == frame.Bottom)) {
-			// 			Assert.Equal (hLine, rune);
-			// 		} else if ((c == frame.X - drawMarginFrame || c == frame.Right)
-			// 			&& r >= frame.Y && r <= frame.Bottom - drawMarginFrame) {
-			// 			Assert.Equal (vLine, rune);
-			// 		} else {
-			// 			text += rune.ToString ();
-			// 		}
-			// 	}
-			// }
-			// Assert.Equal ("This is a test", text.Trim ());
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the left Effect3D
-		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-		//			c < frame.X - drawMarginFrame - sumThickness.Left; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the right Effect3D
-		//	for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
-		//		for (int c = frame.Right + drawMarginFrame + sumThickness.Right;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the lower Effect3D
-		//	for (int r = frame.Bottom + drawMarginFrame + sumThickness.Bottom;
-		//		r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
-		//		for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
-		//			c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.DarkGray, color.Background);
-		//		}
-		//	}
-
-		//	// Check the Child frame
-		//	for (int r = frame.Y; r < frame.Y + frame.Height; r++) {
-		//		for (int c = frame.X; c < frame.X + frame.Width; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.BrightGreen, color.Foreground);
-		//			Assert.Equal (Color.Black, color.Background);
-		//		}
-		//	}
-		//}
-
-		//[Fact]
-		//[AutoInitShutdown]
-		//public void DrawContent_With_Parent_Border ()
-		//{
-		//	var top = Application.Top;
-		//	var driver = (FakeDriver)Application.Driver;
-
-		// [Fact]
-		// [AutoInitShutdown]
-		// public void DrawContent_With_Parent_Border ()
-		// {
-		// 	var top = Application.Top;
-		// 	var driver = (FakeDriver)Application.Driver;
-
-		//	top.LayoutSubviews ();
-		//	frameView.Redraw (frameView.Bounds);
-
-		//	var frame = frameView.Frame;
-		//	var drawMarginFrame = frameView.Border.DrawMarginFrame ? 1 : 0;
-		//	var borderThickness = frameView.Border.BorderThickness;
-		//	var padding = frameView.Border.Padding;
-
-		//	var effect3DOffset = frameView.Border.Effect3DOffset;
-		//	var borderStyle = frameView.Border.BorderStyle;
-
-		//	// Check the upper BorderThickness
-		//	for (int r = frame.Y;
-		//		r < Math.Min (frame.Y + borderThickness.Top, frame.Bottom); r++) {
-		//		for (int c = frame.X;
-		//			c < frame.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the left BorderThickness
-		//	for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
-		//		r < frame.Bottom - borderThickness.Bottom; r++) {
-		//		for (int c = frame.X;
-		//			c < Math.Min (frame.X + borderThickness.Left, frame.Right); c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the right BorderThickness
-		//	for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
-		//		r < frame.Bottom - borderThickness.Bottom; r++) {
-		//		for (int c = Math.Max (frame.Right - borderThickness.Right, frame.X);
-		//			c < frame.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-		//	// Check the lower BorderThickness
-		//	for (int r = Math.Max (frame.Bottom - borderThickness.Bottom, frame.Y);
-		//		r < frame.Bottom; r++) {
-		//		for (int c = frame.X;
-		//			c < frame.Right; c++) {
-
-		//			var color = (Attribute)driver.Contents [r, c, 1];
-		//			Assert.Equal (Color.Red, color.Background);
-		//		}
-		//	}
-
-
-		//	//TODO: Re-do padding tests
-
-		//	//// Check the upper Padding
-		//	//for (int r = frame.Y + borderThickness.Top;
-		//	//	r < Math.Min (frame.Y + sumThickness.Top, frame.Bottom - borderThickness.Bottom); r++) {
-		//	//	for (int c = frame.X + borderThickness.Left;
-		//	//		c < frame.Right - borderThickness.Right; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.BrightGreen, color.Background);
-		//	//	}
-		//	//}
-		//	//// Check the left Padding
-		//	//for (int r = frame.Y + sumThickness.Top;
-		//	//				r < frame.Bottom - sumThickness.Bottom; r++) {
-		//	//	for (int c = frame.X + borderThickness.Left;
-		//	//		c < Math.Min (frame.X + sumThickness.Left, frame.Right - borderThickness.Right); c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.BrightGreen, color.Background);
-		//	//	}
-		//	//}
-
-		//	//// Check the right Padding
-		//	//// Draw the right Padding
-		//	//for (int r = frame.Y + sumThickness.Top;
-		//	//	r < frame.Bottom - sumThickness.Bottom; r++) {
-		//	//	for (int c = Math.Max (frame.Right - sumThickness.Right, frame.X + sumThickness.Left);
-		//	//		c < Math.Max (frame.Right - borderThickness.Right, frame.X + sumThickness.Left); c++) {
-
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.BrightGreen, color.Background);
-		//	//	}
-		//	//}
-
-		//	//// Check the lower Padding
-		//	//for (int r = Math.Max (frame.Bottom - sumThickness.Bottom, frame.Y + borderThickness.Top);
-		//	//	r < frame.Bottom - borderThickness.Bottom; r++) {
-		//	//	for (int c = frame.X + borderThickness.Left;
-		//	//		c < frame.Right - borderThickness.Right; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.BrightGreen, color.Background);
-		//	//	}
-		//	//}
-
-		//	Rune hLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.HLine : (borderStyle == BorderStyle.Double ? driver.HDLine : ' ')) : ' ';
-		//	Rune vLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.VLine : (borderStyle == BorderStyle.Double ? driver.VDLine : ' ')) : ' ';
-		//	Rune uRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.URCorner : (borderStyle == BorderStyle.Double ? driver.URDCorner : ' ')) : ' ';
-		//	Rune uLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.ULCorner : (borderStyle == BorderStyle.Double ? driver.ULDCorner : ' ')) : ' ';
-		//	Rune lLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.LLCorner : (borderStyle == BorderStyle.Double ? driver.LLDCorner : ' ')) : ' ';
-		//	Rune lRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
-		//		? driver.LRCorner : (borderStyle == BorderStyle.Double ? driver.LRDCorner : ' ')) : ' ';
-
-		//	// TODO: redo margin tests
-			
-		//	//var text = "";
-		//	//// Check the MarginFrame
-		//	//for (int r = frame.Y + sumThickness.Top;
-		//	//	r < frame.Bottom - sumThickness.Bottom; r++) {
-		//	//	for (int c = frame.X + sumThickness.Left;
-		//	//		c <= frame.Right - sumThickness.Right - 1; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		var rune = (Rune)driver.Contents [r, c, 0];
-		//	//		Assert.Equal (Color.Black, color.Background);
-		//	//		if (c == frame.X + sumThickness.Left && r == frame.Y + sumThickness.Top) {
-		//	//			Assert.Equal (uLCorner, rune);
-		//	//		} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
-		//	//			&& r == frame.Y + sumThickness.Top) {
-		//	//			Assert.Equal (uRCorner, rune);
-		//	//		} else if (c == frame.X + sumThickness.Left
-		//	//			&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
-		//	//			Assert.Equal (lLCorner, rune);
-		//	//		} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
-		//	//			&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
-		//	//			Assert.Equal (lRCorner, rune);
-		//	//		} else if (c > frame.X + sumThickness.Left
-		//	//			&& (r == frame.Y + sumThickness.Top
-		//	//			|| r == frame.Bottom - drawMarginFrame - sumThickness.Bottom)) {
-		//	//			Assert.Equal (hLine, rune);
-		//	//		} else if ((c == frame.X + sumThickness.Left
-		//	//			|| c == frame.Right - drawMarginFrame - sumThickness.Right)
-		//	//			&& r >= frame.Y + drawMarginFrame + sumThickness.Top) {
-		//	//			Assert.Equal (vLine, rune);
-		//	//		} else {
-		//	//			text += rune.ToString ();
-		//	//		}
-		//	//	}
-		//	//}
-		//	//Assert.Equal ("This is a test", text.Trim ());
-
-			// 		var color = (Attribute)driver.Contents [r, c, 1];
-			// 		var rune = (Rune)driver.Contents [r, c, 0];
-			// 		Assert.Equal (Color.Black, color.Background);
-			// 		if (c == frame.X + sumThickness.Left && r == frame.Y + sumThickness.Top) {
-			// 			Assert.Equal (uLCorner, rune);
-			// 		} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
-			// 			&& r == frame.Y + sumThickness.Top) {
-			// 			Assert.Equal (uRCorner, rune);
-			// 		} else if (c == frame.X + sumThickness.Left
-			// 			&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
-			// 			Assert.Equal (lLCorner, rune);
-			// 		} else if (c == frame.Right - drawMarginFrame - sumThickness.Right
-			// 			&& r == frame.Bottom - drawMarginFrame - sumThickness.Bottom) {
-			// 			Assert.Equal (lRCorner, rune);
-			// 		} else if (c > frame.X + sumThickness.Left
-			// 			&& (r == frame.Y + sumThickness.Top
-			// 			|| r == frame.Bottom - drawMarginFrame - sumThickness.Bottom)) {
-			// 			Assert.Equal (hLine, rune);
-			// 		} else if ((c == frame.X + sumThickness.Left
-			// 			|| c == frame.Right - drawMarginFrame - sumThickness.Right)
-			// 			&& r >= frame.Y + drawMarginFrame + sumThickness.Top) {
-			// 			Assert.Equal (vLine, rune);
-			// 		} else {
-			// 			text += rune.ToString ();
-			// 		}
-			// 	}
-			// }
-			// Assert.Equal ("This is a test", text.Trim ());
-
-			// // Check the upper Effect3D
-			// for (int r = frame.Y + effect3DOffset.Y;
-			// 	r < frame.Y; r++) {
-			// 	for (int c = frame.X + effect3DOffset.X;
-			// 		c < frame.Right + effect3DOffset.X; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.DarkGray, color.Background);
-		//	//	}
-		//	//}
-
-		//	//// Check the left Effect3D
-		//	//for (int r = frame.Y + effect3DOffset.Y;
-		//	//	r < frame.Bottom + effect3DOffset.Y; r++) {
-		//	//	for (int c = frame.X + effect3DOffset.X;
-		//	//		c < frame.X; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.DarkGray, color.Background);
-		//	//	}
-		//	//}
-
-		//	//// Check the right Effect3D
-		//	//for (int r = frame.Y + effect3DOffset.Y;
-		//	//	r < frame.Bottom + effect3DOffset.Y; r++) {
-		//	//	for (int c = frame.Right;
-		//	//		c < frame.Right + effect3DOffset.X; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.DarkGray, color.Background);
-		//	//	}
-		//	//}
-
-		//	//// Check the lower Effect3D
-		//	//for (int r = frame.Bottom;
-		//	//	r < frame.Bottom + effect3DOffset.Y; r++) {
-		//	//	for (int c = frame.X + effect3DOffset.X;
-		//	//		c < frame.Right + effect3DOffset.X; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.DarkGray, color.Background);
-		//	//	}
-		//	//}
-
-		//	//// Check the Child frame
-		//	//for (int r = frame.Y + drawMarginFrame + sumThickness.Top;
-		//	//	r < frame.Bottom - drawMarginFrame - sumThickness.Bottom; r++) {
-		//	//	for (int c = frame.X + drawMarginFrame + sumThickness.Left;
-		//	//		c < frame.Right - drawMarginFrame - sumThickness.Right; c++) {
-
-		//	//		var color = (Attribute)driver.Contents [r, c, 1];
-		//	//		Assert.Equal (Color.BrightGreen, color.Foreground);
-		//	//		Assert.Equal (Color.Black, color.Background);
-		//	//	}
-		//	//}
-		//}
-
-		[Fact, AutoInitShutdown]
-		public void BorderOnControlWithNoChildren ()
+		[Fact]
+		public void View_SetBorderStyle ()
 		{
-			var label = new TextField ("Loading...") {
-				Border = new Border () {
-					BorderStyle = BorderStyle.Single,
-					DrawMarginFrame = true,
-					PaddingThickness = new Thickness (1),
-					ForgroundColor = Color.White
-				}
-			};
-
-			Application.Top.Add (label);
-
-			Assert.Null (Record.Exception (() => label.Redraw (label.Bounds)));
+			var view = new View ();
+			view.BorderStyle = LineStyle.Single;
+			Assert.Equal (LineStyle.Single, view.BorderStyle);
+			Assert.Equal (new Thickness(1), view.BorderFrame.Thickness);
+
+			view.BorderStyle = LineStyle.Double;
+			Assert.Equal (LineStyle.Double, view.BorderStyle);
+			Assert.Equal (new Thickness (1), view.BorderFrame.Thickness);
+
+			view.BorderStyle = LineStyle.None;
+			Assert.Equal (LineStyle.None, view.BorderStyle);
+			Assert.Equal (Thickness.Empty, view.BorderFrame.Thickness);
 		}
 
-//		[Fact, AutoInitShutdown]
-//		public void BorderStyle_And_DrawMarginFrame_Gets_Sets ()
-//		{
-//			var lblTop = new Label ("At 0,0");
-//			var lblFrame = new Label ("Centered") { X = Pos.Center (), Y = Pos.Center () };
-//			var frame = new FrameView () { Y = 1, Width = 20, Height = 3 };
-//			var lblFill = new Label () { Width = Dim.Fill(),Height = Dim.Fill(), Visible = false };
-//			var fillText = new System.Text.StringBuilder ();
-//			for (int i = 0; i < frame.Bounds.Height; i++) {
-//				if (i > 0) {
-//					fillText.AppendLine ("");
-//				}
-//				for (int j = 0; j < frame.Bounds.Width; j++) {
-//					fillText.Append ("█");
-//				}
-//			}
-//			lblFill.Text = fillText.ToString ();
-//			frame.Add (lblFill, lblFrame);
-//			var lblBottom = new Label ("At 0,4") { Y = 4 };
-//			Application.Top.Add (lblTop, frame, lblBottom);
-//			Application.Begin (Application.Top);
-
-//			Assert.Equal (BorderStyle.Single, frame.Border.BorderStyle);
-//			Assert.True (frame.Border.DrawMarginFrame);
-//			TestHelpers.AssertDriverContentsWithFrameAre (@"
-//At 0,0              
-//┌──────────────────┐
-//│     Centered     │
-//└──────────────────┘
-//At 0,4              ", output);
-
-//			frame.Border.BorderStyle = BorderStyle.None;
-//			Application.Refresh ();
-//			Assert.True (frame.Border.DrawMarginFrame);
-//			TestHelpers.AssertDriverContentsWithFrameAre (@"
-//At 0,0        
-              
-//      Centered
-              
-//At 0,4        ", output);
-
-////			frame.Border.DrawMarginFrame = false;
-////			lblFill.Visible = true;
-////			Application.Refresh ();
-////			TestHelpers.AssertDriverContentsWithFrameAre (@"
-////At 0,0              
-////████████████████████
-////██████Centered██████
-////████████████████████
-////At 0,4              ", output);
+		//[Fact]
+		//public void View_BorderStyleChanged ()
+		//{
 		//}
 	}
 }

+ 340 - 0
UnitTests/View/DrawTests.cs

@@ -0,0 +1,340 @@
+using NStack;
+using System;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Terminal.Gui.ViewsTests {
+	public class DrawTests {
+		readonly ITestOutputHelper output;
+
+		public DrawTests (ITestOutputHelper output)
+		{
+			this.output = output;
+		}
+		
+		// TODO: The tests below that use Label should use View instead.
+		[Fact, AutoInitShutdown]
+		public void Non_Bmp_ConsoleWidth_ColumnWidth_Equal_Two ()
+		{
+			ustring us = "\U0001d539";
+			Rune r = 0x1d539;
+
+			Assert.Equal ("𝔹", us);
+			Assert.Equal ("𝔹", r.ToString ());
+			Assert.Equal (us, r.ToString ());
+
+			Assert.Equal (2, us.ConsoleWidth);
+			Assert.Equal (2, Rune.ColumnWidth (r));
+
+			var win = new Window () { Title = us };
+			var label = new Label (ustring.Make (r));
+			var tf = new TextField (us) { Y = 1, Width = 3 };
+			win.Add (label, tf);
+			var top = Application.Top;
+			top.Add (win);
+
+			Application.Begin (top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			var expected = @"
+┌┤𝔹├────┐
+│𝔹      │
+│𝔹      │
+└────────┘";
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+
+			TestHelpers.AssertDriverContentsAre (expected, output);
+
+			var expectedColors = new Attribute [] {
+				// 0
+				Colors.Base.Normal,
+				// 1
+				Colors.Base.Focus,
+				// 2
+				Colors.Base.HotNormal
+			};
+
+			TestHelpers.AssertDriverColorsAre (@"
+0022000000
+0000000000
+0111000000
+0000000000", expectedColors);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void CJK_Compatibility_Ideographs_ConsoleWidth_ColumnWidth_Equal_Two ()
+		{
+			ustring us = "\U0000f900";
+			Rune r = 0xf900;
+
+			Assert.Equal ("豈", us);
+			Assert.Equal ("豈", r.ToString ());
+			Assert.Equal (us, r.ToString ());
+
+			Assert.Equal (2, us.ConsoleWidth);
+			Assert.Equal (2, Rune.ColumnWidth (r));
+
+			var win = new Window () { Title = us };
+			var label = new Label (ustring.Make (r));
+			var tf = new TextField (us) { Y = 1, Width = 3 };
+			win.Add (label, tf);
+			var top = Application.Top;
+			top.Add (win);
+
+			Application.Begin (top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			var expected = @"
+┌┤豈├────┐
+│豈      │
+│豈      │
+└────────┘";
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+
+			TestHelpers.AssertDriverContentsAre (expected, output);
+
+			var expectedColors = new Attribute [] {
+				// 0
+				Colors.Base.Normal,
+				// 1
+				Colors.Base.Focus,
+				// 2
+				Colors.Base.HotNormal
+			};
+
+			TestHelpers.AssertDriverColorsAre (@"
+0022000000
+0000000000
+0111000000
+0000000000", expectedColors);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Colors_On_TextAlignment_Right_And_Bottom ()
+		{
+			var labelRight = new Label ("Test") {
+				Width = 6,
+				Height = 1,
+				TextAlignment = TextAlignment.Right,
+				ColorScheme = Colors.Base
+			};
+			var labelBottom = new Label ("Test", TextDirection.TopBottom_LeftRight) {
+				Y = 1,
+				Width = 1,
+				Height = 6,
+				VerticalTextAlignment = VerticalTextAlignment.Bottom,
+				ColorScheme = Colors.Base
+			};
+			var top = Application.Top;
+			top.Add (labelRight, labelBottom);
+
+			Application.Begin (top);
+			((FakeDriver)Application.Driver).SetBufferSize (7, 7);
+
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+  Test
+      
+      
+T     
+e     
+s     
+t     ", output);
+
+			TestHelpers.AssertDriverColorsAre (@"
+000000
+0
+0
+0
+0
+0
+0", new Attribute [] { Colors.Base.Normal });
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Draw_Negative_Bounds_Horizontal_Without_New_Lines ()
+		{
+			// BUGBUG: This previously assumed the default height of a View was 1. 
+			var subView = new View () { Id = "subView", Y = 1, Width = 7, Height = 1, Text = "subView" };
+			var view = new View () { Id = "view", Width = 20, Height = 2, Text = "01234567890123456789" };
+			view.Add (subView);
+			var content = new View () { Id = "content", Width = 20, Height = 20 };
+			content.Add (view);
+			var container = new View () { Id = "container", X = 1, Y = 1, Width = 5, Height = 5 };
+			container.Add (content);
+			var top = Application.Top;
+			top.Add (container);
+			// BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
+
+			void Top_LayoutComplete (object sender, LayoutEventArgs e)
+			{
+				Application.Driver.Clip = container.Frame;
+			}
+			top.LayoutComplete += Top_LayoutComplete;
+			Application.Begin (top);
+
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 01234
+ subVi", output);
+
+			content.X = -1;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 12345
+ ubVie", output);
+
+			content.Y = -1;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ ubVie", output);
+
+			content.Y = -2;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
+
+			content.X = -20;
+			content.Y = 0;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
+		}
+
+
+		[Fact, AutoInitShutdown]
+		public void Draw_Negative_Bounds_Horizontal_With_New_Lines ()
+		{
+			var subView = new View () { Id = "subView", X = 1, Width = 1, Height = 7, Text = "s\nu\nb\nV\ni\ne\nw" };
+			var view = new View () { Id = "view", Width = 2, Height = 20, Text = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9" };
+			view.Add (subView);
+			var content = new View () { Id = "content", Width = 20, Height = 20 };
+			content.Add (view);
+			var container = new View () { Id = "container", X = 1, Y = 1, Width = 5, Height = 5 };
+			container.Add (content);
+			var top = Application.Top;
+			top.Add (container);
+			Application.Driver.Clip = container.Frame;
+			Application.Begin (top);
+
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 0s
+ 1u
+ 2b
+ 3V
+ 4i", output);
+
+			content.X = -1;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ s
+ u
+ b
+ V
+ i", output);
+
+			content.X = -2;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
+
+			content.X = 0;
+			content.Y = -1;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 1u
+ 2b
+ 3V
+ 4i
+ 5e", output);
+
+			content.Y = -6;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 6w
+ 7 
+ 8 
+ 9 
+ 0 ", output);
+
+			content.Y = -19;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 9", output);
+
+			content.Y = -20;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
+
+			content.X = -2;
+			content.Y = 0;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Draw_Negative_Bounds_Vertical ()
+		{
+			var subView = new View () { Id = "subView", X = 1, Width = 1, Height = 7, Text = "subView", TextDirection = TextDirection.TopBottom_LeftRight };
+			var view = new View () { Id = "view", Width = 2, Height = 20, Text = "01234567890123456789", TextDirection = TextDirection.TopBottom_LeftRight };
+			view.Add (subView);
+			var content = new View () { Id = "content", Width = 20, Height = 20 };
+			content.Add (view);
+			var container = new View () { Id = "container", X = 1, Y = 1, Width = 5, Height = 5 };
+			container.Add (content);
+			var top = Application.Top;
+			top.Add (container);
+			Application.Driver.Clip = container.Frame;
+			Application.Begin (top);
+
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 0s
+ 1u
+ 2b
+ 3V
+ 4i", output);
+
+			content.X = -1;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ s
+ u
+ b
+ V
+ i", output);
+
+			content.X = -2;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
+
+			content.X = 0;
+			content.Y = -1;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 1u
+ 2b
+ 3V
+ 4i
+ 5e", output);
+
+			content.Y = -6;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 6w
+ 7 
+ 8 
+ 9 
+ 0 ", output);
+
+			content.Y = -19;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ 9", output);
+
+			content.Y = -20;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
+
+			content.X = -2;
+			content.Y = 0;
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre ("", output);
+		}
+	}
+}
+

+ 29 - 2
UnitTests/View/FrameTests.cs

@@ -18,6 +18,31 @@ namespace Terminal.Gui.ViewTests {
 			this.output = output;
 		}
 
+		[Fact]
+		public void GetFramesThickness ()
+		{
+			var view = new View ();
+			Assert.Equal (Thickness.Empty, view.GetFramesThickness ());
+
+			view.Margin.Thickness = new Thickness (1);
+			Assert.Equal (new Thickness (1), view.GetFramesThickness ());
+
+			view.BorderFrame.Thickness = new Thickness (1);
+			Assert.Equal (new Thickness (2), view.GetFramesThickness ());
+
+			view.Padding.Thickness = new Thickness (1);
+			Assert.Equal (new Thickness (3), view.GetFramesThickness ());
+
+			view.Padding.Thickness = new Thickness (2);
+			Assert.Equal (new Thickness (4), view.GetFramesThickness ());
+
+			view.Padding.Thickness = new Thickness (1, 2, 3, 4);
+			Assert.Equal (new Thickness (3, 4, 5, 6), view.GetFramesThickness ());
+
+			view.Margin.Thickness = new Thickness (1, 2, 3, 4);
+			Assert.Equal (new Thickness (3, 5, 7, 9), view.GetFramesThickness ());
+		}
+
 		[Theory, AutoInitShutdown]
 		[InlineData (0)]
 		[InlineData (1)]
@@ -25,7 +50,8 @@ namespace Terminal.Gui.ViewTests {
 		[InlineData (3)]
 		public void BorderFrame_With_Title_Size_Height (int height)
 		{
-			var win = new Window ("1234") {
+			var win = new Window () { 
+				Title = "1234",
 				Width = Dim.Fill (),
 				Height = Dim.Fill ()
 			};
@@ -82,7 +108,8 @@ namespace Terminal.Gui.ViewTests {
 		[InlineData (10)]
 		public void BorderFrame_With_Title_Size_Width (int width)
 		{
-			var win = new Window ("1234") {
+			var win = new Window () {
+				Title = "1234",
 				Width = Dim.Fill (),
 				Height = Dim.Fill ()
 			};

+ 838 - 0
UnitTests/View/Layout/AutoSizeTests.cs

@@ -0,0 +1,838 @@
+using NStack;
+using System;
+using System.Collections.Generic;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Terminal.Gui.ViewTests {
+	public class AutoSizeTests {
+		readonly ITestOutputHelper output;
+
+		public AutoSizeTests (ITestOutputHelper output)
+		{
+			this.output = output;
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_GetAutoSize_Horizontal ()
+		{
+			var text = "text";
+			var view = new View () {
+				Text = text,
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			var size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 1), size);
+
+			view.Text = $"{text}\n{text}";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 2), size);
+
+			view.Text = $"{text}\n{text}\n{text}+";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length + 1, 3), size);
+
+			text = string.Empty;
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (0, 0), size);
+
+			text = "1";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (1, 1), size);
+
+			text = "界";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (2, 1), size);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_GetAutoSize_Vertical()
+		{
+			var text = "text";
+			var view = new View () {
+				Text = text,
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			var size = view.GetAutoSize ();
+			Assert.Equal (new Size (1, text.Length), size);
+
+			view.Text = $"{text}\n{text}";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (2, text.Length), size);
+
+			view.Text = $"{text}\n{text}\n{text}+";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (3, text.Length + 1), size);
+
+			text = string.Empty;
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (0, 0), size);
+
+			text = "1";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (1, 1), size);
+
+			text = "界";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (2, 1), size);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_GetAutoSize_Left()
+		{
+			var text = "This is some text.";
+			var view = new View () {
+				Text = text,
+				TextAlignment = TextAlignment.Left,
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			var size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 1), size);
+
+			view.Text = $"{text}\n{text}";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 2), size);
+
+			view.Text = $"{text}\n{text}\n{text}+";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length + 1, 3), size);
+
+			text = string.Empty;
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (0, 0), size);
+
+			text = "1";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (1, 1), size);
+
+			text = "界";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (2, 1), size);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_GetAutoSize_Right ()
+		{
+			var text = "This is some text.";
+			var view = new View () {
+				Text = text,
+				TextAlignment = TextAlignment.Right,
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			var size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 1), size);
+
+			view.Text = $"{text}\n{text}";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 2), size);
+
+			view.Text = $"{text}\n{text}\n{text}+";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length + 1, 3), size);
+
+			text = string.Empty;
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (0, 0), size);
+
+			text = "1";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (1, 1), size);
+
+			text = "界";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (2, 1), size);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_GetAutoSize_Centered ()
+		{
+			var text = "This is some text.";
+			var view = new View () {
+				Text = text,
+				TextAlignment = TextAlignment.Centered,
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			var size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 1), size);
+
+			view.Text = $"{text}\n{text}";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length, 2), size);
+
+			view.Text = $"{text}\n{text}\n{text}+";
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (text.Length + 1, 3), size);
+
+			text = string.Empty;
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (0, 0), size);
+
+			text = "1";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (1, 1), size);
+
+			text = "界";
+			view.Text = text;
+			size = view.GetAutoSize ();
+			Assert.Equal (new Size (2, 1), size);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_False_View_IsEmpty_False_Return_Null_Lines ()
+		{
+			var text = "Views";
+			var view = new View () {
+				Width = Dim.Fill () - text.Length,
+				Height = 1,
+				Text = text
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			Assert.Equal (5, text.Length);
+			Assert.False (view.AutoSize);
+			Assert.Equal (new Rect (0, 0, 3, 1), view.Frame);
+			Assert.Equal (new Size (3, 1), view.TextFormatter.Size);
+			Assert.Equal (new List<ustring> () { "Vie" }, view.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 10, 4), win.Frame);
+			Assert.Equal (new Rect (0, 0, 10, 4), Application.Top.Frame);
+			var expected = @"
+┌────────┐
+│Vie     │
+│        │
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			view.Width = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 0, 1), view.Frame);
+			Assert.Equal (new Size (0, 1), view.TextFormatter.Size);
+			Assert.Equal (new List<ustring> () { ustring.Empty }, view.TextFormatter.Lines);
+			expected = @"
+┌────────┐
+│        │
+│        │
+└────────┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_False_View_IsEmpty_True_Minimum_Height ()
+		{
+			var text = "Views";
+			var view = new View () {
+				Width = Dim.Fill () - text.Length,
+				Text = text
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			Assert.Equal (5, text.Length);
+			Assert.False (view.AutoSize);
+			Assert.Equal (new Rect (0, 0, 3, 1), view.Frame);
+			Assert.Equal (new Size (3, 1), view.TextFormatter.Size);
+			Assert.Single (view.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 10, 4), win.Frame);
+			Assert.Equal (new Rect (0, 0, 10, 4), Application.Top.Frame);
+			var expected = @"
+┌────────┐
+│Vie     │
+│        │
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			view.Width = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 0, 1), view.Frame);
+			Assert.Equal (new Size (0, 1), view.TextFormatter.Size);
+			var exception = Record.Exception (() => Assert.Equal (new List<ustring> () { ustring.Empty }, view.TextFormatter.Lines));
+			Assert.Null (exception);
+			expected = @"
+┌────────┐
+│        │
+│        │
+└────────┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_True_Label_IsEmpty_False_Never_Return_Null_Lines ()
+		{
+			var text = "Label";
+			var label = new Label () {
+				Width = Dim.Fill () - text.Length,
+				Height = 1,
+				Text = text
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			Assert.Equal (5, text.Length);
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 5, 1), label.Frame);
+			Assert.Equal (new Size (5, 1), label.TextFormatter.Size);
+			Assert.Equal (new List<ustring> () { "Label" }, label.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 10, 4), win.Frame);
+			Assert.Equal (new Rect (0, 0, 10, 4), Application.Top.Frame);
+			var expected = @"
+┌────────┐
+│Label   │
+│        │
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			label.Width = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 5, 1), label.Frame);
+			Assert.Equal (new Size (5, 1), label.TextFormatter.Size);
+			Assert.Single (label.TextFormatter.Lines);
+			expected = @"
+┌────────┐
+│Label   │
+│        │
+└────────┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_False_Label_IsEmpty_True_Return_Null_Lines ()
+		{
+			var text = "Label";
+			var label = new Label () {
+				Width = Dim.Fill () - text.Length,
+				Height = 1,
+				Text = text,
+				AutoSize = false
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			Assert.Equal (5, text.Length);
+			Assert.False (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 3, 1), label.Frame);
+			Assert.Equal (new Size (3, 1), label.TextFormatter.Size);
+			Assert.Equal (new List<ustring> () { "Lab" }, label.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 10, 4), win.Frame);
+			Assert.Equal (new Rect (0, 0, 10, 4), Application.Top.Frame);
+			var expected = @"
+┌────────┐
+│Lab     │
+│        │
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			label.Width = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.False (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 0, 1), label.Frame);
+			Assert.Equal (new Size (0, 1), label.TextFormatter.Size);
+			Assert.Equal (new List<ustring> { ustring.Empty }, label.TextFormatter.Lines);
+			expected = @"
+┌────────┐
+│        │
+│        │
+└────────┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_True_Label_IsEmpty_False_Minimum_Height ()
+		{
+			var text = "Label";
+			var label = new Label () {
+				Width = Dim.Fill () - text.Length,
+				Text = text
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			Assert.Equal (5, text.Length);
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 5, 1), label.Frame);
+			Assert.Equal (new Size (5, 1), label.TextFormatter.Size);
+			Assert.Equal (new List<ustring> () { "Label" }, label.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 10, 4), win.Frame);
+			Assert.Equal (new Rect (0, 0, 10, 4), Application.Top.Frame);
+			var expected = @"
+┌────────┐
+│Label   │
+│        │
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			label.Width = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 5, 1), label.Frame);
+			Assert.Equal (new Size (5, 1), label.TextFormatter.Size);
+			var exception = Record.Exception (() => Assert.Single (label.TextFormatter.Lines));
+			Assert.Null (exception);
+			expected = @"
+┌────────┐
+│Label   │
+│        │
+└────────┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_False_Label_Height_Zero_Returns_Minimum_Height ()
+		{
+			var text = "Label";
+			var label = new Label () {
+				Width = Dim.Fill () - text.Length,
+				Text = text,
+				AutoSize = false
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (10, 4);
+
+			Assert.Equal (5, text.Length);
+			Assert.False (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 3, 1), label.Frame);
+			Assert.Equal (new Size (3, 1), label.TextFormatter.Size);
+			Assert.Single (label.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 10, 4), win.Frame);
+			Assert.Equal (new Rect (0, 0, 10, 4), Application.Top.Frame);
+			var expected = @"
+┌────────┐
+│Lab     │
+│        │
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			label.Width = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 0, 1), label.Frame);
+			Assert.Equal (new Size (0, 1), label.TextFormatter.Size);
+			var exception = Record.Exception (() => Assert.Equal (new List<ustring> () { ustring.Empty }, label.TextFormatter.Lines));
+			Assert.Null (exception);
+			expected = @"
+┌────────┐
+│        │
+│        │
+└────────┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 10, 4), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_True_View_IsEmpty_False_Minimum_Width ()
+		{
+			var text = "Views";
+			var view = new View () {
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				Height = Dim.Fill () - text.Length,
+				Text = text,
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (4, 10);
+
+			Assert.Equal (5, text.Length);
+			Assert.True (view.AutoSize);
+			Assert.Equal (new Rect (0, 0, 1, 5), view.Frame);
+			Assert.Equal (new Size (1, 5), view.TextFormatter.Size);
+			Assert.Equal (new List<ustring> () { "Views" }, view.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 4, 10), win.Frame);
+			Assert.Equal (new Rect (0, 0, 4, 10), Application.Top.Frame);
+			var expected = @"
+┌──┐
+│V │
+│i │
+│e │
+│w │
+│s │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			view.Height = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 1, 5), view.Frame);
+			Assert.Equal (new Size (1, 5), view.TextFormatter.Size);
+			var exception = Record.Exception (() => Assert.Single (view.TextFormatter.Lines));
+			Assert.Null (exception);
+			expected = @"
+┌──┐
+│V │
+│i │
+│e │
+│w │
+│s │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_False_View_Width_Null_Returns_Host_Frame_Width ()
+		{
+			var text = "Views";
+			var view = new View () {
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				Height = Dim.Fill () - text.Length,
+				Text = text
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (4, 10);
+
+			Assert.Equal (5, text.Length);
+			Assert.False (view.AutoSize);
+			Assert.Equal (new Rect (0, 0, 1, 3), view.Frame);
+			Assert.Equal (new Size (1, 3), view.TextFormatter.Size);
+			Assert.Single (view.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 4, 10), win.Frame);
+			Assert.Equal (new Rect (0, 0, 4, 10), Application.Top.Frame);
+			var expected = @"
+┌──┐
+│V │
+│i │
+│e │
+│  │
+│  │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			view.Height = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 1, 0), view.Frame);
+			Assert.Equal (new Size (1, 0), view.TextFormatter.Size);
+			var exception = Record.Exception (() => Assert.Equal (new List<ustring> () { ustring.Empty }, view.TextFormatter.Lines));
+			Assert.Null (exception);
+			expected = @"
+┌──┐
+│  │
+│  │
+│  │
+│  │
+│  │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_True_View_IsEmpty_False_Minimum_Width_Wide_Rune ()
+		{
+			var text = "界View";
+			var view = new View () {
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				Height = Dim.Fill () - text.Length,
+				Text = text,
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (4, 10);
+
+			Assert.Equal (5, text.Length);
+			Assert.True (view.AutoSize);
+			Assert.Equal (new Rect (0, 0, 2, 5), view.Frame);
+			Assert.Equal (new Size (2, 5), view.TextFormatter.Size);
+			Assert.Equal (new List<ustring> () { "界View" }, view.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 4, 10), win.Frame);
+			Assert.Equal (new Rect (0, 0, 4, 10), Application.Top.Frame);
+			var expected = @"
+┌──┐
+│界│
+│V │
+│i │
+│e │
+│w │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			view.Height = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 2, 5), view.Frame);
+			Assert.Equal (new Size (2, 5), view.TextFormatter.Size);
+			var exception = Record.Exception (() => Assert.Equal (new List<ustring> () { "界View" }, view.TextFormatter.Lines));
+			Assert.Null (exception);
+			expected = @"
+┌──┐
+│界│
+│V │
+│i │
+│e │
+│w │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_False_View_Width_Zero_Returns_Minimum_Width_With_Wide_Rune ()
+		{
+			var text = "界View";
+			var view = new View () {
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				Height = Dim.Fill () - text.Length,
+				Text = text
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (view);
+			Application.Top.Add (win);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (4, 10);
+
+			Assert.Equal (5, text.Length);
+			Assert.False (view.AutoSize);
+			Assert.Equal (new Rect (0, 0, 2, 3), view.Frame);
+			Assert.Equal (new Size (2, 3), view.TextFormatter.Size);
+			Assert.Single (view.TextFormatter.Lines);
+			Assert.Equal (new Rect (0, 0, 4, 10), win.Frame);
+			Assert.Equal (new Rect (0, 0, 4, 10), Application.Top.Frame);
+			var expected = @"
+┌──┐
+│界│
+│V │
+│i │
+│  │
+│  │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+
+			text = "0123456789";
+			Assert.Equal (10, text.Length);
+			view.Height = Dim.Fill () - text.Length;
+			Application.Refresh ();
+
+			Assert.Equal (new Rect (0, 0, 2, 0), view.Frame);
+			Assert.Equal (new Size (2, 0), view.TextFormatter.Size);
+			var exception = Record.Exception (() => Assert.Equal (new List<ustring> () { ustring.Empty }, view.TextFormatter.Lines));
+			Assert.Null (exception);
+			expected = @"
+┌──┐
+│  │
+│  │
+│  │
+│  │
+│  │
+│  │
+│  │
+│  │
+└──┘
+";
+
+			pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 4, 10), pos);
+		}
+	}
+}

+ 18 - 18
UnitTests/View/Layout/DimTests.cs

@@ -259,7 +259,7 @@ namespace Terminal.Gui.ViewTests {
 		{
 			var t = Application.Top;
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				Width = Dim.Fill (0),
 				Height = Dim.Sized (10)
 			};
@@ -296,7 +296,7 @@ namespace Terminal.Gui.ViewTests {
 		{
 			var t = new View ("top") { Width = 80, Height = 25 };
 
-			var w = new Window (new Rect (1, 2, 4, 5), "w");
+			var w = new Window (new Rect (1, 2, 4, 5)) { Title = "w" };
 			t.Add (w);
 			t.LayoutSubviews ();
 
@@ -310,7 +310,7 @@ namespace Terminal.Gui.ViewTests {
 		{
 			var t = new View ("top") { Width = 80, Height = 25 };
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				Width = Dim.Fill (0),
 				Height = Dim.Sized (10)
 			};
@@ -339,7 +339,7 @@ namespace Terminal.Gui.ViewTests {
 			// Testing with the Button because it properly handles the Dim class.
 			var t = Application.Top;
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				Width = 100,
 				Height = 100
 			};
@@ -550,18 +550,18 @@ namespace Terminal.Gui.ViewTests {
 		[Fact]
 		public void DimCombine_ObtuseScenario_Throw_If_SuperView_Refs_SubView ()
 		{
-			var t = new View ("top") { Width = 80, Height = 25 };
+			var t = new View () { Width = 80, Height = 25 };
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				Width = Dim.Width (t) - 2,    // 78
 				Height = Dim.Height (t) - 2   // 23
 			};
-			var f = new FrameView ("f");
-			var v1 = new View ("v1") {
+			var f = new FrameView ();
+			var v1 = new View () {
 				Width = Dim.Width (w) - 2,    // 76
 				Height = Dim.Height (w) - 2   // 21
 			};
-			var v2 = new View ("v2") {
+			var v2 = new View () {
 				Width = Dim.Width (v1) - 2,   // 74
 				Height = Dim.Height (v1) - 2  // 19
 			};
@@ -594,16 +594,16 @@ namespace Terminal.Gui.ViewTests {
 		{
 			var t = new View ("top") { Width = 80, Height = 25 };
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				Width = Dim.Width (t) - 2,    // 78
 				Height = Dim.Height (t) - 2   // 23
 			};
-			var f = new FrameView ("f");
-			var v1 = new View ("v1") {
+			var f = new FrameView ();
+			var v1 = new View () {
 				Width = Dim.Width (w) - 2,    // 76
 				Height = Dim.Height (w) - 2   // 21
 			};
-			var v2 = new View ("v2") {
+			var v2 = new View () {
 				Width = Dim.Width (v1) - 2,   // 74
 				Height = Dim.Height (v1) - 2  // 19
 			};
@@ -633,23 +633,23 @@ namespace Terminal.Gui.ViewTests {
 		[Fact]
 		public void PosCombine_View_Not_Added_Throws ()
 		{
-			var t = new View ("t") { Width = 80, Height = 50 };
+			var t = new View () { Width = 80, Height = 50 };
 
 			// BUGBUG: v2 - super should not reference it's superview (t)
-			var super = new View ("super") {
+			var super = new View () {
 				Width = Dim.Width (t) - 2,
 				Height = Dim.Height (t) - 2
 			};
 			t.Add (super);
 
-			var sub = new View ("sub");
+			var sub = new View ();
 			super.Add (sub);
 
-			var v1 = new View ("v1") {
+			var v1 = new View () {
 				Width = Dim.Width (super) - 2,
 				Height = Dim.Height (super) - 2
 			};
-			var v2 = new View ("v2") {
+			var v2 = new View () {
 				Width = Dim.Width (v1) - 2,
 				Height = Dim.Height (v1) - 2
 			};

+ 63 - 8
UnitTests/View/Layout/LayoutTests.cs

@@ -1,10 +1,6 @@
-using NStack;
-using System;
-using System.Collections.Generic;
-using System.Xml.Linq;
+using System;
 using Xunit;
 using Xunit.Abstractions;
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
 
 // Alias Console to MockConsole so we don't accidentally use Console
 using Console = Terminal.Gui.FakeConsole;
@@ -325,7 +321,7 @@ namespace Terminal.Gui.ViewTests {
 		[Fact, AutoInitShutdown]
 		public void AutoSize_False_ResizeView_With_Dim_Fill_After_IsInitialized ()
 		{
-			var win = new Window (new Rect (0, 0, 30, 80), "");
+			var win = new Window (new Rect (0, 0, 30, 80));
 			var label = new Label () { AutoSize = false, Width = Dim.Fill (), Height = Dim.Fill () };
 			win.Add (label);
 			Application.Top.Add (win);
@@ -350,7 +346,7 @@ namespace Terminal.Gui.ViewTests {
 		[Fact, AutoInitShutdown]
 		public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_After_IsAdded_And_IsInitialized ()
 		{
-			var win = new Window (new Rect (0, 0, 30, 80), "win");
+			var win = new Window (new Rect (0, 0, 30, 80));
 			var label = new Label () { Width = Dim.Fill () };
 			win.Add (label);
 			Application.Top.Add (win);
@@ -386,7 +382,7 @@ namespace Terminal.Gui.ViewTests {
 		[Fact, AutoInitShutdown]
 		public void AutoSize_False_SetWidthHeight_With_Dim_Fill_And_Dim_Absolute_With_Initialization ()
 		{
-			var win = new Window (new Rect (0, 0, 30, 80), "");
+			var win = new Window (new Rect (0, 0, 30, 80));
 			var label = new Label () { Width = Dim.Fill () };
 			win.Add (label);
 			Application.Top.Add (win);
@@ -1859,5 +1855,64 @@ Y
 
 			Application.End (rs);
 		}
+
+
+		[Fact]
+		public void Draw_Vertical_Throws_IndexOutOfRangeException_With_Negative_Bounds ()
+		{
+			Application.Init (new FakeDriver ());
+
+			var top = Application.Top;
+
+			var view = new View ("view") {
+				Y = -2,
+				Height = 10,
+				TextDirection = TextDirection.TopBottom_LeftRight
+			};
+			top.Add (view);
+
+			Application.Iteration += () => {
+				Assert.Equal (-2, view.Y);
+
+				Application.RequestStop ();
+			};
+
+			try {
+				Application.Run ();
+			} catch (IndexOutOfRangeException ex) {
+				// After the fix this exception will not be caught.
+				Assert.IsType<IndexOutOfRangeException> (ex);
+			}
+
+			// Shutdown must be called to safely clean up Application if Init has been called
+			Application.Shutdown ();
+		}
+
+		[Fact]
+		public void Draw_Throws_IndexOutOfRangeException_With_Negative_Bounds ()
+		{
+			Application.Init (new FakeDriver ());
+
+			var top = Application.Top;
+
+			var view = new View ("view") { X = -2 };
+			top.Add (view);
+
+			Application.Iteration += () => {
+				Assert.Equal (-2, view.X);
+
+				Application.RequestStop ();
+			};
+
+			try {
+				Application.Run ();
+			} catch (IndexOutOfRangeException ex) {
+				// After the fix this exception will not be caught.
+				Assert.IsType<IndexOutOfRangeException> (ex);
+			}
+
+			// Shutdown must be called to safely clean up Application if Init has been called
+			Application.Shutdown ();
+		}
 	}
 }

+ 14 - 14
UnitTests/View/Layout/PosTests.cs

@@ -531,7 +531,7 @@ namespace Terminal.Gui.ViewTests {
 				Application.Iteration = () => {
 					Application.RequestStop ();
 				};
-				var win = new Window ("window") {
+				var win = new Window () {
 					X = 0,
 					Y = 0,
 					Width = Dim.Fill (),
@@ -676,11 +676,11 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				X = Pos.Left (t) + 2,
 				Y = Pos.At (2)
 			};
-			var v = new View ("v") {
+			var v = new View () {
 				X = Pos.Center (),
 				Y = Pos.Percent (10),
 				ForceValidatePosDim = true
@@ -709,7 +709,7 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window (new Rect (1, 2, 4, 5), "w");
+			var w = new Window (new Rect (1, 2, 4, 5));
 			t.Add (w);
 
 			t.Ready += (s, e) => {
@@ -731,11 +731,11 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				X = Pos.Left (t) + 2,
 				Y = Pos.At (2)
 			};
-			var v = new View ("v") {
+			var v = new View () {
 				X = Pos.Center (),
 				Y = Pos.Percent (10)
 			};
@@ -763,16 +763,16 @@ namespace Terminal.Gui.ViewTests {
 		//{
 		//	Application.Init (new FakeDriver ());
 
-		//	var w = new Window ("w") {
+		//	var w = new Window () {
 		//		X = Pos.Left (Application.Top) + 2,
 		//		Y = Pos.Top (Application.Top) + 2
 		//	};
-		//	var f = new FrameView ("f");
-		//	var v1 = new View ("v1") {
+		//	var f = new FrameView ();
+		//	var v1 = new View () {
 		//		X = Pos.Left (w) + 2,
 		//		Y = Pos.Top (w) + 2
 		//	};
-		//	var v2 = new View ("v2") {
+		//	var v2 = new View () {
 		//		X = Pos.Left (v1) + 2,
 		//		Y = Pos.Top (v1) + 2
 		//	};
@@ -810,16 +810,16 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window ("w") {
+			var w = new Window () {
 				X = Pos.Left (t) + 2,
 				Y = Pos.Top (t) + 2
 			};
-			var f = new FrameView ("f");
-			var v1 = new View ("v1") {
+			var f = new FrameView ();
+			var v1 = new View () {
 				X = Pos.Left (w) + 2,
 				Y = Pos.Top (w) + 2
 			};
-			var v2 = new View ("v2") {
+			var v2 = new View () {
 				X = Pos.Left (v1) + 2,
 				Y = Pos.Top (v1) + 2
 			};

+ 14 - 14
UnitTests/View/NavigationTests.cs

@@ -472,9 +472,9 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window ("w");
-			var f = new FrameView ("f");
-			var v = new View ("v") { CanFocus = true };
+			var w = new Window ();
+			var f = new FrameView ();
+			var v = new View () { CanFocus = true };
 			f.Add (v);
 			w.Add (f);
 			t.Add (w);
@@ -509,9 +509,9 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window ("w");
-			var f = new FrameView ("f");
-			var v = new View ("v") { CanFocus = true };
+			var w = new Window ();
+			var f = new FrameView ();
+			var v = new View () { CanFocus = true };
 			f.Add (v);
 			w.Add (f);
 			t.Add (w);
@@ -552,10 +552,10 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window ("w");
-			var f = new FrameView ("f");
-			var v1 = new View ("v1") { CanFocus = true };
-			var v2 = new View ("v2") { CanFocus = true };
+			var w = new Window ();
+			var f = new FrameView ();
+			var v1 = new View () { CanFocus = true };
+			var v2 = new View () { CanFocus = true };
 			f.Add (v1, v2);
 			w.Add (f);
 			t.Add (w);
@@ -587,10 +587,10 @@ namespace Terminal.Gui.ViewTests {
 
 			var t = Application.Top;
 
-			var w = new Window ("w");
-			var f = new FrameView ("f");
-			var v1 = new View ("v1");
-			var v2 = new View ("v2") { CanFocus = true };
+			var w = new Window ();
+			var f = new FrameView ();
+			var v1 = new View ();
+			var v2 = new View () { CanFocus = true };
 			f.Add (v1, v2);
 			w.Add (f);
 			t.Add (w);

+ 8 - 8
UnitTests/View/ViewTests.cs

@@ -567,9 +567,9 @@ namespace Terminal.Gui.ViewTests {
 			//Assert.Equal (new Rect (new Point (0, 0), rect.Size), view._needsDisplay);
 			Assert.True (view.LayoutNeeded);
 			Assert.False (view._childNeedsDisplay);
-			Assert.False (view.addingView);
-			view.addingView = true;
-			Assert.True (view.addingView);
+			Assert.False (view._addingView);
+			view._addingView = true;
+			Assert.True (view._addingView);
 			view.ViewToScreen (0, 0, out int rcol, out int rrow);
 			Assert.Equal (1, rcol);
 			Assert.Equal (1, rrow);
@@ -937,8 +937,8 @@ namespace Terminal.Gui.ViewTests {
 			Assert.True (horizontalView.AutoSize);
 			Assert.Equal (new Rect (0, 0, 12, 1), horizontalView.Frame);
 			Assert.Equal (new Size (12, 1), horizontalView.GetSizeNeededForTextWithoutHotKey ());
-			Assert.Equal (new Size (12, 1), horizontalView.GetSizeNeededForTextAndHotKey ());
-			Assert.Equal (horizontalView.TextFormatter.Size, horizontalView.GetSizeNeededForTextAndHotKey ());
+			//Assert.Equal (new Size (12, 1), horizontalView.GetSizeNeededForTextAndHotKey ());
+			//Assert.Equal (horizontalView.TextFormatter.Size, horizontalView.GetSizeNeededForTextAndHotKey ());
 			Assert.Equal (horizontalView.Frame.Size, horizontalView.GetSizeNeededForTextWithoutHotKey ());
 
 			Assert.True (verticalView.AutoSize);
@@ -946,7 +946,7 @@ namespace Terminal.Gui.ViewTests {
 			//Assert.Equal (new Rect (0, 0, 2, 11), verticalView.Frame);
 			//Assert.Equal (new Size (2, 11), verticalView.GetSizeNeededForTextWithoutHotKey ());
 			//Assert.Equal (new Size (2, 11), verticalView.GetSizeNeededForTextAndHotKey ());
-			Assert.Equal (verticalView.TextFormatter.Size, verticalView.GetSizeNeededForTextAndHotKey ());
+			//Assert.Equal (verticalView.TextFormatter.Size, verticalView.GetSizeNeededForTextAndHotKey ());
 			Assert.Equal (verticalView.Frame.Size, verticalView.GetSizeNeededForTextWithoutHotKey ());
 
 			text = "Say He_llo 你";
@@ -956,8 +956,8 @@ namespace Terminal.Gui.ViewTests {
 			Assert.True (horizontalView.AutoSize);
 			Assert.Equal (new Rect (0, 0, 12, 1), horizontalView.Frame);
 			Assert.Equal (new Size (12, 1), horizontalView.GetSizeNeededForTextWithoutHotKey ());
-			Assert.Equal (new Size (13, 1), horizontalView.GetSizeNeededForTextAndHotKey ());
-			Assert.Equal (horizontalView.TextFormatter.Size, horizontalView.GetSizeNeededForTextAndHotKey ());
+			//Assert.Equal (new Size (13, 1), horizontalView.GetSizeNeededForTextAndHotKey ());
+			//Assert.Equal (horizontalView.TextFormatter.Size, horizontalView.GetSizeNeededForTextAndHotKey ());
 			Assert.Equal (horizontalView.Frame.Size, horizontalView.GetSizeNeededForTextWithoutHotKey ());
 
 			Assert.True (verticalView.AutoSize);

+ 10 - 14
UnitTests/Views/ButtonTests.cs

@@ -215,7 +215,7 @@ namespace Terminal.Gui.ViewsTests {
 				X = Pos.Center (),
 				Y = Pos.Center ()
 			};
-			var win = new Window ("Test Demo 你") {
+			var win = new Window () {
 				Width = Dim.Fill (),
 				Height = Dim.Fill ()
 			};
@@ -233,7 +233,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (new Rect (0, 0, 16, 1), btn.Bounds);
 
 			var expected = @"
-┌┤Test Demo 你├──────────────┐
+┌────────────────────────────┐
 │                            │
 │      [ Say Hello 你 ]      │
 │                            │
@@ -255,7 +255,6 @@ namespace Terminal.Gui.ViewsTests {
 			var win = new Window () {
 				Width = Dim.Fill (),
 				Height = Dim.Fill (),
-				Title = "Test Demo 你"
 			};
 			win.Add (btn);
 			Application.Top.Add (win);
@@ -271,7 +270,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (new Rect (0, 0, 16, 1), btn.Bounds);
 
 			var expected = @"
-┌┤Test Demo 你├──────────────┐
+┌────────────────────────────┐
 │                            │
 │      [ Say Hello 你 ]      │
 │                            │
@@ -294,7 +293,6 @@ namespace Terminal.Gui.ViewsTests {
 			var win = new Window () {
 				Width = Dim.Fill (),
 				Height = Dim.Fill (),
-				Title = "Test Demo 你"
 			};
 			win.Add (btn);
 			Application.Top.Add (win);
@@ -308,7 +306,7 @@ namespace Terminal.Gui.ViewsTests {
 			Application.Begin (Application.Top);
 			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 			var expected = @"
-┌┤Test Demo 你├──────────────┐
+┌────────────────────────────┐
 │                            │
 │      [ Say Hello 你 ]      │
 │                            │
@@ -330,7 +328,6 @@ namespace Terminal.Gui.ViewsTests {
 			var win = new Window () {
 				Width = Dim.Fill (),
 				Height = Dim.Fill (),
-				Title = "Test Demo 你"
 			};
 			win.Add (btn);
 			Application.Top.Add (win);
@@ -340,7 +337,7 @@ namespace Terminal.Gui.ViewsTests {
 			Application.Begin (Application.Top);
 			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 			var expected = @"
-┌┤Test Demo 你├──────────────┐
+┌────────────────────────────┐
 │                            │
 │      [ Say Hello 你 ]      │
 │                            │
@@ -354,7 +351,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.True (btn.AutoSize);
 			Application.Refresh ();
 			expected = @"
-┌┤Test Demo 你├──────────────┐
+┌────────────────────────────┐
 │                            │
 │  [ Say Hello 你 changed ]  │
 │                            │
@@ -377,7 +374,6 @@ namespace Terminal.Gui.ViewsTests {
 			var win = new Window () {
 				Width = Dim.Fill (),
 				Height = Dim.Fill (),
-				Title = "Test Demo 你"
 			};
 			win.Add (btn);
 			Application.Top.Add (win);
@@ -387,7 +383,7 @@ namespace Terminal.Gui.ViewsTests {
 			Application.Begin (Application.Top);
 			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 			var expected = @"
-┌┤Test Demo 你├──────────────┐
+┌────────────────────────────┐
 │                            │
 │            [ Say Hello 你 ]│
 │                            │
@@ -401,7 +397,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.True (btn.AutoSize);
 			Application.Refresh ();
 			expected = @"
-┌┤Test Demo 你├──────────────┐
+┌────────────────────────────┐
 │                            │
 │    [ Say Hello 你 changed ]│
 │                            │
@@ -483,7 +479,7 @@ namespace Terminal.Gui.ViewsTests {
 			};
 			tabView.AddTab (new TabView.Tab ("Find", tab), true);
 
-			var win = new Window ("Find") {
+			var win = new Window () {
 				Width = Dim.Fill (),
 				Height = Dim.Fill ()
 			};
@@ -512,7 +508,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (new Rect (0, 3, 12, 1), ckbMatchCase.Frame);
 			Assert.Equal (new Rect (0, 4, 18, 1), ckbMatchWholeWord.Frame);
 			var expected = @"
-┌┤Find├──────────────────────────────────────────────┐
+┌────────────────────────────────────────────────────┐
 │┌────┐                                              │
 ││Find│                                              │
 ││    └─────────────────────────────────────────────┐│

+ 2 - 2
UnitTests/Views/ContextMenuTests.cs

@@ -637,7 +637,7 @@ namespace Terminal.Gui.ViewsTests {
 				Width = 20
 			};
 
-			var win = new Window ("Window");
+			var win = new Window ();
 			win.Add (label, tf);
 
 			var statusBar = new StatusBar (new StatusItem [] {
@@ -658,7 +658,7 @@ namespace Terminal.Gui.ViewsTests {
 			Application.Top.Redraw (Application.Top.Bounds);
 			var expected = @"
  File  Edit                                 
-┌┤Window├──────────────────────────────────┐
+┌──────────────────────────────────────────┐
 │                                          │
 │                                          │
 │                                          │

+ 3 - 4
UnitTests/Views/FrameViewTests.cs

@@ -22,19 +22,19 @@ namespace Terminal.Gui.ViewsTests {
 			var fv = new FrameView ();
 			Assert.Equal (string.Empty, fv.Title);
 			Assert.Equal (string.Empty, fv.Text);
-			Assert.NotNull (fv.Border);
+			Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
 			fv = new FrameView ("Test");
 			Assert.Equal ("Test", fv.Title);
 			Assert.Equal (string.Empty, fv.Text);
-			Assert.NotNull (fv.Border);
+			Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
 			fv = new FrameView (new Rect (1, 2, 10, 20), "Test");
 			Assert.Equal ("Test", fv.Title);
 			Assert.Equal (string.Empty, fv.Text);
-			Assert.NotNull (fv.Border);
 			fv.BeginInit ();
 			fv.EndInit ();
+			Assert.Equal (LineStyle.Single, fv.BorderStyle);
 			Assert.Equal (new Rect (1, 2, 10, 20), fv.Frame);
 		}
 
@@ -45,7 +45,6 @@ namespace Terminal.Gui.ViewsTests {
 			var fv = new FrameView ();
 			Assert.Equal (string.Empty, fv.Title);
 			Assert.Equal (string.Empty, fv.Text);
-			Assert.NotNull (fv.Border);
 			Application.Top.Add (fv);
 			Application.Begin (Application.Top);
 			Assert.Equal (new Rect (0, 0, 0, 0), fv.Frame);

+ 912 - 0
UnitTests/Views/LabelTests.cs

@@ -0,0 +1,912 @@
+using System;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Terminal.Gui.ViewsTests {
+	public class LabelTests {
+		readonly ITestOutputHelper output;
+
+		public LabelTests (ITestOutputHelper output)
+		{
+			this.output = output;
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Constructors_Defaults ()
+		{
+			var label = new Label ();
+			Assert.Equal (string.Empty, label.Text);
+			Application.Top.Add (label);
+			var rs = Application.Begin (Application.Top);
+			
+			Assert.Equal (TextAlignment.Left, label.TextAlignment);
+			Assert.True (label.AutoSize);
+			Assert.False (label.CanFocus);
+			Assert.Equal (new Rect (0, 0, 0, 1), label.Frame);
+			Assert.Equal (Key.Null, label.HotKey);
+			var expected = @"";
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Application.End (rs);
+			
+			label = new Label ("ARGS", true) { Text = "Test" };
+			Assert.True (label.AutoSize);
+			Assert.Equal ("Test", label.Text);
+			Application.Top.Add (label);
+			rs = Application.Begin (Application.Top);
+
+			Assert.Equal ("Test", label.TextFormatter.Text);
+			Assert.Equal (new Rect (0, 0, 4, 1), label.Frame);
+			expected = @"
+Test
+";
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Application.End (rs);
+			
+			label = new Label (3, 4, "Test", true);
+			Assert.Equal ("Test", label.Text);
+			Application.Top.Add (label);
+			rs = Application.Begin (Application.Top);
+
+			Assert.Equal ("Test", label.TextFormatter.Text);
+			Assert.Equal (new Rect (3, 4, 4, 1), label.Frame);
+			expected = @"
+   Test
+";
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+
+			Application.End (rs);
+		}
+
+		[Fact]
+		public void TestAssignTextToLabel ()
+		{
+			View b = new Label () { Text = "heya" };
+			Assert.Equal ("heya", b.Text);
+			Assert.True (b.TextFormatter.Text.Contains ("heya"));
+			b.Text = "heyb";
+			Assert.Equal ("heyb", b.Text);
+			Assert.True (b.TextFormatter.Text.Contains ("heyb"));
+
+			// with cast
+			Assert.Equal ("heyb", ((Label)b).Text);
+		}
+
+
+		[Fact, AutoInitShutdown]
+		public void Update_Only_On_Or_After_Initialize ()
+		{
+			var label = new Label ("Say Hello 你") {
+				X = Pos.Center (),
+				Y = Pos.Center ()
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+
+			Assert.False (label.IsInitialized);
+
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
+
+			Assert.True (label.IsInitialized);
+			Assert.Equal ("Say Hello 你", label.Text);
+			Assert.Equal ("Say Hello 你", label.TextFormatter.Text);
+			Assert.Equal (new Rect (0, 0, 12, 1), label.Bounds);
+
+			var expected = @"
+┌────────────────────────────┐
+│                            │
+│        Say Hello 你        │
+│                            │
+└────────────────────────────┘
+";
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 30, 5), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Update_Parameterless_Only_On_Or_After_Initialize ()
+		{
+			var label = new Label () {
+				X = Pos.Center (),
+				Y = Pos.Center (),
+				Text = "Say Hello 你",
+				AutoSize = true
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill (),
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+
+			Assert.False (label.IsInitialized);
+
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
+
+			Assert.True (label.IsInitialized);
+			Assert.Equal ("Say Hello 你", label.Text);
+			Assert.Equal ("Say Hello 你", label.TextFormatter.Text);
+			Assert.Equal (new Rect (0, 0, 12, 1), label.Bounds);
+
+			var expected = @"
+┌────────────────────────────┐
+│                            │
+│        Say Hello 你        │
+│                            │
+└────────────────────────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 30, 5), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_Stays_True_With_EmptyText ()
+		{
+			var label = new Label () {
+				X = Pos.Center (),
+				Y = Pos.Center (),
+				AutoSize = true
+			};
+
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill (),
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+
+			Assert.True (label.AutoSize);
+
+			label.Text = "Say Hello 你";
+
+			Assert.True (label.AutoSize);
+
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
+			var expected = @"
+┌────────────────────────────┐
+│                            │
+│        Say Hello 你        │
+│                            │
+└────────────────────────────┘
+";
+
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_Stays_True_Center ()
+		{
+			var label = new Label () {
+				X = Pos.Center (),
+				Y = Pos.Center (),
+				Text = "Say Hello 你"
+			};
+
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill (),
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+
+			Assert.True (label.AutoSize);
+
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
+			var expected = @"
+┌────────────────────────────┐
+│                            │
+│        Say Hello 你        │
+│                            │
+└────────────────────────────┘
+";
+
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+
+			Assert.True (label.AutoSize);
+			label.Text = "Say Hello 你 changed";
+			Assert.True (label.AutoSize);
+			Application.Refresh ();
+			expected = @"
+┌────────────────────────────┐
+│                            │
+│    Say Hello 你 changed    │
+│                            │
+└────────────────────────────┘
+";
+
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void AutoSize_Stays_True_AnchorEnd ()
+		{
+			var label = new Label () {
+				Y = Pos.Center (),
+				Text = "Say Hello 你",
+				AutoSize = true
+			};
+			label.X = Pos.AnchorEnd () - Pos.Function (() => TextFormatter.GetTextWidth (label.TextFormatter.Text));
+
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill (),
+			};
+			win.Add (label);
+			Application.Top.Add (win);
+
+			Assert.True (label.AutoSize);
+
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
+			var expected = @"
+┌────────────────────────────┐
+│                            │
+│                Say Hello 你│
+│                            │
+└────────────────────────────┘
+";
+
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+
+			Assert.True (label.AutoSize);
+			label.Text = "Say Hello 你 changed";
+			Assert.True (label.AutoSize);
+			Application.Refresh ();
+			expected = @"
+┌────────────────────────────┐
+│                            │
+│        Say Hello 你 changed│
+│                            │
+└────────────────────────────┘
+";
+
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+		}
+		
+		[Fact, AutoInitShutdown]
+		public void Pos_Center_Layout_AutoSize_True ()
+		{
+			var Label = new Label ("012345678901") {
+				X = Pos.Center (),
+				Y = Pos.Center (),
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (Label);
+			Application.Top.Add (win);
+
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
+			Assert.True (Label.AutoSize);
+			//Assert.Equal (new Rect (5, 1, 18, 1), Label.Frame);
+			var expected = @"
+┌────────────────────────────┐
+│                            │
+│        012345678901        │
+│                            │
+└────────────────────────────┘
+";
+
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Pos_Center_Layout_AutoSize_False ()
+		{                               
+			var Label = new Label ("012345678901") {
+				X = Pos.Center (),
+				Y = Pos.Center (),
+				AutoSize = false,
+				Width = 20,
+				TextAlignment = TextAlignment.Centered
+			};
+			var win = new Window () {
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			win.Add (Label);
+			Application.Top.Add (win);
+
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (30, 5);
+			Assert.False (Label.AutoSize);
+			Assert.Equal (new Rect (4, 1, 20, 1), Label.Frame);
+			var expected = @"
+┌────────────────────────────┐
+│                            │
+│        012345678901        │
+│                            │
+└────────────────────────────┘
+";
+			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+		}
+		
+		//[Fact, AutoInitShutdown]
+		//public void Label_HotKeyChanged_EventFires ()
+		//{
+		//	var label = new Label ("Yar");
+
+		//	object sender = null;
+		//	KeyChangedEventArgs args = null;
+
+		//	label.HotKeyChanged += (s, e) =>{
+		//		sender = s;
+		//		args = e;
+
+		//	};
+			
+		//	label.HotKey = Key.r;
+		//	Assert.Same (label, sender);
+		//	Assert.Equal (Key.Y, args.OldKey);
+		//	Assert.Equal (Key.r, args.NewKey);
+
+		//}
+		
+		[Fact, AutoInitShutdown]
+		public void Label_HotKeyChanged_EventFires_WithNone ()
+		{
+			var label = new Label ();
+
+			object sender = null;
+			KeyChangedEventArgs args = null;
+
+			label.HotKeyChanged += (s, e) => {
+				sender = s;
+				args = e;
+
+			};
+
+			label.HotKey = Key.r;
+			Assert.Same (label, sender);
+			Assert.Equal (Key.Null, args.OldKey);
+			Assert.Equal (Key.r, args.NewKey);
+		}
+
+
+		[Fact, AutoInitShutdown]
+		public void Label_WordWrap_PreserveTrailingSpaces_Horizontal_With_Simple_Runes ()
+		{
+			var text = "A sentence has words.";
+			var width = 3;
+			var height = 8;
+			var wrappedLines = TextFormatter.WordWrapText (text, width, true);
+			var breakLines = "";
+			foreach (var line in wrappedLines) breakLines += $"{line}{Environment.NewLine}";
+			var label = new Label (breakLines) { Width = Dim.Fill (), Height = Dim.Fill () };
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (label);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (width + 2, height + 2);
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, width, height + 1), label.Frame);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), frame.Frame);
+
+			var expected = @"
+┌───┐
+│A  │
+│sen│
+│ten│
+│ce │
+│has│
+│   │
+│wor│
+│ds.│
+└───┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_WordWrap_PreserveTrailingSpaces_Vertical_With_Simple_Runes ()
+		{
+			var text = "A sentence has words.";
+			var width = 8;
+			var height = 3;
+			var wrappedLines = TextFormatter.WordWrapText (text, height, true);
+			var breakLines = "";
+			for (int i = 0; i < wrappedLines.Count; i++) breakLines += $"{wrappedLines [i]}{(i < wrappedLines.Count - 1 ? Environment.NewLine : string.Empty)}";
+			var label = new Label (breakLines) {
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (label);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (width + 2, height + 2);
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, width, height), label.Frame);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), frame.Frame);
+
+			var expected = @"
+┌────────┐
+│Astch wd│
+│ eeea os│
+│ nn s r.│
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_WordWrap_PreserveTrailingSpaces_Horizontal_With_Wide_Runes ()
+		{
+			var text = "文に は言葉 があり ます。";
+			var width = 6;
+			var height = 8;
+			var wrappedLines = TextFormatter.WordWrapText (text, width, true);
+			var breakLines = "";
+			foreach (var line in wrappedLines) breakLines += $"{line}{Environment.NewLine}";
+			var label = new Label (breakLines) { Width = Dim.Fill (), Height = Dim.Fill () };
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (label);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (width + 2, height + 2);
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, width, height), label.Frame);
+			Assert.Equal (new Size (width, height), label.TextFormatter.Size);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), frame.Frame);
+
+			var expected = @"
+┌──────┐
+│文に  │
+│は言葉│
+│ があ │
+│り ま │
+│す。  │
+│      │
+│      │
+│      │
+└──────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_WordWrap_PreserveTrailingSpaces_Vertical_With_Wide_Runes ()
+		{
+			var text = "文に は言葉 があり ます。";
+			var width = 8;
+			var height = 4;
+			var wrappedLines = TextFormatter.WordWrapText (text, width, true);
+			var breakLines = "";
+			for (int i = 0; i < wrappedLines.Count; i++) breakLines += $"{wrappedLines [i]}{(i < wrappedLines.Count - 1 ? Environment.NewLine : string.Empty)}";
+			var label = new Label (breakLines) {
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				Width = Dim.Fill (),
+				Height = Dim.Fill ()
+			};
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (label);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (width + 2, height + 2);
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, width, height), label.Frame);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), frame.Frame);
+
+			var expected = @"
+┌────────┐
+│文言あす│
+│に葉り。│
+│        │
+│はがま  │
+└────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, width + 2, height + 2), pos);
+		}
+
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Horizontal_Simple_TextAlignments_Justified ()
+		{
+			var text = "01234 01234";
+			var width = 20;
+			var lblJust = new Label (text) { Y = 0, Width = width, TextAlignment = TextAlignment.Justified };
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (lblJust);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (width + 2, 3);
+
+			var expected = @"
+┌────────────────────┐
+│01234          01234│
+└────────────────────┘
+";
+			Assert.Equal (new Rect (0, 0, width, 1), lblJust.Frame);
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, width + 2, 3), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Horizontal_Simple_Runes ()
+		{
+			var label = new Label ("Demo Simple Rune");
+			Application.Top.Add (label);
+			Application.Begin (Application.Top);
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 16, 1), label.Frame);
+
+			var expected = @"
+Demo Simple Rune
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 16, 1), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Vertical_Simple_Runes ()
+		{
+			var label = new Label ("Demo Simple Rune") {
+				TextDirection = TextDirection.TopBottom_LeftRight
+			};
+			Application.Top.Add (label);
+			Application.Begin (Application.Top);
+
+			Assert.NotNull (label.Width);
+			Assert.NotNull (label.Height);
+
+			var expected = @"
+D
+e
+m
+o
+ 
+S
+i
+m
+p
+l
+e
+ 
+R
+u
+n
+e
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 1, 16), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Horizontal_Wide_Runes ()
+		{
+			var label = new Label ("デモエムポンズ");
+			Application.Top.Add (label);
+			Application.Begin (Application.Top);
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 14, 1), label.Frame);
+
+			var expected = @"
+デモエムポンズ
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 14, 1), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Vertical_Wide_Runes ()
+		{
+			var label = new Label ("デモエムポンズ") {
+				TextDirection = TextDirection.TopBottom_LeftRight
+			};
+			Application.Top.Add (label);
+			Application.Begin (Application.Top);
+
+			var expected = @"
+デ
+モ
+エ
+ム
+ポ
+ン
+ズ
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 2, 7), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Vertical_Wide_Runes_With_ForceValidatePosDim ()
+		{
+			var label = new Label ("デモエムポンズ") {
+				Width = Dim.Fill (),
+				Height = Dim.Percent (50f),
+				TextDirection = TextDirection.TopBottom_LeftRight,
+				ForceValidatePosDim = true
+			};
+			Application.Top.Add (label);
+			Application.Begin (Application.Top);
+
+			Assert.True (label.AutoSize);
+			Assert.Equal (new Rect (0, 0, 80, 12), label.Frame);
+
+			var expected = @"
+デ
+モ
+エ
+ム
+ポ
+ン
+ズ
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 2, 7), pos);
+		}
+
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Horizontal_Simple_TextAlignments ()
+		{
+			var text = "Hello World";
+			var width = 20;
+			var lblLeft = new Label (text) { Width = width };
+			var lblCenter = new Label (text) { Y = 1, Width = width, TextAlignment = TextAlignment.Centered };
+			var lblRight = new Label (text) { Y = 2, Width = width, TextAlignment = TextAlignment.Right };
+			var lblJust = new Label (text) { Y = 3, Width = width, TextAlignment = TextAlignment.Justified };
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (lblLeft, lblCenter, lblRight, lblJust);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (width + 2, 6);
+
+			Assert.True (lblLeft.AutoSize);
+			Assert.True (lblCenter.AutoSize);
+			Assert.True (lblRight.AutoSize);
+			Assert.True (lblJust.AutoSize);
+			Assert.Equal (new Rect (0, 0, width, 1), lblLeft.Frame);
+			Assert.Equal (new Rect (0, 1, width, 1), lblCenter.Frame);
+			Assert.Equal (new Rect (0, 2, width, 1), lblRight.Frame);
+			Assert.Equal (new Rect (0, 3, width, 1), lblJust.Frame);
+			Assert.Equal (new Rect (0, 0, width + 2, 6), frame.Frame);
+
+			var expected = @"
+┌────────────────────┐
+│Hello World         │
+│    Hello World     │
+│         Hello World│
+│Hello          World│
+└────────────────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, width + 2, 6), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Vertical_Simple_TextAlignments ()
+		{
+			var text = "Hello World";
+			var height = 20;
+			var lblLeft = new Label (text, direction: TextDirection.TopBottom_LeftRight) { Height = height };
+			var lblCenter = new Label (text, direction: TextDirection.TopBottom_LeftRight) { X = 2, Height = height, VerticalTextAlignment = VerticalTextAlignment.Middle };
+			var lblRight = new Label (text, direction: TextDirection.TopBottom_LeftRight) { X = 4, Height = height, VerticalTextAlignment = VerticalTextAlignment.Bottom };
+			var lblJust = new Label (text, direction: TextDirection.TopBottom_LeftRight) { X = 6, Height = height, VerticalTextAlignment = VerticalTextAlignment.Justified };
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (lblLeft, lblCenter, lblRight, lblJust);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (9, height + 2);
+
+			Assert.True (lblLeft.AutoSize);
+			Assert.True (lblCenter.AutoSize);
+			Assert.True (lblRight.AutoSize);
+			Assert.True (lblJust.AutoSize);
+			Assert.Equal (new Rect (0, 0, 1, height), lblLeft.Frame);
+			Assert.Equal (new Rect (2, 0, 1, height), lblCenter.Frame);
+			Assert.Equal (new Rect (4, 0, 1, height), lblRight.Frame);
+			Assert.Equal (new Rect (6, 0, 1, height), lblJust.Frame);
+			Assert.Equal (new Rect (0, 0, 9, height + 2), frame.Frame);
+
+			var expected = @"
+┌───────┐
+│H     H│
+│e     e│
+│l     l│
+│l     l│
+│o H   o│
+│  e    │
+│W l    │
+│o l    │
+│r o    │
+│l   H  │
+│d W e  │
+│  o l  │
+│  r l  │
+│  l o  │
+│  d    │
+│    W W│
+│    o o│
+│    r r│
+│    l l│
+│    d d│
+└───────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 9, height + 2), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Horizontal_Wide_TextAlignments ()
+		{
+			var text = "こんにちは 世界";
+			var width = 25;
+			var lblLeft = new Label (text) { Width = width };
+			var lblCenter = new Label (text) { Y = 1, Width = width, TextAlignment = TextAlignment.Centered };
+			var lblRight = new Label (text) { Y = 2, Width = width, TextAlignment = TextAlignment.Right };
+			var lblJust = new Label (text) { Y = 3, Width = width, TextAlignment = TextAlignment.Justified };
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (lblLeft, lblCenter, lblRight, lblJust);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (width + 2, 6);
+
+			Assert.True (lblLeft.AutoSize);
+			Assert.True (lblCenter.AutoSize);
+			Assert.True (lblRight.AutoSize);
+			Assert.True (lblJust.AutoSize);
+			Assert.Equal (new Rect (0, 0, width, 1), lblLeft.Frame);
+			Assert.Equal (new Rect (0, 1, width, 1), lblCenter.Frame);
+			Assert.Equal (new Rect (0, 2, width, 1), lblRight.Frame);
+			Assert.Equal (new Rect (0, 3, width, 1), lblJust.Frame);
+			Assert.Equal (new Rect (0, 0, width + 2, 6), frame.Frame);
+
+			var expected = @"
+┌─────────────────────────┐
+│こんにちは 世界          │
+│     こんにちは 世界     │
+│          こんにちは 世界│
+│こんにちは           世界│
+└─────────────────────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, width + 2, 6), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Vertical_Wide_TextAlignments ()
+		{
+			var text = "こんにちは 世界";
+			var height = 23;
+			var lblLeft = new Label (text) { Width = 2, Height = height, TextDirection = TextDirection.TopBottom_LeftRight };
+			var lblCenter = new Label (text) { X = 3, Width = 2, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, VerticalTextAlignment = VerticalTextAlignment.Middle };
+			var lblRight = new Label (text) { X = 6, Width = 2, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, VerticalTextAlignment = VerticalTextAlignment.Bottom };
+			var lblJust = new Label (text) { X = 9, Width = 2, Height = height, TextDirection = TextDirection.TopBottom_LeftRight, VerticalTextAlignment = VerticalTextAlignment.Justified };
+			var frame = new FrameView () { Width = Dim.Fill (), Height = Dim.Fill () };
+
+			frame.Add (lblLeft, lblCenter, lblRight, lblJust);
+			Application.Top.Add (frame);
+			Application.Begin (Application.Top);
+			((FakeDriver)Application.Driver).SetBufferSize (13, height + 2);
+
+			// All AutoSize are false because the Frame.Height != TextFormatter.Size.Height
+			Assert.True (lblLeft.AutoSize);
+			Assert.True (lblCenter.AutoSize);
+			Assert.True (lblRight.AutoSize);
+			Assert.True (lblJust.AutoSize);
+			Assert.Equal (new Rect (0, 0, 2, height), lblLeft.Frame);
+			Assert.Equal (new Rect (3, 0, 2, height), lblCenter.Frame);
+			Assert.Equal (new Rect (6, 0, 2, height), lblRight.Frame);
+			Assert.Equal (new Rect (9, 0, 2, height), lblJust.Frame);
+			Assert.Equal (new Rect (0, 0, 13, height + 2), frame.Frame);
+
+			var expected = @"
+┌───────────┐
+│こ       こ│
+│ん       ん│
+│に       に│
+│ち       ち│
+│は       は│
+│           │
+│世         │
+│界 こ      │
+│   ん      │
+│   に      │
+│   ち      │
+│   は      │
+│           │
+│   世      │
+│   界      │
+│      こ   │
+│      ん   │
+│      に   │
+│      ち   │
+│      は   │
+│           │
+│      世 世│
+│      界 界│
+└───────────┘
+";
+
+			var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+			Assert.Equal (new Rect (0, 0, 13, height + 2), pos);
+		}
+
+		[Fact, AutoInitShutdown]
+		public void Label_Draw_Fill_Remaining ()
+		{
+			var view = new View ("This view needs to be cleared before rewritten.");
+
+			var tf1 = new TextFormatter ();
+			tf1.Text = "This TextFormatter (tf1) without fill will not be cleared on rewritten.";
+			var tf1Size = tf1.Size;
+
+			var tf2 = new TextFormatter ();
+			tf2.Text = "This TextFormatter (tf2) with fill will be cleared on rewritten.";
+			var tf2Size = tf2.Size;
+
+			Application.Top.Add (view);
+			Application.Begin (Application.Top);
+
+			tf1.Draw (new Rect (new Point (0, 1), tf1Size), view.GetNormalColor (), view.ColorScheme.HotNormal, default, false);
+
+			tf2.Draw (new Rect (new Point (0, 2), tf2Size), view.GetNormalColor (), view.ColorScheme.HotNormal);
+
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+This view needs to be cleared before rewritten.                        
+This TextFormatter (tf1) without fill will not be cleared on rewritten.
+This TextFormatter (tf2) with fill will be cleared on rewritten.       
+", output);
+
+			view.Text = "This view is rewritten.";
+			view.Redraw (view.Bounds);
+
+			tf1.Text = "This TextFormatter (tf1) is rewritten.";
+			tf1.Draw (new Rect (new Point (0, 1), tf1Size), view.GetNormalColor (), view.ColorScheme.HotNormal, default, false);
+
+			tf2.Text = "This TextFormatter (tf2) is rewritten.";
+			tf2.Draw (new Rect (new Point (0, 2), tf2Size), view.GetNormalColor (), view.ColorScheme.HotNormal);
+
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+This view is rewritten.                                                
+This TextFormatter (tf1) is rewritten.will not be cleared on rewritten.
+This TextFormatter (tf2) is rewritten.                                 
+", output);
+		}
+
+	}
+}

+ 1 - 1
UnitTests/Views/MenuTests.cs

@@ -1691,7 +1691,7 @@ else 					Assert.True (mCurrent.MouseEvent (new MouseEvent () {
 └──────────────────────────────────────┘", output);
 
 			Assert.True (menu.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
-			top.Redraw (top.Bounds);
+			Application.Refresh ();
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌──────────────────────────────────────┐
 │ File  Edit                           │

+ 4 - 4
UnitTests/Views/ScrollBarViewTests.cs

@@ -825,7 +825,7 @@ namespace Terminal.Gui.ViewsTests {
 				Height = Dim.Fill (),
 				Text = "This is the help text for the Second Step.\n\nPress the button to see a message box.\n\nEnter name too."
 			};
-			var win = new Window ("Test") {
+			var win = new Window () {
 				Width = Dim.Fill (),
 				Height = Dim.Fill ()
 			};
@@ -889,7 +889,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (0, scrollBar.Position);
 			Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
 			var expected = @"
-┌┤Test├─────────────────────────────────────┐
+┌───────────────────────────────────────────┐
 │This is the help text for the Second Step. │
 │                                           │
 │Press the button to see a message box.     │
@@ -926,7 +926,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (0, scrollBar.Position);
 			Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
 			expected = @"
-┌┤Test├──────────────────┐
+┌────────────────────────┐
 │This is the help text   │
 │for the Second Step.    │
 │                        │
@@ -962,7 +962,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (0, scrollBar.Position);
 			Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
 			expected = @"
-┌┤Test├──┐
+┌────────┐
 │This   ▲│
 │is the ┬│
 │help   ││

+ 3 - 3
UnitTests/Views/ScrollViewTests.cs

@@ -524,7 +524,7 @@ namespace Terminal.Gui.ViewsTests {
 00000000000000000000000
 00000000000000000000000", attributes);
 
-			sv.Add (new Window ("1") { X = 3, Y = 3, Width = 20, Height = 20 });
+			sv.Add (new Window { X = 3, Y = 3, Width = 20, Height = 20 });
 
 			Application.Refresh ();
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
@@ -534,7 +534,7 @@ namespace Terminal.Gui.ViewsTests {
-      ┌┤1├──░          
+      ┌─────░          
       │     ░          
       │     ░          
       │     ░          
@@ -617,7 +617,7 @@ namespace Terminal.Gui.ViewsTests {
 				ShowVerticalScrollIndicator = true
 			};
 			scrollView.Add (view);
-			var win = new Window (new Rect (1, 1, 20, 14), "");
+			var win = new Window (new Rect (1, 1, 20, 14));
 			win.Add (scrollView);
 			Application.Top.Add (win);
 			Application.Begin (Application.Top);

+ 40 - 49
UnitTests/Views/ToplevelTests.cs

@@ -41,7 +41,7 @@ namespace Terminal.Gui.ViewsTests {
 
 		[Fact]
 		[AutoInitShutdown]
-		public void Application_Top_EnsureVisibleBounds_To_Driver_Rows_And_Cols ()
+		public void Application_Top_GetLocationThatFits_To_Driver_Rows_And_Cols ()
 		{
 			var iterations = 0;
 
@@ -201,7 +201,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (top, Application.Top);
 
 			// Application.Top without menu and status bar.
-			var supView = top.EnsureVisibleBounds (top, 2, 2, out int nx, out int ny, out MenuBar mb, out StatusBar sb);
+			var supView = top.GetLocationThatFits (top, 2, 2, out int nx, out int ny, out MenuBar mb, out StatusBar sb);
 			Assert.Equal (Application.Top, supView);
 			Assert.Equal (0, nx);
 			Assert.Equal (0, ny);
@@ -212,7 +212,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.NotNull (top.MenuBar);
 
 			// Application.Top with a menu and without status bar.
-			top.EnsureVisibleBounds (top, 2, 2, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (top, 2, 2, out nx, out ny, out mb, out sb);
 			Assert.Equal (0, nx);
 			Assert.Equal (1, ny);
 			Assert.NotNull (mb);
@@ -222,7 +222,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.NotNull (top.StatusBar);
 
 			// Application.Top with a menu and status bar.
-			top.EnsureVisibleBounds (top, 2, 2, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (top, 2, 2, out nx, out ny, out mb, out sb);
 			Assert.Equal (0, nx);
 			// The available height is lower than the Application.Top height minus
 			// the menu bar and status bar, then the top can go beyond the bottom
@@ -234,7 +234,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Null (top.MenuBar);
 
 			// Application.Top without a menu and with a status bar.
-			top.EnsureVisibleBounds (top, 2, 2, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (top, 2, 2, out nx, out ny, out mb, out sb);
 			Assert.Equal (0, nx);
 			// The available height is lower than the Application.Top height minus
 			// the status bar, then the top can go beyond the bottom
@@ -251,13 +251,13 @@ namespace Terminal.Gui.ViewsTests {
 			top.LayoutSubviews ();
 
 			// The SuperView is always the same regardless of the caller.
-			supView = top.EnsureVisibleBounds (win, 0, 0, out nx, out ny, out mb, out sb);
+			supView = top.GetLocationThatFits (win, 0, 0, out nx, out ny, out mb, out sb);
 			Assert.Equal (Application.Top, supView);
-			supView = win.EnsureVisibleBounds (win, 0, 0, out nx, out ny, out mb, out sb);
+			supView = win.GetLocationThatFits (win, 0, 0, out nx, out ny, out mb, out sb);
 			Assert.Equal (Application.Top, supView);
 
 			// Application.Top without menu and status bar.
-			top.EnsureVisibleBounds (win, 0, 0, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (win, 0, 0, out nx, out ny, out mb, out sb);
 			Assert.Equal (0, nx);
 			Assert.Equal (0, ny);
 			Assert.Null (mb);
@@ -267,7 +267,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.NotNull (top.MenuBar);
 
 			// Application.Top with a menu and without status bar.
-			top.EnsureVisibleBounds (win, 2, 2, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (win, 2, 2, out nx, out ny, out mb, out sb);
 			Assert.Equal (0, nx);
 			Assert.Equal (1, ny);
 			Assert.NotNull (mb);
@@ -277,7 +277,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.NotNull (top.StatusBar);
 
 			// Application.Top with a menu and status bar.
-			top.EnsureVisibleBounds (win, 30, 20, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (win, 30, 20, out nx, out ny, out mb, out sb);
 			Assert.Equal (0, nx);
 			// The available height is lower than the Application.Top height minus
 			// the menu bar and status bar, then the top can go beyond the bottom
@@ -296,7 +296,7 @@ namespace Terminal.Gui.ViewsTests {
 			top.Add (win);
 
 			// Application.Top without menu and status bar.
-			top.EnsureVisibleBounds (win, 0, 0, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (win, 0, 0, out nx, out ny, out mb, out sb);
 			Assert.Equal (0, nx);
 			Assert.Equal (0, ny);
 			Assert.Null (mb);
@@ -306,7 +306,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.NotNull (top.MenuBar);
 
 			// Application.Top with a menu and without status bar.
-			top.EnsureVisibleBounds (win, 2, 2, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (win, 2, 2, out nx, out ny, out mb, out sb);
 			Assert.Equal (2, nx);
 			Assert.Equal (2, ny);
 			Assert.NotNull (mb);
@@ -316,7 +316,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.NotNull (top.StatusBar);
 
 			// Application.Top with a menu and status bar.
-			top.EnsureVisibleBounds (win, 30, 20, out nx, out ny, out mb, out sb);
+			top.GetLocationThatFits (win, 30, 20, out nx, out ny, out mb, out sb);
 			Assert.Equal (20, nx); // 20+60=80
 			Assert.Equal (9, ny); // 9+15+1(mb)=25
 			Assert.NotNull (mb);
@@ -341,7 +341,7 @@ namespace Terminal.Gui.ViewsTests {
 		{
 			var isRunning = false;
 
-			var win1 = new Window ("Win1") { Id = "win1", Width = Dim.Percent (50f), Height = Dim.Fill () };
+			var win1 = new Window () { Id = "win1", Width = Dim.Percent (50f), Height = Dim.Fill () };
 			var lblTf1W1 = new Label ("Enter text in TextField on Win1:") { Id = "lblTf1W1" };
 			var tf1W1 = new TextField ("Text1 on Win1") { Id = "tf1W1", X = Pos.Right (lblTf1W1) + 1, Width = Dim.Fill () };
 			var lblTvW1 = new Label ("Enter text in TextView on Win1:") { Id = "lblTvW1", Y = Pos.Bottom (lblTf1W1) + 1 };
@@ -350,7 +350,7 @@ namespace Terminal.Gui.ViewsTests {
 			var tf2W1 = new TextField ("Text2 on Win1") { Id = "tf2W1", X = Pos.Left (tf1W1), Width = Dim.Fill () };
 			win1.Add (lblTf1W1, tf1W1, lblTvW1, tvW1, lblTf2W1, tf2W1);
 
-			var win2 = new Window ("Win2") { Id = "win2", X = Pos.Right (win1) + 1, Width = Dim.Percent (50f), Height = Dim.Fill () };
+			var win2 = new Window () { Id = "win2", X = Pos.Right (win1) + 1, Width = Dim.Percent (50f), Height = Dim.Fill () };
 			var lblTf1W2 = new Label ("Enter text in TextField on Win2:") { Id = "lblTf1W2" };
 			var tf1W2 = new TextField ("Text1 on Win2") { Id = "tf1W2", X = Pos.Right (lblTf1W2) + 1, Width = Dim.Fill () };
 			var lblTvW2 = new Label ("Enter text in TextView on Win2:") { Id = "lblTvW2", Y = Pos.Bottom (lblTf1W2) + 1 };
@@ -453,7 +453,7 @@ namespace Terminal.Gui.ViewsTests {
 
 			var isRunning = true;
 
-			var win1 = new Window ("Win1") { Width = Dim.Percent (50f), Height = Dim.Fill () };
+			var win1 = new Window () { Id = "win1", Width = Dim.Percent (50f), Height = Dim.Fill () };
 			var lblTf1W1 = new Label ("Enter text in TextField on Win1:");
 			var tf1W1 = new TextField ("Text1 on Win1") { X = Pos.Right (lblTf1W1) + 1, Width = Dim.Fill () };
 			var lblTvW1 = new Label ("Enter text in TextView on Win1:") { Y = Pos.Bottom (lblTf1W1) + 1 };
@@ -462,7 +462,7 @@ namespace Terminal.Gui.ViewsTests {
 			var tf2W1 = new TextField ("Text2 on Win1") { X = Pos.Left (tf1W1), Width = Dim.Fill () };
 			win1.Add (lblTf1W1, tf1W1, lblTvW1, tvW1, lblTf2W1, tf2W1);
 
-			var win2 = new Window ("Win2") { Width = Dim.Percent (50f), Height = Dim.Fill () };
+			var win2 = new Window () { Id = "win2", Width = Dim.Percent (50f), Height = Dim.Fill () };
 			var lblTf1W2 = new Label ("Enter text in TextField on Win2:");
 			var tf1W2 = new TextField ("Text1 on Win2") { X = Pos.Right (lblTf1W2) + 1, Width = Dim.Fill () };
 			var lblTvW2 = new Label ("Enter text in TextView on Win2:") { Y = Pos.Bottom (lblTf1W2) + 1 };
@@ -666,16 +666,6 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (Key.Q | Key.CtrlMask, Application.QuitKey);
 		}
 
-		[Fact]
-		[AutoInitShutdown]
-		public void FileDialog_FileSystemWatcher ()
-		{
-			for (int i = 0; i < 8; i++) {
-				var fd = new FileDialog ();
-				fd.Ready += (s, e) => Application.RequestStop ();
-				Application.Run (fd);
-			}
-		}
 
 		[Fact, AutoInitShutdown]
 		public void Mouse_Drag_On_Top_With_Superview_Null ()
@@ -825,8 +815,8 @@ namespace Terminal.Gui.ViewsTests {
 			var win = new Window () {
 				X = 3,
 				Y = 2,
-				Width = Dim.Fill (10),
-				Height = Dim.Fill (5)
+				Width = 10,
+				Height = 5
 			};
 			var top = Application.Top;
 			top.Add (win);
@@ -841,7 +831,9 @@ namespace Terminal.Gui.ViewsTests {
 			Application.Iteration = () => {
 				iterations++;
 				if (iterations == 0) {
-					((FakeDriver)Application.Driver).SetBufferSize (20, 10);
+					((FakeDriver)Application.Driver).SetBufferSize (30, 10);
+				} else if (iterations == 1) {
+					location = win.Frame;
 
 					Assert.Null (Application.MouseGrabView);
 					// Grab the mouse
@@ -856,8 +848,7 @@ namespace Terminal.Gui.ViewsTests {
 
 					Assert.Equal (win, Application.MouseGrabView);
 					Assert.Equal (location, Application.MouseGrabView.Frame);
-
-				} else if (iterations == 1) {
+				} else if (iterations == 2) {
 					Assert.Equal (win, Application.MouseGrabView);
 					// Drag to left
 					movex = 1;
@@ -873,14 +864,14 @@ namespace Terminal.Gui.ViewsTests {
 
 					Assert.Equal (win, Application.MouseGrabView);
 
-				} else if (iterations == 2) {
+				} else if (iterations == 3) {
 					// we should have moved +1, +0
 					Assert.Equal (win, Application.MouseGrabView);
 					Assert.Equal (win, Application.MouseGrabView);
 					location.Offset (movex, movey);
 					Assert.Equal (location, Application.MouseGrabView.Frame);
 
-				} else if (iterations == 3) {
+				} else if (iterations == 4) {
 					Assert.Equal (win, Application.MouseGrabView);
 					// Drag up
 					movex = 0;
@@ -896,13 +887,13 @@ namespace Terminal.Gui.ViewsTests {
 
 					Assert.Equal (win, Application.MouseGrabView);
 
-				} else if (iterations == 4) {
+				} else if (iterations == 5) {
 					// we should have moved +0, -1
 					Assert.Equal (win, Application.MouseGrabView);
 					location.Offset (movex, movey);
 					Assert.Equal (location, Application.MouseGrabView.Frame);
 
-				} else if (iterations == 5) {
+				} else if (iterations == 6) {
 					Assert.Equal (win, Application.MouseGrabView);
 					// Ungrab the mouse
 					movex = 0;
@@ -917,7 +908,7 @@ namespace Terminal.Gui.ViewsTests {
 						});
 
 					Assert.Null (Application.MouseGrabView);
-				} else if (iterations == 8) {
+				} else if (iterations == 7) {
 					Application.RequestStop ();
 				}
 			};
@@ -926,7 +917,7 @@ namespace Terminal.Gui.ViewsTests {
 		}
 
 		[Fact, AutoInitShutdown]
-		public void EnsureVisibleBounds_With_Border_Null_Not_Throws ()
+		public void GetLocationThatFits_With_Border_Null_Not_Throws ()
 		{
 			var top = new Toplevel ();
 			Application.Begin (top);
@@ -1052,7 +1043,7 @@ namespace Terminal.Gui.ViewsTests {
 				Height = 16,
 				ContentSize = new Size (200, 100)
 			};
-			var win = new Window ("Window") { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3) };
+			var win = new Window () { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3) };
 			scrollView.Add (win);
 			var top = Application.Top;
 			top.Add (scrollView);
@@ -1066,7 +1057,7 @@ namespace Terminal.Gui.ViewsTests {
-      ┌┤Window├───────────────────────────┴
+      ┌───────────────────────────────────┴
       │                                   ░
       │                                   ░
       │                                   ░
@@ -1111,7 +1102,7 @@ namespace Terminal.Gui.ViewsTests {
-         ┌┤Window├────────────────────────░
+         ┌────────────────────────────────░
          │                                ░
          │                                ░
          │                                ░
@@ -1138,7 +1129,7 @@ namespace Terminal.Gui.ViewsTests {
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
-     ┌┤Window├────────────────────────────│
+     ┌────────────────────────────────────│
      │                                    ┴
      │                                    ░
      │                                    ░
@@ -1178,7 +1169,7 @@ namespace Terminal.Gui.ViewsTests {
 		public void Dialog_Bounds_Bigger_Than_Driver_Cols_And_Rows_Allow_Drag_Beyond_Left_Right_And_Bottom ()
 		{
 			var top = Application.Top;
-			var dialog = new Dialog ("", 20, 3, new Button ("Ok"));
+			var dialog = new Dialog (new Button ("Ok")) { Width = 20, Height = 3 };
 			Application.Begin (top);
 			((FakeDriver)Application.Driver).SetBufferSize (40, 10);
 			Application.Begin (dialog);
@@ -1295,7 +1286,7 @@ namespace Terminal.Gui.ViewsTests {
 		[Fact, AutoInitShutdown]
 		public void Single_Smaller_Top_Will_Have_Cleaning_Trails_Chunk_On_Move ()
 		{
-			var dialog = new Dialog ("Single smaller Dialog") { Width = 30, Height = 10 };
+			var dialog = new Dialog () { Width = 30, Height = 10 };
 			dialog.Add (new Label (
 				"How should I've to react. Cleaning all chunk trails or setting the 'Cols' and 'Rows' to this dialog length?\n" +
 				"Cleaning is more easy to fix this.") {
@@ -1313,7 +1304,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Null (Application.MouseGrabView);
 			Assert.Equal (new Rect (25, 7, 30, 10), dialog.Frame);
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
-                         ┌┤Single smaller Dialog├─────┐
+                         ┌────────────────────────────┐
                          │ How should I've to react.  │
                          │Cleaning all chunk trails or│
                          │   setting the 'Cols' and   │
@@ -1339,7 +1330,7 @@ namespace Terminal.Gui.ViewsTests {
 
 			Assert.Equal (new Rect (25, 7, 30, 10), dialog.Frame);
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
-                         ┌┤Single smaller Dialog├─────┐
+                         ┌────────────────────────────┐
                          │ How should I've to react.  │
                          │Cleaning all chunk trails or│
                          │   setting the 'Cols' and   │
@@ -1364,7 +1355,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (dialog, Application.MouseGrabView);
 			Assert.Equal (new Rect (20, 10, 30, 10), dialog.Frame);
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
-                    ┌┤Single smaller Dialog├─────┐
+                    ┌────────────────────────────┐
                     │ How should I've to react.  │
                     │Cleaning all chunk trails or│
                     │   setting the 'Cols' and   │
@@ -1418,7 +1409,7 @@ namespace Terminal.Gui.ViewsTests {
 					Y = viewToScreen.Y + 1,
 					Width = 18,
 					Height = 5,
-					Border = new Border () { BorderStyle = BorderStyle.Single }
+					BorderStyle = LineStyle.Single 
 				};
 				Application.Current.DrawContentComplete += Current_DrawContentComplete;
 				top.Add (view);
@@ -1441,7 +1432,7 @@ namespace Terminal.Gui.ViewsTests {
 					Application.Current.DrawContentComplete -= Current_DrawContentComplete;
 				}
 			};
-			var dialog = new Dialog ("", 15, 10, btnPopup);
+			var dialog = new Dialog (btnPopup) { Width = 15, Height = 10 };
 			var rs = Application.Begin (dialog);
 
 			Assert.Equal (new Rect (2, 5, 15, 10), dialog.Frame);

+ 3 - 3
UnitTests/Views/WindowTests.cs

@@ -45,7 +45,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (TextDirection.LeftRight_TopBottom, r.TextDirection);
 
 			// Empty Rect
-			r = new Window (Rect.Empty, "title");
+			r = new Window (Rect.Empty) { Title = "title" };
 			Assert.NotNull (r);
 			Assert.Equal ("title", r.Title);
 			Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
@@ -69,14 +69,14 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (TextDirection.LeftRight_TopBottom, r.TextDirection);
 
 			// Rect with values
-			r = new Window (new Rect (1, 2, 3, 4), "title");
+			r = new Window (new Rect (1, 2, 3, 4)) { Title = "title" };
 			Assert.Equal ("title", r.Title);
 			Assert.NotNull (r);
 			Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
 			Assert.Equal ("Window(title)({X=1,Y=2,Width=3,Height=4})", r.ToString ());
 			Assert.True (r.CanFocus);
 			Assert.False (r.HasFocus);
-			Assert.Equal (new Rect (0, 0, 3, 4), r.Bounds);
+			Assert.Equal (new Rect (0, 0, 1, 2), r.Bounds);
 			Assert.Equal (new Rect (1, 2, 3, 4), r.Frame);
 			Assert.Null (r.Focused);
 			Assert.NotNull (r.ColorScheme);

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott