C#打印带文本的文本框

时间:2015-01-24 09:45:36

标签: c# console cursor ascii offset

我试图模拟文本框式游戏口袋妖怪。我把句子读成.txt文件,当字符符合文本框框架的边缘时,应该换行并继续写。我尝试使用这种方法,但它不起作用。我知道你有帮助吗?

public void DrawTextBox()
{
    //CONTROLLO INPUT
    ConsoleKeyInfo key = Console.ReadKey(true);

    switch (key.Key)
    {
        case ConsoleKey.Spacebar:
            isPress = true;
            break;
    }

    //STAMPO
    if (isPress ==true)
    {
        for (i = 0; i < Height; i++)
        {
           Console.CursorTop = Offset.y + i;

            for (j = 0; j < Width; j++)
            {
                Console.CursorLeft = Offset.x + j;

                if (Console.CursorLeft == Width - Offset.x)
                {
                    Console.CursorTop+=1;
                    Console.CursorLeft = 0;
                }

                else
                    Console.Write(Dialog[i, j].Char);

                Thread.Sleep(200);
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

为该文本框启用多行属性