MainWindow.xaml.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Diagnostics;
  3. using System.Windows;
  4. using MediaBrowser.Common.Logging;
  5. using MediaBrowser.Controller;
  6. using MediaBrowser.Model.Progress;
  7. using System.Threading.Tasks;
  8. using MediaBrowser.Common.UI;
  9. namespace MediaBrowser.ServerApplication
  10. {
  11. /// <summary>
  12. /// Interaction logic for MainWindow.xaml
  13. /// </summary>
  14. public partial class MainWindow : Window
  15. {
  16. public MainWindow()
  17. {
  18. InitializeComponent();
  19. LoadKernel();
  20. }
  21. private async void LoadKernel()
  22. {
  23. Progress<TaskProgress> progress = new Progress<TaskProgress>();
  24. Splash splash = new Splash(progress);
  25. splash.Show();
  26. try
  27. {
  28. DateTime now = DateTime.Now;
  29. await new Kernel().Init(progress);
  30. double seconds = (DateTime.Now - now).TotalSeconds;
  31. Logger.LogInfo("Kernel.Init completed in {0} seconds.", seconds);
  32. // Don't show the system tray icon until the kernel finishes.
  33. this.MbTaskbarIcon.Visibility = System.Windows.Visibility.Visible;
  34. }
  35. catch (Exception ex)
  36. {
  37. MessageBox.Show("There was an error launching Media Browser Server: " + ex.Message);
  38. Close();
  39. }
  40. finally
  41. {
  42. splash.Close();
  43. }
  44. }
  45. #region Context Menu events
  46. private void cmOpenDashboard_click(object sender, RoutedEventArgs e)
  47. {
  48. App.OpenDashboard();
  49. }
  50. private void cmVisitCT_click(object sender, RoutedEventArgs e)
  51. {
  52. using (Process process = Process.Start("http://community.mediabrowser.tv/"))
  53. {
  54. }
  55. }
  56. private void cmExit_click(object sender, RoutedEventArgs e)
  57. {
  58. this.Close();
  59. }
  60. #endregion
  61. }
  62. }