Beispiel #1
0
        protected virtual void DrawTitle(ConsoleGraphics g)
        {
            var maxCharacters = g.Width - 2 - ReserveRightAreaTitle;
            var text          = (this.Title = this.Title == null ? string.Empty : this.Title).TruncWords(maxCharacters);
            var trailing      = "";

            switch (this.TitlePosition)
            {
            case EnumTitlePosition.Right:
                for (var i = 0; i < maxCharacters - text.Length; i++)
                {
                    trailing += ' ';
                }
                break;

            case EnumTitlePosition.Center:
                var leftAdd = (maxCharacters - text.Length) / 2;
                for (var i = 0; i < leftAdd; i++)
                {
                    trailing += ' ';
                }
                break;
            }
            text = $"{trailing}{text}";
            g.DrawText(1, 0, text, this.ForegroundColor);
        }