[Admin] tierrilopes Posted February 20, 2017 at 11:41 PM Share Posted February 20, 2017 at 11:41 PM Uma rápida implementação de um slider de imagens. Vídeo: [media] [/media] Código do timer: ++numero_img; if (numero_img >= 5) { numero_img = 1; } if (numero_img == 1) { pictureBox1.Image = TMTPatcher.Properties.Resources.ninja; pictureBox1.Refresh(); } else if (numero_img == 2) { pictureBox1.Image = TMTPatcher.Properties.Resources.shaman; pictureBox1.Refresh(); } else if (numero_img == 3) { pictureBox1.Image = TMTPatcher.Properties.Resources.sura; pictureBox1.Refresh(); } else if (numero_img == 4) { pictureBox1.Image = TMTPatcher.Properties.Resources.warrior; pictureBox1.Refresh(); } Edit: Utilizar o código aqui colocado e não o do vídeo. O do video utiliza while (1=1) e Sleep(5000) que está incorrecto visto já estar dento de um timer. Adicionar apenas o código acima dentro do patcher. Link to comment
[Admin] tierrilopes Posted February 21, 2017 at 01:36 AM Author Share Posted February 21, 2017 at 01:36 AM Caso queiram utilizar imagens alojadas remotamente, substituam: (exemplo dado com ninja, mesmo para os outros) pictureBox1.Image = TMTPatcher.Properties.Resources.ninja; Por: var request = WebRequest.Create("http://url.com/imagem.jpg"); using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) { pictureBox1.Image = Bitmap.FromStream(stream); } Onde http://url.com/imagem.jpg É o endereço completo da imagem. Link to comment
[Admin] tierrilopes Posted May 2, 2017 at 01:30 AM Author Share Posted May 2, 2017 at 01:30 AM Substituir o código do timer por: ++numero_img; switch (numero_img) { case 2: pictureBox1.Image = Properties.Resources.shaman; pictureBox1.Refresh(); break; case 3: pictureBox1.Image = Properties.Resources.sura; pictureBox1.Refresh(); break; case 4: pictureBox1.Image = Properties.Resources.warrior; pictureBox1.Refresh(); break; default: pictureBox1.Image = Properties.Resources.ninja; pictureBox1.Refresh(); numero_img = 1; break; } Link to comment
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