我有一个C#应用程序,它使用NotifyIcon.ShowBalloonTip
在Windows中显示几种不同类型的气球通知。如果用户点击它,我希望能够将操作与每个气球提示相关联。但是,NotifyIcon.BalloonTipClicked
似乎没有提供用户实际点击的气球的任何指示。如何确定用户与之交互的气球提示?
以下是展示问题的简短示例:
var notifyIcon = new System.Windows.Forms.NotifyIcon
{
Text = "testing notifications",
Icon = System.Drawing.SystemIcons.Application,
Visible = true
};
notifyIcon.BalloonTipClicked += (sender, args) =>
{
Console.WriteLine($"User clicked a balloon, but which one? sender: {sender}, args: {args}");
};
for (var i = 0; i < 5; i++) {
notifyIcon.ShowBalloonTip(30000, $"title {i}", $"text {i}", System.Windows.Forms.ToolTipIcon.Info);
}