namespace Terminal.Gui; /// /// Draws a single line using the specified by . /// /// /// public class Line : View, IOrientation { private readonly OrientationHelper _orientationHelper; /// Constructs a Line object. public Line () { CanFocus = false; base.SuperViewRendersLineCanvas = true; _orientationHelper = new (this); _orientationHelper.Orientation = Orientation.Horizontal; OnOrientationChanged(Orientation); } #region IOrientation members /// /// The direction of the line. If you change this you will need to manually update the Width/Height of the /// control to cover a relevant area based on the new direction. /// public Orientation Orientation { get => _orientationHelper.Orientation; set => _orientationHelper.Orientation = value; } /// public event EventHandler> OrientationChanging; /// public event EventHandler> OrientationChanged; /// Called when has changed. /// public void OnOrientationChanged (Orientation newOrientation) { switch (newOrientation) { case Orientation.Horizontal: Height = 1; Width = Dim.Fill (); break; case Orientation.Vertical: Width = 1; Height = Dim.Fill (); break; } } #endregion /// protected override bool OnDrawingContent () { Point pos = ViewportToScreen (Viewport).Location; int length = Orientation == Orientation.Horizontal ? Frame.Width : Frame.Height; LineCanvas?.AddLine ( pos, length, Orientation, BorderStyle ); //SuperView?.SetNeedsDraw (); return true; } }