From 5f5fec429e47aab1e00278ce9072c6525bff1da1 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 23 Nov 2014 19:02:01 -0500 Subject: update mac project --- MediaBrowser.Server.Mac/AppController.cs | 51 ++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'MediaBrowser.Server.Mac/AppController.cs') diff --git a/MediaBrowser.Server.Mac/AppController.cs b/MediaBrowser.Server.Mac/AppController.cs index d2ef0cd92..1823e2152 100644 --- a/MediaBrowser.Server.Mac/AppController.cs +++ b/MediaBrowser.Server.Mac/AppController.cs @@ -20,9 +20,11 @@ namespace MediaBrowser.Server.Mac private NSMenuItem apiMenuItem; private NSMenuItem communityMenuItem; + public static AppController Instance; + public AppController() { - + Instance = this; } public override void AwakeFromNib() @@ -71,13 +73,14 @@ namespace MediaBrowser.Server.Mac statusItem.Menu.AddItem (quitMenuItem); } - private IServerApplicationHost AppHost{ get; set;} - private ILogger Logger{ get; set;} + public IServerApplicationHost AppHost{ get; set;} + public IServerConfigurationManager ConfigurationManager { get; set;} + public ILogger Logger{ get; set;} + public ILocalizationManager Localization { get; set;} private void Quit(NSObject sender) { - NSApplication.SharedApplication.Terminate(this); - //AppHost.Shutdown(); + AppHost.Shutdown(); } private void Community(NSObject sender) @@ -104,6 +107,44 @@ namespace MediaBrowser.Server.Mac { BrowserLauncher.OpenSwagger(AppHost, Logger); } + + public void Terminate() + { + InvokeOnMainThread (() => NSApplication.SharedApplication.Terminate(this)); + } + + private string _uiCulture; + /// + /// Handles the ConfigurationUpdated event of the Instance control. + /// + /// The source of the event. + /// The instance containing the event data. + void Instance_ConfigurationUpdated(object sender, EventArgs e) + { + if (!string.Equals(ConfigurationManager.Configuration.UICulture, _uiCulture, + StringComparison.OrdinalIgnoreCase)) + { + LocalizeText(); + } + } + + private void LocalizeText() + { + _uiCulture = ConfigurationManager.Configuration.UICulture; + + BeginInvokeOnMainThread (LocalizeInternal); + } + + private void LocalizeInternal() { + + quitMenuItem.Title = Localization.GetLocalizedString("LabelExit"); + communityMenuItem.Title = Localization.GetLocalizedString("LabelVisitCommunity"); + githubMenuItem.Title = Localization.GetLocalizedString("LabelGithub"); + apiMenuItem.Title = Localization.GetLocalizedString("LabelApiDocumentation"); + developerMenuItem.Title = Localization.GetLocalizedString("LabelDeveloperResources"); + browseMenuItem.Title = Localization.GetLocalizedString("LabelBrowseLibrary"); + configureMenuItem.Title = Localization.GetLocalizedString("LabelConfigureMediaBrowser"); + } } } -- cgit v1.2.3