Line.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. {
  8. BorderStyle = LineStyle.Single;
  9. Border.Thickness = new Thickness (0);
  10. }
  11. /// <summary>
  12. /// The direction of the line. If you change this you will need to manually update the Width/Height of the
  13. /// control to cover a relevant area based on the new direction.
  14. /// </summary>
  15. public Orientation Orientation { get; set; }
  16. /// <inheritdoc/>
  17. public override void OnDrawContent (Rectangle viewport)
  18. {
  19. LineCanvas lc = LineCanvas;
  20. if (SuperView is Adornment adornment)
  21. {
  22. lc = adornment.Parent.LineCanvas;
  23. }
  24. lc.AddLine (
  25. ViewportToScreen (viewport).Location,
  26. Orientation == Orientation.Horizontal ? Frame.Width : Frame.Height,
  27. Orientation,
  28. BorderStyle
  29. );
  30. }
  31. }