C#控制台滚动 [英] C# Console Scrolling

查看:260
本文介绍了C#控制台滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我只是想到了一个游戏的好主意,我想马上开始使用它,唯一的是,我需要能够左右滚动.在C#控制台中,如果您在右边写的太多了,那么文本就落到了下一行,我希望能够扩展该限制,以便它可以越过屏幕,并且您需要滚动才能看到它,但是当达到幕帘字符限制时,它将下降到下一行.请帮忙!

hey guys,

i just thought of a great idea for a game and i want to get started on it right away, the only thing is, i need to be able to scroll left and right. In C# Console, if you write too much to the right, then the text just goes down onto the next line, i want to be able to extend that limit so that it can go past the screen and you need to scroll to see it, but when it reaches a curtain character limit, it goes down onto the next line. Please Help!

推荐答案

更好的方法是在内存中保留一个大小与木板"大小相同的缓冲区,然后仅画出木板的一部分即可.在屏幕上可见.如果您尝试使用Console API进行操作,则最终会出现滚动条,这将使您难以忍受.

坦白说,您可以在Windows窗体中执行此操作而无需控制台窗口,并且具有更好的性能和控制力.您可以根据需要以任何方式绘制文本,最好使用等距字体,并且如果不需要的话,也不必具有任何奇特的"图形.只需在需要的地方画出文字即可.

哦,缓冲技术在Windows窗体中的工作原理比在控制台中更好.
The better way of doing this would be to keep a buffer in memory the size of your "board", then just draw the portion of the board that is visible on screen. If you try to do it using the Console API, you''ll end up with scroll bars that will be a pain in the ass to work with.

Frankly, you can do this in Windows Forms WITHOUT a console window and have better performance and control. You can draw your text any way you want, preferrably using a mono-spaced font, and you don''t have to have any of the "fancy" graphics if you don''t want to. Just draw the text where it needs to go.

Oh, the buffering technique works even better in Windows Forms than it does in a console.


这篇关于C#控制台滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆