diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs
index c5b62d74c..4bff663c2 100644
--- a/Terminal.Gui/Views/FrameView.cs
+++ b/Terminal.Gui/Views/FrameView.cs
@@ -1,68 +1,61 @@
-using System;
-using System.Linq;
+using System.Linq;
using System.Text.Json.Serialization;
-using System.Text;
-using static Terminal.Gui.ConfigurationManager;
-namespace Terminal.Gui {
+namespace Terminal.Gui;
+///
+/// The FrameView is a container frame that draws a frame around the contents. It is similar to
+/// a GroupBox in Windows.
+///
+public class FrameView : View {
///
- /// The FrameView is a container frame that draws a frame around the contents. It is similar to
- /// a GroupBox in Windows.
+ /// Initializes a new instance of the class using layout.
///
- public class FrameView : View {
- ///
- /// Initializes a new instance of the class using layout.
- ///
- /// Frame.
- /// Title.
- /// Views.
- public FrameView (Rect frame, string title = null, View [] views = null) : base (frame)
- {
- SetInitialProperties (frame, title, views);
+ /// Title.
+ /// Views.
+ public FrameView (string title = null, View [] views = null)
+ {
+ SetInitialProperties (title, views);
+ }
+
+ ///
+ /// Initializes a new instance of the class using layout.
+ ///
+ /// Title.
+ public FrameView (string title)
+ {
+ SetInitialProperties (title, null);
+ }
+
+ ///
+ /// Initializes a new instance of the class using layout.
+ ///
+ public FrameView () : this (title: string.Empty) { }
+
+ ///
+ /// The default for 's border. The default is .
+ ///
+ ///
+ /// This property can be set in a Theme to change the default for all s.
+ ///
+ [SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
+ public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
+
+ void SetInitialProperties (string title, View [] views = null)
+ {
+ this.Title = title;
+ Border.Thickness = new Thickness (1);
+ Border.LineStyle = DefaultBorderStyle;
+ //Border.ColorScheme = ColorScheme;
+ Border.Data = "Border";
+ }
+
+ ///
+ public override bool OnEnter (View view)
+ {
+ if (Subviews.Count == 0 || !Subviews.Any (subview => subview.CanFocus)) {
+ Application.Driver?.SetCursorVisibility (CursorVisibility.Invisible);
}
- ///
- /// Initializes a new instance of the class using layout.
- ///
- /// Title.
- public FrameView (string title)
- {
- SetInitialProperties (Rect.Empty, title, null);
- }
-
- ///
- /// Initializes a new instance of the class using layout.
- ///
- public FrameView () : this (title: string.Empty) {
-
- }
-
- ///
- /// The default for 's border. The default is .
- ///
- ///
- /// This property can be set in a Theme to change the default for all s.
- ///
- [SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))]
- public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
-
- void SetInitialProperties (Rect frame, string title, View [] views = null)
- {
- this.Title = title;
- Border.Thickness = new Thickness (1);
- Border.LineStyle = DefaultBorderStyle;
- //Border.ColorScheme = ColorScheme;
- Border.Data = "Border";
- }
-
- ///
- public override bool OnEnter (View view)
- {
- if (Subviews.Count == 0 || !Subviews.Any (subview => subview.CanFocus)) {
- Application.Driver?.SetCursorVisibility (CursorVisibility.Invisible);
- }
-
- return base.OnEnter (view);
- }
+ return base.OnEnter (view);
}
}
diff --git a/UnitTests/Views/FrameViewTests.cs b/UnitTests/Views/FrameViewTests.cs
index 05c5296c8..7eb2a4e5d 100644
--- a/UnitTests/Views/FrameViewTests.cs
+++ b/UnitTests/Views/FrameViewTests.cs
@@ -1,93 +1,86 @@
-using Microsoft.VisualStudio.TestPlatform.Utilities;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Xunit;
+using Xunit;
using Xunit.Abstractions;
-namespace Terminal.Gui.ViewsTests {
- public class FrameViewTests {
- readonly ITestOutputHelper output;
+namespace Terminal.Gui.ViewsTests;
+public class FrameViewTests {
+ readonly ITestOutputHelper _output;
- public FrameViewTests (ITestOutputHelper output)
- {
- this.output = output;
- }
+ public FrameViewTests (ITestOutputHelper output)
+ {
+ this._output = output;
+ }
- [Fact]
- public void Constuctors_Defaults ()
- {
- var fv = new FrameView ();
- Assert.Equal (string.Empty, fv.Title);
- Assert.Equal (string.Empty, fv.Text);
- Assert.Equal (LineStyle.Single, fv.BorderStyle);
+ [Fact]
+ public void Constructors_Defaults ()
+ {
+ var fv = new FrameView ();
+ Assert.Equal (string.Empty, fv.Title);
+ Assert.Equal (string.Empty, fv.Text);
+ Assert.Equal (LineStyle.Single, fv.BorderStyle);
- fv = new FrameView ("Test");
- Assert.Equal ("Test", fv.Title);
- Assert.Equal (string.Empty, fv.Text);
- Assert.Equal (LineStyle.Single, fv.BorderStyle);
+ fv = new FrameView ("Test");
+ Assert.Equal ("Test", fv.Title);
+ Assert.Equal (string.Empty, fv.Text);
+ 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);
- fv.BeginInit ();
- fv.EndInit ();
- Assert.Equal (LineStyle.Single, fv.BorderStyle);
- Assert.Equal (new Rect (1, 2, 10, 20), fv.Frame);
- }
+ fv = new FrameView ("Test") { X = 1, Y = 2, Width = 10, Height = 20 };
+ Assert.Equal ("Test", fv.Title);
+ Assert.Equal (string.Empty, fv.Text);
+ fv.BeginInit ();
+ fv.EndInit ();
+ Assert.Equal (LineStyle.Single, fv.BorderStyle);
+ Assert.Equal (new Rect (1, 2, 10, 20), fv.Frame);
+ }
- [Fact, AutoInitShutdown]
- public void Draw_Defaults ()
- {
- ((FakeDriver)Application.Driver).SetBufferSize (10, 10);
- var fv = new FrameView ();
- Assert.Equal (string.Empty, fv.Title);
- Assert.Equal (string.Empty, fv.Text);
- Application.Top.Add (fv);
- Application.Begin (Application.Top);
- Assert.Equal (new Rect (0, 0, 0, 0), fv.Frame);
- TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
+ [Fact, AutoInitShutdown]
+ public void Draw_Defaults ()
+ {
+ ((FakeDriver)Application.Driver).SetBufferSize (10, 10);
+ var fv = new FrameView ();
+ Assert.Equal (string.Empty, fv.Title);
+ Assert.Equal (string.Empty, fv.Text);
+ Application.Top.Add (fv);
+ Application.Begin (Application.Top);
+ Assert.Equal (new Rect (0, 0, 0, 0), fv.Frame);
+ TestHelpers.AssertDriverContentsWithFrameAre (@"", _output);
- fv.Height = 5;
- fv.Width = 5;
- Assert.Equal (new Rect (0, 0, 5, 5), fv.Frame);
- Application.Refresh ();
- TestHelpers.AssertDriverContentsWithFrameAre (@"
+ fv.Height = 5;
+ fv.Width = 5;
+ Assert.Equal (new Rect (0, 0, 5, 5), fv.Frame);
+ Application.Refresh ();
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
┌───┐
│ │
│ │
│ │
-└───┘", output);
+└───┘", _output);
- fv.X = 1;
- fv.Y = 2;
- Assert.Equal (new Rect (1, 2, 5, 5), fv.Frame);
- Application.Refresh ();
- TestHelpers.AssertDriverContentsWithFrameAre (@"
+ fv.X = 1;
+ fv.Y = 2;
+ Assert.Equal (new Rect (1, 2, 5, 5), fv.Frame);
+ Application.Refresh ();
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
┌───┐
│ │
│ │
│ │
- └───┘", output);
+ └───┘", _output);
- fv.X = -1;
- fv.Y = -2;
- Assert.Equal (new Rect (-1, -2, 5, 5), fv.Frame);
- Application.Refresh ();
- TestHelpers.AssertDriverContentsWithFrameAre (@"
+ fv.X = -1;
+ fv.Y = -2;
+ Assert.Equal (new Rect (-1, -2, 5, 5), fv.Frame);
+ Application.Refresh ();
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
│
│
-───┘", output);
+───┘", _output);
- fv.X = 7;
- fv.Y = 8;
- Assert.Equal (new Rect (7, 8, 5, 5), fv.Frame);
- Application.Refresh ();
- TestHelpers.AssertDriverContentsWithFrameAre (@"
+ fv.X = 7;
+ fv.Y = 8;
+ Assert.Equal (new Rect (7, 8, 5, 5), fv.Frame);
+ Application.Refresh ();
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
┌──
- │ ", output);
- }
+ │ ", _output);
}
}