2012-08-04 16:54:00 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2012-08-12 11:12:59 -07:00
|
|
|
|
using System.Diagnostics;
|
2012-08-04 16:54:00 -07:00
|
|
|
|
using System.Windows;
|
2012-08-19 15:47:02 -07:00
|
|
|
|
using MediaBrowser.Common.Kernel;
|
2012-08-19 15:35:45 -07:00
|
|
|
|
using MediaBrowser.Common.UI;
|
2012-08-04 18:13:32 -07:00
|
|
|
|
using MediaBrowser.Controller;
|
2012-08-12 11:12:59 -07:00
|
|
|
|
using Microsoft.Shell;
|
2012-08-04 16:54:00 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.ServerApplication
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for App.xaml
|
|
|
|
|
/// </summary>
|
2012-08-19 15:47:02 -07:00
|
|
|
|
public partial class App : BaseApplication, ISingleInstanceApp
|
2012-08-04 16:54:00 -07:00
|
|
|
|
{
|
2012-08-04 19:44:08 -07:00
|
|
|
|
private const string Unique = "MediaBrowser3";
|
2012-08-12 11:12:59 -07:00
|
|
|
|
|
2012-08-04 19:44:08 -07:00
|
|
|
|
[STAThread]
|
|
|
|
|
public static void Main()
|
|
|
|
|
{
|
|
|
|
|
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
|
|
|
|
|
{
|
|
|
|
|
var application = new App();
|
|
|
|
|
application.InitializeComponent();
|
2012-08-19 15:35:45 -07:00
|
|
|
|
|
2012-08-04 19:44:08 -07:00
|
|
|
|
application.Run();
|
2012-08-19 15:35:45 -07:00
|
|
|
|
|
2012-08-04 19:44:08 -07:00
|
|
|
|
// Allow single instance code to perform cleanup operations
|
|
|
|
|
SingleInstance<App>.Cleanup();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-11 12:37:14 -07:00
|
|
|
|
|
2012-08-04 19:44:08 -07:00
|
|
|
|
#region ISingleInstanceApp Members
|
|
|
|
|
public bool SignalExternalCommandLineArgs(IList<string> args)
|
|
|
|
|
{
|
2012-08-05 09:09:45 -07:00
|
|
|
|
OpenDashboard();
|
|
|
|
|
|
2012-08-04 19:44:08 -07:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2012-08-05 09:09:45 -07:00
|
|
|
|
public static void OpenDashboard()
|
|
|
|
|
{
|
2012-09-11 12:37:14 -07:00
|
|
|
|
OpenUrl("http://localhost:" + Kernel.Instance.Configuration.HttpServerPortNumber +
|
|
|
|
|
"/mediabrowser/dashboard/index.html");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void OpenUrl(string url)
|
|
|
|
|
{
|
|
|
|
|
var process = new Process
|
2012-08-12 11:12:59 -07:00
|
|
|
|
{
|
2012-09-11 12:37:14 -07:00
|
|
|
|
StartInfo = new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = url
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
EnableRaisingEvents = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
process.Exited += ProcessExited;
|
|
|
|
|
|
|
|
|
|
process.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ProcessExited(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
(sender as Process).Dispose();
|
2012-08-05 09:09:45 -07:00
|
|
|
|
}
|
2012-08-19 15:47:02 -07:00
|
|
|
|
|
|
|
|
|
protected override IKernel InstantiateKernel()
|
|
|
|
|
{
|
|
|
|
|
return new Kernel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Window InstantiateMainWindow()
|
|
|
|
|
{
|
|
|
|
|
return new MainWindow();
|
|
|
|
|
}
|
2012-08-04 16:54:00 -07:00
|
|
|
|
}
|
|
|
|
|
}
|