VidU Posted April 30, 2008 at 09:12 PM Report Share #182726 Posted April 30, 2008 at 09:12 PM Boas queria saber se existe alguma funçao predefinida que me permita desenhar a mesma imagem varias vezes no form, sem "substituir" a anterior? por exemplo: public void Draww(Graphics g) { int x=10; int y=10; SolidBrush castanho = new SolidBrush(Color.Brown); Rectangle rect = new Rectangle(x, y, 65, 70); g.FillRectangle(castanho, rect); } Ao chamar esta funçao no evento Paint, ele vai me desenhar um rectangulo castanho nas coordenadas 10,10, mas se eu voltar a chamar a funçao e se x=20 e y=20, o rectangulo das coordenadas 10,10 ira desaparecer, e aparecer este novo nas cordenadas 20,20. Portanto o que eu pretendia era uma funçao que me permitisse ter os dois rectangulos desenhados, ou seja, sempre que queira desenhar um rectangulo, ele acrescentar um rectangulo ao formulario inves de o substituir. Cumps 😉 Link to comment Share on other sites More sharing options...
Betovsky Posted April 30, 2008 at 09:21 PM Report Share #182729 Posted April 30, 2008 at 09:21 PM Hmm... assim de imediato diria que o parâmetro (ou seja, Graphics g) vem sem o rectângulo previamente. Não tem lógica desenhares 1 rectângulo e o outro desaparecer, por isso é que penso que no evento Paint o rectângulo antigo já desapareceu. Mas tenho que testar primeiro, tudo o que disse foram suposições. "Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !" Sign on a computer system consultant's desk Link to comment Share on other sites More sharing options...
VidU Posted May 1, 2008 at 06:44 PM Author Report Share #182868 Posted May 1, 2008 at 06:44 PM ok esqueçam.. lol Decidi resolver o meu problema atraves de array que vai guardar as coordenadas onde tem de desenhar o rectangulo..assim consigo pintar diversos rectangulos. obrigado 😉 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now