1

我正在为 CE 6.5 创建一个通知,但是这个通知是在循环检查时提出的——所以通知图标逐渐建立起来。有没有办法删除它们?或者也许根本不让他们出现?重要的是通知窗口,而不是系统托盘图标。图标上的 .Dispose() 没有做任何事情,也没有取消它(仍然存在,只是空白)。我尝试在气球变化上制作一个事件,如果不可见它会 dispose(),但仍然没有工作。

        notification.BalloonChanged += new Microsoft.WindowsCE.Forms.BalloonChangedEventHandler(
            delegate(object s, Microsoft.WindowsCE.Forms.BalloonChangedEventArgs e)
            {
                if (!notification.Visible)
                    notification.Dispose();
            });

我所有的搜索都只返回了程序完成后的处置建议。无论如何,这就是我的工作。谢谢!

    private delegate void DelegateNotificationWindow(string error, int seconds);
    private void InvokeNotificationWindow(string message, int seconds)
    {
        Microsoft.WindowsCE.Forms.Notification notification = new Microsoft.WindowsCE.Forms.Notification();
        notification.Icon = Properties.Resources.Icon;
        notification.InitialDuration = seconds;
        notification.Caption = "Notification";
        notification.Critical = false;
        notification.Text = String.Format("<html><body><b>{0}</b></body></html>", message);
        notification.Visible = true;
    }

    public void ShowNotification(NotificationType type)
    {
        string message = "";
        switch (type)
        {
            case NotificationType.None: return;
            case NotificationType.NewEntitiesAvailable:
                message = "New Inspections/Works available, please run Receive New.";
                break;
        }
        DelegateNotificationWindow dlgt = new DelegateNotificationWindow(InvokeNotificationWindow);
        this.BeginInvoke(dlgt, message, 10);
    }
4

1 回答 1

0

Dispose 是对的,我只需要制作一个单独的计时器而不是使用事件。这似乎对我想要的有用。

        Timer _timer = new Timer();
        _timer.Tick += new EventHandler(delegate(object s, EventArgs e) { notification.Dispose(); });
        _timer.Interval = seconds * 1000;
        _timer.Enabled = true;
于 2012-05-30T09:50:49.150 回答