.NET 中使用 GDI 的可滚动控件和区域
我无法理解使用 C#、.NET 3.5 和 GDI+ 在自定义控件中创建可滚动区域的正确方法。
Microsoft 是否有任何关于执行此操作的正确方法的文档?网络上有没有像样的入门书?
我的担忧主要是:如果我在内存中创建一个大型图形画布,那么关于画布可以(并且应该)有多大的具体细节是什么?性能方面有哪些考虑?我应该提前渲染多少可滚动区域?
例如,如果我要根据预先存在的数据渲染一个非常大的图形,我是否应该将整个图形渲染到图形内存,然后将其传输到“可滚动”区域?或者,这会耗尽可用的图形相关内存并开始写入页面文件吗?
澄清:
例如,您的网络浏览器不会在您每次滚动时通过重新渲染所有元素来“重绘”客户区域。页面的静态元素一次渲染到一个大表面上,当您移动滚动条时,预渲染的起始偏移量会被简单地修改。
这就是我想要的行为。我不想在绘画事件上“绘制滚动范围的开始值和结束值之间的内容”。
I am having trouble understanding the proper way to create a scrollable area within a custom control using C#, .NET 3.5 and GDI+.
Is there any documentation from Microsoft about the correct way to go about doing so? Is there a decent primer anywhere on the web?
My concerns are mainly: if I create a large graphical canvas in memory, what are the specific details about how large the canvas can (and should be)? What are the performance considerations? How much of the scrollable area should I render in advance?
For example, if I were rendering a very large graphical plot from pre-existing data, should I just render the ENTIRE plot to graphic memory and then blit it into the "scrollable" area? Or, would that exhaust available graphic related memory and start writing into the paging file?
Clarification:
For example, your web-broser isn't "redrawing" the client area everytime you scroll by re-rendering all of the elements. Static elements of the page are rendered once to a large surface, and when you move the scroll bar, the starting offset of the pre-render is simply modified.
That is the sort of behavior I'm going for. I don't want to "draw the content that would be between the start and end values for my scroll range" on paint events.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在谈论 WinForms - 从 ScrollableControl 派生您的控件。定义客户端大小并在 OnPaint 中绘制适当的部分。
该控件为您处理所有滚动细节
If you are talking WinForms - derive your control from ScrollableControl. Define the Client Size and just paint the appropriate portion in OnPaint.
The control handles all scrolling details for you