MainWindow.xaml.cs 2.0 KB

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