diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-07-29 22:47:20 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-07-29 22:47:20 -0400 |
| commit | 32abd342e19437021c01a43ec3df701ef1b213ea (patch) | |
| tree | 1df4070e69ac80bb66b2c6d57942926d7914c245 /MediaBrowser.ServerApplication/ServerNotifyIcon.cs | |
| parent | d174f641836eea232885a45dec86ab0a9f3c9f4b (diff) | |
| parent | cb994c3e7abbc49e661b8704e4bdf31a68e6e694 (diff) | |
Merge branch 'dev' of https://github.com/MediaBrowser/Emby into dev
Diffstat (limited to 'MediaBrowser.ServerApplication/ServerNotifyIcon.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/ServerNotifyIcon.cs | 65 |
1 files changed, 18 insertions, 47 deletions
diff --git a/MediaBrowser.ServerApplication/ServerNotifyIcon.cs b/MediaBrowser.ServerApplication/ServerNotifyIcon.cs index 27816db5a..d04128a18 100644 --- a/MediaBrowser.ServerApplication/ServerNotifyIcon.cs +++ b/MediaBrowser.ServerApplication/ServerNotifyIcon.cs @@ -4,14 +4,13 @@ using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Startup.Common.Browser; using System; +using System.ComponentModel; using System.Windows.Forms; namespace MediaBrowser.ServerApplication { public class ServerNotifyIcon : IDisposable { - bool IsDisposing = false; - private NotifyIcon notifyIcon1; private ContextMenuStrip contextMenuStrip1; private ToolStripMenuItem cmdExit; @@ -21,25 +20,13 @@ namespace MediaBrowser.ServerApplication private ToolStripMenuItem cmdRestart; private ToolStripSeparator toolStripSeparator1; private ToolStripMenuItem cmdCommunity; + private Container components; private readonly ILogger _logger; private readonly IServerApplicationHost _appHost; private readonly IServerConfigurationManager _configurationManager; private readonly ILocalizationManager _localization; - public bool Visible - { - get - { - return notifyIcon1.Visible; - } - set - { - Action act = () => notifyIcon1.Visible = false; - Invoke(act); - } - } - public void Invoke(Action action) { contextMenuStrip1.Invoke(action); @@ -55,7 +42,7 @@ namespace MediaBrowser.ServerApplication _appHost = appHost; _configurationManager = configurationManager; - var components = new System.ComponentModel.Container(); + components = new System.ComponentModel.Container(); var resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); contextMenuStrip1 = new ContextMenuStrip(components); @@ -138,32 +125,6 @@ namespace MediaBrowser.ServerApplication LocalizeText(); notifyIcon1.DoubleClick += notifyIcon1_DoubleClick; - Application.ThreadExit += Application_ThreadExit; - Application.ApplicationExit += Application_ApplicationExit; - } - - void Application_ThreadExit(object sender, EventArgs e) - { - try - { - notifyIcon1.Visible = false; - } - catch - { - - } - } - - void Application_ApplicationExit(object sender, EventArgs e) - { - try - { - notifyIcon1.Visible = false; - } - catch - { - - } } void notifyIcon1_DoubleClick(object sender, EventArgs e) @@ -222,16 +183,26 @@ namespace MediaBrowser.ServerApplication _appHost.Shutdown(); } - ~ServerNotifyIcon() + public void Dispose() { - Dispose(); + Dispose(true); } - public void Dispose() + protected virtual void Dispose(bool disposing) { - if (!IsDisposing) + if (disposing) { - IsDisposing = true; + if (notifyIcon1 != null) + { + notifyIcon1.Visible = false; + notifyIcon1.Dispose(); + notifyIcon1 = null; + } + + if (components != null) + { + components.Dispose(); + } } } } |
