/// <summary>
        /// This is the click handler for the 'Scenario1BtnDefault' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario1BtnDefault_Click(object sender, RoutedEventArgs e)
        {
            String rss = scenario1RssInput.Text;
            if (null != rss && "" != rss)
            {
                try
                {
                    String xml;
                    var doc = new Windows.Data.Xml.Dom.XmlDocument();
                    scenario1OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);
                    doc.LoadXml(xml);

                    // create a rss CDataSection and insert into DOM tree
                    var cdata = doc.CreateCDataSection(rss);
                    var element = doc.GetElementsByTagName("content").Item(0);
                    element.AppendChild(cdata);

                    Scenario.RichEditBoxSetMsg(scenario1Result, doc.GetXml(), true);
                }
                catch (Exception exp)
                {
                    Scenario.RichEditBoxSetError(scenario1Result, exp.Message);
                }
            }
            else
            {
                Scenario.RichEditBoxSetError(scenario1Result, "Please type in RSS content in the [RSS Content] box firstly.");
            }
        }
Пример #2
0
        private void LiveTitle()
        {
            XDocument xdoc = XDocument.Load("LiveTitle.xml");

            Windows.Data.Xml.Dom.XmlDocument doc = new Windows.Data.Xml.Dom.XmlDocument();
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Clear();
            updater.EnableNotificationQueue(true);

            doc.LoadXml(xdoc.ToString());
            TileNotification notification = new TileNotification(doc);

            updater.Update(notification);

            for (int i = 0; i < 5; i++)
            {
                foreach (XElement xe in xdoc.Descendants("binding"))
                {
                    foreach (XElement xxe in xdoc.Descendants("image"))
                    {
                        xxe.SetAttributeValue("src", "Assets/SplashScreen.scale-100.png");
                    }
                }
                doc.LoadXml(xdoc.ToString());
                notification = new TileNotification(doc);
                updater.Update(notification);
            }

            //await ChangeTitle();
        }
Пример #3
0
        public async Task RefreshAsync(bool notify, bool checkDownloads, bool forceRefresh)
        {
            try
            {
                foreach (var episode in Episodes)
                {
                    if (episode.IsAlreadyDownloaded || episode.DownloadInProgress)
                    {
                        if (episode.IsPlayed && LocalSettings.Instance.DeleteDownloadWhenPlayed)
                        {
                            episode.DeleteDownload(true);
                        }

                        if (episode.DownloadedDate.HasValue && DateTime.Now.Subtract(episode.DownloadedDate.Value).TotalDays >= LocalSettings.Instance.DeleteEpisodesOlderThan)
                        {
                            episode.DeleteDownload(true);
                        }
                    }
                }

                GetLocalImage();

                if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
                {
                    if (checkDownloads)
                    {
                        CheckForAutomaticDownloads();
                    }
                    return;
                }

                if (!forceRefresh && !LocalSettings.Instance.Metered && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
                {
                    return;
                }

                var data = await CoreTools.DownloadStringAsync(FeedUrl, true, Login, Password);

                var document = new Windows.Data.Xml.Dom.XmlDocument();

                try
                {
                    data = data.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
                    document.LoadXml(data);
                }
                catch
                {
                    data = await CoreTools.DownloadStringAsync(FeedUrl, false, Login, Password);

                    document.LoadXml(data);
                }

                await ParseAsync(document, notify, checkDownloads);
            }
            catch
            {
                // Ignore error
            }
        }
Пример #4
0
        public static async Task <Podcast> ParseAsync(string url, bool checkDownloads, string login = null, string password = null)
        {
            try
            {
                var data = await CoreTools.DownloadStringAsync(url, true, login, password);

                var document = new Windows.Data.Xml.Dom.XmlDocument();

                try
                {
                    document.LoadXml(data);
                }
                catch
                {
                    data = await CoreTools.DownloadStringAsync(url, false, login, password);

                    document.LoadXml(data);
                }

                var channel = document.GetElementsByTagName("channel")[0] as Windows.Data.Xml.Dom.XmlElement;

                var result = new Podcast
                {
                    Title       = channel.GetChildNodeTextValue("title", "").Sanitize(),
                    Description = channel.GetChildNodeTextValue("description", "").Sanitize(),
                    Link        = channel.GetChildNodeTextValue("link", ""),
                    Image       = channel.GetChildNodeAttribute("itunes:image", "href", ""),
                    FeedUrl     = url,
                    Login       = login,
                    Password    = password
                };

                if (string.IsNullOrEmpty(result.Image))
                {
                    result.LocalImage = "ms-appx:///Assets/IconFull.png";
                }

                if (string.IsNullOrEmpty(result.Description))
                {
                    result.Description = channel.GetChildNodeTextValue("itunes:summary", "").Sanitize();
                }

                await result.ParseAsync(document, false, checkDownloads);

                result.ReOrder();

                return(result);
            }
            catch
            {
                return(null);
            }
        }
Пример #5
0
        public static async void CreateAlarm(this Todo item)
        {
            var doc = new Windows.Data.Xml.Dom.XmlDocument();

            doc.LoadXml(await FileIO.ReadTextAsync(await StorageFile.GetFileFromApplicationUriAsync(
                                                       new Uri("ms-appx:///XMLs/AlarmToast.xml"))));
            doc.LoadXml(doc.GetXml().Replace("Header", item.Subject));
            doc.LoadXml(doc.GetXml().Replace("Detail", item.Detail));
            DateTimeOffset offset = item.StartTime;
            var            toast  = new ScheduledToastNotification(doc, offset);

            toast.Id = item.Id.ToString();
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
        }
        /// <summary>
        /// This is the click handler for the 'Scenario2BtnDefault' button.
        /// This function will look up products and mark hot products.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario2BtnDefault_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                String xml;
                scenario2OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);

                var doc = new Windows.Data.Xml.Dom.XmlDocument();
                doc.LoadXml(xml);

                // Mark 'hot' attribute to '1' if 'sell10days' is greater than 'InStore'
                var xpath         = "/products/product[Sell10day>InStore]/@hot";
                var hotAttributes = doc.SelectNodes(xpath);
                for (uint index = 0; index < hotAttributes.Length; index++)
                {
                    hotAttributes.Item(index).NodeValue = "1";
                }

                Scenario.RichEditBoxSetMsg(scenario2Result, doc.GetXml(), true);
                scenario2BtnSave.IsEnabled = true;  // enable Save button
            }
            catch (Exception exp)
            {
                Scenario.RichEditBoxSetError(scenario2Result, exp.Message);
            }
        }
Пример #7
0
        private void btnSendAdaptive_Click(object sender, RoutedEventArgs e)
        {
            // Construct the tile content as a string
            string content = $@"
                                <tile>
                                    <visual>
 
                                        <binding template='TileMedium' displayName='A'>
                                            <text>{_header_adaptive}</text>
                                            <text hint-style='captionSubtle'>{_line1}</text>
                                            <text hint-style='captionSubtle'>{_line2}</text>
                                            <text hint-style='captionSubtle'>{_line3}</text>
                                        </binding>
 
                                    </visual>
                                </tile>";

            // Load the string into an XmlDocument
            var doc = new Windows.Data.Xml.Dom.XmlDocument();

            doc.LoadXml(content);

            // Then create the tile notification
            var notification = new TileNotification(doc);

            // And send the notification
            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
        //private async void Button_Tapped_1(object sender, TappedRoutedEventArgs e)
        //{
        //    this.moreButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        //    var g = SampleDataSource.GetGroup("XKCD");
        //    //if((itemGridView.DataContext as SampleDataGroup).Title == g.Title)
        //        await SampleDataSource.addPreviousN(g.Items.Last(), g, 30);
        //    this.moreButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
        //    //this.itemGridView.ScrollIntoView(g.Items.Last());
        //}

        #region bunch of confusing shit
        private void PushtoLive_Tapped_1(object sender, TappedRoutedEventArgs e)
        {
            // create a string with the tile template xml



            string tileXmlString = "<tile>"
                                   + "<visual>"
                                   + "<binding template='TileWideImageAndText01'>"
                                   + "<text id='1'>" + Data.SampleDataSource.GetGroup("XKCD").Items[0].Title + "</text> "
                                   + "<image id='1' src='" + Data.SampleDataSource.GetGroup("XKCD").Items[0]._imagePath + "' alt='Web image'/>"
                                   + "</binding>"
                                   + "<binding template='TileSquareImage'>"
                                   + "<image id='1' src='" + Data.SampleDataSource.GetGroup("XKCD").Items[0]._imagePath + "' alt='Web image'/>"
                                   + "</binding>"
                                   + "</visual>"
                                   + "</tile>";

            // create a DOM
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                // load the xml string into the DOM, catching any invalid xml characters
                tileDOM.LoadXml(tileXmlString);

                // create a tile notification
                TileNotification tile = new TileNotification(tileDOM);

                // send the notification to the app's application tile
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
            }
            catch (Exception)
            {
            }
        }
        void UpdateBadgeWithGlyphWithStringManipulation()
        {
            // Create a string with the badge template xml.
            string badgeXmlString = "<badge value='" + ((TileGlyph)GlyphList.SelectedItem).Name.ToString() + "'/>";

            Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                // Create a DOM.
                badgeDOM.LoadXml(badgeXmlString);

                // Load the xml string into the DOM, catching any invalid xml characters.
                BadgeNotification badge = new BadgeNotification(badgeDOM);

                // Create a badge notification and send it to the application’s tile.
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);

                OutputTextBlock.Text = badgeDOM.GetXml();
                rootPage.NotifyUser("Badge sent", NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                OutputTextBlock.Text = string.Empty;
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
        void DisplayAudioToastWithStringManipulation(string audioSrc)
        {
            string toastXmlString = String.Empty;

            if (audioSrc.Equals("Silent"))
            {
                toastXmlString = "<toast>"
                                 + "<visual version='1'>"
                                 + "<binding template='ToastText02'>"
                                 + "<text id='1'>Sound:</text>"
                                 + "<text id='2'>" + audioSrc + "</text>"
                                 + "</binding>"
                                 + "</visual>"
                                 + "<audio silent='true'/>"
                                 + "</toast>";
            }
            else if (audioSrc.Equals("Default"))
            {
                toastXmlString = "<toast>"
                                 + "<visual version='1'>"
                                 + "<binding template='ToastText02'>"
                                 + "<text id='1'>Sound:</text>"
                                 + "<text id='2'>" + audioSrc + "</text>"
                                 + "</binding>"
                                 + "</visual>"
                                 + "</toast>";
            }
            else
            {
                toastXmlString = "<toast>"
                                 + "<visual version='1'>"
                                 + "<binding template='ToastText02'>"
                                 + "<text id='1'>Sound:</text>"
                                 + "<text id='2'>" + audioSrc + "</text>"
                                 + "</binding>"
                                 + "</visual>"
                                 + "<audio src='ms-winsoundevent:Notification." + audioSrc + "'/>"
                                 + "</toast>";
            }

            Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                toastDOM.LoadXml(toastXmlString);

                rootPage.NotifyUser(toastDOM.GetXml(), NotifyType.StatusMessage);

                // Create a toast, then create a ToastNotifier object to show
                // the toast
                ToastNotification toast = new ToastNotification(toastDOM);

                // 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);
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
Пример #11
0
        /// <summary>
        /// 通过Xml磁贴模版文件更新默认磁贴内容
        /// </summary>
        /// <param name="tileXml"></param>
        public static void UpdateTileNotificationsByXml(string tileXmlString)
        {
            /*
             * string tileXmlString = "<tile>"
             + "<visual version='3'>"
             + "<binding template='TileSquare71x71Image'>"
             + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
             + "</binding>"
             + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>"
             + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
             + "</binding>"
             + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>"
             + "<image id='1' src='ms-appx:///images/redWide310x150.png' alt='Red image'/>"
             + "<text id='1'>This tile notification uses ms-appx images</text>"
             + "</binding>"
             + "<binding template='TileSquare310x310Image'>"
             + "<image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/>"
             + "</binding>"
             + "</visual>"
             + "</tile>";
             * */

            // Create a DOM.
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();

            // Load the xml string into the DOM.
            tileDOM.LoadXml(tileXmlString);

            // Create a tile notification.
            TileNotification tile = new TileNotification(tileDOM);

            // Send the notification to the application’s tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
        }
Пример #12
0
        void NotifGenerator(AppointmentDetails details)
        {
            var xmlToastTemplate = String.Format("<toast launch=\"app-defined-string\">" +
                                                 "<visual>" +
                                                 "<binding template =\"ToastGeneric\">" +
                                                 "<text>Reminder</text>" +
                                                 "<text>" +
                                                 "You have an appointment with {0} at {1},{2} in 30 minutes" +
                                                 "</text>" +
                                                 "</binding>" +
                                                 "</visual>" +
                                                 "</toast>", details.doc_name, details.hosp_name, details.location);

            // load the template as XML document
            var xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();

            xmlDocument.LoadXml(xmlToastTemplate);


            // create the toast notification and show to user
            var toastNotification = new ToastNotification(xmlDocument);
            var notification      = ToastNotificationManager.CreateToastNotifier();

            notification.Show(toastNotification);
        }
Пример #13
0
        public static Windows.Data.Xml.Dom.XmlDocument CreateToast(string message)
        {
            var xDoc = new XDocument(
                new XElement("toast",
                             new XElement("visual",
                                          new XElement("binding", new XAttribute("template", "ToastGeneric"),
                                                       new XElement("text", message)
                                            //,new XElement("text", "Are you sure?") // uncomment for second line
                                                       )
                                          ) // for actions uncomment following
                                            //,
                                            //new XElement("actions",
                                            //new XElement("action", new XAttribute("activationType", "background"),
                                            //new XAttribute("content", "Yes"), new XAttribute("arguments", "yes")),
                                            //new XElement("action", new XAttribute("activationType", "background"),
                                            //new XAttribute("content", "No"), new XAttribute("arguments", "no"))
                                            //)
                             )
                );

            var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();

            xmlDoc.LoadXml(xDoc.ToString());
            return(xmlDoc);
        }
Пример #14
0
        private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                var item = (MagnetUri)e.ClickedItem;
                if (ViewModel.OpenHere)
                {
                    await Launcher.LaunchUriAsync(new Uri(item.OrginalUri));
                }
                else
                {
                    var http   = new HttpClient();
                    var result = (await http.PostAsync(new Uri(ViewModel.OpenWebpageUri), new HttpStringContent(item.OrginalUri)));
                    if (result.IsSuccessStatusCode)
                    {
                        var str = await result.Content.ReadAsStringAsync();

                        //str = "Added " + item.Name;
                        var toastXmlString = $"<toast><visual version='1'><binding template='ToastText01'><text id='1'>{str}</text></binding></visual></toast>";
                        Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
                        toastDOM.LoadXml(toastXmlString);
                        ToastNotification toast = new ToastNotification(toastDOM);
                        ToastNotificationManager.CreateToastNotifier().Show(toast);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #15
0
        public static void Tile(String FromNickName, String ToNickName)
        {
            Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument();
            xdoc.LoadXml(File.ReadAllText("tile.xml"));
            Windows.Data.Xml.Dom.XmlNodeList TileList = xdoc.GetElementsByTagName("text");
            TileList[0].InnerText  = FromNickName;
            TileList[1].InnerText  = "To";
            TileList[2].InnerText  = ToNickName;
            TileList[3].InnerText  = FromNickName;
            TileList[4].InnerText  = "To";
            TileList[5].InnerText  = ToNickName;
            TileList[6].InnerText  = FromNickName;
            TileList[7].InnerText  = "To";
            TileList[8].InnerText  = ToNickName;
            TileList[9].InnerText  = FromNickName;
            TileList[10].InnerText = "To";
            TileList[11].InnerText = ToNickName;

            TileNotification notification = new TileNotification(xdoc);

            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notification);
        }
Пример #16
0
        public void showToast()
        {
            TryCreateShortcut();
            var dq       = "\"";
            var toastXml = $@"
<toast duration={dq}long{dq}>
    <visual>
        <binding template={dq}ToastText02{dq}>
            <text id={dq}1{dq}>test Title</text>
            <text id={dq}2{dq}>test content</text>
        </binding>
    </visual>
  <actions>
  <input id={dq}snoozeTime{dq} type={dq}selection{dq} defaultInput={dq}15{dq}>
    #5つまで
    <selection id={dq}3{dq} content={dq}3 minutes{dq} />
    <selection id={dq}5{dq} content={dq}5 minutes{dq} />
    <selection id={dq}10{dq} content={dq}10 minutes{dq} />
    <selection id={dq}15{dq} content={dq}15 minutes{dq} />
    <selection id={dq}30{dq} content={dq}30 minutes{dq} />
  </input>
  <action activationType={dq}system{dq} arguments={dq}snooze{dq} hint-inputId={dq}snoozeTime{dq} content={dq}{dq}/>
  <action activationType={dq}system{dq} arguments={dq}dismiss{dq} content={dq}{dq}/>
  </actions>
</toast>
";

            var tileXml = new Windows.Data.Xml.Dom.XmlDocument();

            tileXml.LoadXml(toastXml);
            var toast  = new ToastNotification(tileXml);//.Dump();
            var notify = ToastNotificationManager.CreateToastNotifier(appId);

            notify.Show(toast);
        }
Пример #17
0
        void UpdateTileWithWebImageWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // create a string with the tile template xml
            string tileXmlString = "<tile>"
                                   + "<visual>"
                                   + "<binding template='TileWideImageAndText01'>"
                                   + "<text id='1'>This tile notification uses web images</text>"
                                   + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>"
                                   + "</binding>"
                                   + "<binding template='TileSquareImage'>"
                                   + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>"
                                   + "</binding>"
                                   + "</visual>"
                                   + "</tile>";

            // create a DOM
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                // load the xml string into the DOM, catching any invalid xml characters
                tileDOM.LoadXml(tileXmlString);

                // create a tile notification
                TileNotification tile = new TileNotification(tileDOM);

                // send the notification to the app's application tile
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

                OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml());
            }
            catch (Exception)
            {
                OutputTextBlock.Text = "Error loading the xml, check for invalid characters in the input";
            }
        }
Пример #18
0
        //private void ButtonCustomSnoozeTimes_Click(object sender, RoutedEventArgs e)
        //{
        //    Show(new ToastContent()
        //    {
        //        Scenario = ToastScenario.Reminder,

        //        Visual = new ToastVisual()
        //        {
        //            TitleText = new ToastText() { Text = "Daily Triage" },
        //            BodyTextLine1 = new ToastText() { Text = "10:00 AM - 10:30 AM" }
        //        },

        //        Launch = "392914",

        //        Actions = new ToastActionsCustom()
        //        {
        //            Inputs =
        //            {
        //                new ToastSelectionBox("snoozeAmount")
        //                {
        //                    Title = "Remind me...",
        //                    Items =
        //                    {
        //                        new ToastSelectionBoxItem("1", "Super soon (1 min)"),
        //                        new ToastSelectionBoxItem("5", "In a few mins"),
        //                        new ToastSelectionBoxItem("15", "When it starts"),
        //                        new ToastSelectionBoxItem("60", "After it's done")
        //                    },
        //                    DefaultSelectionBoxItemId = "1"
        //                }
        //            },

        //            Buttons =
        //            {
        //                new ToastButtonSnooze()
        //                {
        //                    SelectionBoxId = "snoozeAmount"
        //                },

        //                new ToastButtonDismiss()
        //            }
        //        }
        //    });
        //}

        //private void ButtonCustomSnoozeAndDismissText_Click(object sender, RoutedEventArgs e)
        //{
        //    Show(new ToastContent()
        //    {
        //        Visual = new ToastVisual()
        //        {
        //            TitleText = new ToastText() { Text = "Work" },
        //            BodyTextLine1 = new ToastText() { Text = "Wake up & go to work!!!" }
        //        },

        //        Launch = "394815",

        //        Scenario = ToastScenario.Alarm,

        //        Actions = new ToastActionsCustom()
        //        {
        //            Buttons =
        //            {
        //                new ToastButtonSnooze("5 more mins plz"),
        //                new ToastButtonDismiss("ok im awake")
        //            }
        //        }
        //    });
        //}

        //private void ButtonSystemSnoozeDismiss_Click(object sender, RoutedEventArgs e)
        //{
        //    Show(new ToastContent()
        //    {
        //        Visual = new ToastVisual()
        //        {
        //            TitleText = new ToastText() { Text = "Se ha recibido la anotación Registro General de Entradas 2016/234" },
        //            BodyTextLine1 = new ToastText() { Text = "Destinada al usuario 'OMAS'" }
        //        },
        //        Launch = "984910",
        //        Scenario = ToastScenario.Reminder,
        //        Actions = new ToastActionsSnoozeAndDismiss()
        //    });
        //}

        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            // template to load for showing Toast Notification
            StringBuilder xmlToast = new StringBuilder();

            xmlToast.Append("<toast launch=\"abs-alerta\">");
            xmlToast.Append("<visual>");
            xmlToast.Append("<binding template =\"ToastGeneric\">");
            xmlToast.Append("<image placement=\"AppLogoOverride\" src=\"Assets/Samples/Toasts/logoAbsis.gif\"/>");
            xmlToast.Append("<text>Sistema de Alertas ABSIS</text>");
            xmlToast.Append("<text>");
            xmlToast.Append("Registro General de Entradas 2.016/345");
            xmlToast.Append("</text>");
            xmlToast.Append("</binding>");
            xmlToast.Append("</visual>");
            xmlToast.Append("<actions>");
            xmlToast.Append("<action content=\"check\" arguments=\"check\" imageUri=\"check.png\" />");
            xmlToast.Append("<action content=\"cancel\" arguments=\"cancel\" />");
            xmlToast.Append("</actions>");
            xmlToast.Append("<audio src=\"ms-winsoundevent:Notification.Reminder\"/>");
            xmlToast.Append("</toast>");

            var xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();

            xmlDocument.LoadXml(xmlToast.ToString());

            var toastNotification = new ToastNotification(xmlDocument);
            var notification      = ToastNotificationManager.CreateToastNotifier();

            notification.Show(toastNotification);
        }
        private void SendTileNotificationWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                string tileXmlString = "<tile>"
                                       + "<visual version='2'>"
                                       + "<binding template='TileWide310x150Text04' fallback='TileWideText04'>"
                                       + "<text id='1'>Send to a secondary tile from strings</text>"
                                       + "</binding>"
                                       + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                                       + "<text id='1'>Send to a secondary tile from strings</text>"
                                       + "</binding>"
                                       + "</visual>"
                                       + "</tile>";

                Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
                tileDOM.LoadXml(tileXmlString);
                TileNotification tile = new TileNotification(tileDOM);

                // Send the notification to the secondary tile by creating a secondary tile updater
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(tile);

                rootPage.NotifyUser("Tile notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
            }
        }
        void UpdateTileWithImageWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // Create a string with the tile template xml.
            // Note that the version is set to "2" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes.
            // This is so that the notification can be understood by a Windows 8 machine as well.
            string tileXmlString = "<tile>"
                                   + "<visual version='2'>"
                                   + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>"
                                   + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
                                   + "</binding>"
                                   + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>"
                                   + "<image id='1' src='ms-appx:///images/redWide310x150.png' alt='Red image'/>"
                                   + "<text id='1'>This tile notification uses ms-appx images</text>"
                                   + "</binding>"
                                   + "<binding template='TileSquare310x310Image'>"
                                   + "<image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/>"
                                   + "</binding>"
                                   + "</visual>"
                                   + "</tile>";

            // Create a DOM.
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();

            // Load the xml string into the DOM.
            tileDOM.LoadXml(tileXmlString);

            // Create a tile notification.
            TileNotification tile = new TileNotification(tileDOM);

            // Send the notification to the application’s tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

            OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml());
        }
Пример #21
0
        private void UpdateTileWithTextWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // Create a string with the tile template xml.
            // Note that the version is set to "3" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes.
            // This is so that the notification can be understood by Windows 8 and Windows 8.1 machines as well.
            string tileXmlString =
                "<tile>"
                + "<visual version='3'>"
                + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                + "<text id='1'>Hello World! My very own tile notification</text>"
                + "</binding>"
                + "<binding template='TileWide310x150Text03' fallback='TileWideText03'>"
                + "<text id='1'>Hello World! My very own tile notification</text>"
                + "</binding>"
                + "<binding template='TileSquare310x310Text09'>"
                + "<text id='1'>Hello World! My very own tile notification</text>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

            // Create a DOM.
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();

            // Load the xml string into the DOM.
            tileDOM.LoadXml(tileXmlString);

            // Create a tile notification.
            TileNotification tile = new TileNotification(tileDOM);

            // Send the notification to the application? tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

            OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml());
            rootPage.NotifyUser("Tile notification with text sent", NotifyType.StatusMessage);
        }
        /// <summary>
        /// This is the click handler for the 'Scenario1BtnDefault' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario1BtnDefault_Click(object sender, RoutedEventArgs e)
        {
            String rss = scenario1RssInput.Text;

            if (null != rss && "" != rss)
            {
                try
                {
                    String xml;
                    var    doc = new Windows.Data.Xml.Dom.XmlDocument();
                    scenario1OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);
                    doc.LoadXml(xml);

                    // create a rss CDataSection and insert into DOM tree
                    var cdata   = doc.CreateCDataSection(rss);
                    var element = doc.GetElementsByTagName("content").Item(0);
                    element.AppendChild(cdata);

                    Scenario.RichEditBoxSetMsg(scenario1Result, doc.GetXml(), true);
                }
                catch (Exception exp)
                {
                    Scenario.RichEditBoxSetError(scenario1Result, exp.Message);
                }
            }
            else
            {
                Scenario.RichEditBoxSetError(scenario1Result, "Please type in RSS content in the [RSS Content] box firstly.");
            }
        }
Пример #23
0
        private void ClearClipboard()
        {
            var timeout     = s_resources.GetString("TimeoutText");
            var attribution = s_resources.GetString("TimeoutAttribution");

            var toastText = $@"<toast>
  <visual>
    <binding template=""ToastGeneric"">
      <text>{timeout}</text>
      <text>{attribution}</text>
    </binding>
  </visual>
</toast>";
            var xmlDoc    = new Windows.Data.Xml.Dom.XmlDocument();

            xmlDoc.LoadXml(toastText);

            Clipboard.Clear();

            var notification = new ToastNotification(xmlDoc)
            {
                NotificationMirroring = NotificationMirroring.Disabled,
                ExpirationTime        = DateTimeOffset.Now.AddSeconds(10)
            };

            ToastNotificationManager.CreateToastNotifier().Show(notification);
        }
Пример #24
0
        public static void SendDebugToast(string title, string text)
        {
#if DEBUG
            // template to load for showing Toast Notification
            var xmlToastTemplate = "<toast launch=\"app-defined-string\">" +
                                   "<visual>" +
                                   "<binding template =\"ToastGeneric\">" +
                                   "<text>" + WebUtility.HtmlEncode(title) + "</text>" +
                                   "<text>" +
                                   WebUtility.HtmlEncode(text) +
                                   "</text>" +
                                   "</binding>" +
                                   "</visual>" +
                                   "</toast>";

            // load the template as XML document
            var xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();
            xmlDocument.LoadXml(xmlToastTemplate);

            // create the toast notification and show to user
            var toastNotification = new Windows.UI.Notifications.ToastNotification(xmlDocument);
            var notification      = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
            notification.Show(toastNotification);
#endif
        }
        void ScheduleTileWithStringManipulation(String updateString, DateTime dueTime, int idNumber)
        {
            string tileXmlString = "<tile>"
                                   + "<visual version='2'>"
                                   + "<binding template='TileWide310x150Text09' fallback='TileWideText09'>"
                                   + "<text id='1'>" + updateString + "</text>"
                                   + "<text id='2'>" + "Received: " + dueTime.ToLocalTime() + "</text>"
                                   + "</binding>"
                                   + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                                   + "<text id='1'>" + updateString + "</text>"
                                   + "</binding>"
                                   + "</visual>"
                                   + "</tile>";

            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                tileDOM.LoadXml(tileXmlString);

                // Create the notification object
                ScheduledTileNotification futureTile = new ScheduledTileNotification(tileDOM, dueTime);
                futureTile.Id = "Tile" + idNumber;

                // Add to schedule
                // You can update a secondary tile in the same manner using CreateTileUpdaterForSecondaryTile(tileId)
                // See "Tiles" sample for more details
                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);
                rootPage.NotifyUser("Scheduled a tile with ID: " + futureTile.Id, NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
        protected static async Task <XmlDocument> ParseXmlResponse(HttpResponseMessage response)
        {
            try
            {
                if (ApplicationDiagnostics.VerboseLogging)
                {
                    Debug.WriteLine("XML REST response:\r\n" + UrlHelper.SafeToAbsoluteUri(response.RequestMessage.RequestUri) + "\r\n");
                }
            }
            catch (Exception e)
            {
                Debug.Fail("Failed to log REST response: " + e.ToString());
            }

            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                var         xml    = await response.Content.ReadAsStringAsync();

                if (String.IsNullOrWhiteSpace(xml))
                {
                    return(null);
                }
                xmlDoc.LoadXml(xml);
                XmlHelper.ApplyBaseUri(xmlDoc, response.Headers.Location);

                return(xmlDoc);
            }
            catch (Exception e)
            {
                Debug.Fail("Malformed XML document: " + e.ToString());
                return(null);
            }
        }
Пример #27
0
        /// <summary>
        /// displays a toast with the given heading, body, and optional second body
        /// </summary>
        /// <param name="heading">A required heading</param>
        /// <param name="body">A required body</param>
        /// <param name="body2">an optional second body</param>
        private void ShowToast(string heading, string body, string body2)
        {
            var builder = new StringBuilder();

            builder.Append("<toast><visual version='1'><binding template='ToastText04'><text id='1'>")
            .Append(heading)
            .Append("</text><text id='2'>")
            .Append(body)
            .Append("</text>");

            if (!string.IsNullOrEmpty(body2))
            {
                builder.Append("<text id='3'>")
                .Append(body2)
                .Append("</text>");
            }

            builder.Append("</binding>")
            .Append("</visual>")
            .Append("</toast>");

            var toastDom = new Windows.Data.Xml.Dom.XmlDocument();

            toastDom.LoadXml(builder.ToString());
            var toast = new ToastNotification(toastDom);

            try
            {
                ToastNotificationManager.CreateToastNotifier().Show(toast);
            }
            catch (Exception)
            {
                //do nothing, toast will gracefully fail
            }
        }
        void UpdateTileWithImageWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // create a string with the tile template xml
            string tileXmlString = "<tile>"
                                   + "<visual>"
                                   + "<binding template='TileWideImageAndText01'>"
                                   + "<text id='1'>This tile notification uses ms-appx images</text>"
                                   + "<image id='1' src='ms-appx:///images/redWide.png' alt='Red image'/>"
                                   + "</binding>"
                                   + "<binding template='TileSquareImage'>"
                                   + "<image id='1' src='ms-appx:///images/graySquare.png' alt='Gray image'/>"
                                   + "</binding>"
                                   + "</visual>"
                                   + "</tile>";

            // create a DOM
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            // load the xml string into the DOM, catching any invalid xml characters
            tileDOM.LoadXml(tileXmlString);

            // create a tile notification
            TileNotification tile = new TileNotification(tileDOM);

            // send the notification to the app's application tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

            OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml());
        }
Пример #29
0
        public static void CreateToast(object objectInfo)
        {
            var xDoc = new XDocument(
                new XElement("toast",
                             new XElement("visual",
                                          new XElement("binding", new XAttribute("template", "ToastGeneric"),
                                                       new XElement("text", "C# Corner"),
                                                       new XElement("text", "Did you got MVP award?")
                                                       )
                                          ), // actions
                             new XElement("actions",
                                          new XElement("action", new XAttribute("activationType", "background"),
                                                       new XAttribute("content", "Yes"), new XAttribute("arguments", "yes")),
                                          new XElement("action", new XAttribute("activationType", "background"),
                                                       new XAttribute("content", "No"), new XAttribute("arguments", "no"))
                                          )
                             )
                );

            var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();

            xmlDoc.LoadXml(xDoc.ToString());
            //return xmlDoc;
            //var xmdock = NotificationTest.CreateToast();
            var toast  = new ToastNotification(xmlDoc);
            var notifi = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();

            notifi.Show(toast);
        }
        private async Task <XmlDocument> GetCreatedEntity(HttpResponseMessage postResponse, PostNewImageResult result)
        {
            result.editUri = postResponse.Headers["Location"];
            string contentLocation = postResponse.Headers["Content-Location"];

            if (string.IsNullOrEmpty(result.editUri) || result.editUri != contentLocation)
            {
                XmlRestRequestHelper.XmlRequestResult xmlResult = new XmlRestRequestHelper.XmlRequestResult();

                xmlResult.uri = postResponse.RequestMessage.RequestUri;
                if (!string.IsNullOrEmpty(result.editUri))
                {
                    xmlResult.uri = new Uri(result.editUri);
                }
                XmlDocument doc = await xmlRestRequestHelper.Get(_requestFilter, xmlResult);

                result.etag = xmlResult.responseHeaders["ETag"];
                return(doc);
            }
            else
            {
                result.etag = postResponse.Headers["ETag"];
                XmlDocument xmlDoc = new XmlDocument();

                var xml = await postResponse.Content.ReadAsStringAsync();

                xmlDoc.LoadXml(xml);

                XmlHelper.ApplyBaseUri(xmlDoc, postResponse.RequestMessage.RequestUri);
                return(xmlDoc);
            }
        }
        private async Task ParseMediaEntry(string mediaEntryString, PicasaPostImage postImage)
        {
            postImage.srcUrl = null;

            // First try <content src>
            var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();

            xmlDoc.LoadXml(mediaEntryString);
            var contentEl = xmlDoc.SelectSingleNodeNS("/atom:entry/atom:content", _nsMgr.ToNSMethodFormat());

            if (contentEl != null)
            {
                postImage.srcUrl = XmlHelper.GetUrl(contentEl, "@src", _nsMgr, null);
            }

            // Then try media RSS
            if (postImage.srcUrl == null || postImage.srcUrl.Length == 0)
            {
                contentEl = xmlDoc.SelectSingleNodeNS("/atom:entry/media:group/media:content[@medium='image']", _nsMgr.ToNSMethodFormat());
                if (contentEl == null)
                {
                    throw new ArgumentException("Picasa photo entry was missing content element");
                }
                postImage.srcUrl = XmlHelper.GetUrl(contentEl, "@url", _nsMgr, null);
            }

            postImage.editUri = AtomEntry.GetLink(xmlDoc.SelectSingleNodeNS("/atom:entry", _nsMgr.ToNSMethodFormat()), _nsMgr, "edit-media", null, null, null);
        }
Пример #32
0
        async Task <SyndicationFeed> ReadFromWebWithAlternative()
        {
            // including user agent, otherwise FB rejects the request
            var _Client    = new HttpClient();
            var _UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)";

            _Client.DefaultRequestHeaders.Add("user-agent", _UserAgent);

            // fetch as string to avoid error
            var _Uri      = new Uri(this.SourceUrl);
            var _Response = await _Client.GetAsync(_Uri);

            var _String = await _Response.Content.ReadAsStringAsync();

            // convert to xml (will validate, too)
            var _XmlDocument = new Windows.Data.Xml.Dom.XmlDocument();

            _XmlDocument.LoadXml(_String);

            // manually fill feed from xml
            var _Feed = new Windows.Web.Syndication.SyndicationFeed();

            _Feed.LoadFromXml(_XmlDocument);
            return(_Feed);
        }
        /// <summary>
        /// This is the click handler for the 'Scenario2BtnDefault' button.
        /// This function will look up products and mark hot products.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario2BtnDefault_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                String xml;
                scenario2OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);

                var doc = new Windows.Data.Xml.Dom.XmlDocument();
                doc.LoadXml(xml);

                // Mark 'hot' attribute to '1' if 'sell10days' is greater than 'InStore'
                var xpath = "/products/product[Sell10day>InStore]/@hot";
                var hotAttributes = doc.SelectNodes(xpath);
                for (uint index = 0; index < hotAttributes.Length; index++)
                {
                    hotAttributes.Item(index).NodeValue = "1";
                }

                Scenario.RichEditBoxSetMsg(scenario2Result, doc.GetXml(), true);
                scenario2BtnSave.IsEnabled = true;  // enable Save button
            }
            catch (Exception exp)
            {
                Scenario.RichEditBoxSetError(scenario2Result, exp.Message);
            }
        }
 private void ShowToast(string message)
 {
     var toastXmlString = string.Format("<toast><visual version='1'><binding template='ToastText01'><text id='1'>{0}</text></binding></visual></toast>", message);
     var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
     xmlDoc.LoadXml(toastXmlString);
     var toast = new ToastNotification(xmlDoc);
     ToastNotificationManager.CreateToastNotifier().Show(toast);
 }
 private void SendBadgeWithStringManipulation_Click(object sender, RoutedEventArgs e)
 {
     string badgeXmlString = "<badge value='6'/>";
     Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();
     badgeDOM.LoadXml(badgeXmlString);
     BadgeNotification badge = new BadgeNotification(badgeDOM);
     BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
     rootPage.NotifyUser("Badge notification sent", NotifyType.StatusMessage);
 }
Пример #36
0
        private async void themNhacNhoButton_Click(object sender, RoutedEventArgs e)
        {
            // kiem tra ngay gio bao
            if (ngayDatePicker.Date == null || ngayDatePicker.Date < DateTime.Today || (ngayDatePicker.Date == DateTime.Today && gioTimePicker.Time < DateTime.Now.TimeOfDay))
            {
                MessageDialog msDialog1 = new MessageDialog("Ngày báo phải ở tương lai");
                await msDialog1.ShowAsync();
                return;
            }
            // lay thoi gian 
            int day = ngayDatePicker.Date.Value.Day;
            int month = ngayDatePicker.Date.Value.Month;
            int year = ngayDatePicker.Date.Value.Year;
            int hour = gioTimePicker.Time.Hours;
            int minute = gioTimePicker.Time.Minutes;
            DateTime thoigianbao = new DateTime(year, month, day, hour, minute, 0);
            string content = noidungTextBox.Text;
            //int snooze = Convert.ToInt32(((ComboBoxItem)baolaiComboBox.SelectedItem).Tag) * 60;
            //Debug.WriteLine(snooze);
            var xmlString = @"
<toast launch='args' scenario='alarm'>
    <visual>
        <binding template='ToastGeneric'>
            <text>Giảm cân 360</text>
            <text>" + content + @"</text>
        </binding>
    </visual>
    <actions>
        <input id='snoozeTime' type='selection' defaultInput='5'>
            <selection id = '1' content = '1 minutes' />
            <selection id = '5' content = '5 minutes' />
            <selection id = '10' content = '10 minutes' />
            <selection id = '20' content = '20 minutes' />
            <selection id = '30' content = '30 minutes' />
        </input >
        <action activationType='system' arguments = 'snooze' hint-inputId='snoozeTime'
                content = 'Báo lại' />
        <action activationType='system' arguments = 'dismiss'
                content = 'Bỏ qua' />
    </actions>
    <audio loop='true' src='ms-winsoundevent:Notification.Looping.Alarm2' />
</toast>";
            var doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml(xmlString);
            //var toast = new ToastNotification(doc);
            ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier();
            //thoi gian bao lai
            //TimeSpan snoozeInterval = TimeSpan.FromSeconds(snooze);
            // bao vao thoi gian 
            //var scheduledToast = new ScheduledToastNotification(doc, thoigianbao, snoozeInterval, 0);
            var scheduledToast = new ScheduledToastNotification(doc, thoigianbao);
            toastNotifier.AddToSchedule(scheduledToast);

            MessageDialog msDialog = new MessageDialog("Thêm nhắc nhở thành công");
            await msDialog.ShowAsync();
            Frame.Navigate(typeof(TrangChu), nguoidung);
        }
Пример #37
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();
     badgeDOM.LoadXml(string.Format(Common.NotificationXML.ToastInternetXML, "test111", "test112"));
     ToastNotification toast = new ToastNotification(badgeDOM);
     toast.SuppressPopup = true;
     toast.Tag = "msdn";
     ToastNotificationManager.CreateToastNotifier().Show(toast);
     toast.Activated += Toast_Activated;
 }
        public static void AddNotification(Activity act)
        {
            // notifications will be created only for planned activities
            if (act.List != "Zaplanowane") return;

            // setting notification delivery time
            DateTimeOffset scheduledTime = ((DateTimeOffset)act.StartDate).LocalDateTime;
            if (act.StartHour != null)
                scheduledTime = scheduledTime.Add((TimeSpan)act.StartHour);
            else if (act.StartDate == DateTime.Today)
                scheduledTime = scheduledTime.Add(new TimeSpan(16, 0, 0));
            else
                scheduledTime = scheduledTime.Add(new TimeSpan(9, 0, 0));
            //scheduledTime = DateTime.Now.AddSeconds(5); // debug setting

            // checking if notification can be created
            if (scheduledTime < DateTime.Now) return;

            // creating notification message
            string when = (act.StartHour == null) ? "dzisiaj" : act.StartHourUI;
            if (!string.IsNullOrEmpty(act.EstimationUI))
                when += ", przez " + act.EstimationUI;
            else if (act.EstimationId == 1)
                when += ", przez 30min";

            string contentString =
            "<toast scenario=\"reminder\" duration=\"long\">" +
                "<visual>" +
                    "<binding template=\"ToastGeneric\">" +
                        "<text id=\"1\">" + act.Title + "</text>" +
                        "<text id=\"2\">" + when + "</text>" +
                    "</binding>" +
                "</visual>" +
                "<commands>" +
                    "<command id=\"snooze\"/>" +
                    "<command id=\"dismiss\"/>" +
                "</commands>" +
            "</toast>";
            Windows.Data.Xml.Dom.XmlDocument content = new Windows.Data.Xml.Dom.XmlDocument();
            content.LoadXml(contentString);

            // creating new notification
            var newToast = new Windows.UI.Notifications.ScheduledToastNotification(content, scheduledTime, TimeSpan.FromMinutes(5), 0);
            newToast.Id = act.Id.ToString();

            // removing old scheduled notification if exists
            RemoveNotification(act);

            // adding new notification to schedule
            Windows.UI.Notifications.ToastNotifier toastNotifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
            toastNotifier.AddToSchedule(newToast);
        }
        private void btnSetLottoOn_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;
            if (b != null)
            {
                string toastTemplate = b.Name;
                string alarmName = "";

                if (toastTemplate.Contains("On"))
                {
                    alarmName = "Alarm is set on";
                }
                else
                {
                    alarmName = "Alarm is set off";
                }

                string toastXmlString =
                    "<toast duration=\"long\">\n" +
                        "<visual>\n" +
                            "<binding template=\"ToastText02\">\n" +
                                "<text id=\"1\">Lotto and LottoPlus Notifications</text>\n" +
                                "<text id=\"2\">" + alarmName + "</text>\n" +
                            "</binding>\n" +
                        "</visual>\n" +
                        "<commands scenario=\"alarm\">\n" +
                            "<command id=\"snooze\"/>\n" +
                            "<command id=\"dismiss\"/>\n" +
                        "</commands>\n" +
                        "<audio src=\"ms-winsoundevent:Notification.Looping.Alarm2\" loop=\"true\" />\n" +
                    "</toast>\n";
                var toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
                toastDOM.LoadXml(toastXmlString);

                var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();

                if (toastTemplate.Contains("On"))
                {
                    int customSnoozeSeconds = 5 * 60;
                    TimeSpan snoozeInterval = TimeSpan.FromSeconds(customSnoozeSeconds);
                    var customAlarmScheduledToast = new Windows.UI.Notifications.ScheduledToastNotification(toastDOM, DateTime.Now.AddSeconds(5), snoozeInterval, 0);
                    toastNotifier.AddToSchedule(customAlarmScheduledToast);
                }
                else
                {
                    var customAlarmScheduledToast = new Windows.UI.Notifications.ScheduledToastNotification(toastDOM, DateTime.Now.AddSeconds(5));
                    toastNotifier.AddToSchedule(customAlarmScheduledToast);
                }


            }
        }
Пример #40
0
        private async Task RefreshTile()
        {
            Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument();
            
            HttpClient httpClient = new HttpClient();

           
            var httpResponse = await httpClient.SendRequestAsync(new HttpRequestMessage(HttpMethod.Get,
                new Uri(BackgroundTasks.Config.TileUpdateUlr)));

            xdoc.LoadXml(httpResponse.Content.ToString());

            _tileUpdater.Update(new TileNotification(xdoc));
        }
Пример #41
0
        public static void UpdateTile(string xml, DateTimeOffset? expirationTime)
        {
            var tileXml = new Windows.Data.Xml.Dom.XmlDocument();
            tileXml.LoadXml(xml);
            var notification = new TileNotification(tileXml);
            if (expirationTime != null)
            {
                if (expirationTime > DateTimeOffset.Now)
                {
                    notification.ExpirationTime = expirationTime;
                }
            }

            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
        /// <summary>
        /// This is the click handler for the 'Scenario2BtnSave' button.
        /// This function is to save the new xml in which hot products are marked to a file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Scenario2BtnSave_Click(object sender, RoutedEventArgs e)
        {
            String xml;
            scenario2Result.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);

            var doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml(xml);

            // save xml to a file
            var file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("HotProducts.xml", Windows.Storage.CreationCollisionOption.GenerateUniqueName);
            await doc.SaveToFileAsync(file);

            Scenario.RichEditBoxSetMsg(scenario2Result, "Save to \"" + file.Path + "\" successfully.", true);

            scenario2BtnSave.IsEnabled = false;
        }
        private void SendTileWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            string tileXmlString = "<tile>"
                                 + "<visual version='2'>"
                                 + "<binding template='TileWide310x150SmallImageAndText03' fallback='TileWideSmallImageAndText03'>"
                                 + "<image id='1' src='ms-appx:///images/tile-sdk.png'/>"
                                 + "<text id='1'>This tile notification has an image, but it won't be displayed on the lock screen</text>"
                                 + "</binding>"
                                 + "</visual>"
                                 + "</tile>";

            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            tileDOM.LoadXml(tileXmlString);
            TileNotification tile = new TileNotification(tileDOM);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
            rootPage.NotifyUser("Tile notification sent", NotifyType.StatusMessage);
        }
Пример #44
0
 private void InitTiles()
 {
     Random random = new Random();
     for (int i = 0; i < 13; i++)
     {
         string tileXmlString = "<tile>" + "<visual>"
         + "<binding template='TileWideImage' branding='None'>"
         + "<image id='1' src='ms-appx:///Assets/" + random.Next(0,30) +".png' alt='alt text'/>"
         + "</binding>"
         + "<binding template='TileSquareImage' branding='None'>"
         + "<image id='1' src='ms-appx:///Assets/" + random.Next(0, 30) + ".png' alt='alt text'/>"
         + "</binding>"
         + "</visual>"
         + "</tile>";
         Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
         tileDOM.LoadXml(tileXmlString);
         TileNotification tile = new TileNotification(tileDOM);
         TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
     }
 }
        /// <summary>
        /// This is the click handler for the 'Scenario4BtnDefault' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario4BtnDefault_Click(object sender, RoutedEventArgs e)
        {
            String xml;
            scenario4OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml);

            var doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml(xml);

            var thisYear = 2012;    // Here we don't use DateTime.Now.Year to get the current year so that all gifts can be delivered.
            var previousOneYear = thisYear - 1;
            var previousFiveYear = thisYear - 5;
            var previousTenYear = thisYear - 10;

            var xpathArray = new String[3];
            // select >= 1 year and < 5 years
            xpathArray[0] = "descendant::employee[startyear <= " + previousOneYear + " and startyear > " + previousFiveYear + "]";
            // select >= 5 years and < 10 years
            xpathArray[1] = "descendant::employee[startyear <= " + previousFiveYear + " and startyear > " + previousTenYear + "]";
            // select >= 10 years
            xpathArray[2] = "descendant::employee[startyear <= " + previousTenYear + "]";

            var Gifts = new String[3] { "Gift Card", "XBOX", "Windows Phone" };

            var output = new StringBuilder();
            uint i = 0;
            foreach (var xpath in xpathArray)
            {
                var employees = doc.SelectNodes(xpath);
                foreach (var emplopyee in employees)
                {
                    var employeeName = emplopyee.SelectSingleNode("descendant::name");
                    var department = emplopyee.SelectSingleNode("descendant::department");

                    output.AppendFormat("[{0}]/[{1}]/[{2}]\n", employeeName.FirstChild.NodeValue, department.FirstChild.NodeValue, Gifts[(i++) % 3]);
                }
            }

            Scenario.RichEditBoxSetMsg(scenario4Result, output.ToString(), true);
        }
        void UpdateTileWithImageWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // Create a string with the tile template xml.
            // Note that the version is set to "3" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes.
            // This is so that the notification can be understood by Windows 8 and Windows 8.1 machines as well.
            string tileXmlString = "<tile>"
                + "<visual version='3'>"
                + "<binding template='TileSquare71x71Image'>"
                + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
                + "</binding>"
                + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>"
                + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
                + "</binding>"
                + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>"
                + "<image id='1' src='ms-appx:///images/redWide310x150.png' alt='Red image'/>"
                + "<text id='1'>This tile notification uses ms-appx images</text>"
                + "</binding>"
                + "<binding template='TileSquare310x310Image'>"
                + "<image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

            // Create a DOM.
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();

            // Load the xml string into the DOM.
            tileDOM.LoadXml(tileXmlString);

            // Create a tile notification.
            TileNotification tile = new TileNotification(tileDOM);

            // Send the notification to the application’s tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

            OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml());
            rootPage.NotifyUser("Tile notification with local images sent", NotifyType.StatusMessage);
        }
Пример #47
0
 private void sendToast(uint _progress)
 {
     string offtopic_ToastActionXML =
       "<toast>"
       + "  <visual>"
       + "    <binding template='ToastGeneric'>"
       + "      <text>{0}</text>"
       + "      <text>{1}</text>"
       + "      <image placement='AppLogoOverride' src='StoreLogo.png' />"
       + "    </binding>"
       + "  </visual>"
       + "  <actions>"
       + "<input id = 'message' type = 'text' placeholderContent = 'remark:' />"
       + "    <action content='Mark as Offtopic' arguments='offtopic'  activationType='foreground'/>" //background  foreground
       + "    <action content='{2}' arguments='ignore' />"
       + "  </actions>"
       + "</toast>";
     Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();
     badgeDOM.LoadXml(string.Format(offtopic_ToastActionXML, _progress+"% completed!", "testa","test"));
     DateTime starttime = DateTime.Now.AddSeconds(10);
     ToastNotification toast = new ToastNotification(badgeDOM);
     ToastNotificationManager.CreateToastNotifier().Show(toast);
     toast.Activated += Toast_Activated;
 }
Пример #48
0
        public void checkAndNotify()
        {
            //check if it is time
            string current = getCurrentMeal();

            if (!current.Equals(""))
            {

                Eat eat = null;
                eat = EatDB.getByDayID(_day.DayID).Where(et => et.Kind == current).First() as Eat;

                if (!eat.Notified)
                {


                    eat.Notified = true;
                    EatDB edb = new EatDB(eat);
                    edb.save();
                    //notify:
                    string toast = "<toast>"
                            + "<visual>"
                            + "<binding template = \"ToastGeneric\" >"
                            + "<text> Time to eat! </text>"
                            + "</binding>"
                            + "</visual>"
                            + "<audio src=\"ms - winsoundevent:Notification.Reminder\"/>"
                            + "</toast>";


                    Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
                    toastDOM.LoadXml(toast);

                    ToastNotification toastNotification = new ToastNotification(toastDOM);

                    var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();
                    toastNotifier.Show(toastNotification);

                }
                this.tbNextMeal.Text = "It is time for your";
                this.countdown.Text = current + " now!";
                rectTime.Visibility = Visibility.Collapsed;
                rectTimeBG.Visibility = Visibility.Collapsed;
                //countdown.Visibility = Visibility.Collapsed;

            }
            else
            {

                rectTime.Visibility = Visibility.Visible;
                rectTimeBG.Visibility = Visibility.Visible;
                countdown.Visibility = Visibility.Visible;
                updateCountdown();
            }


        }
Пример #49
0
        void UpdateTileWithWebImageWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // Create a string with the tile template xml.
            // Note that the version is set to "2" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes.
            // This is so that the notification can be understood by a Windows 8 machine as well.
            string tileXmlString =
                "<tile>"
                + "<visual version='2' addImageQuery='true'>"
                + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>"
                + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>"
                + "</binding>"
                + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>"
                + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>"
                + "<text id='1'>This tile notification uses web images.</text>"
                + "</binding>"
                + "<binding template='TileSquare310x310Image'>"
                + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

            // Create a DOM.
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                // Load the xml string into the DOM, catching any invalid xml characters.
                tileDOM.LoadXml(tileXmlString);

                // Create a tile notification.
                TileNotification tile = new TileNotification(tileDOM);

                // Send the notification to the application’s tile.
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

                OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml());
            }
            catch (Exception)
            {
                OutputTextBlock.Text = "Error loading the xml, check for invalid characters in the input";
            }
        }
        private void SendTileNotificationWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button != null)
            {
                string tileXmlString = "<tile>"
                                     + "<visual version='2'>"
                                     + "<binding template='TileWide310x150Text04' fallback='TileWideText04'>"
                                     + "<text id='1'>Send to a secondary tile from strings</text>"
                                     + "</binding>"
                                     + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                                     + "<text id='1'>Send to a secondary tile from strings</text>"
                                     + "</binding>"
                                     + "</visual>"
                                     + "</tile>";

                Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
                tileDOM.LoadXml(tileXmlString);
                TileNotification tile = new TileNotification(tileDOM);

                // Send the notification to the secondary tile by creating a secondary tile updater
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(tile);

                rootPage.NotifyUser("Tile notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
            }
        }
        void ScheduleTileWithStringManipulation(String updateString, DateTime dueTime, int idNumber)
        {
            string tileXmlString = "<tile>"
                         + "<visual version='2'>"
                         + "<binding template='TileWide310x150Text09' fallback='TileWideText09'>"
                         + "<text id='1'>" + updateString + "</text>"
                         + "<text id='2'>" + "Received: " + dueTime.ToLocalTime() + "</text>"
                         + "</binding>"
                         + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                         + "<text id='1'>" + updateString + "</text>"
                         + "</binding>"
                         + "</visual>"
                         + "</tile>";

            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                tileDOM.LoadXml(tileXmlString);

                // Create the notification object
                ScheduledTileNotification futureTile = new ScheduledTileNotification(tileDOM, dueTime);
                futureTile.Id = "Tile" + idNumber;

                // Add to schedule
                // You can update a secondary tile in the same manner using CreateTileUpdaterForSecondaryTile(tileId)
                // See "Tiles" sample for more details
                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);
                rootPage.NotifyUser("Scheduled a tile with ID: " + futureTile.Id, NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
Пример #52
0
        void DisplayLongToastWithStringManipulation(bool loopAudio)
        {
            string toastXmlString = String.Empty;
            if (loopAudio)
            {
                toastXmlString = "<toast duration='long'>"
                            + "<visual version='1'>"
                            + "<binding template='ToastText02'>"
                            + "<text id='1'>Long Duration Toast</text>"
                            + "<text id='2'>Looping audio</text>"
                            + "</binding>"
                            + "</visual>"
                            + "<audio loop='true' src='ms-winsoundevent:Notification.Looping.Alarm'/>"
                            + "</toast>";
            }
            else
            {
                toastXmlString = "<toast duration='long'>"
                         + "<visual version='1'>"
                         + "<binding template='ToastText02'>"
                         + "<text id='1'>Long Toast</text>"
                         + "</binding>"
                         + "</visual>"
                         + "<audio loop='true' src='ms-winsoundevent:Notification.IM'/>"
                         + "</toast>";
            }

            Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
            toastDOM.LoadXml(toastXmlString);

            // Create a toast, then create a ToastNotifier object to show
            // the toast
            scenario6Toast = new ToastNotification(toastDOM);
            ToastNotificationManager.CreateToastNotifier().Show(scenario6Toast);
            rootPage.NotifyUser(toastDOM.GetXml(), NotifyType.StatusMessage);
        }
Пример #53
0
        /// <summary>
        /// 通过Xml磁贴模版文件更新默认磁贴内容
        /// </summary>
        /// <param name="tileXml"></param>
        public static void UpdateSecondaryTileNotificationsByXml(string tileId, string tileXmlString)
        {

            /*
            string tileXmlString = "<tile>"
                + "<visual version='3'>"
                + "<binding template='TileSquare71x71Image'>"
                + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
                + "</binding>"
                + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>"
                + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
                + "</binding>"
                + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>"
                + "<image id='1' src='ms-appx:///images/redWide310x150.png' alt='Red image'/>"
                + "<text id='1'>This tile notification uses ms-appx images</text>"
                + "</binding>"
                + "<binding template='TileSquare310x310Image'>"
                + "<image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/>"
                + "</binding>"
                + "</visual>"
                + "</tile>";
             * */

            // Create a DOM.
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();

            // Load the xml string into the DOM.
            tileDOM.LoadXml(tileXmlString);

            // Create a tile notification.
            TileNotification tile = new TileNotification(tileDOM);

            // Send the notification to the application’s tile.
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tile);
        }
Пример #54
0
        /// <summary>
        /// 通过Xml磁贴模版文件更新磁贴图标
        /// </summary>
        /// <param name="TileGlyph"></param>
        public static void UpdateBadgeWithGlyphByXml(string tileId, string TileGlyph)
        {


            /*
                            public class TileGlyph
                {
                    public string Name { get; private set; }
                    public bool IsAvailable { get; private set; }
                    public TileGlyph(string name, bool isAvailable)
                    {
                        this.Name = name;
                        this.IsAvailable = isAvailable;
                    }
                    public override string ToString()
                    {
                        return Name;
                    }
                }

                public class TileGlyphCollection : ObservableCollection<TileGlyph>
                {
        
                    public TileGlyphCollection()
                    {
                        // Some glyphs are only available on Windows
            #if WINDOWS_PHONE_APP
                        const bool windows = false;
                        const bool phone = true;
            #else
                        const bool windows = true;
                        const bool phone = false;
            #endif

                        Add(new TileGlyph("none", windows | phone));
                        Add(new TileGlyph("activity", windows));
                        Add(new TileGlyph("alert", windows | phone));
                        Add(new TileGlyph("available", windows));
                        Add(new TileGlyph("away", windows));
                        Add(new TileGlyph("busy", windows));
                        Add(new TileGlyph("newMessage", windows));
                        Add(new TileGlyph("paused", windows));
                        Add(new TileGlyph("playing", windows));
                        Add(new TileGlyph("unavailable", windows));
                        Add(new TileGlyph("error", windows));
                        Add(new TileGlyph("attention", windows | phone));
                        Add(new TileGlyph("alarm", windows));
                    }
                }
                     * */

            // Create a string with the badge template xml.
            string badgeXmlString = "<badge value='" + TileGlyph + "'/>";
            Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();

            // Create a DOM.
            badgeDOM.LoadXml(badgeXmlString);

            // Load the xml string into the DOM, catching any invalid xml characters.
            BadgeNotification badge = new BadgeNotification(badgeDOM);

            // Create a badge notification and send it to the application’s tile.
            BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(tileId).Update(badge);


        }
Пример #55
0
        /// <summary>
        /// 通过Xml磁贴模版文件更新磁贴数字
        /// </summary>
        /// <param name="number"></param>
        public static void UpdateSecondaryBadgeWithNumberWithByXml(string tileId, int number)
        {
            // Create a string with the badge template xml.
            string badgeXmlString = "<badge value='" + number + "'/>";
            Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();
            // Create a DOM.
            badgeDOM.LoadXml(badgeXmlString);

            // Load the xml string into the DOM, catching any invalid xml characters.
            BadgeNotification badge = new BadgeNotification(badgeDOM);

            // Create a badge notification and send it to the application’s tile.
            BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(tileId).Update(badge);
        }
        private void SendBadgeNotificationWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button != null)
            {
                string badgeXmlString = "<badge value='9'/>";
                Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();
                badgeDOM.LoadXml(badgeXmlString);
                BadgeNotification badge = new BadgeNotification(badgeDOM);

                // Send the notification to the secondary tile
                BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(badge);

                rootPage.NotifyUser("Badge notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
            }
        }
        void ScheduleToastWithStringManipulation(String updateString, DateTime dueTime, int idNumber)
        {
            // Scheduled toasts use the same toast templates as all other kinds of toasts.
            string toastXmlString = "<toast>"
            + "<visual version='2'>"
            + "<binding template='ToastText02'>"
            + "<text id='2'>" + updateString + "</text>"
            + "<text id='1'>" + "Received: " + dueTime.ToLocalTime() + "</text>"
            + "</binding>"
            + "</visual>"
            + "</toast>";

            Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                toastDOM.LoadXml(toastXmlString);

                ScheduledToastNotification toast;
                if (RepeatBox.IsChecked != null && (bool)RepeatBox.IsChecked)
                {
                    toast = new ScheduledToastNotification(toastDOM, dueTime, TimeSpan.FromSeconds(60), 5);

                    // You can specify an ID so that you can manage toasts later.
                    // Make sure the ID is 15 characters or less.
                    toast.Id = "Repeat" + idNumber;
                }
                else
                {
                    toast = new ScheduledToastNotification(toastDOM, dueTime);
                    toast.Id = "Toast" + idNumber;
                }

                ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                rootPage.NotifyUser("Scheduled a toast with ID: " + toast.Id, NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
        //nouvel 
        void ScheduleToastWithStringManipulation(string updateString, DateTime dueTime, int idNumber)
        {
            string drugnameandinformation;
            if (drug.instruction == "No Instrucction")
            {
                 drugnameandinformation = drug.name;
            }
            else
            {
                 drugnameandinformation = drug.name + " : " + drug.instruction;
            }
            
            // Scheduled toasts use the same toast templates as all other kinds of toasts.
            string toastXmlString = "<toast>"
            + "<visual version='2'>"
            + "<binding template='ToastText02'>"
            + "<text id='1'>" + updateString + "</text>"
            + "<text id='2'>" + drugnameandinformation + "</text>"
            + "</binding>"
            + "</visual>"
            + "</toast>";

            Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                toastDOM.LoadXml(toastXmlString);

                ScheduledToastNotification toast;
               
                 //   toast = new ScheduledToastNotification(toastDOM, dueTime, TimeSpan.FromSeconds(60), 5);

                    // You can specify an ID so that you can manage toasts later.
                    // Make sure the ID is 15 characters or less.
                //    toast.Id = "Repeat" + idNumber;
              
                
                  toast = new ScheduledToastNotification(toastDOM, dueTime);
                  toast.Id = "Toast" + idNumber;

                ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
             //   NotifyUser("Scheduled a toast with ID: " + toast.Id, NotifyType.StatusMessage);
                myNotification m = new myNotification();
                m.myShedule = toast;
                m.alarmId = maxid + 1;
                a.shs.Add(toast.Id);
                ObservableCollection<myNotification> notifs = IsolatedStorageHelper.GetObject<ObservableCollection<myNotification>>("notifications");
                notifs.Add(m);
                IsolatedStorageHelper.SaveObject<ObservableCollection<myNotification>>("notifications", notifs);
                //  a.notifications.Add(toast);
            }
            catch (Exception)
            {
               // NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
Пример #59
0
        void DisplayAudioToastWithStringManipulation(string audioSrc)
        {
            string toastXmlString = String.Empty;

            if (audioSrc.Equals("Silent"))
            {
                toastXmlString = "<toast>"
                               + "<visual version='1'>"
                               + "<binding template='ToastText02'>"
                               + "<text id='1'>Sound:</text>"
                               + "<text id='2'>" + audioSrc + "</text>"
                               + "</binding>"
                               + "</visual>"
                               + "<audio silent='true'/>"
                               + "</toast>";
            }
            else if (audioSrc.Equals("Default"))
            {
                toastXmlString = "<toast>"
                           + "<visual version='1'>"
                           + "<binding template='ToastText02'>"
                           + "<text id='1'>Sound:</text>"
                           + "<text id='2'>" + audioSrc + "</text>"
                           + "</binding>"
                           + "</visual>"
                           + "</toast>";
            }
            else
            {
                toastXmlString = "<toast>"
                           + "<visual version='1'>"
                           + "<binding template='ToastText02'>"
                           + "<text id='1'>Sound:</text>"
                           + "<text id='2'>" + audioSrc + "</text>"
                           + "</binding>"
                           + "</visual>"
                           + "<audio src='ms-winsoundevent:Notification." + audioSrc + "'/>"
                           + "</toast>";
            }

            Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                toastDOM.LoadXml(toastXmlString);

                rootPage.NotifyUser(toastDOM.GetXml(), NotifyType.StatusMessage);

                // Create a toast, then create a ToastNotifier object to show
                // the toast
                ToastNotification toast = new ToastNotification(toastDOM);

                // 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);
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
        /// <summary>
        /// displays a toast with the given heading, body, and optional second body
        /// </summary>
        /// <param name="heading">A required heading</param>
        /// <param name="body">A required body</param>
        /// <param name="body2">an optional second body</param>
        private void ShowToast( string heading, string body, string body2 )
        {
            var builder = new StringBuilder();
            builder.Append( "<toast><visual version='1'><binding template='ToastText04'><text id='1'>" )
                .Append( heading )
                .Append( "</text><text id='2'>" )
                .Append( body )
                .Append( "</text>" );

            if( !string.IsNullOrEmpty( body2 ) )
            {
                builder.Append( "<text id='3'>" )
                    .Append( body2 )
                    .Append( "</text>" );
            }

            builder.Append( "</binding>" )
                .Append( "</visual>" )
                .Append( "</toast>" );

            var toastDom = new Windows.Data.Xml.Dom.XmlDocument();
            toastDom.LoadXml( builder.ToString() );
            var toast = new ToastNotification( toastDom );
            try
            {
                ToastNotificationManager.CreateToastNotifier().Show( toast );
            }
            catch( Exception )
            {
                //do nothing, toast will gracefully fail
            }
        }