/// <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.");
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Displays an image-based Toast Message
        /// </summary>
        /// <param name="appId">string-based application ID for handling Toast messages</param>
        /// <param name="title">Title of the toast message to be displayed</param>
        /// <param name="message">Message for the toast to contain</param>
        /// <param name="image">Image to display in the toast message</param>
        static void ShowImageToast(string appId, string title, string message, string image)
        {
            Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(
                ToastTemplateType.ToastImageAndText02);

            // Fill in the text elements
            Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
            stringElements[0].AppendChild(toastXml.CreateTextNode(title));
            stringElements[1].AppendChild(toastXml.CreateTextNode(message));

            // Specify the absolute path to an image
            String imagePath = "file:///" + image;

            Windows.Data.Xml.Dom.XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
            imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;

            // Create the toast and attach event listeners
            ToastNotification toast = new ToastNotification(toastXml);

            ToastEvents events = new ToastEvents();

            toast.Activated += events.ToastActivated;
            toast.Dismissed += events.ToastDismissed;
            toast.Failed    += events.ToastFailed;

            // Show the toast. Be sure to specify the AppUserModelId
            // on your application's shortcut!
            ToastNotificationManager.CreateToastNotifier(appId).Show(toast);
        }
Ejemplo n.º 4
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);
        }
        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);
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public async System.Threading.Tasks.Task LoadKML(System.Collections.Generic.List<Windows.Devices.Geolocation.BasicGeoposition> mapdata)
        {
            Windows.Data.Xml.Dom.XmlLoadSettings loadSettings = new Windows.Data.Xml.Dom.XmlLoadSettings();
            loadSettings.ElementContentWhiteSpace = false;
            Windows.Data.Xml.Dom.XmlDocument kml = new Windows.Data.Xml.Dom.XmlDocument();
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".kml");
            Windows.Storage.IStorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                string[] stringSeparators = new string[] { ",17" };
                kml = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(file);
                var element = kml.GetElementsByTagName("coordinates").Item(0);
                string ats  = element.FirstChild.GetXml();

                string[] atsa = ats.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                int size = atsa.Length-1;
                for (int i = 0; i < size; i++)
                {
                    string[] coord = atsa[i].Split(',');
                    double longi = Convert.ToDouble(coord[0]);
                    double lati = Convert.ToDouble(coord[1]);
                    mapdata.Add(new Windows.Devices.Geolocation.BasicGeoposition() { Latitude = lati, Longitude = longi });
                }
            }
        }
        /// <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);
            }
        }
        /// <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);
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        //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)
            {
            }
        }
        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);
        }
Ejemplo n.º 14
0
        private void toastWindowNotification(string text)
        {
            try
            {
                // Get a toast XML template
                Windows.Data.Xml.Dom.XmlDocument toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastImageAndText03);

                // Fill in the text elements
                Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
                for (int i = 0; i < stringElements.Length; i++)
                {
                    stringElements[i].AppendChild(toastXml.CreateTextNode(text));
                }

                // Specify the absolute path to an image
                String imagePath = "file:///" + Path.GetFullPath("toastImageAndText.png"); // 없으면 기본 아이콘 이미지로 알아서 뜸. ACT있는곳에 넣어야되는듯 dll옆이 아니라
                Windows.Data.Xml.Dom.XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
                imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;

                // Create the toast and attach event listeners
                Windows.UI.Notifications.ToastNotification toast = new Windows.UI.Notifications.ToastNotification(toastXml);

                // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut!
                Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast);
            }
            catch (Exception e)
            {
                Log.Ex(e, "error");
            }
        }
        async void XsltInit()
        {
            try
            {
                Windows.Storage.StorageFolder storageFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("xsltTransform");

                Windows.Storage.StorageFile xmlFile = await storageFolder.GetFileAsync("xmlContent.xml");

                Windows.Storage.StorageFile xsltFile = await storageFolder.GetFileAsync("xslContent.xml");

                // load xml file
                Windows.Data.Xml.Dom.XmlDocument doc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xmlFile);

                Scenario.RichEditBoxSetMsg(scenario5Xml, doc.GetXml(), false);

                // load xslt file
                doc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xsltFile);

                // Display xml and xslt file content in the input fields
                Scenario.RichEditBoxSetMsg(scenario5Xslt, doc.GetXml(), false);
                Scenario.RichEditBoxSetMsg(scenario5Result, "", true);
            }
            catch (Exception exp)
            {
                Scenario.RichEditBoxSetMsg(scenario5Xml, "", false);
                Scenario.RichEditBoxSetMsg(scenario5Xslt, "", false);
                Scenario.RichEditBoxSetError(scenario5Result, exp.Message);
                rootPage.NotifyUser("Exception occured while loading xml file!", NotifyType.ErrorMessage);
            }
        }
        /// <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.");
            }
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        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());
        }
        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);
            }
        }
        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);
            }
        }
        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 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());
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Helper method to pop a toast
        /// </summary>
        private void DoToast(int numEventsOfInterest, string eventName)
        {
            // pop a toast for each geofence event
            ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier();

            // Create a two line toast and add audio reminder

            // Here the xml that will be passed to the
            // ToastNotification for the toast is retrieved
            Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            // Set both lines of text
            Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text");
            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode("Geolocation Sample"));

            if (1 == numEventsOfInterest)
            {
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(eventName));
            }
            else
            {
                string secondLine = "There are " + numEventsOfInterest + " new geofence events";
                toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(secondLine));
            }

            // now create a xml node for the audio source
            Windows.Data.Xml.Dom.IXmlNode   toastNode = toastXml.SelectSingleNode("/toast");
            Windows.Data.Xml.Dom.XmlElement audio     = toastXml.CreateElement("audio");
            audio.SetAttribute("src", "ms-winsoundevent:Notification.SMS");

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotifier.Show(toast);
        }
Ejemplo n.º 24
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";
            }
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
        private void toastWindowNotification(string text)
        {
#if COMPATIBLE
            Task.Run(() =>
            {
                MessageBox.Show(text, "ACTFate", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
            });
#else
            {
                try
                {
                    // Get a toast XML template
                    Windows.Data.Xml.Dom.XmlDocument toastXml = Windows.UI.Notifications.ToastNotificationManager.GetTemplateContent(Windows.UI.Notifications.ToastTemplateType.ToastImageAndText03);

                    // Fill in the text elements
                    Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
                    for (int i = 0; i < stringElements.Length; i++)
                    {
                        stringElements[i].AppendChild(toastXml.CreateTextNode(text));
                    }

                    // Create the toast and attach event listeners
                    Windows.UI.Notifications.ToastNotification toast = new Windows.UI.Notifications.ToastNotification(toastXml);

                    // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut!
                    Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast);
                }
                catch (Exception e)
                {
                    Log.Ex(e, "error");
                }
            }
#endif
        }
Ejemplo n.º 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
            }
        }
        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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 30
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);
        }
Ejemplo n.º 31
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 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);
            }
        }
Ejemplo n.º 33
0
        public async void Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            try
            {
                DeviceConnectionChangeTriggerDetails details = (DeviceConnectionChangeTriggerDetails)taskInstance.TriggerDetails;
                BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync(details.DeviceId);

                SmartPack device = new SmartPack(bleDevice);

                if (bleDevice.ConnectionStatus == BluetoothConnectionStatus.Connected)
                {
                    if (device.AlertOnDevice && device.HasLinkLossService)
                    {
                        await device.SetAlertLevelCharacteristic();
                    }
                }
                else
                {
                    if (device.AlertOnPhone)
                    {
                        XmlDocument xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
                        xml.SelectSingleNode("/toast/visual/binding/text").InnerText = string.Format("Device {0} is out of range.", device.Name);
                        ToastNotification toast    = new ToastNotification(xml);
                        ToastNotifier     notifier = ToastNotificationManager.CreateToastNotifier();
                        notifier.Show(toast);
                    }
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
        private async Task SetTileNotification()
        {
            Windows.Data.Xml.Dom.XmlDocument _Tile = null;
            if (string.IsNullOrEmpty(this.Image))
            {
                // a template without an image
                _Tile = Windows.UI.Notifications.TileUpdateManager
                        .GetTemplateContent(Windows.UI.Notifications.TileTemplateType.TileSquareText01);
            }
            else
            {
                // a template with an image
                _Tile = Windows.UI.Notifications.TileUpdateManager
                        .GetTemplateContent(Windows.UI.Notifications.TileTemplateType.TileSquarePeekImageAndText01);
                var _Path = await TileHelper
                            .ResizeForTile(m_Question.Image, TileHelper.TileSize.Square);

                (_Tile.GetElementsByTagName("image")[0] as Windows.Data.Xml.Dom.XmlElement)
                .SetAttribute("src", _Path.ToString());
            }
            var _Texts = _Tile.GetElementsByTagName("text");

            _Texts[0].InnerText = this.Answer;
            _Texts[1].InnerText = Choices[1];
            _Texts[2].InnerText = Choices[2];
            _Texts[3].InnerText = Choices[3];
            var _Notification = new Windows.UI.Notifications.TileNotification(_Tile)
            {
                Tag = "no-repeat"
            };
            var _Updater = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();

            _Updater.Clear();
            _Updater.Update(_Notification);
        }
 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);
 }
Ejemplo n.º 37
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);
        }
Ejemplo n.º 38
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);
                }


            }
        }
Ejemplo n.º 41
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));
        }
Ejemplo n.º 42
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);
        }
        void UpdateTileWithWebImageWithStringManipulation_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' addImageQuery='true'>"
                + "<binding template='TileSquare71x71Image'>"
                + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>"
                + "</binding>"
                + "<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());
                rootPage.NotifyUser("Tile notification with web images sent", NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                OutputTextBlock.Text = string.Empty;
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
Ejemplo n.º 46
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);
        }
Ejemplo n.º 49
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);
            }
        }
        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);
            }
        }
        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);
            }
        }
Ejemplo n.º 53
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);
        }
        /// <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
            }
        }
Ejemplo n.º 55
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();
            }


        }
        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);
            }
        }
        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);
            }
        }
Ejemplo n.º 58
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);
        }
Ejemplo n.º 59
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);


        }
Ejemplo n.º 60
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);
        }