2014-11-23 20:57:25 +00:00
|
|
|
using MediaBrowser.Controller;
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
using MediaBrowser.Controller.Localization;
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
using MediaBrowser.Server.Startup.Common.Browser;
|
2014-11-21 17:13:21 +00:00
|
|
|
using System;
|
|
|
|
using MonoMac.Foundation;
|
|
|
|
using MonoMac.AppKit;
|
|
|
|
|
2014-11-21 17:20:28 +00:00
|
|
|
namespace MediaBrowser.Server.Mac
|
2014-11-21 17:13:21 +00:00
|
|
|
{
|
|
|
|
[Register("AppController")]
|
|
|
|
public partial class AppController : NSObject
|
|
|
|
{
|
2014-11-23 20:57:25 +00:00
|
|
|
private NSMenuItem browseMenuItem;
|
|
|
|
private NSMenuItem configureMenuItem;
|
|
|
|
private NSMenuItem developerMenuItem;
|
|
|
|
private NSMenuItem quitMenuItem;
|
|
|
|
private NSMenuItem githubMenuItem;
|
|
|
|
private NSMenuItem apiMenuItem;
|
|
|
|
private NSMenuItem communityMenuItem;
|
|
|
|
|
2014-11-21 17:13:21 +00:00
|
|
|
public AppController()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void AwakeFromNib()
|
|
|
|
{
|
2014-11-22 16:38:48 +00:00
|
|
|
var statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
|
|
|
|
statusItem.Menu = statusMenu;
|
|
|
|
statusItem.Image = NSImage.ImageNamed("touchicon");
|
|
|
|
statusItem.HighlightMode = true;
|
2014-11-21 17:13:21 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
statusItem.Menu.RemoveAllItems ();
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
|
|
|
|
Browse (this);
|
|
|
|
});
|
|
|
|
statusItem.Menu.AddItem (browseMenuItem);
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
|
|
|
|
Configure (this);
|
|
|
|
});
|
|
|
|
statusItem.Menu.AddItem (configureMenuItem);
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
developerMenuItem = new NSMenuItem ("Developer Resources");
|
|
|
|
statusItem.Menu.AddItem (developerMenuItem);
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
var developerMenu = new NSMenu ();
|
|
|
|
developerMenuItem.Submenu = developerMenu;
|
|
|
|
|
|
|
|
apiMenuItem = new NSMenuItem ("Api Documentation", "a", delegate {
|
|
|
|
ApiDocs (this);
|
|
|
|
});
|
|
|
|
developerMenu.AddItem (apiMenuItem);
|
|
|
|
|
|
|
|
githubMenuItem = new NSMenuItem ("Github", "g", delegate {
|
|
|
|
Github (this);
|
|
|
|
});
|
|
|
|
developerMenu.AddItem (githubMenuItem);
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
|
|
|
|
Community (this);
|
|
|
|
});
|
|
|
|
statusItem.Menu.AddItem (communityMenuItem);
|
|
|
|
|
|
|
|
quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
|
|
|
|
Quit (this);
|
|
|
|
});
|
|
|
|
statusItem.Menu.AddItem (quitMenuItem);
|
2014-11-22 17:15:33 +00:00
|
|
|
}
|
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
private IServerApplicationHost AppHost{ get; set;}
|
|
|
|
private ILogger Logger{ get; set;}
|
|
|
|
|
|
|
|
private void Quit(NSObject sender)
|
2014-11-22 17:15:33 +00:00
|
|
|
{
|
2014-11-23 20:57:25 +00:00
|
|
|
NSApplication.SharedApplication.Terminate(this);
|
|
|
|
//AppHost.Shutdown();
|
|
|
|
}
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
private void Community(NSObject sender)
|
|
|
|
{
|
|
|
|
BrowserLauncher.OpenCommunity(Logger);
|
2014-11-22 17:15:33 +00:00
|
|
|
}
|
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
private void Configure(NSObject sender)
|
2014-11-22 17:15:33 +00:00
|
|
|
{
|
2014-11-23 20:57:25 +00:00
|
|
|
BrowserLauncher.OpenDashboard(AppHost, Logger);
|
|
|
|
}
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
private void Browse(NSObject sender)
|
|
|
|
{
|
|
|
|
BrowserLauncher.OpenWebClient(AppHost, Logger);
|
2014-11-22 17:15:33 +00:00
|
|
|
}
|
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
private void Github(NSObject sender)
|
2014-11-22 17:15:33 +00:00
|
|
|
{
|
2014-11-23 20:57:25 +00:00
|
|
|
BrowserLauncher.OpenGithub(Logger);
|
|
|
|
}
|
2014-11-22 17:15:33 +00:00
|
|
|
|
2014-11-23 20:57:25 +00:00
|
|
|
private void ApiDocs(NSObject sender)
|
|
|
|
{
|
|
|
|
BrowserLauncher.OpenSwagger(AppHost, Logger);
|
2014-11-21 17:13:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|