示例#1
0
        private void RenderBorder(IBorderable control, Point location, Size size, BorderCharType borderCharType)
        {
            ConsoleColor previousBackground = ConsoleAdapter.BackgroundColor;

            ConsoleAdapter.BackgroundColor = control.BorderBackgroundColor;

            ConsoleColor previousForeground = ConsoleAdapter.ForegroundColor;

            ConsoleAdapter.ForegroundColor = control.BorderForegroundColor;
            RenderVerticalLine(
                new Point
            {
                Left = location.Left + 1,
                Top  = location.Top
            },
                size.Width - 2, borderCharType.HorizontalChar);
            RenderVerticalLine(
                new Point
            {
                Left = location.Left + 1,
                Top  = location.Top + size.Height - 1
            },
                size.Width - 2, borderCharType.HorizontalChar);
            RenderHorizontalLine(
                new Point
            {
                Left = location.Left,
                Top  = location.Top + 1
            },
                size.Height - 2, borderCharType.VerticalChar);
            RenderHorizontalLine(
                new Point
            {
                Left = location.Left + size.Width - 1,
                Top  = location.Top + 1
            },
                size.Height - 2, borderCharType.VerticalChar);

            ConsoleAdapter.MoveCursor(location.Left + size.Width - 1, location.Top + size.Height - 1);
            if (!(RenderOptions.WindowHeight == location.Left + size.Width && RenderOptions.WindowHeight == location.Top + size.Height))
            {
                ConsoleAdapter.Write(borderCharType.BottomRightChar);
            }
            else
            {
                ConsoleAdapter.MoveCursor(location.Left, location.Top);
                ConsoleAdapter.Write(borderCharType.BottomRightChar);
                ConsoleAdapter.MoveArea(location.Left, location.Top, 1, 1, location.Left + size.Width - 1, location.Top + size.Height - 1);
            }

            ConsoleAdapter.MoveCursor(location.Left, location.Top);
            ConsoleAdapter.Write(borderCharType.TopLeftChar);

            ConsoleAdapter.MoveCursor(location.Left, location.Top + size.Height - 1);
            ConsoleAdapter.Write(borderCharType.BottomLeftChar);

            ConsoleAdapter.MoveCursor(location.Left + size.Width - 1, location.Top);
            ConsoleAdapter.Write(borderCharType.TopRightChar);
            ConsoleAdapter.BackgroundColor = previousBackground;
            ConsoleAdapter.ForegroundColor = previousForeground;
        }