Ejemplo n.º 1
0
        public static void ShowSimpleToast(string text)
        {
            ToastContent toastContent = new ToastContent
            {
                Visual = new ToastVisual
                {
                    BindingGeneric = new ToastBindingGeneric
                    {
                        Children =
                        {
                            new AdaptiveText
                            {
                                Text = text
                            }
                        }
                    }
                },
            };

            ToastNotification           toast = new ToastNotification(toastContent.GetXml());
            OnChatMessageToastEventArgs args  = new OnChatMessageToastEventArgs(toast, null);

            OnChatMessageToast?.Invoke(args);

            PopToast(toast, args);
        }
Ejemplo n.º 2
0
        private static ToastNotification PopToast(ToastContent content)
        {
            ToastNotification toast = new ToastNotification(content.GetXml())
            {
                Data = new NotificationData()
            };
            OnChatMessageToastEventArgs args = new OnChatMessageToastEventArgs(toast, null);

            OnChatMessageToast?.Invoke(args);
            PopToast(toast, args);
            return(toast);
        }
Ejemplo n.º 3
0
        private static void PopToast(ToastContent content, ChatModel chat, string group)
        {
            ToastNotification toast = new ToastNotification(content.GetXml())
            {
                Group = group
            };

            OnChatMessageToastEventArgs args = new OnChatMessageToastEventArgs(toast, chat);

            OnChatMessageToast?.Invoke(args);

            PopToast(toast, args);
        }
Ejemplo n.º 4
0
        private static void PopToast(ToastNotification toast, OnChatMessageToastEventArgs args)
        {
            switch (args.toasterTypeOverride)
            {
            case ChatMessageToasterType.FULL:
                // Make sure we only send actual on screen popups every 5 seconds:
                toast.SuppressPopup = DateTime.Now.Subtract(lastPopToast).CompareTo(POP_TOAST_TIMEOUT_TS) < 0;
                lastPopToast        = DateTime.Now;

                ToastNotificationManager.CreateToastNotifier().Show(toast);
                Logger.Debug("Toast for group: " + toast.Group + " toasted with toaster type: " + args.toasterTypeOverride.ToString());
                break;

            case ChatMessageToasterType.REDUCED:
                PopToastReduced();
                Logger.Debug("Toast for group: " + toast.Group + " toasted with toaster type: " + args.toasterTypeOverride.ToString());
                break;

            default:
                Logger.Debug("Toast for group: " + toast.Group + " canceled.");
                break;
            }
        }
Ejemplo n.º 5
0
        public static void ShowAccountMessageToast(string text, string accountBareJid, string tag)
        {
            ToastContent toastContent = new ToastContent
            {
                Visual = new ToastVisual
                {
                    BindingGeneric = new ToastBindingGeneric
                    {
                        Children =
                        {
                            new AdaptiveText
                            {
                                Text = text
                            },
                            new AdaptiveText
                            {
                                Text      = accountBareJid,
                                HintStyle = AdaptiveTextStyle.CaptionSubtle
                            }
                        }
                    }
                },
            };

            ToastNotification toast = new ToastNotification(toastContent.GetXml())
            {
                Group = ACCOUNT_GROUP_PREFIX + accountBareJid,
                Tag   = tag
            };

            OnChatMessageToastEventArgs args = new OnChatMessageToastEventArgs(toast, null);

            OnChatMessageToast?.Invoke(args);

            ToastNotificationManager.History.Remove(tag, ACCOUNT_GROUP_PREFIX + accountBareJid);
            PopToast(toast, args);
        }