App.xaml.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Windows;
  5. using MediaBrowser.Controller;
  6. using Microsoft.Shell;
  7. namespace MediaBrowser.ServerApplication
  8. {
  9. /// <summary>
  10. /// Interaction logic for App.xaml
  11. /// </summary>
  12. public partial class App : Application, ISingleInstanceApp
  13. {
  14. private const string Unique = "MediaBrowser3";
  15. [STAThread]
  16. public static void Main()
  17. {
  18. if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
  19. {
  20. var application = new App();
  21. application.InitializeComponent();
  22. application.Run();
  23. // Allow single instance code to perform cleanup operations
  24. SingleInstance<App>.Cleanup();
  25. }
  26. }
  27. #region ISingleInstanceApp Members
  28. public bool SignalExternalCommandLineArgs(IList<string> args)
  29. {
  30. OpenDashboard();
  31. return true;
  32. }
  33. #endregion
  34. protected override void OnExit(ExitEventArgs e)
  35. {
  36. base.OnExit(e);
  37. Kernel.Instance.Dispose();
  38. }
  39. public static void OpenDashboard()
  40. {
  41. using (Process process = Process.Start("http://localhost:" + Kernel.Instance.Configuration.HttpServerPortNumber + "/mediabrowser/dashboard/index.html"))
  42. {
  43. }
  44. }
  45. }
  46. }