I’m creating a notification for CE 6.5, but this notification is brought up on a looped check – so gradually the notification icons are building up. Is there a way to remove them? Or perhaps let them not appear at all? The notification window is whats important, not the system tray icon.
.Dispose() on the icon doesn’t do anything, neither does nullifying it (still there, just blank). I tried making an event on balloon change, and if not visible it would dispose(), but still didn’t work.
notification.BalloonChanged += new Microsoft.WindowsCE.Forms.BalloonChangedEventHandler(
delegate(object s, Microsoft.WindowsCE.Forms.BalloonChangedEventArgs e)
{
if (!notification.Visible)
notification.Dispose();
});
All my searches have only returned advice on disposing after the program is done.
Anyway here is what I have thats working. Thanks!
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);
}
Dispose was right, I just needed to make a separate timer rather than use the events. This seemed to have worked for what I wanted.