Esempio n. 1
0
 public static (IConsole top, IConsole bottom) SplitTopBottom(this Window c, BorderCollapse border = Collapse)
 {
     return(_SplitTopBottom(c, null, null, LineThickNess.Single, border, c.ForegroundColor, c.BackgroundColor));
 }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 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));
 }
Esempio n. 4
0
 public static (IConsole left, IConsole right) SplitLeftRight(this Window c, BorderCollapse border = Collapse)
 {
     return(_SplitLeftRight(c, null, null, LineThickNess.Single, border, c.ForegroundColor, c.BackgroundColor));
 }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
 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));
 }