public void DrawRectangle (int x, int y, int width, int height, ConsoleColor? color = null, LineThickness? thickness = null)
 {
     if (thickness == null)
         thickness = LineThickness.Single;
     DrawHorizontalLine(x, y, width, color, thickness.Value.Top);
     DrawHorizontalLine(x, y + height - 1, width, color, thickness.Value.Bottom);
     DrawVerticalLine(x, y, height, color, thickness.Value.Left);
     DrawVerticalLine(x + width - 1, y, height, color, thickness.Value.Right);
 }
Exemple #2
0
 public Document CreateDocument (Data data)
 {
     var cellHeaderThickness = new LineThickness(LineWidth.Single, LineWidth.Wide);
     return new Document { Color = White, Background = Black }
         .AddChildren(
             "Hello world!",
             new List()
                 .AddChildren(
                     data.Items.Select(d => new Div().AddChildren(d.Name))
                 ),
             new Div()
                 .AddChildren(
                     data.Items.Select(d => d.Name + " ")
                 ),
             new Grid()
                 .AddColumns(
                     GridLength.Auto,
                     GridLength.Auto,
                     GridLength.Auto
                 )
                 .AddChildren(
                     new Cell { Stroke = cellHeaderThickness }.AddChildren("Id"),
                     new Cell { Stroke = cellHeaderThickness }.AddChildren("Name"),
                     new Cell { Stroke = cellHeaderThickness }.AddChildren("Value"),
                     data.Items.Select(d => new[] {
                         new Cell { Color = Yellow, Align = HorizontalAlignment.Right }.AddChildren(d.Id),
                         new Cell { Color = Gray }.AddChildren(d.Name),
                         new Cell { Color = Gray }.AddChildren(d.Value),
                     })
                 ),
             new Dock { Width = 80, Align = HorizontalAlignment.Left, Color = Gray, Background = Blue }
                 .AddChildren(
                     new Div { Width = 20, Margin = new Thickness(1, 1, 0, 1), Padding = 1, Background = DarkBlue, TextWrap = TextWrapping.CharWrap }
                         .Set(Dock.ToProperty, DockTo.Left)
                         .AddChildren(LoremIpsumCharWrap(data)),
                     new Div { Height = 10, Margin = new Thickness(1, 1, 1, 0), Padding = 1, Background = DarkBlue }
                         .Set(Dock.ToProperty, DockTo.Top)
                         .AddChildren(LoremIpsumWordWrapWithSpaces(data)),
                     new Div { Width = 20, Margin = new Thickness(0, 1, 1, 1), Padding = 1, Background = DarkBlue }
                         .Set(Dock.ToProperty, DockTo.Right)
                         .AddChildren(LoremIpsumWordWrapWithZeroWidthSpaces(data)),
                     new Div { Height = 10, Margin = new Thickness(1, 0, 1, 1), Padding = 1, Background = DarkBlue }
                         .Set(Dock.ToProperty, DockTo.Bottom)
                         .AddChildren(LoremIpsumWordWrapWithNoBreakSpaces(data)),
                     new Border { Margin = 1, Padding = 1, Background = DarkCyan, Shadow = new Thickness(-1, -1, 1, 1), Stroke = LineThickness.Single }
                         .AddChildren(LoremIpsumWordWrapWithSoftHyphens(data))
                 ),
             "",
             new Canvas { Width = 80, Height = 43, Align = HorizontalAlignment.Left, Color = Gray, Background = Blue }
                 .AddChildren(
                     new Div { Width = 38, Height = 20, Padding = 1, Background = DarkBlue, TextWrap = TextWrapping.CharWrap }
                         .Set(Canvas.LeftProperty, 1).Set(Canvas.TopProperty, 1)
                         .AddChildren(LoremIpsumCharWrap(data)),
                     new Div { Width = 38, Height = 20, Padding = 1, Background = DarkBlue }
                         .Set(Canvas.LeftProperty, 1).Set(Canvas.BottomProperty, 1)
                         .AddChildren(LoremIpsumWordWrapWithSpaces(data)),
                     new Div { Width = 38, Height = 20, Padding = 1, Background = DarkBlue }
                         .Set(Canvas.RightProperty, 1).Set(Canvas.TopProperty, 1)
                         .AddChildren(LoremIpsumWordWrapWithZeroWidthSpaces(data)),
                     new Div { Width = 38, Height = 20, Padding = 1, Background = DarkBlue }
                         .Set(Canvas.RightProperty, 1).Set(Canvas.BottomProperty, 1)
                         .AddChildren(LoremIpsumWordWrapWithNoBreakSpaces(data)),
                     new Border { Width = 38, Height = 20, Padding = 1, Background = DarkCyan, Shadow = new Thickness(-1, -1, 1, 1), Stroke = LineThickness.Single }
                         .Set(Canvas.LeftProperty, 21).Set(Canvas.TopProperty, 11)
                         .AddChildren(LoremIpsumWordWrapWithSoftHyphens(data))
                 )
         );
 }
Exemple #3
0
 public Border ()
 {
     Stroke = LineThickness.None;
     ShadowColorMap = ColorMaps.Darkest;
 }
 public void DrawRectangle (Rect rect, ConsoleColor? color = null, LineThickness? thickness = null)
 {
     DrawRectangle(rect.X, rect.Y, rect.Width, rect.Height, color, thickness);
 }
Exemple #5
0
        public void RenderCustomBorders ()
        {
            var headerThickness = new LineThickness(LineWidth.Single, LineWidth.Wide);
            var grid = new Grid { Stroke = new LineThickness(LineWidth.None) }
                .AddColumns(GridLength.Char(1), GridLength.Char(1), GridLength.Char(1))
                .AddChildren(
                    new Cell { Stroke = headerThickness }.AddChildren(1),
                    new Cell { Stroke = headerThickness }.AddChildren(2),
                    new Cell { Stroke = headerThickness }.AddChildren(3),
                    new Cell().AddChildren(4),
                    new Cell().AddChildren(5),
                    new Cell().AddChildren(6)
                );

            GetRenderedText(grid, 8).Should().BeLines(
                "╒═╤═╤═╕ ",
                "│1│2│3│ ",
                "╞═╪═╪═╡ ",
                "│4│5│6│ ",
                "└─┴─┴─┘ ");
        }