Exemplo n.º 1
0
        public MainPage()
        {
            this.InitializeComponent();
            this.DataContext = new SampleViewModel();
            IToastImageAndText02 trying_toast = ToastContentFactory.CreateToastImageAndText02();

            trying_toast.TextHeading.Text  = "Toast notification Example";
            trying_toast.TextBodyWrap.Text = "Animu Quiz app";
            ScheduledToastNotification giveittime;

            giveittime    = new ScheduledToastNotification(trying_toast.GetXml(), DateTime.Now.AddSeconds(2));
            giveittime.Id = "Any_ID";
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(giveittime);
        }
Exemplo n.º 2
0
        public static void DisplayTwoLines(String _text1, String _text2, String _picture)
        {
            IToastImageAndText02 templateContent = ToastContentFactory.CreateToastImageAndText02();

            templateContent.TextHeading.Text  = _text1;
            templateContent.TextBodyWrap.Text = _text2;
            templateContent.Image.Src         = _picture;

            IToastNotificationContent toastContent = templateContent;

            ToastNotification toast = toastContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Post弹出消息对话框可设置WEB的图片
        /// </summary>
        /// <param name="toastImageSrc">Web Uri</param>
        /// <param name="title">主题</param>
        /// <param name="description">内容</param>
        /// <param name="notificationSound">声音(默认是成功的声音)</param>
        public static void DisplayWebImageCustomToast(string toastImageSrc, string title, string description, NotificationToastSound notificationSound = NotificationToastSound.Success)
        {
            IToastImageAndText02 toastContent = ToastContentFactory.CreateToastImageAndText02();

            toastContent.TextHeading.Text  = title;
            toastContent.TextBodyWrap.Text = description;
            toastContent.Image.Src         = toastImageSrc;
            toastContent.Image.Alt         = toastImageSrc;
            switch (notificationSound)
            {
            case NotificationToastSound.Success:
            {
                toastContent.Audio.Content = ToastAudioContent.Default;
                break;
            }

            case NotificationToastSound.Failure:
            {
                toastContent.Audio.Content = ToastAudioContent.Mail;
                break;
            }

            case NotificationToastSound.News:
            {
                toastContent.Audio.Content = ToastAudioContent.Reminder;
                break;
            }

            default:
            {
                toastContent.Audio.Content = ToastAudioContent.Default;
                break;
            }
            }
            ToastNotification toast = toastContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Exemplo n.º 4
0
        public MainPage()
        {
            this.InitializeComponent();

            ApplicationView.PreferredLaunchViewSize      = new Size(770, 550);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;


            //notification
            IToastImageAndText02 weather_notifications = ToastContentFactory.CreateToastImageAndText02();

            weather_notifications.TextHeading.Text  = "Aplikacja pogodowa załadowana poprawnie";
            weather_notifications.TextBodyWrap.Text = "WeatherApp";
            ScheduledToastNotification giveittime;

            giveittime    = new ScheduledToastNotification(weather_notifications.GetXml(), DateTime.Now.AddSeconds(2));
            giveittime.Id = "Any_ID";
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(giveittime);


            //live tiles
            var template = TileContentFactory.CreateTileSquare150x150PeekImageAndText01();

            template.TextBody1.Text = "Aplikacja pogodowa";
            template.Image.Src      = "ms-appx:///Assets/pogoda.png";

            var wideTemlate = TileContentFactory.CreateTileWide310x150PeekImageAndText01();

            wideTemlate.TextBodyWrap.Text    = "Aplikacja pogodowa - szerszy tile";
            wideTemlate.Image.Src            = "ms-appx:///Assets/pogoda.png";
            wideTemlate.Square150x150Content = template;

            TileNotification wideNotification = wideTemlate.CreateNotification();
            TileUpdater      updater          = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(wideNotification);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Post弹出消息对话框可设置WEB的图片
        /// </summary>
        /// <param name="toastImageSrc"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        public static void DisplayWebImageToast(string toastImageSrc, string title, string description, ToastAudioContent toastAudioContent = ToastAudioContent.Default)
        {
            //var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);

            //var imageElements = toastXml.GetElementsByTagName("image");
            //var imageElement = (XmlElement)imageElements.Item(0);
            //imageElement.SetAttribute("src", toastImageSrc == null ? string.Empty : toastImageSrc);
            //imageElement.SetAttribute("alt", "");

            //var textElements = toastXml.GetElementsByTagName("text");
            //for (uint i = 0; i < textElements.Length; i++)
            //{
            //    string text = null;
            //    if (i == 0) text = title;
            //    else if (i == 1) text = description;
            //    if (text != null)
            //        textElements.Item(i).AppendChild(toastXml.CreateTextNode(text));
            //}

            ////Debug.WriteLine(toastXml.GetXml());

            //var toast = new ToastNotification(toastXml);
            ////toast.Failed += toast_Failed;
            //ToastNotificationManager.CreateToastNotifier().Show(toast);

            IToastImageAndText02 toastContent = ToastContentFactory.CreateToastImageAndText02();

            toastContent.TextHeading.Text  = title;
            toastContent.TextBodyWrap.Text = description;
            toastContent.Image.Src         = toastImageSrc;
            toastContent.Image.Alt         = toastImageSrc;
            toastContent.Audio.Content     = toastAudioContent;
            ToastNotification toast = toastContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }