Line.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace Terminal.Gui;
  2. /// <summary>Draws a single line using the <see cref="LineStyle"/> specified by <see cref="View.BorderStyle"/>.</summary>
  3. public class Line : View
  4. {
  5. /// <summary>Constructs a Line object.</summary>
  6. public Line () { }
  7. /// <summary>
  8. /// The direction of the line. If you change this you will need to manually update the Width/Height of the
  9. /// control to cover a relevant area based on the new direction.
  10. /// </summary>
  11. public Orientation Orientation { get; set; }
  12. /// <inheritdoc/>
  13. public override bool OnDrawAdornments ()
  14. {
  15. Rectangle screenBounds = BoundsToScreen (Bounds);
  16. LineCanvas lc;
  17. lc = SuperView?.LineCanvas;
  18. lc.AddLine (
  19. screenBounds.Location,
  20. Orientation == Orientation.Horizontal ? Frame.Width : Frame.Height,
  21. Orientation,
  22. BorderStyle
  23. );
  24. return true;
  25. }
  26. //public override void OnDrawContentComplete (Rect contentArea)
  27. //{
  28. // var screenBounds = ViewToScreen (Frame);
  29. //}
  30. /// <inheritdoc/>
  31. public override void OnDrawContent (Rectangle contentArea) { OnDrawAdornments (); }
  32. }