我的Paint方法大大影响了我的程序GUI的性能 [英] My Method on Paint drastically effects my program GUI's performance

查看:53
本文介绍了我的Paint方法大大影响了我的程序GUI的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想请求你的帮助,伙计们。由于某些原因,如果我在我的图片框的绘图事件处理程序中包含以下行,则GUI行为非常奇怪(好像它不能绘制所有控件,其中一些是不可见的,或者程序就像在那里一样没有线程)。原因是因为我包含了那些代码行。但它背后的真正原因是什么?是因为Paint事件处理程序试图一直重新绘制控件或什么?

展开 | 选择 | Wrap < span class =codeDivider> | 行号

解决方案

< blockquote>我认为你有一个递归循环。


每次画画时,你都会创建一个新的MyGraph

展开 | 选择 | Wrap | 行号


我明白了,然后我将需要修复你指出的第二行。


我不是说听起来令人沮丧,但我认为你需要做更多的事情。


我可以指出你的Paint处理器实际上并没有画任何东西,而你的MyGraph实际上并没有 返回 一个图形?


我不知道你的整个项目是什么,或者这些是如何融入事物计划的...但我打赌你不需要如果你已经在使用一种方法来构建图像,为Picturebox编写一个自定义的Paint处理程序。


让你的MyGraph方法返回完成的图像(对于任何称为它的方法),然后设定那个返回的图像为PictureBox.Image


Hello everyone,
I would like to ask for your help, guys. For some reasons, if i include the following lines in my paint event handler of my picture box, the GUI acts very weird (as if it cannot "draw" all the controls, some of them are invisible or the program acts as if there is no threading). The reason is because I include those lines of code. But what is the real reason behind it? Is it because Paint event handler tries to re-paint the controls all the time or what?

Expand|Select|Wrap|Line Numbers

解决方案

I think you have a recursive loop going on.

Every time you paint, you make a new MyGraph

Expand|Select|Wrap|Line Numbers


I see, then i will need to fix the second line you pointed out.


I don''t mean to sound disheartening, but I think you will need to do more than that.

May I point out that your Paint handler doesn''t actually paint anything, and that your MyGraph doesn''t actually return a graphic?

I have no idea what your total project is, or how these fit into the scheme of things... but I''m going to bet that you don''t need to write a custom Paint handler for the Picturebox if you are already using a method to build the image.

Have your MyGraph method return the finished image (to whatever method called it), then set that returned image as the PictureBox.Image


这篇关于我的Paint方法大大影响了我的程序GUI的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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