Line.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. public override bool OnDrawFrames()
  20. {
  21. var screenBounds = ViewToScreen (Bounds);
  22. LineCanvas lc;
  23. lc = SuperView?.LineCanvas;
  24. lc.AddLine (screenBounds.Location, Orientation == Orientation.Horizontal ? Frame.Width : Frame.Height, Orientation, BorderStyle);
  25. return true;
  26. }
  27. //public override void OnDrawContentComplete (Rect viewport)
  28. //{
  29. // var screenBounds = ViewToScreen (Frame);
  30. //}
  31. public override void Redraw (Rect bounds)
  32. {
  33. OnDrawFrames ();
  34. }
  35. }
  36. }