diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs
index 59f7bf4b8..a36093906 100644
--- a/Terminal.Gui/View/ViewDrawing.cs
+++ b/Terminal.Gui/View/ViewDrawing.cs
@@ -503,5 +503,25 @@ namespace Terminal.Gui {
DrawContentComplete?.Invoke (this, new DrawEventArgs (contentArea));
}
+ ///
+ /// Draw a frame based on the passed bounds to the screen relative.
+ ///
+ /// The bounds view relative.
+ /// The line style.
+ /// The color to use.
+ public void DrawFrame (Rect bounds, LineStyle lineStyle, Attribute? attribute = null)
+ {
+ var vts = ViewToScreen (bounds);
+ LineCanvas.AddLine (new Point (vts.X, vts.Y), vts.Width,
+ Orientation.Horizontal, lineStyle, attribute);
+ LineCanvas.AddLine (new Point (vts.Right - 1, vts.Y), vts.Height,
+ Orientation.Vertical, lineStyle, attribute);
+ LineCanvas.AddLine (new Point (vts.X, vts.Bottom - 1), vts.Width,
+ Orientation.Horizontal, lineStyle, attribute);
+ LineCanvas.AddLine (new Point (vts.X, vts.Y), vts.Height,
+ Orientation.Vertical, lineStyle, attribute);
+
+ OnRenderLineCanvas ();
+ }
}
}
\ No newline at end of file
diff --git a/UnitTests/View/DrawTests.cs b/UnitTests/View/DrawTests.cs
index e744b361d..8027710b4 100644
--- a/UnitTests/View/DrawTests.cs
+++ b/UnitTests/View/DrawTests.cs
@@ -334,6 +334,23 @@ t ", output);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre ("", output);
}
+
+ [Fact, AutoInitShutdown]
+ public void DrawFrame_Test ()
+ {
+ var label = new View () { X = Pos.Center (), Y = Pos.Center (), Text = "test", AutoSize = true };
+ var view = new View () { Width = 10, Height = 5 };
+ view.DrawContentComplete += (s, e) => view.DrawFrame (view.Bounds, LineStyle.Single);
+ view.Add (label);
+ Application.Top.Add (view);
+ Application.Begin (Application.Top);
+
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
+┌────────┐
+│ │
+│ test │
+│ │
+└────────┘", output);
+ }
}
}
-