Пример #1
0
        private void DrawTitleLeft(ContainerBuffer buffer)
        {
            var counter = 0;

            for (var i = 3; i < Math.Min(Size.Width, Title.Length) - 3; i++)
            {
                buffer[i, 1] = new ConsoleElement(Title[counter], ForegroundColor, BackgroundColor);
                counter++;
            }
        }
Пример #2
0
        private void DrawTitleRight(ContainerBuffer buffer)
        {
            var counter = 0;

            for (var i = Size.Width - 3; i > Math.Max(3, Size.Width - 3 - Title.Length); i++)
            {
                buffer[i, 1] = new ConsoleElement(Title[counter], ForegroundColor, BackgroundColor);
                counter++;
            }
        }
Пример #3
0
        internal override ContainerBuffer CreateContainerBuffer()
        {
            var buffer = new ContainerBuffer(Size);

            DrawBorder(buffer);

            if (!string.IsNullOrEmpty(Title))
            {
                DrawTitle(buffer);
            }

            return(buffer);
        }
Пример #4
0
        private void DrawTitleCenter(ContainerBuffer buffer)
        {
            var start = Math.Max(3, Size.Width / 2 - Title.Length / 2);
            var end   = Math.Min(Size.Width - 3, Title.Length);

            var counter = 0;

            for (var i = start; i < end; i++)
            {
                buffer[i, 1] = new ConsoleElement(Title[counter], ForegroundColor, BackgroundColor);
                counter++;
            }
        }
Пример #5
0
 private void DrawBorder(ContainerBuffer buffer)
 {
     for (var y = 0; y < Size.Height; y++)
     {
         for (var x = 0; x < Size.Width; x++)
         {
             if (y == 0)
             {
                 if (x == 0)
                 {
                     buffer[x, y] = new ConsoleElement(Border.TopLeftCorner, ForegroundColor, BackgroundColor);
                 }
                 else if (x == Size.Width - 1)
                 {
                     buffer[x, y] = new ConsoleElement(Border.TopRightCorner, ForegroundColor, BackgroundColor);
                 }
                 else
                 {
                     buffer[x, y] = new ConsoleElement(Border.HorizontalLine, ForegroundColor, BackgroundColor);
                 }
             }
             else if (y == Size.Height - 1)
             {
                 if (x == 0)
                 {
                     buffer[x, y] = new ConsoleElement(Border.BottomLeftCorner, ForegroundColor, BackgroundColor);
                 }
                 else if (x == Size.Width - 1)
                 {
                     buffer[x, y] = new ConsoleElement(Border.BottomRightCorner, ForegroundColor, BackgroundColor);
                 }
                 else
                 {
                     buffer[x, y] = new ConsoleElement(Border.HorizontalLine, ForegroundColor, BackgroundColor);
                 }
             }
             else
             {
                 if (x == 0 || x == Size.Width - 1)
                 {
                     buffer[x, y] = new ConsoleElement(Border.VerticalLine, ForegroundColor, BackgroundColor);
                 }
                 else
                 {
                     buffer[x, y] = new ConsoleElement(' ', ForegroundColor, BackgroundColor);
                 }
             }
         }
     }
 }
Пример #6
0
        private void DrawTitle(ContainerBuffer buffer)
        {
            switch (TitleAlignment)
            {
            case TextAlignment.Left:
                DrawTitleLeft(buffer);
                break;

            case TextAlignment.Right:
                DrawTitleRight(buffer);
                break;

            case TextAlignment.Center:
                DrawTitleCenter(buffer);
                break;

            default:
                throw new NotImplementedException();
            }
        }