public Split(int size, string title, LineThickNess thickness, ConsoleColor foreground) { Size = size; Title = title; Thickness = thickness; Foreground = foreground; }
public void draw_a_box_around_the_scrollable_window(LineThickNess thickness) { var c = new MockConsole(10, 8); var w = Window.Open(0, 0, 10, 5, "title", thickness, White, Black, c); var expected = new string[0]; switch (thickness) { case LineThickNess.Single: expected = new[] { "┌─ title ┐", "│ │", "│ │", "│ │", "└────────┘" }; break; case LineThickNess.Double: expected = new[] { "╔═ title ╗", "║ ║", "║ ║", "║ ║", "╚════════╝" }; break; } c.BufferWritten.Should().BeEquivalentTo(expected); }
public Draw(IConsole console, LineThickNess thickness = LineThickNess.Single, MergeOrOverlap mergeOrOverlap = MergeOrOverlap.Merge) { _console = console; _mergeOrOverlap = mergeOrOverlap; _lineMerger = new LineMerger(); Thickness = thickness; }
private void DrawBoxLines(int sx, int sy, int ex, int ey, LineThickNess thickness) { var line = thickness == LineThickNess.Single ? ThinBox : ThickBox; DrawCorners(sx, sy, ex, ey, line); DrawHorizontal(sx + 1, sy, ex - 1, line); DrawVertical(sx, sy + 1, ey - 1, line); DrawVertical(ex, sy + 1, ey - 1, line); DrawHorizontal(sx + 1, ey, ex - 1, line); }
public void overlapping_boxes_and_merge_tests(LineThickNess firstThickness, LineThickNess secondThickness, MergeOrOverlap merge) { using (ApprovalResults.ForScenario(firstThickness, secondThickness, merge)) { var console = new MockConsole(80, 35); console.WriteLine("box1 :{0}, box2:{1}, MergeOrOverlap:{2}", firstThickness, secondThickness, merge); var line = new Draw(console, firstThickness, merge); // draw two overlapping boxes line.Box(10, 10, 20, 20, firstThickness); line.Box(15, 15, 25, 25, secondThickness); Approvals.Verify(console.BufferWrittenString); } }
public static Window Open(int x, int y, int width, int height, string title, LineThickNess thickNess = LineThickNess.Double, ConsoleColor foregroundColor = ConsoleColor.Gray, ConsoleColor backgroundColor = ConsoleColor.Black, IConsole console = null) { var echoConsole = console ?? new Writer(); var window = new Window(x + 1, y + 1, width - 2, height - 2, foregroundColor, backgroundColor, true, echoConsole); var state = echoConsole.State; try { echoConsole.ForegroundColor = foregroundColor; echoConsole.BackgroundColor = backgroundColor; new Draw(echoConsole).Box(x, y, x + (width - 1), y + (height - 1), title, LineThickNess.Double); } finally { echoConsole.State = state; } return(window); }
public static IConsole SplitRight(this IConsole c, string title, LineThickNess thickness) { return(_LeftRight(c, title, true, true, thickness, c.ForegroundColor)); }
internal static (IConsole top, IConsole bottom) _SplitTopBottom(IConsole c, string topTitle, string bottomTitle, LineThickNess thickness, BorderCollapse border, ConsoleColor foreground, ConsoleColor background) { if (border == None) { var top = LayoutExtensions._TopBot(c, topTitle, false, false, thickness, foreground); var bottom = LayoutExtensions._TopBot(c, bottomTitle, true, false, thickness, foreground); return(top, bottom); } if (border == Separate) { var top = LayoutExtensions._TopBot(c, topTitle, false, true, thickness, foreground); var bottom = LayoutExtensions._TopBot(c, bottomTitle, true, true, thickness, foreground); return(top, bottom); } lock (Window._staticLocker) { int h = c.WindowHeight; int width = c.WindowWidth; int topHeight = (h - 3) / 2; int bottomHeight = h - topHeight - 3; char leftChar = thickness == LineThickNess.Double ? '╠' : '├'; char rightChar = thickness == LineThickNess.Double ? '╣' : '┤'; c.DoCommand(c, () => { new Draw(c) .Box(0, 0, width - 1, topHeight + 1, topTitle, thickness); new Draw(c) .Box(0, topHeight + 1, width - 1, bottomHeight + topHeight + 2, bottomTitle, thickness); // print the edges c.PrintAt(0, topHeight + 1, leftChar); c.PrintAt(width, topHeight + 1, rightChar); }); var topWin = Window._CreateFloatingWindow(1, 1, width - 2, topHeight, foreground, background, true, c, null); var bottomWin = Window._CreateFloatingWindow(1, topHeight + 2, width - 2, bottomHeight, foreground, background, true, c, null); return(topWin, bottomWin); } }
public static (IConsole top, IConsole bottom) SplitTopBottom(this Window c, string topTitle, string bottomTitle, LineThickNess thickness, ConsoleColor foreground, ConsoleColor background, BorderCollapse border = Collapse) { return(_SplitTopBottom(c, topTitle, bottomTitle, thickness, border, foreground, background)); }
public Split(int size, string title, LineThickNess thickness) { Size = size; Title = title; Thickness = thickness; }
public static IConsole SplitLeft(this IConsole c, string title, LineThickNess thickness, ConsoleColor foreground) { return(_LeftRight(c, title, false, true, thickness, foreground)); }
internal static (IConsole left, IConsole right) _SplitLeftRight(IConsole c, string leftTitle, string rightTitle, LineThickNess thickness, BorderCollapse border, ConsoleColor foreground, ConsoleColor background) { if (border == None) { var left = LayoutExtensions._LeftRight(c, leftTitle, false, false, thickness, foreground); var right = LayoutExtensions._LeftRight(c, rightTitle, true, false, thickness, foreground); return(left, right); } if (border == Separate) { var left = LayoutExtensions._LeftRight(c, leftTitle, false, true, thickness, foreground); var right = LayoutExtensions._LeftRight(c, rightTitle, true, true, thickness, foreground); return(left, right); } lock (Window._staticLocker) { int h = c.WindowHeight; int w = c.WindowWidth - 3; int leftWidth = w / 2; int rightWidth = (w - leftWidth); c.DoCommand(c, () => { //todo need unit test for merging two boxes :D for now, lets print them twice so we get true overlap to start with new Draw(c) .Box(0, 0, leftWidth + 1, h - 1, leftTitle, thickness); new Draw(c) .Box(leftWidth + 1, 0, rightWidth + leftWidth + 2, h - 1, rightTitle, thickness); // print the corners c.PrintAt(leftWidth + 1, 0, '┬'); c.PrintAt(leftWidth + 1, h - 1, '┴'); }); var leftWin = Window._CreateFloatingWindow(1, 1, leftWidth, h - 2, foreground, background, true, c, null); var rightWin = Window._CreateFloatingWindow(leftWidth + 2, 1, rightWidth, h - 2, foreground, background, true, c, null); return(leftWin, rightWin); } }
public static (IConsole left, IConsole right) SplitLeftRight(this Window c, string leftTitle, string rightTitle, LineThickNess thickness, ConsoleColor foreground, ConsoleColor background, BorderCollapse border = Collapse) { return(_SplitLeftRight(c, leftTitle, rightTitle, thickness, border, foreground, background)); }
public Draw Box(int sx, int sy, int ex, int ey, LineThickNess thickness = LineThickNess.Single) { Box(sx, sy, ex, ey, "", thickness); return(this); }
public static IConsole SplitTop(this IConsole c, string title, LineThickNess thickness) { return(_TopBot(c, title, false, true, thickness, c.ForegroundColor)); }
public static IConsole SplitBottom(this IConsole c, string title, LineThickNess thickness, ConsoleColor foreground) { return(_TopBot(c, title, true, true, thickness, foreground)); }
public static IConsole SplitBottom(this Window c, string title, LineThickNess thickness, ConsoleColor foreground) { return(LayoutExtensions._TopBot(c, title, true, true, thickness, foreground)); }
public static IConsole SplitLeft(this Window c, string title, LineThickNess thickness) { return(LayoutExtensions._LeftRight(c, title, false, true, thickness, c.ForegroundColor)); }
public void Box(int sx, int sy, int ex, int ey, LineThickNess thickness = LineThickNess.Single) { Box(sx, sy, ex, ey, "", thickness); }