Skip to content

Commit 33d26ce

Browse files
committed
chore: update the usage of TrayIconHost
1 parent 70ec61a commit 33d26ce

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,28 @@ Similar to WPF UI.
585585
{
586586
_ = GetInstance();
587587
}
588+
589+
public static void ShowNotification(string title, string content, ToolTipIcon icon = default, int timeout = 5000, Action? clickEvent = null, Action? closeEvent = null)
590+
{
591+
var iconHost = GetInstance()._iconHost;
592+
if (iconHost is null) return;
593+
594+
iconHost.ShowBalloonTip(timeout, title, content, icon);
595+
iconHost.BalloonTipClicked += OnIconOnBalloonTipClicked;
596+
iconHost.BalloonTipClosed += OnIconOnBalloonTipClosed;
597+
598+
void OnIconOnBalloonTipClicked(object? sender, EventArgs e)
599+
{
600+
clickEvent?.Invoke();
601+
iconHost.BalloonTipClicked -= OnIconOnBalloonTipClicked;
602+
}
603+
604+
void OnIconOnBalloonTipClosed(object? sender, EventArgs e)
605+
{
606+
closeEvent?.Invoke();
607+
iconHost.BalloonTipClosed -= OnIconOnBalloonTipClosed;
608+
}
609+
}
588610
}
589611

590612
internal partial class TrayIconManager : ObservableObject

0 commit comments

Comments
 (0)