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

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

                    notifyIcon.ShowBalloonTip(5000, title, message, ToolTipIcon.Info);
                    notifyIcon.Visible = false;
                }
            } catch (Exception e) {
                Logging.Error(e);
            }
        }
Beispiel #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, message, AppIconService.GetAppIconUri(), click ?? _defaultAction);
 }