Bonjour,
Je voudrais avoir une progressBar au lancement de mon application le temps que l'application se charge.
Comment puis je mesurer le temps que l'application prend à se charger?
Bonjour,
Je voudrais avoir une progressBar au lancement de mon application le temps que l'application se charge.
Comment puis je mesurer le temps que l'application prend à se charger?
Jette un oeil la dessus, ca t'aidera p-e: http://ligao101.wordpress.com/2007/0...ss-bar-in-wpf/
Thomas LEBRUN: MCAD.NET, MCTS (Win et Web), MCPD(Win et Web) & Microsoft MVP Client Application Development
WPF par la pratique, mon livre sur WPF ! (également disponible ici ou là)
A la découverte de .NET
j'ai moi meme fait un splash pour une application avec un progress bar
voic i le code du spash screen
voic le code de l'appilication
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 ///<summary> /// Interaction logic for Splash.xaml ///</summary> publicpartialclassSplash : Window { //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ public Splash() { InitializeComponent(); this.Loaded += newRoutedEventHandler(Splash_Loaded); this.Version.Content = Assembly.GetEntryAssembly().GetName().Version.ToString(); } //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ void Splash_Loaded(object sender, RoutedEventArgs e) { IAsyncResult result = null; // This is an anonymous delegate that will be called when the initialization has COMPLETED AsyncCallback initCompleted = delegate(IAsyncResult ar) { App.Current.ApplicationInitialize.EndInvoke(result); // Ensure we call close on the UI Thread. Dispatcher.BeginInvoke(DispatcherPriority.Normal, (App.Invoker)delegate { Close(); }); }; // This starts the initialization process on the Application result = App.Current.ApplicationInitialize.BeginInvoke(this, initCompleted, null); } //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ publicvoid SetProgress(double progress) { // Ensure we update on the UI Thread. Dispatcher.BeginInvoke(DispatcherPriority.Normal, (App.Invoker)delegate { progBar.Value = progress; }); } //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ } //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
evidement tu lance la splash screen
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
44
45
46
47 ///<summary> /// Interaction logic for App.xaml ///</summary> publicpartialclassApp : Application { internaldelegatevoidInvoker(); public App() { ApplicationInitialize = _applicationInitialize; object ob = Application.Current.Resources; } publicstaticnewApp Current { get { returnApplication.Current asApp; } } internaldelegatevoidApplicationInitializeDelegate(Splash splashWindow); internalApplicationInitializeDelegate ApplicationInitialize; privatevoid _applicationInitialize(Splash splashWindow) { // fake workload, but with progress updates. Thread.Sleep(500); splashWindow.SetProgress(0.2); Thread.Sleep(500); splashWindow.SetProgress(0.4); Thread.Sleep(500); splashWindow.SetProgress(0.6); Thread.Sleep(500); splashWindow.SetProgress(0.8); Thread.Sleep(500); splashWindow.SetProgress(1); // Create the main window, but on the UI thread. Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Invoker)delegate { MainWindow = newMainWindow2(); MainWindow.Show(); }); } //[STAThreadAttribute()] //public static void Main() //{ // App app = new App(); // app.Run(new Splash()); //} }
je suis pas sur a 100% que ca reponde bien a ton besoin cmais c'est une piste de recherche tout de meme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <Applicationx:Class="SentinelSAS.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Splash.xaml"ShutdownMode="OnMainWindowClose"> </Application>
Thomas LEBRUN: MCAD.NET, MCTS (Win et Web), MCPD(Win et Web) & Microsoft MVP Client Application Development
WPF par la pratique, mon livre sur WPF ! (également disponible ici ou là)
A la découverte de .NET
Partager