Skip to content

Commit

Permalink
Polishing code and up version number
Browse files Browse the repository at this point in the history
  • Loading branch information
nikvoronin committed Sep 2, 2024
1 parent cfb25e3 commit 6874c68
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Xm4Battery/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,21 @@ private static void UpdateUi(
NotifyIcon notifyIconCtrl,
Xm4State currentState )
{
var items = notifyIconCtrl.ContextMenuStrip!.Items;
items[ConnectCtxMenuItemName]!.Enabled = !currentState.Connected;
items[DisconnectCtxMenuItemName]!.Enabled = currentState.Connected;
ArgumentNullException.ThrowIfNull( xm4 );
ArgumentNullException.ThrowIfNull( notifyIconCtrl );
ArgumentNullException.ThrowIfNull( currentState );

var items = notifyIconCtrl.ContextMenuStrip?.Items
?? throw new InvalidOperationException(
"Can not get itens of the context menu strip. Context menu is null." );

if (items[ConnectCtxMenuItemName] is not null
and var connectCtxMenuItem)
connectCtxMenuItem.Enabled = !currentState.Connected;

if (items[DisconnectCtxMenuItemName] is not null
and var disconnectCtxMenuItemName)
disconnectCtxMenuItemName.Enabled = currentState.Connected;

var prevIcon = notifyIconCtrl.Icon;

Expand Down Expand Up @@ -221,7 +233,7 @@ private static void LogException( Exception exception ) =>
const string NotifyIcon_BatteryLevelTitle = "XM4 Battery Level";

const string AppName = "Xm4Battery";
const string AppVersion = "4.7.28";
const string AppVersion = "4.9.2";
const string GithubProjectUrl = "https://github.com/nikvoronin/WmiPnp";

internal enum ErrorLevel
Expand Down

0 comments on commit 6874c68

Please sign in to comment.