Exemple #1
0
        private static void ShowFallback(string title, string message, Action click)
        {
            try {
                var text       = title + Environment.NewLine + message;
                var notifyIcon = new NotifyIcon {
                    Icon    = AppIconService.GetTrayIcon(),
                    Text    = text.Length > 63 ? text.Substring(0, 63) : text,
                    Visible = true
                };

                if (click != null)
                {
                    notifyIcon.BalloonTipClicked += (sender, args) => { click.InvokeInMainThreadAsync(); };
                }

                notifyIcon.ShowBalloonTip(5000, title, message, ToolTipIcon.Info);
                notifyIcon.BalloonTipClosed += (sender, args) => {
                    notifyIcon.Visible = false;
                    notifyIcon.Dispose();
                };
            } catch (Exception e) {
                Logging.Error(e);
            }
        }
Exemple #2
0
 /// <summary>
 /// Show a toast.
 /// </summary>
 /// <param name="title">Ex.: “Something Happened”</param>
 /// <param name="message">Ex.: “This and that. Without dot in the end”</param>
 /// <param name="click">Click action</param>
 public static void Show(string title, string message, Action click = null)
 {
     Show(title.ToTitle(), message, AppIconService.GetAppIconUri(), click ?? _defaultAction);
 }