PageRenderTime 15ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Application/GUI/Windows/CloseProgress.xaml.cs

http://yet-another-music-application.googlecode.com/
C# | 96 lines | 63 code | 5 blank | 28 comment | 1 complexity | e178875d65fdb53cfaf7aec0362d5b6b MD5 | raw file
 1/**
 2 * CloseProgress.cs
 3 * 
 4 * A window that performs the closing progress
 5 * 
 6 * * * * * * * * *
 7 * 
 8 * This code is part of the Stoffi Music Player Project.
 9 * Visit our website at: stoffiplayer.com
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 3 of the License, or (at your option) any later version.
15 * 
16 * See stoffiplayer.com/license for more information.
17 **/
18
19using System;
20using System.Collections.Generic;
21using System.IO;
22using System.Linq;
23using System.Text;
24using System.Threading;
25using System.Windows;
26using System.Windows.Controls;
27using System.Windows.Data;
28using System.Windows.Documents;
29using System.Windows.Input;
30using System.Windows.Media;
31using System.Windows.Media.Imaging;
32using System.Windows.Shapes;
33using System.Windows.Threading;
34
35namespace Stoffi
36{
37	/// <summary>
38	/// Interaction logic for UpgradeProgress.xaml
39	/// </summary>
40	public partial class CloseProgress : Window
41	{
42		/// <summary>
43		/// Creates an instance of the UpgradeProgress control
44		/// </summary>
45		public CloseProgress()
46		{
47			InitializeComponent();
48		}
49
50		/// <summary>
51		/// Invoked when the control is loaded
52		/// </summary>
53		/// <param name="sender">The sender of the event</param>
54		/// <param name="e">The event data</param>
55		private void Window_Loaded(object sender, RoutedEventArgs e)
56		{
57			FilesystemManager.ProgramIsClosed = true;
58			progressBar.Maximum = 2000;
59			progressBar.Value = 0;
60			progressBar.IsIndeterminate = true;
61			double max = progressBar.Maximum;
62
63			ThreadStart CloseThread = delegate()
64			{
65				Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
66				{
67					progressLabel.Content = U.T("SavingSettings", "Content");
68				}));
69				SettingsManager.Save();
70				if (UpgradeManager.Pending)
71				{
72					Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
73					{
74						progressLabel.Content = U.T("UpgradeInProgress");
75					}));
76					UpgradeManager.Finish();
77				}
78				UpgradeManager.Clean();
79				MediaManager.Clean();
80
81				Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
82				{
83					progressLabel.Content = U.T("Closing", "Content");
84				}));
85				Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
86				{
87					this.Close();
88				}));
89			};
90			Thread closeThread = new Thread(CloseThread);
91			closeThread.Name = "Close thread";
92			closeThread.Priority = ThreadPriority.Normal;
93			closeThread.Start();
94		}
95	}
96}