Files
spectre.console/src/Spectre.Console/Extensions/LayoutExtensions.cs
Patrik Svensson c3ec6a7363 Add Layout widget (#1041)
* Add width to panels
* Add height to panels
* Replace RenderContext with RenderOptions
* Remove exclusivity from alternative buffer
* Add Layout widget
* Add Align widget
2022-11-15 10:12:17 +01:00

59 lines
1.6 KiB
C#

namespace Spectre.Console;
/// <summary>
/// Contains extension methods for <see cref="Layout"/>.
/// </summary>
public static class LayoutExtensions
{
/// <summary>
/// Sets the ratio of the layout.
/// </summary>
/// <param name="layout">The layout.</param>
/// <param name="ratio">The ratio.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static Layout Ratio(this Layout layout, int ratio)
{
if (layout is null)
{
throw new ArgumentNullException(nameof(layout));
}
layout.Ratio = ratio;
return layout;
}
/// <summary>
/// Sets the size of the layout.
/// </summary>
/// <param name="layout">The layout.</param>
/// <param name="size">The size.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static Layout Size(this Layout layout, int size)
{
if (layout is null)
{
throw new ArgumentNullException(nameof(layout));
}
layout.Size = size;
return layout;
}
/// <summary>
/// Sets the minimum width of the layout.
/// </summary>
/// <param name="layout">The layout.</param>
/// <param name="size">The size.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static Layout MinimumSize(this Layout layout, int size)
{
if (layout is null)
{
throw new ArgumentNullException(nameof(layout));
}
layout.MinimumSize = size;
return layout;
}
}