Example #1
0
        public static void PrintHeader(ICellSurface target, SadConsole.UI.Colors themeColors, Point position, int totalWidth, string text)
        {
            totalWidth = totalWidth - text.Length - 3;

            if (totalWidth < 0)
            {
                throw new Exception("Header text too small");
            }

            var lineText = ColoredString.FromGradient(
                new Gradient(
                    new[] { themeColors.White, themeColors.White, themeColors.Gray, themeColors.Gray, themeColors.GrayDark, themeColors.GrayDark },
                    new[] { 0f, 0.3f, 0.31f, 0.65f, 0.66f, 1f }),
                new string((char)196, totalWidth));

            target.Print(position.X, position.Y, new ColoredString(new ColoredGlyph(themeColors.White, Color.Transparent, 196))
                         + new ColoredString(new ColoredGlyph(themeColors.Cyan, Color.Transparent, 254))
                         + new ColoredString(text, themeColors.Title, Color.Transparent)
                         + new ColoredString(new ColoredGlyph(themeColors.Cyan, Color.Transparent, 254))
                         );

            var targetPosition = Point.FromIndex(position.ToIndex(target.Width) + text.Length + 3, target.Width);

            target.Print(targetPosition.X, targetPosition.Y, lineText);
        }