namespace Spectre.Console; /// /// Contains extension methods for . /// public static class PanelExtensions { /// /// Sets the panel header. /// /// The panel. /// The header text. /// The header alignment. /// The same instance so that multiple calls can be chained. public static Panel Header(this Panel panel, string text, Justify? alignment = null) { if (panel is null) { throw new ArgumentNullException(nameof(panel)); } if (text is null) { throw new ArgumentNullException(nameof(text)); } alignment ??= panel.Header?.Justification; return Header(panel, new PanelHeader(text, alignment)); } /// /// Sets the panel header alignment. /// /// The panel. /// The header alignment. /// The same instance so that multiple calls can be chained. public static Panel HeaderAlignment(this Panel panel, Justify alignment) { if (panel is null) { throw new ArgumentNullException(nameof(panel)); } if (panel.Header != null) { // Update existing style panel.Header.Justification = alignment; } else { // Create header Header(panel, string.Empty, alignment); } return panel; } /// /// Sets the panel header. /// /// The panel. /// The header to use. /// The same instance so that multiple calls can be chained. public static Panel Header(this Panel panel, PanelHeader header) { if (panel is null) { throw new ArgumentNullException(nameof(panel)); } panel.Header = header; return panel; } }