/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. using System;
  19. using System.Collections.Generic;
  20. using System.IO;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Threading;
  24. using System.Windows;
  25. using System.Windows.Controls;
  26. using System.Windows.Data;
  27. using System.Windows.Documents;
  28. using System.Windows.Input;
  29. using System.Windows.Media;
  30. using System.Windows.Media.Imaging;
  31. using System.Windows.Shapes;
  32. using System.Windows.Threading;
  33. namespace Stoffi
  34. {
  35. /// <summary>
  36. /// Interaction logic for UpgradeProgress.xaml
  37. /// </summary>
  38. public partial class CloseProgress : Window
  39. {
  40. /// <summary>
  41. /// Creates an instance of the UpgradeProgress control
  42. /// </summary>
  43. public CloseProgress()
  44. {
  45. InitializeComponent();
  46. }
  47. /// <summary>
  48. /// Invoked when the control is loaded
  49. /// </summary>
  50. /// <param name="sender">The sender of the event</param>
  51. /// <param name="e">The event data</param>
  52. private void Window_Loaded(object sender, RoutedEventArgs e)
  53. {
  54. FilesystemManager.ProgramIsClosed = true;
  55. progressBar.Maximum = 2000;
  56. progressBar.Value = 0;
  57. progressBar.IsIndeterminate = true;
  58. double max = progressBar.Maximum;
  59. ThreadStart CloseThread = delegate()
  60. {
  61. Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
  62. {
  63. progressLabel.Content = U.T("SavingSettings", "Content");
  64. }));
  65. SettingsManager.Save();
  66. if (UpgradeManager.Pending)
  67. {
  68. Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
  69. {
  70. progressLabel.Content = U.T("UpgradeInProgress");
  71. }));
  72. UpgradeManager.Finish();
  73. }
  74. UpgradeManager.Clean();
  75. MediaManager.Clean();
  76. Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
  77. {
  78. progressLabel.Content = U.T("Closing", "Content");
  79. }));
  80. Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
  81. {
  82. this.Close();
  83. }));
  84. };
  85. Thread closeThread = new Thread(CloseThread);
  86. closeThread.Name = "Close thread";
  87. closeThread.Priority = ThreadPriority.Normal;
  88. closeThread.Start();
  89. }
  90. }
  91. }