Skip to content

Commit ca65848

Browse files
committed
Restructured toast/balloontip code
- Sub made private, unshared and removed static references to instance members - Added logging for troubleshooting
1 parent f904ba4 commit ca65848

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

WinNUT_V2/WinNUT-Client/WinNUT.vb

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -863,15 +863,21 @@ Public Class WinNUT
863863
End If
864864
End Sub
865865

866-
Public Shared Sub Event_ChangeStatus() Handles Me.On_Battery, Me.On_Line,
867-
UPS_Device.Lost_Connect, UPS_Device.Connected, UPS_Device.Disconnected
868-
869-
WinNUT.NotifyIcon.BalloonTipText = WinNUT.NotifyIcon.Text
870-
If WinNUT.AllowToast And WinNUT.NotifyIcon.BalloonTipText <> "" Then
871-
Dim Toastparts As String() = WinNUT.NotifyIcon.BalloonTipText.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
872-
WinNUT.ToastPopup.SendToast(Toastparts)
873-
ElseIf WinNUT.NotifyIcon.Visible = True And WinNUT.NotifyIcon.BalloonTipText <> "" Then
874-
WinNUT.NotifyIcon.ShowBalloonTip(10000)
866+
''' <summary>
867+
''' Handle Toast (Windows 10+) and/or NotifyIcon pop-ups.
868+
''' </summary>
869+
Private Sub ToastNotifyIcon() Handles Me.On_Battery, Me.On_Line, UPS_Device.Lost_Connect,
870+
UPS_Device.Connected, UPS_Device.Disconnected
871+
872+
LogFile.LogTracing("ToastNotifyIcon running.", LogLvl.LOG_DEBUG, Me)
873+
NotifyIcon.BalloonTipText = NotifyIcon.Text
874+
If AllowToast And NotifyIcon.BalloonTipText <> "" Then
875+
Dim Toastparts As String() = NotifyIcon.BalloonTipText.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
876+
LogFile.LogTracing("Sending Toast popup with text: " & NotifyIcon.BalloonTipText, LogLvl.LOG_DEBUG, Me)
877+
ToastPopup.SendToast(Toastparts)
878+
ElseIf NotifyIcon.Visible = True And NotifyIcon.BalloonTipText <> "" Then
879+
LogFile.LogTracing("Sending NotifyIcon ballowtip: " & NotifyIcon.BalloonTipText, LogLvl.LOG_DEBUG, Me)
880+
NotifyIcon.ShowBalloonTip(10000)
875881
End If
876882
End Sub
877883

0 commit comments

Comments
 (0)