Bonjour à tous,
J'ai essayé comme on m'avais précédemment conseillé ici d'utiliser les buffered graphics pour un programme que je suis en train de faire :
un menu avec 5 boutons (images) et qui affiche une image transparente par dessus l'image séléctionnée au moment T.
Mon menu :
A B C [D] E
Tout allait bien, quand je déplaçais avec les flèches ça allait assez vite et tout. Mais depuis que j'ai ajouté un fond à mon programme (en plein écran), il faut presque attendre une seconde quand j'appuie sur la flèche pour passer à l'icone suivante.
Les éléments essentiels de mon code :
Y a-t'il quelque chose que j'ai mal fait ??? ou est-ce que j'ai déja atteint les limites de c# (j'espère pas) ???
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 BufferedGraphicsContext context; BufferedGraphics bufferedGraphics; Graphics g; ... //dans le load : context = new BufferedGraphicsContext(); context.MaximumBuffer = new Size(this.Width + 1, this.Height + 1); bufferedGraphics = context.Allocate(this.CreateGraphics(), new Rectangle(0, 0, this.Width, this.Height)); g = bufferedGraphics.Graphics; ... //Dans la fonction lors que j'appiue sur une flèche du clavier : g.Clear(Color.Black); g.DrawImage(Image.FromFile(@"C:\wall.jpg"), new Point(0, 0)); Image img_over = Image.FromFile(@"C:\over.png"); int espace = (this.Width - (imglist.Images.Count * imglist.ImageSize.Width)) / (imglist.Images.Count + 1); int position_x = 0; for (int i = 0; i < imglist.Images.Count; i++) // 0 ==> 6 { position_x += espace; g.DrawImage(imglist.Images[i], new Point(position_x, (this.Height - imglist.ImageSize.Height) / 2)); if (i == menu_position) { g.DrawImage(img_over, new Point(position_x - ((img_over.Width - imglist.ImageSize.Width) / 2), ((this.Height - imglist.ImageSize.Height) / 2) - ((img_over.Height - imglist.ImageSize.Height) / 2))); } position_x += imglist.ImageSize.Width; } bufferedGraphics.Render();
Merci d'avance pour votre gracieuseaide !!!
Partager