aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/App.xaml.cs
blob: db229905d29ba73442e9adb2d663c5beec5a17b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.UI;
using MediaBrowser.Controller;
using Microsoft.Shell;

namespace MediaBrowser.ServerApplication
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : BaseApplication, ISingleInstanceApp
    {
        private const string Unique = "MediaBrowser3";

        [STAThread]
        public static void Main()
        {
            if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
            {
                var application = new App();
                application.InitializeComponent();

                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance<App>.Cleanup();
            }
        }
        
        #region ISingleInstanceApp Members
        public bool SignalExternalCommandLineArgs(IList<string> args)
        {
            OpenDashboard();

            return true;
        }
        #endregion

        public static void OpenDashboard()
        {
            using (Process process = Process.Start("http://localhost:" + Kernel.Instance.Configuration.HttpServerPortNumber + "/mediabrowser/dashboard/index.html"))
            {
            }
        }

        protected override IKernel InstantiateKernel()
        {
            return new Kernel();
        }

        protected override Window InstantiateMainWindow()
        {
            return new MainWindow();
        }
    }
}