2014-05-21 19:33:46 +00:00
|
|
|
|
using MediaBrowser.Controller;
|
2014-02-15 21:17:36 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-03-31 01:00:47 +00:00
|
|
|
|
using MediaBrowser.Controller.Localization;
|
2014-02-15 21:17:36 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2014-11-09 18:24:57 +00:00
|
|
|
|
using MediaBrowser.Server.Startup.Common.Browser;
|
2014-05-21 19:33:46 +00:00
|
|
|
|
using System;
|
2016-07-29 23:44:14 +00:00
|
|
|
|
using System.ComponentModel;
|
2014-05-21 19:33:46 +00:00
|
|
|
|
using System.Windows.Forms;
|
2014-02-15 21:17:36 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.ServerApplication
|
|
|
|
|
{
|
|
|
|
|
public class ServerNotifyIcon : IDisposable
|
|
|
|
|
{
|
2014-11-10 04:20:11 +00:00
|
|
|
|
private NotifyIcon notifyIcon1;
|
|
|
|
|
private ContextMenuStrip contextMenuStrip1;
|
|
|
|
|
private ToolStripMenuItem cmdExit;
|
|
|
|
|
private ToolStripMenuItem cmdBrowse;
|
|
|
|
|
private ToolStripMenuItem cmdConfigure;
|
|
|
|
|
private ToolStripSeparator toolStripSeparator2;
|
|
|
|
|
private ToolStripMenuItem cmdRestart;
|
|
|
|
|
private ToolStripSeparator toolStripSeparator1;
|
|
|
|
|
private ToolStripMenuItem cmdCommunity;
|
2016-07-29 23:44:14 +00:00
|
|
|
|
private Container components;
|
2014-02-15 21:17:36 +00:00
|
|
|
|
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IServerApplicationHost _appHost;
|
|
|
|
|
private readonly IServerConfigurationManager _configurationManager;
|
2014-03-31 01:00:47 +00:00
|
|
|
|
private readonly ILocalizationManager _localization;
|
2014-02-15 21:17:36 +00:00
|
|
|
|
|
2016-04-23 18:38:36 +00:00
|
|
|
|
public void Invoke(Action action)
|
|
|
|
|
{
|
|
|
|
|
contextMenuStrip1.Invoke(action);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-30 04:19:45 +00:00
|
|
|
|
public ServerNotifyIcon(ILogManager logManager,
|
|
|
|
|
IServerApplicationHost appHost,
|
2014-11-09 18:24:57 +00:00
|
|
|
|
IServerConfigurationManager configurationManager,
|
|
|
|
|
ILocalizationManager localization)
|
2014-02-15 21:17:36 +00:00
|
|
|
|
{
|
|
|
|
|
_logger = logManager.GetLogger("MainWindow");
|
2014-03-31 01:00:47 +00:00
|
|
|
|
_localization = localization;
|
2014-02-15 21:17:36 +00:00
|
|
|
|
_appHost = appHost;
|
|
|
|
|
_configurationManager = configurationManager;
|
2015-09-30 04:19:45 +00:00
|
|
|
|
|
2016-07-29 23:44:14 +00:00
|
|
|
|
components = new System.ComponentModel.Container();
|
2015-09-30 04:19:45 +00:00
|
|
|
|
|
2014-02-15 21:17:36 +00:00
|
|
|
|
var resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
2014-11-10 04:20:11 +00:00
|
|
|
|
contextMenuStrip1 = new ContextMenuStrip(components);
|
|
|
|
|
notifyIcon1 = new NotifyIcon(components);
|
2015-09-30 04:19:45 +00:00
|
|
|
|
|
2014-11-10 04:20:11 +00:00
|
|
|
|
cmdExit = new ToolStripMenuItem();
|
|
|
|
|
cmdCommunity = new ToolStripMenuItem();
|
|
|
|
|
toolStripSeparator1 = new ToolStripSeparator();
|
|
|
|
|
cmdRestart = new ToolStripMenuItem();
|
|
|
|
|
toolStripSeparator2 = new ToolStripSeparator();
|
|
|
|
|
cmdConfigure = new ToolStripMenuItem();
|
|
|
|
|
cmdBrowse = new ToolStripMenuItem();
|
2015-09-30 04:19:45 +00:00
|
|
|
|
|
2014-02-15 21:17:36 +00:00
|
|
|
|
//
|
|
|
|
|
// notifyIcon1
|
|
|
|
|
//
|
|
|
|
|
notifyIcon1.ContextMenuStrip = contextMenuStrip1;
|
2015-06-03 05:28:37 +00:00
|
|
|
|
notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
2015-03-21 16:10:02 +00:00
|
|
|
|
notifyIcon1.Text = "Emby";
|
2014-02-15 21:17:36 +00:00
|
|
|
|
notifyIcon1.Visible = true;
|
|
|
|
|
//
|
|
|
|
|
// contextMenuStrip1
|
|
|
|
|
//
|
2014-11-10 04:20:11 +00:00
|
|
|
|
contextMenuStrip1.Items.AddRange(new ToolStripItem[] {
|
2014-02-15 21:17:36 +00:00
|
|
|
|
cmdBrowse,
|
|
|
|
|
cmdConfigure,
|
|
|
|
|
toolStripSeparator2,
|
|
|
|
|
cmdRestart,
|
|
|
|
|
toolStripSeparator1,
|
|
|
|
|
cmdCommunity,
|
|
|
|
|
cmdExit});
|
|
|
|
|
contextMenuStrip1.Name = "contextMenuStrip1";
|
|
|
|
|
contextMenuStrip1.ShowCheckMargin = true;
|
|
|
|
|
contextMenuStrip1.ShowImageMargin = false;
|
|
|
|
|
contextMenuStrip1.Size = new System.Drawing.Size(209, 214);
|
|
|
|
|
//
|
|
|
|
|
// cmdExit
|
|
|
|
|
//
|
|
|
|
|
cmdExit.Name = "cmdExit";
|
|
|
|
|
cmdExit.Size = new System.Drawing.Size(208, 22);
|
|
|
|
|
//
|
|
|
|
|
// cmdCommunity
|
|
|
|
|
//
|
|
|
|
|
cmdCommunity.Name = "cmdCommunity";
|
|
|
|
|
cmdCommunity.Size = new System.Drawing.Size(208, 22);
|
|
|
|
|
//
|
|
|
|
|
// toolStripSeparator1
|
|
|
|
|
//
|
|
|
|
|
toolStripSeparator1.Name = "toolStripSeparator1";
|
|
|
|
|
toolStripSeparator1.Size = new System.Drawing.Size(205, 6);
|
|
|
|
|
//
|
|
|
|
|
// cmdRestart
|
|
|
|
|
//
|
|
|
|
|
cmdRestart.Name = "cmdRestart";
|
|
|
|
|
cmdRestart.Size = new System.Drawing.Size(208, 22);
|
|
|
|
|
//
|
|
|
|
|
// toolStripSeparator2
|
|
|
|
|
//
|
|
|
|
|
toolStripSeparator2.Name = "toolStripSeparator2";
|
|
|
|
|
toolStripSeparator2.Size = new System.Drawing.Size(205, 6);
|
|
|
|
|
//
|
|
|
|
|
// cmdConfigure
|
|
|
|
|
//
|
|
|
|
|
cmdConfigure.Name = "cmdConfigure";
|
|
|
|
|
cmdConfigure.Size = new System.Drawing.Size(208, 22);
|
|
|
|
|
//
|
|
|
|
|
// cmdBrowse
|
|
|
|
|
//
|
|
|
|
|
cmdBrowse.Name = "cmdBrowse";
|
|
|
|
|
cmdBrowse.Size = new System.Drawing.Size(208, 22);
|
|
|
|
|
|
|
|
|
|
cmdExit.Click += cmdExit_Click;
|
|
|
|
|
cmdRestart.Click += cmdRestart_Click;
|
|
|
|
|
cmdConfigure.Click += cmdConfigure_Click;
|
|
|
|
|
cmdCommunity.Click += cmdCommunity_Click;
|
|
|
|
|
cmdBrowse.Click += cmdBrowse_Click;
|
|
|
|
|
|
|
|
|
|
_configurationManager.ConfigurationUpdated += Instance_ConfigurationUpdated;
|
|
|
|
|
|
2014-03-31 01:00:47 +00:00
|
|
|
|
LocalizeText();
|
|
|
|
|
|
2015-04-12 16:46:29 +00:00
|
|
|
|
notifyIcon1.DoubleClick += notifyIcon1_DoubleClick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-04-24 03:03:49 +00:00
|
|
|
|
BrowserLauncher.OpenDashboard(_appHost);
|
2014-02-15 21:17:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-31 01:00:47 +00:00
|
|
|
|
private void LocalizeText()
|
|
|
|
|
{
|
|
|
|
|
_uiCulture = _configurationManager.Configuration.UICulture;
|
|
|
|
|
|
|
|
|
|
cmdExit.Text = _localization.GetLocalizedString("LabelExit");
|
|
|
|
|
cmdCommunity.Text = _localization.GetLocalizedString("LabelVisitCommunity");
|
|
|
|
|
cmdBrowse.Text = _localization.GetLocalizedString("LabelBrowseLibrary");
|
2015-03-21 18:12:12 +00:00
|
|
|
|
cmdConfigure.Text = _localization.GetLocalizedString("LabelConfigureServer");
|
2014-03-31 01:00:47 +00:00
|
|
|
|
cmdRestart.Text = _localization.GetLocalizedString("LabelRestartServer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _uiCulture;
|
2014-02-15 21:17:36 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles the ConfigurationUpdated event of the Instance control.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">The source of the event.</param>
|
|
|
|
|
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
|
|
|
|
void Instance_ConfigurationUpdated(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-03-31 01:00:47 +00:00
|
|
|
|
if (!string.Equals(_configurationManager.Configuration.UICulture, _uiCulture,
|
|
|
|
|
StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
LocalizeText();
|
|
|
|
|
}
|
2014-02-15 21:17:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmdBrowse_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-04-24 03:03:49 +00:00
|
|
|
|
BrowserLauncher.OpenWebClient(_appHost);
|
2014-02-15 21:17:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmdCommunity_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-04-24 03:03:49 +00:00
|
|
|
|
BrowserLauncher.OpenCommunity(_appHost);
|
2014-02-15 21:17:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmdConfigure_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-04-24 03:03:49 +00:00
|
|
|
|
BrowserLauncher.OpenDashboard(_appHost);
|
2014-02-15 21:17:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmdRestart_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_appHost.Restart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmdExit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_appHost.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 23:44:14 +00:00
|
|
|
|
public void Dispose()
|
2014-02-15 21:17:36 +00:00
|
|
|
|
{
|
2016-07-29 23:44:14 +00:00
|
|
|
|
Dispose(true);
|
2014-02-15 21:17:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 23:44:14 +00:00
|
|
|
|
protected virtual void Dispose(bool disposing)
|
2014-02-15 21:17:36 +00:00
|
|
|
|
{
|
2016-07-29 23:44:14 +00:00
|
|
|
|
if (disposing)
|
2014-02-15 21:17:36 +00:00
|
|
|
|
{
|
2016-07-29 23:44:14 +00:00
|
|
|
|
if (notifyIcon1 != null)
|
|
|
|
|
{
|
|
|
|
|
notifyIcon1.Visible = false;
|
|
|
|
|
notifyIcon1.Dispose();
|
|
|
|
|
notifyIcon1 = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (components != null)
|
|
|
|
|
{
|
|
|
|
|
components.Dispose();
|
|
|
|
|
}
|
2014-02-15 21:17:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-09-30 04:19:45 +00:00
|
|
|
|
}
|