Margin.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Linq;
  3. namespace Terminal.Gui;
  4. /// <summary>
  5. /// The Margin for a <see cref="View"/>.
  6. /// </summary>
  7. /// <remarks>
  8. /// <para>
  9. /// See the <see cref="Adornment"/> class.
  10. /// </para>
  11. /// </remarks>
  12. public class Margin : Adornment {
  13. /// <inheritdoc />
  14. public Margin () { /* Do nothing; A parameter-less constructor is required to support all views unit tests. */ }
  15. /// <inheritdoc />
  16. public Margin (View parent) : base (parent) { /* Do nothing; View.CreateAdornment requires a constructor that takes a parent */ }
  17. /// <summary>
  18. /// The color scheme for the Margin. If set to <see langword="null"/>, gets the <see cref="Adornment.Parent"/>'s <see cref="View.SuperView"/> scheme.
  19. /// color scheme.
  20. /// </summary>
  21. public override ColorScheme ColorScheme {
  22. get {
  23. if (base.ColorScheme != null) {
  24. return base.ColorScheme;
  25. }
  26. return Parent?.SuperView?.ColorScheme ?? Colors.ColorSchemes ["TopLevel"];
  27. }
  28. set {
  29. base.ColorScheme = value;
  30. Parent?.SetNeedsDisplay ();
  31. }
  32. }
  33. }