Line.cs 1.2 KB

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