开发者

how drag a shape in picture box?

I have a project that in those i draw some shape from some layer. For example I h开发者_开发知识库ave two circle in circle Layer and three rectangle in rectangle Layer and so on.I draw the result with call Layer.Draw and marge the layers result with a Graphics object. I can select one shape in picture box and specify it on layer. and i can drag it with redraw its layer and re marge all with graphics.it works ! but too slow!!

how i can optimize this?


in old solution i draw shapes into layer.image and in on Paint event marge they with e.Graphic. I solve this problem with passing the graphic object into layers and draw shapes with it. my program work very good!


Once upon a time I had a project where speed while drawing images was neccessary. I used the unlock method to access the bits directly (http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.unlockbits.aspx). But this method is pretty unsafe and also complicated, so you should avoid this, whenever you can.

Just try to optimize your program and remove unneccesary draws. Primary draws to the GUI are very slow, so try to not update the picture box permanently but only when it is neccesarry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜