PowerArgs.Cli.ConsoleBitmap.DrawString C# (CSharp) Method

DrawString() public method

public DrawString ( string str, int x, int y, bool vert = false ) : void
str string
x int
y int
vert bool
return void
        public void DrawString(string str, int x, int y, bool vert = false)
        {
            DrawString(new ConsoleString(str), x, y, vert);
        }

Same methods

ConsoleBitmap::DrawString ( ConsoleString str, int x, int y, bool vert = false ) : void

Usage Example

Example #1
0
        /// <summary>
        /// paints the text box
        /// </summary>
        /// <param name="context"></param>
        protected override void OnPaint(ConsoleBitmap context)
        {
            var toPaint = textState.CurrentValue;

            var offset = 0;

            if (toPaint.Length >= Width && textState.CursorPosition > Width - 1)
            {
                offset  = (textState.CursorPosition + 1) - Width;
                toPaint = toPaint.Substring(offset);
            }

            var bgTransformed = new List <ConsoleCharacter>();

            foreach (var c in toPaint)
            {
                if (c.BackgroundColor == ConsoleString.DefaultBackgroundColor && Background != ConsoleString.DefaultBackgroundColor)
                {
                    bgTransformed.Add(new ConsoleCharacter(c.Value, Foreground, Background));
                }
                else
                {
                    bgTransformed.Add(c);
                }
            }

            context.DrawString(new ConsoleString(bgTransformed), 0, 0);

            if (blinkState && BlinkEnabled)
            {
                char blinkChar = textState.CursorPosition >= toPaint.Length ? ' ' : toPaint[textState.CursorPosition].Value;
                var  pen       = new ConsoleCharacter(blinkChar, DefaultColors.FocusContrastColor, DefaultColors.FocusColor);
                context.DrawPoint(pen, textState.CursorPosition - offset, 0);
            }
        }
All Usage Examples Of PowerArgs.Cli.ConsoleBitmap::DrawString