public void Update( NotificationInformation notifyInformation, string title, string message, params string[] details) { var baloonTipText = string.Join("\r\n", message, string.Join("\r\n", details)); var requireUpdate = (notifyIcon_.BalloonTipTitle != title) || (notifyIcon_.BalloonTipText != baloonTipText); if (requireUpdate == false) { return; } var requirePlaySoundAndToast = requireUpdate && (notifyIcon_.BalloonTipText.StartsWith(message) == false); if ((iconState_ != 0) && (notifyInformation.IsBlink == false)) { iconState_ = 0; timer_.Stop(); } notifyIcon_.Icon = currentIcon_ = notifyInformation.Icon; notifyIcon_.BalloonTipIcon = notifyInformation.ToolTipIcon; notifyIcon_.BalloonTipTitle = title; notifyIcon_.BalloonTipText = baloonTipText; var text = string.Format("{0}\r\n{1}", title, baloonTipText); if (text.Length > 60) { text = text.Substring(0, 60) + "..."; } notifyIcon_.Text = text; if (notifyBaloonTip_ == true) { notifyIcon_.ShowBalloonTip(notifyInformation.IsLong ? 25000 : 7000); } if ((iconState_ == 0) && (notifyInformation.IsBlink == true)) { iconState_ = 1; timer_.Interval = 500; timer_.Start(); } if (requirePlaySoundAndToast == false) { return; } if ((showToast_ != null) && (notifyToast_ == true)) { showToast_(title, baloonTipText, notifyInformation.ToastIcon.ToString(), notifyInformation.IsLong); } if (notifySound_ == true) { SystemSoundPlayer.Play(notifyInformation.PlaySymbol); } }
private void UpdateNotifier( NotificationInformation notifyInformation, string title, string message, params string[] details) { Debug.Assert(notifyInformation != null); Debug.Assert(title != null); Debug.Assert(message != null); Application.Current.Dispatcher.BeginInvoke(new Action(() => { notifier_.Update(notifyInformation, title, message, details); })); }