diff --git a/src/App.xaml.cs b/src/App.xaml.cs index 7680b30..5cc4714 100644 --- a/src/App.xaml.cs +++ b/src/App.xaml.cs @@ -1,7 +1,6 @@ using Microsoft.Win32; using System; using System.Diagnostics; -using System.Drawing; using System.IO; using System.Net; using System.Reflection; @@ -254,8 +253,6 @@ protected override void OnStartup(StartupEventArgs e) _notifyIcon = new NotifyIcon(); _notifyIcon.Click += OnNotifyIconClick; _notifyIcon.DoubleClick += OnNotifyIconClick; - _notifyIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); - _notifyIcon.Visible = true; // DI/IOC DependencyInjection.Container.Register(_notifyIcon); diff --git a/src/Core/Localizer.cs b/src/Core/Localizer.cs index bb9a683..abb74e0 100644 --- a/src/Core/Localizer.cs +++ b/src/Core/Localizer.cs @@ -95,7 +95,7 @@ public static Dictionary Languages return CultureInfo.GetCultures(CultureTypes.AllCultures) .Where(culture => resourceNames.Contains(culture.EnglishName, StringComparer.OrdinalIgnoreCase)) - .OrderBy(culture => culture.NativeName) + .OrderBy(culture => culture.NativeName, StringComparer.InvariantCultureIgnoreCase) .ToDictionary(culture => culture.EnglishName, culture => culture.NativeName.ToTitleCase()); } catch (Exception e) diff --git a/src/Service/NotificationService.cs b/src/Service/NotificationService.cs index ecf1ca6..31cd158 100644 --- a/src/Service/NotificationService.cs +++ b/src/Service/NotificationService.cs @@ -1,4 +1,6 @@ using System; +using System.Drawing; +using System.Reflection; using System.Windows.Forms; using System.Windows.Input; using Application = System.Windows.Application; @@ -51,6 +53,9 @@ public void Initialize() { Application.Current.Shutdown(); }); + + _notifyIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + _notifyIcon.Visible = true; } /// @@ -80,8 +85,10 @@ public void Notify(string message, string title = null, int timeout = 5, Enums.N { try { - if (_notifyIcon != null) - _notifyIcon.ShowBalloonTip(timeout * 1000, title, message, (ToolTipIcon)icon); + if (_notifyIcon == null) + return; + + _notifyIcon.ShowBalloonTip(timeout * 1000, title, message, (ToolTipIcon)icon); } catch { @@ -97,6 +104,9 @@ public void UpdateInfo(Memory memory) { try { + if (_notifyIcon == null) + return; + _notifyIcon.Text = string.Format("{0} {1}{2}%", Localizer.String.MemoryUsage, Environment.NewLine, memory.UsedPercentage); } catch