FrameView.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Text.Json.Serialization;
  2. namespace Terminal.Gui;
  3. /// <summary>
  4. /// The FrameView is a container frame that draws a frame around the contents. It is similar to a GroupBox in
  5. /// Windows.
  6. /// </summary>
  7. public class FrameView : View
  8. {
  9. /// <summary>
  10. /// Initializes a new instance of the <see cref="Gui.FrameView"/> class using <see cref="LayoutStyle.Computed"/>
  11. /// layout.
  12. /// </summary>
  13. public FrameView ()
  14. {
  15. Border.Thickness = new Thickness (1);
  16. Border.LineStyle = DefaultBorderStyle;
  17. //Border.ColorScheme = ColorScheme;
  18. Border.Data = "Border";
  19. }
  20. /// <summary>
  21. /// The default <see cref="LineStyle"/> for <see cref="FrameView"/>'s border. The default is
  22. /// <see cref="LineStyle.Single"/>.
  23. /// </summary>
  24. /// <remarks>
  25. /// This property can be set in a Theme to change the default <see cref="LineStyle"/> for all
  26. /// <see cref="FrameView"/>s.
  27. /// </remarks>
  28. [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
  29. [JsonConverter (typeof (JsonStringEnumConverter))]
  30. public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single;
  31. /// <inheritdoc/>
  32. public override bool OnEnter (View view)
  33. {
  34. if (Subviews.Count == 0 || !Subviews.Any (subview => subview.CanFocus))
  35. {
  36. Application.Driver?.SetCursorVisibility (CursorVisibility.Invisible);
  37. }
  38. return base.OnEnter (view);
  39. }
  40. }