Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMundstein committed Aug 8, 2023
1 parent cf3b982 commit b7efa55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
using System.Reflection;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Localizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static Dictionary<string, string> 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)
Expand Down
14 changes: 12 additions & 2 deletions src/Service/NotificationService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -51,6 +53,9 @@ public void Initialize()
{
Application.Current.Shutdown();
});

_notifyIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
_notifyIcon.Visible = true;
}

/// <summary>
Expand Down Expand Up @@ -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
{
Expand All @@ -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
Expand Down

0 comments on commit b7efa55

Please sign in to comment.