C # Update only PictureBox / Panel when they report update?

I am making a bomber game in a windows C # form application. It has more than 300 pictures (walls) that are placed on the panel. This panel also contains a picture of the scorer himself.

When you change the location of the bombermans carton box, all the controls in the panel are automatically updated. Since there are so many controls on this panel, and because the camera changes its location several times per second, the program becomes broken when you try to move it.

I want to have control over the panel update event (and it controls), because I think my problem is resolved when only the images that need updating are updated, are updated programmatically.

I hope someone can help me!

Ruud.

+3
source share
2 answers

If you move the child, the parent must be updated, because he may need to draw the area in which the child was previously. It also means that all children (parents) will be updated.

OTH, . , , Panel ( ). ( ) / Panel/Parent. .

0

, , , . , , , , Invalidate.

- .

//Invalidate previous position of bomberman
Rectangle invalid = new Rectangle(picturebox1.Location.x,picturebox1.Location.y,picturebox1.Width,picturebox1.Height);
Invalidate(invalid);
//Add code to move your picture box and then call above two lines again
invalid = new Rectangle(picturebox1.Location.x,picturebox1.Location.y,picturebox1.Width,picturebox1.Height);
Invalidate(invalid);

, - ...

. http://msdn.microsoft.com/en-us/library/ms229628.aspx

0

Source: https://habr.com/ru/post/1786601/


All Articles