Salut,
je débute en C# et je travaille sur un petit logiciel MultiFonction avec un SplashScreen au démarrage:
Ma classe LoadFunction.cs:
Ma form FSplash.cs:
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
32
33
34
35
36
37
38
39
40
41
42
43 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MultiThing.Splash { class LoadFunction { FSplash splash = new FSplash(); public void LoadLibrairies() { splash.txtLoad.Text = "Chargement des librairies..."; splash.txtLoad.Refresh(); splash.barLoad.Value = 0; } public void LoadFiles() { splash.txtLoad.Text = "Chargement des fichiers..."; splash.barLoad.Value = 20; } public void LoadPlugins() { splash.txtLoad.Text = "Chargement des plugins..."; splash.barLoad.Value = 40; } public void LoadPrefs() { splash.txtLoad.Text = "Chargement des préférences utilisateurs..."; splash.barLoad.Value = 60; } public void LoadCache() { splash.txtLoad.Text = "Mise en cache..."; splash.barLoad.Value = 80; } public void Starting() { splash.txtLoad.Text = "C'est parti !"; splash.barLoad.Value = 100; } } }
Vous allez dire que sa charge rien mais oui car je n'ai pas encore developpé tous le reste du programme ^^
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
32
33
34
35
36
37 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; using System.Timers; using MultiThing.Splash; namespace MultiThing { public partial class FSplash : Form { public FSplash() { LoadFunction Load = new LoadFunction(); InitializeComponent(); Thread.Sleep(2000); Load.LoadLibrairies(); Thread.Sleep(2000); Load.LoadFiles(); Thread.Sleep(2000); Load.LoadPlugins(); Thread.Sleep(2000); Load.LoadPrefs(); Thread.Sleep(2000); Load.LoadCache(); Thread.Sleep(2000); Load.Starting(); Thread.Sleep(2000); } } }
Et enfete sa affiche ma form que apprès avoir fini les Thread.Sleep, 14 secondes après donc avec le message "C'est parti !"
J'ai aussi essayé avec un Timer mais je n'ai plus le code sous la main et j'avais des erreurs.
Merci d'avance
PS: J'espère être dans la bonne catégorie ^^
Partager