Esempio n. 1
0
        public static void Show(string title, string text)
        {
            IToastNotificationContent toastContent = null;

            IToastText03 templateContent = ToastContentFactory.CreateToastText03();

            templateContent.TextHeadingWrap.Text = title;
            templateContent.TextBody.Text        = text;
            toastContent = templateContent;

            ToastNotification toast = toastContent.CreateNotification();

            toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(1);
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        void DisplayTextToast(ToastTemplateType templateType)
        {
            // Creates a toast using the notification object model, which is another project
            // in this solution.  For an example using Xml manipulation, see the function
            // DisplayToastUsingXmlManipulation below.
            IToastNotificationContent toastContent = null;

            if (templateType == ToastTemplateType.ToastText01)
            {
                IToastText01 templateContent = ToastContentFactory.CreateToastText01();
                templateContent.TextBodyWrap.Text = "Body text that wraps over three lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText02)
            {
                IToastText02 templateContent = ToastContentFactory.CreateToastText02();
                templateContent.TextHeading.Text  = "Heading text";
                templateContent.TextBodyWrap.Text = "Body text that wraps over two lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText03)
            {
                IToastText03 templateContent = ToastContentFactory.CreateToastText03();
                templateContent.TextHeadingWrap.Text = "Heading text that is very long and wraps over two lines";
                templateContent.TextBody.Text        = "Body text";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText04)
            {
                IToastText04 templateContent = ToastContentFactory.CreateToastText04();
                templateContent.TextHeading.Text = "Heading text";
                templateContent.TextBody1.Text   = "First body text";
                templateContent.TextBody2.Text   = "Second body text";
                toastContent = templateContent;
            }

            rootPage.NotifyUser(toastContent.GetContent(), NotifyType.StatusMessage);

            // Create a toast, then create a ToastNotifier object to show
            // the toast
            ToastNotification toast = toastContent.CreateNotification();

            // If you have other applications in your package, you can specify the AppId of
            // the app to create a ToastNotifier for that application
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Esempio n. 3
0
        public static void DisplayTextToast(ToastTemplateType templateType, string fromId, string content, string imageUri)
        {
            // Creates a toast using the notification object model, which is another project
            // in this solution.  For an example using Xml manipulation, see the function
            // DisplayToastUsingXmlManipulation below.
            IToastNotificationContent toastContent = null;

            if (templateType == ToastTemplateType.ToastText01)
            {
                IToastText01 templateContent = ToastContentFactory.CreateToastText01();
                templateContent.TextBodyWrap.Text = "Body text that wraps over three lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText02)
            {
                IToastText02 templateContent = ToastContentFactory.CreateToastText02();
                templateContent.TextHeading.Text  = "Heading text";
                templateContent.TextBodyWrap.Text = "Body text that wraps over two lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText03)
            {
                IToastText03 templateContent = ToastContentFactory.CreateToastText03();
                templateContent.TextHeadingWrap.Text = "Heading text that is very long and wraps over two lines";
                templateContent.TextBody.Text        = "Body text";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText04)
            {
                IToastText04 templateContent = ToastContentFactory.CreateToastText04();
                templateContent.TextHeading.Text = "Heading text";
                templateContent.TextBody1.Text   = "First body text";
                templateContent.TextBody2.Text   = "Second body text";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastImageAndText01)
            {
                IToastImageAndText01 templateContent = ToastContentFactory.CreateToastImageAndText01();
                if (String.IsNullOrWhiteSpace(content) == false)
                {
                    templateContent.TextBodyWrap.Text = content;
                }
                else
                {
                    templateContent.TextBodyWrap.Text = "text here!";
                }

                if (String.IsNullOrWhiteSpace(imageUri) == false)
                {
                    templateContent.Image.Src = imageUri;
                }
                else
                {
                    templateContent.Image.Src = "http://singularlabs.com/wp-content/uploads/2011/11/System-Ninja-2.2.png";
                }

                toastContent = templateContent;
            }

            // Create a toast, then create a ToastNotifier object to show
            // the toast
            ToastNotification           toast = toastContent.CreateNotification();
            Dictionary <String, String> args  = new Dictionary <String, String>();

            args.Add("fromId", fromId);
            args.Add("content", content);
            //toast.Activated += ToastTapped(toast, args);
            toast.Activated += new TypedEventHandler <ToastNotification, object>((sender, e) => ToastTapped(toast, args));
            // If you have other applications in your package, you can specify the AppId of
            // the app to create a ToastNotifier for that application
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }