LoadXml() private method

private LoadXml ( [ xml ) : void
xml [
return void
示例#1
1
        private void btnLocatToastWithAction_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            string title = "Você recebeu uma imagem";
            string content = "Check this out, Happy Canyon in Utah!";
            string image = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-71-81-permanent/2727.happycanyon1_5B00_1_5D00_.jpg";

            string toastActions =
            $@"<toast>
                <visual>
                    <binding template='ToastGeneric'>
                        <text>{title}</text>
                        <text>{content}</text>
                        <image src='{image}' placement='appLogoOverride' hint-crop='circle'/>
                    </binding>
                </visual>
                <actions>
                    <input id = 'message' type = 'text' placeholderContent = 'reply here' />
                    <action activationType = 'background' content = 'reply' arguments = 'reply' />
                    <action activationType = 'foreground' content = 'video call' arguments = 'video' />
                </actions>
            </toast>";

            XmlDocument x = new XmlDocument();
            x.LoadXml(toastActions);
            ToastNotification t = new ToastNotification(x);
            ToastNotificationManager.CreateToastNotifier().Show(t);
        }
示例#2
1
        public static XmlDocument CreateToast(string msg)
        {
            var xDoc = new XDocument(new XElement("toast",
                new XElement("visual",
                new XElement("binding",
                new XAttribute("template", "ToastGeneric"),
                new XElement("text", "BEATS: Alert"),
                new XElement("text", msg)) // binding
                ), // visual
                new XElement("actions",
                new XElement("action",
                new XAttribute("activationType", "foreground"),
                new XAttribute("content", "I'm Okay"),
                new XAttribute("arguments", "yes")),
                new XElement("action",
                new XAttribute("activationType", "foreground"),
                new XAttribute("content", "Help me!"),
                new XAttribute("arguments", "no")))
                // actions
                ));

            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xDoc.ToString());
            return xmlDoc;
        }
示例#3
1
 public static async void actionsToast(string title, string content, string id)
 {
     string xml = "<toast>" +
                     "<visual>" +
                         "<binding template=\"ToastGeneric\">" +
                             "<text></text>" +
                             "<text></text>" +
                         "</binding>" +
                     "</visual>" +
                     "<actions>" +
                         "<input id=\"content\" type=\"text\" placeHolderContent=\"请输入评论\" />" +
                         "<action content = \"确定\" arguments = \"ok" + id + "\" activationType=\"background\" />" +
                         "<action content = \"取消\" arguments = \"cancel\" activationType=\"background\"/>" +
                     "</actions >" +
                  "</toast>";
     // 创建并加载XML文档
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xml);
     XmlNodeList elements = doc.GetElementsByTagName("text");
     elements[0].AppendChild(doc.CreateTextNode(title));
     elements[1].AppendChild(doc.CreateTextNode(content));
     // 创建通知实例
     ToastNotification notification = new ToastNotification(doc);
     //// 显示通知
     //DateTime statTime = DateTime.Now.AddSeconds(10);  //指定应传递 Toast 通知的时间
     //ScheduledToastNotification recurringToast = new ScheduledToastNotification(doc, statTime);  //创建计划的 Toast 通知对象
     //ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast); //向计划中添加 Toast 通知
     ToastNotifier nt = ToastNotificationManager.CreateToastNotifier();
     nt.Show(notification);
 }
        private void OnSendNotification(object sender, RoutedEventArgs e)
        {
            string xml = @"<toast launch=""developer-defined-string"">
                          <visual>
                            <binding template=""ToastGeneric"">
                              <image placement=""appLogoOverride"" src=""Assets/MicrosoftLogo.png"" />
                              <text>DotNet Spain Conference</text>
                              <text>How much do you like my session?</text>
                            </binding>
                          </visual>
                          <actions>
                            <input id=""rating"" type=""selection"" defaultInput=""5"" >
                          <selection id=""1"" content=""1 (Not very much)"" />
                          <selection id=""2"" content=""2"" />
                          <selection id=""3"" content=""3"" />
                          <selection id=""4"" content=""4"" />
                          <selection id=""5"" content=""5 (A lot!)"" />
                            </input>
                            <action activationType=""background"" content=""Vote"" arguments=""vote"" />
                          </actions>
                        </toast>";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            ToastNotification toast = new ToastNotification(doc);
            ToastNotificationManager.CreateToastNotifier().Show(toast);

        }
示例#5
0
文件: Parser.cs 项目: Anvyl/ITMoldova
 /// <summary>
 /// Get all feed data with a structure according to <see cref="ITMUtils.NewsParsing.NewsStruct" />
 /// </summary>
 /// <returns>All feed data into a <see cref="List{Structure}"/> format</returns>
 public async static Task<ObservableCollection<NewsStruct>> GetFeedData()
 {
     ObservableCollection<NewsStruct> result = new ObservableCollection<NewsStruct>();
     HttpClient client = new HttpClient();
     string xml = await client.GetStringAsync(SourceUrl);
     XmlDocument xdoc = new XmlDocument();
     xdoc.LoadXml(xml);
     XmlNodeList nodes = xdoc.SelectNodes(TitlePath);
     foreach (IXmlNode item in nodes)
     {
         result.Add(new NewsStruct() { Title = item.InnerText });
     }
     Regex rgx = new Regex("src=\".+?\"");
     xdoc.LoadXml(xml);
     nodes = xdoc.SelectNodes(DescriptionPath);
     int count = 0;
     string text = string.Empty;
     foreach (IXmlNode item in nodes)
     {
         text = item.NextSibling.NextSibling.InnerText;
         result[count].ImgSource = rgx.Matches(text)[0].Value.Replace("src=\"", string.Empty).Replace("\"", string.Empty);
         result[count].Content = Regex.Replace(Regex.Replace(text, "<.*?>", string.Empty), "&.*?;", string.Empty);
         result[count].EncodedString = text;
         count++;
     }
     nodes = xdoc.SelectNodes(PublishDatePath);
     count = 0;
     foreach (IXmlNode item in nodes)
     {
         result[count].PublishDate = DateTime.Parse(item.InnerText).ToLocalTime();
         result[count].Author = "Autor: " + item.NextSibling.NextSibling.InnerText;
         count++;
     }
     return result;
 }
        public async Task InitAsync(string filename = "onboarding.config")
        {
            if (filename == null)
            {
                throw new ArgumentException("Filename cannot be null", nameof(filename));
            }

            if (_xmlDocument == null)
            {
                _xmlDocument = new XmlDocument();

                var item = await ApplicationData.Current.LocalFolder.TryGetItemAsync(filename);
                if (item == null)
                {
                    var projectFolder = await Package.Current.InstalledLocation.GetFolderAsync("IoTOnboardingService");
                    item = await projectFolder.TryGetItemAsync(filename);

                    if (item != null && item.IsOfType(StorageItemTypes.File))
                    {
                        var file = await ((StorageFile)item).CopyAsync(ApplicationData.Current.LocalFolder);
                        var content = await FileIO.ReadTextAsync(file);
                        _xmlDocument.LoadXml(content);
                    }
                }
                else if (item.IsOfType(StorageItemTypes.File))
                {
                    var content = await FileIO.ReadTextAsync((StorageFile)item);
                    _xmlDocument.LoadXml(content);
                }
            }
        }
示例#7
0
        async private Task UpdateTile()
        {
            string server = settings.server;
            string uid = settings.uid;

            if (server.Length == 0 || uid.Length == 0) return;

            string url = "http://" + server + "/humidor/mobile.php?id=" + uid + "&page=3";

            await doWebReq(url);
            if (failed) await doWebReq(url);

            if (content == null || content.Length == 0) return;

            string xml = getXML(content);

            XmlDocument x = new XmlDocument();
            try
            {
                x.LoadXml(xml);
            }
            catch (Exception ex)
            {
                if (!_debug) return;
                x.LoadXml(getXML("Error Parsing WebXml"));
            }

            var tileNotification = new TileNotification(x);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
示例#8
0
        public async Task RefreshAsync(bool notify, bool checkDownloads, bool forceRefresh)
        {
            try
            {
                foreach (var episode in Episodes)
                {
                    if (episode.IsAlreadyDownloaded || episode.DownloadInProgress)
                    {
                        if (episode.IsPlayed && LocalSettings.Instance.DeleteDownloadWhenPlayed)
                        {
                            episode.DeleteDownload(true);
                        }

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

                GetLocalImage();

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

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

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

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

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

                    document.LoadXml(data);
                }

                await ParseAsync(document, notify, checkDownloads);
            }
            catch
            {
                // Ignore error
            }
        }
示例#9
0
        public void TryUpdateLiveTileAsync(String liveTileText, string imageUrl)
        {
            try
            {
                TileUpdateManager.CreateTileUpdaterForApplication()
                                 .EnableNotificationQueue(true);

                var liveTileXml = @"<tile>
                                      <visual version=""2"">
                                        <binding template=""TileSquare310x310ImageAndTextOverlay01"">
                                          <image id=""1"" src=""" + imageUrl + @""" alt=""alt text""/>
                                          <text id=""1"">" + liveTileText + @"</text>
                                        </binding>
                                      </visual>
                                    </tile>";

                var wideLiveTileXml = @"<tile>
                                          <visual version=""2"">
                                            <binding template=""TileWide310x150PeekImage03"" fallback=""TileWidePeekImage03"">
                                              <image id=""1"" src=""" + imageUrl + @""" alt=""alt text""/>
                                              <text id=""1"">" + liveTileText + @"</text>
                                            </binding>
                                          </visual>
                                        </tile>";

                var squareLiveTileXml = @"<tile>
                                           <visual version=""2"">
                                             <binding template=""TileSquare150x150PeekImageAndText04"" fallback=""TileSquarePeekImageAndText04"">
                                               <image id=""1"" src=""" + imageUrl + @""" alt=""alt text""/>
                                               <text id=""1"">" + liveTileText + @"</text>
                                             </binding>
                                           </visual>
                                         </tile>";

                var tileXml = new XmlDocument();

                tileXml.LoadXml(liveTileXml);
                var tileNotification = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

                tileXml.LoadXml(wideLiveTileXml);
                var wideTileNotification = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(wideTileNotification);

                tileXml.LoadXml(squareLiveTileXml);
                var squareTileNotification = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(squareTileNotification);

                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(new ScheduledTileNotification(tileXml, new DateTimeOffset(0, 0,0,0,0,30,0, new TimeSpan(0,0,30))));
            }
            catch
            {
                // do nothing, it doesn't matter!
            }
        }
示例#10
0
        public static async Task <Podcast> ParseAsync(string url, bool checkDownloads, string login = null, string password = null)
        {
            try
            {
                var data = await CoreTools.DownloadStringAsync(url, true, login, password);

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

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

                    document.LoadXml(data);
                }

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

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

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

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

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

                result.ReOrder();

                return(result);
            }
            catch
            {
                return(null);
            }
        }
示例#11
0
        private async Task<List<TileNotification>> CreateDataTilesAsync()
        {
            var result = new List<TileNotification>();

            var randomEntries = await backendServiceClient.GetRandomEntries(5);

            foreach (var randomEntry in randomEntries)
            {
                var tileHeading = randomEntry.Text;
                var tileText = randomEntry.Definition;

                var wideTile = TileContentFactory.CreateTileWide310x150Text01();
                wideTile.TextHeading.Text = tileHeading;
                wideTile.TextBody1.Text = tileText;

                var squareTile = TileContentFactory.CreateTileSquare150x150Text01();
                squareTile.TextHeading.Text = tileHeading;
                squareTile.TextBody1.Text = tileText;

                wideTile.Square150x150Content = squareTile;

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(wideTile.ToString());

                var notification = new TileNotification(xmlDocument);

                result.Add(notification);
            }

            return result;
        }
        private async void UpdateTilesAsync()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(tileUpdateURL);
                HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
                StreamReader reader = new StreamReader(response.GetResponseStream());

                string tileXml = reader.ReadToEnd();
                Debug.WriteLine(tileXml);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(tileXml);
                TileNotification tileNotification = new TileNotification(xmlDoc);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally
            {
                UpdateTaskCompleted();
            }
        }
示例#13
0
        private async static Task UpdateTilesAsync()
        {
            var todaysNames = await NamedayRepository.GetTodaysNamesAsStringAsync();

            if (todaysNames == null)
            {
                return;
            }

            var template =
                @"<tile>
    <visual version=""4"">
        <binding template=""TileMedium"">
            <text hint-wrap=""true"">{0}</text>
        </binding>
        <binding template=""TileWide"">
            <text hint-wrap=""true"">{0}</text>
        </binding>
    </visual>
</tile>";
            var content = string.Format(template, todaysNames);
            var doc     = new Windows.Data.Xml.Dom.XmlDocument();

            doc.LoadXml(content);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(doc));
        }
        public async Task<bool> IsInFastFood(GeoCoordinate geo)
        {
            XmlDocument doc = new XmlDocument();

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Add("Accept", "text/xml");

                var squarreSize = 0.0002;
                var url = "http://api.openstreetmap.org/api/0.6/map?bbox=" +
                          (geo.Longitude - squarreSize).ToString("G", CultureInfo.InvariantCulture) + "," +
                          (geo.Latitude - squarreSize).ToString("G", CultureInfo.InvariantCulture) + "," +
                          (geo.Longitude + squarreSize).ToString("G", CultureInfo.InvariantCulture) + "," +
                          (geo.Latitude + squarreSize).ToString("G", CultureInfo.InvariantCulture) + "&page=0";
                var uri = new Uri(url);
                HttpResponseMessage response = await client.GetAsync(uri);
                if (response.IsSuccessStatusCode)
                {
                    var s = await response.Content.ReadAsStringAsync();
                    doc.LoadXml(s);
                    var listNodeTag = doc.SelectNodes("//tag[@k='amenity'][@v='fast_food']");
                   // var listNodeTag = doc.SelectNodes("//tag[@k='bus'][@v='bus']");
                    //var busFound = s.IndexOf("bus") > 0;
                    if (listNodeTag.Count > 0)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
示例#15
0
        public void OnUpdateTileClicked(object sender, RoutedEventArgs e)
        {
            string xml = @"<tile>
        <visual>
        <binding template=""TileMedium"">
            <group>
            <subgroup>
                <text hint-style=""subtitle"">John Doe</text>
                <text hint-style=""subtle"">Photos from our trip</text>
                <text hint-style=""subtle"">Thought you might like to see all of</text>
            </subgroup>
            </group>
            <group>
            <subgroup>
                <text hint-style=""subtitle"">Jane Doe</text>
                <text hint-style=""subtle"">Questions about your blog</text>
                <text hint-style=""subtle\"">Have you ever considered writing a</text>
            </subgroup>
            </group>
        </binding>
        </visual>
    </tile>";



            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            TileNotification notification = new TileNotification(doc);
            TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notification);
        }
 public static void Hack()
 {
     var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
     XmlDocument document = new XmlDocument();
     document.LoadXml(xml);
     tileUpdater.Update(new TileNotification(document));
 }
        /// <summary>
        /// Retrieves the notification XML content as a WinRT XML document.
        /// </summary>
        /// <returns>The notification XML content as a WinRT XML document.</returns>
        public XmlDocument GetXml()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(GetContent());

            return doc;
        }
        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);
            }
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        async private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            try
            {
                Windows.Storage.StorageFile file = null;
                Windows.Storage.StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                file = await local.GetFileAsync("profile.xml");

                Stream fStream = await file.OpenStreamForReadAsync();
                StreamReader sr = new StreamReader(fStream);
                string result2 = sr.ReadToEnd();
                sr.Dispose();
                fStream.Dispose();
                XmlDocument profile = new XmlDocument();
                profile.LoadXml(result2);
                input_email.Text = profile.DocumentElement.SelectSingleNode("email").InnerText;
                input_username.Text = profile.DocumentElement.SelectSingleNode("username").InnerText;
                input_phone.Text = profile.DocumentElement.SelectSingleNode("phone").InnerText;


            }
            catch
            {
              
            }

        }
示例#20
0
            static async void SetLiveTileToSingleImage(string wideImageFileName, string mediumImageFileName)
            {
                // Construct the tile content as a string
                string content = $@"
                                <tile>
                                    <visual> 
                                        <binding template='TileSquareImage'>
                                           <image id='1' src='ms-appdata:///local/{mediumImageFileName}' />
                                        </binding> 
                                         <binding  template='TileWideImage' branding='none'>
                                           <image id='1' src='ms-appdata:///local/{wideImageFileName}' />
                                        </binding>
 
                                    </visual>
                                </tile>";

            SecondaryTile sec = new SecondaryTile("tile", "","prof2", new Uri("ms-appdata:///local/{mediumImageFileName}"), TileSize.Square150x150);
            await sec.RequestCreateAsync();
                // Load the string into an XmlDocument
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                // Then create the tile notification
                var notification = new TileNotification(doc);
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(sec.TileId).Update(notification);

        }
        // Windows Live Tile 
        private async static Task UpdateTileAsync()
        {
            var todayNames = await NamedayRepository.GetTodaysNamesAsStringAsync();
            if (todayNames == null)
                return;
            // Hardcoded XML template for Tile with 2 bindings
            var template =
@"<tile>
 <visual version=""4"">
  <binding template=""TileMedium"">
   <text hint-wrap=""true"">{0}</text>
  </binding>
  <binding template=""TileWide"">
   <text hint-wrap=""true"">{0}</text>
  </binding>
 </visual>
</tile>";
            var content = string.Format(template,todayNames);
            var doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml(content);

            // Create and Update Tile Notification
            TileUpdateManager.CreateTileUpdaterForApplication().
                Update(new TileNotification(doc));
            

        }
        public static ToastNotification DisplayToast(string content)
        {
            string xml = $@"<toast activationType='foreground'>
                                            <visual>
                                                <binding template='ToastGeneric'>
                                                    <text>Extended Execution</text>
                                                </binding>
                                            </visual>
                                        </toast>";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            var binding = doc.SelectSingleNode("//binding");

            var el = doc.CreateElement("text");
            el.InnerText = content;
            binding.AppendChild(el); //Add content to notification

            var toast = new ToastNotification(doc);

            ToastNotificationManager.CreateToastNotifier().Show(toast); //Show the toast

            return toast;
        }
示例#23
0
        public async void GenerateQuickAction()
        {
            var toastFile = await StorageFile.GetFileFromApplicationUriAsync(
                new Uri("ms-appx:///XMls/QuickAction.xml"));

            var xmlString = await FileIO.ReadTextAsync(toastFile);

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

            doc.LoadXml(xmlString);
            var toast = new ToastNotification(doc)
            {
                Group         = TRANSLATOR_GROUP,
                SuppressPopup = true
            };

            toast.Dismissed += Toast_Dismissed;
            toast.Activated += ToastOnActivated;
            toast.Failed    += Toast_Failed;

            var history = ToastNotificationManager.History.GetHistory();

            if (!history.Any(t => t.Group.Equals(TRANSLATOR_GROUP)))
            {
                ToastNotificationManager.CreateToastNotifier().Show(toast);
            }
            await Task.Delay(1000);
        }
        private void UpdateTileWithTextWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // create a string with the tile template xml
            string tileXmlString = "<tile>"
                                   + "<visual>"
                                   + "<binding template='TileWideText03'>"
                                   + "<text id='1'>Hello World! My very own tile notification</text>"
                                   + "</binding>"
                                   + "<binding template='TileSquareText04'>"
                                   + "<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, 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());
        }
        private static void UpdateTile()
        {
            var updateManager = TileUpdateManager.CreateTileUpdaterForApplication();
            updateManager.Clear();
            updateManager.EnableNotificationQueue(true);

            //prepare collection
            List<HolidayItem> eventCollection = _manager.GetHolidayList(DateTime.Now);

            if (eventCollection.Count < 5)
            {
                DateTime dt = DateTime.Now.AddMonths(1);
                List<HolidayItem> s = _manager.GetHolidayList(dt);
                eventCollection.AddRange(s);
            }

            //finalize collection
            eventCollection = (eventCollection.Count <= 5) ? eventCollection : eventCollection.Take(5).ToList();
            
            if (eventCollection.Count > 0)
                foreach (var currEvent in eventCollection)
                {
                    //date to show
                    DateTime date = new DateTime((int)currEvent.Year, (int)currEvent.Month, currEvent.Day);

                    var xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(String.Format(DataBakgroundManager.XML_TEMPLATE, date.ToString("d"), currEvent.HolidayName));

                    var notification = new TileNotification(xmlDocument);
                    updateManager.Update(notification);
                }
        }
示例#26
0
        // 更新磁贴,向磁贴中加入一个新图片
        public async void UpdataOneItem(StorageFolder folder, string fileName)
        {
            try
            {
                // 得到该item在本地缓存的本地Uri
                var file = await folder.GetFileAsync(fileName);

                // 进行xml内容的替换
                var doc = new Windows.Data.Xml.Dom.XmlDocument();
                var xml = string.Format(XmlData, "", "", new Uri(file.Path));
                // 磁贴更新
                var update = TileUpdateManager.CreateTileUpdaterForApplication();
                update.EnableNotificationQueue(true);

                doc.LoadXml(WebUtility.HtmlDecode(xml), new XmlLoadSettings
                {
                    ProhibitDtd              = false,
                    ValidateOnParse          = false,
                    ElementContentWhiteSpace = false,
                    ResolveExternals         = false
                });

                // 磁贴添加新图片
                update.Update(new TileNotification(doc));
            }
            catch (Exception)
            {
                // file not download then do not update
            }
        }
        internal XmlRpcMethodResponse(string responseText)
        {
            try
            {
                // analyze the response text to determine the content of the response
                XmlDocument document = new XmlDocument();
                if (responseText != null)
                {
                    responseText = responseText.TrimStart(' ', '\t', '\r', '\n');
                }
                document.LoadXml(responseText);
                IXmlNode responseValue = document.SelectSingleNode("/methodResponse/params/param/value");
                if (responseValue != null)
                {
                    _response = responseValue;
                }
                else
                {
                    // fault occurred
                    _faultOccurred = true;

                    IXmlNode errorCode = document.SelectSingleNode("/methodResponse/fault/value/struct/member[name='faultCode']/value");
                    _faultCode = errorCode.InnerText;

                    IXmlNode errorString = document.SelectSingleNode("/methodResponse/fault/value/struct/member[name='faultString']/value");
                    _faultString = errorString.InnerText;
                }
            }
            catch (Exception ex)
            {
                throw new XmlRpcClientInvalidResponseException(responseText, ex);
            }
        }
        public static ToastNotification PopToast(string title, string content, string tag, string group)
        {
            string xml = $@"<toast activationType='foreground'>
                                            <visual>
                                                <binding template='ToastGeneric'>
                                                </binding>
                                            </visual>
                                        </toast>";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            var binding = doc.SelectSingleNode("//binding");

            var el = doc.CreateElement("text");
            el.InnerText = title;

            binding.AppendChild(el);

            el = doc.CreateElement("text");
            el.InnerText = content;
            binding.AppendChild(el);

            return PopCustomToast(doc, tag, group);
        }
        private void UpdateTile()
        {
            var now = DateTime.Now.ToString("HH:mm:ss");
            var xml =
                "<tile>" +
                "  <visual>" +
                "    <binding template='TileSmall'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileMedium'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileWide'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileLarge'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "  </visual>" +
                "</tile>";

            var tileDom = new XmlDocument();
            tileDom.LoadXml(xml);
            var tile = new TileNotification(tileDom);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
        }
        /// <summary>
        /// Notify immediately using the type of notification
        /// </summary>
        /// <param name="noticeText"></param>
        /// <param name="notificationType"></param>
        public static void NotifyNow(string noticeText, NotificationType notificationType)
        {
            switch (notificationType)
            {
                case NotificationType.Toast:
                    //TODO: Make this hit and deserialize a real XML file
                    string toast = string.Format("<toast>"
                        + "<visual>"
                        + "<binding template = \"ToastGeneric\" >"
                        + "<image placement=\"appLogoOverride\" src=\"Assets\\CompanionAppIcon44x44.png\" />"
                        + "<text>{0}</text>"
                        + "</binding>"
                        + "</visual>"
                        + "</toast>", noticeText);

                    XmlDocument toastDOM = new XmlDocument();
                    toastDOM.LoadXml(toast);
                    ToastNotificationManager.CreateToastNotifier().Show(
                        new ToastNotification(toastDOM));
                    break;
                case NotificationType.Tile:
                    break;
                default:
                    break;
            }
        }
示例#31
0
        /// <summary>
        /// Show notification by custom xml
        /// </summary>
        /// <param name="xml">notification xml</param>
        /// <param name="tag">tag</param>
        /// <param name="group">group</param>
        /// <returns>ToastNotification</returns>
        public static ToastNotification PopCustomToast(string xml, string tag, string group)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            return PopCustomToast(doc, tag, group);
        }
示例#32
0
        public static void Reset()
        {
            UnregisterAllScheduledLiveTiles();

            string xml = "";

            xml += "<tile>\n";
            xml += "    <visual>\n";
            xml += "        <binding template=\"TileLarge\" displayName=\"Vaktija.ba\" branding=\"name\">\n";
            xml += "            <image src=\"Assets/Square310x310Logo.png\" placement=\"background\"/>";
            xml += "        </binding>\n";
            xml += "        <binding template=\"TileWide\" displayName=\"Vaktija.ba\" branding=\"name\">\n";
            xml += "            <image src=\"Assets/Wide310x150Logo.png\" placement=\"background\"/>";
            xml += "        </binding>\n";
            xml += "        <binding template=\"TileMedium\" displayName=\"Vaktija.ba\" branding=\"name\">\n";
            xml += "            <image src=\"Assets/Square150x150Logo.png\" placement=\"background\"/>";
            xml += "        </binding>\n";
            xml += "        <binding template=\"TileSmall\">";
            xml += "            <image src=\"Assets/Square71x71Logo.png\" placement=\"background\"/>";
            xml += "        </binding>";
            xml += "    </visual>\n";
            xml += "</tile>";

            Windows.Data.Xml.Dom.XmlDocument txml = new Windows.Data.Xml.Dom.XmlDocument();
            txml.LoadXml(xml);
            Windows.UI.Notifications.TileNotification tNotification = new Windows.UI.Notifications.TileNotification(txml);
            Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Update(tNotification);
        }
示例#33
0
        public static void ShowToast(string title, string message, [NotNull] Uri icon, Action click) {
            var tempIcon = FilesStorage.Instance.GetFilename("Temporary", "Icon.png");

            if (!File.Exists(tempIcon)) {
                using (var iconStream = Application.GetResourceStream(icon)?.Stream) {
                    if (iconStream != null) {
                        using (var file = new FileStream(tempIcon, FileMode.Create)) {
                            iconStream.CopyTo(file);
                        }
                    }
                }
            }

            var content = new XmlDocument();
            content.LoadXml($@"<toast>
    <visual>
        <binding template=""ToastImageAndText02"">
            <image id=""1"" src=""file://{tempIcon}""/>
            <text id=""1"">{title}</text>
            <text id=""2"">{message}</text>
        </binding>
    </visual>
</toast>");

            var toast = new ToastNotification(content);
            if (click != null) {
                toast.Activated += (sender, args) => {
                    Application.Current.Dispatcher.Invoke(click);
                };
            }

            ToastNotifier.Show(toast);
        }
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var details = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail;
            string arguments = details.Argument;
            var result = details.UserInput;

            if (arguments == "check")
            {
                int sum = int.Parse(result["message"].ToString());
                string message = sum == 15 ? "Congratulations, the answer is correct!" : "Sorry, wrong answer!";

                string xml = $@"<toast>
                              <visual>
                                <binding template=""ToastGeneric"">
                                  <image placement=""appLogoOverride"" src=""Assets/MicrosoftLogo.png"" />
                                  <text>{message}</text>
                                </binding>
                              </visual>
                            </toast>";

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);

                ToastNotification notification = new ToastNotification(doc);
                ToastNotificationManager.CreateToastNotifier().Show(notification);
            }
        }
        /// <summary>
        /// Schedule a notification of the specified date and type.
        /// </summary>
        /// <param name="noticeText"></param>
        /// <param name="dueTime"></param>
        /// <param name="notificationType"></param>
        public static void ScheduleNotification(string noticeText, DateTime dueTime, NotificationType notificationType)
        {
            switch (notificationType)
            {
                case NotificationType.Toast:
                    string toast = string.Format("<toast>"
                        + "<visual>"
                        + "<binding template = \"ToastGeneric\" >"
                        + "<image placement=\"appLogoOverride\" src=\"Assets\\CompanionAppIcon44x44.png\" />"
                        + "<text>{0}</text>"
                        + "</binding>"
                        + "</visual>"
                        + "</toast>", noticeText);

                    XmlDocument toastDOM = new XmlDocument();
                    toastDOM.LoadXml(toast);
                    ScheduledToastNotification toastNotification = new ScheduledToastNotification(toastDOM, dueTime) { Id = "Note_Reminder" };
                    ToastNotificationManager.CreateToastNotifier().AddToSchedule(toastNotification);
                    break;
                case NotificationType.Tile:
                    //TODO: Tile updates
                    throw new NotImplementedException();
                default:
                    break;
            }
        }
        private async void ButtonPinTile_Click(object sender, RoutedEventArgs e)
        {
            base.IsEnabled = false;

            string ImageUrl = _imagePath.ToString();

            SecondaryTile tile = TilesHelper.GenerateSecondaryTile("App Package Image");
            await tile.RequestCreateAsync();

            string tileXmlString =
                "<tile>"
                + "<visual>"
                + "<binding template='TileSmall'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileMedium'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileWide'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileLarge'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(tileXmlString);
            TileNotification notifyTile = new TileNotification(xmlDoc);
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notifyTile);

            base.IsEnabled = true;
        }
示例#37
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            try
            {
                StorageFile localFile = await ApplicationData.Current.LocalFolder.GetFileAsync("usersettings.xml");
                string localData = await FileIO.ReadTextAsync(localFile);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(localData);

                XmlNodeList nodeList = xmlDoc.SelectNodes("Categories/Bill");

                foreach (IXmlNode node in nodeList)
                {
                    string type = node.Attributes[0].NodeValue.ToString();
                    string title = node.Attributes[1].NodeValue.ToString();
                    string subtitle = node.Attributes[2].NodeValue.ToString();
                    string imagePath = node.Attributes[3].NodeValue.ToString();
                    string portalUrl = node.Attributes[4].NodeValue.ToString();

                    string dueDate = node.FirstChild.InnerText;
                    string isPaid = node.LastChild.InnerText;

                    Bill bill = new Bill(title, subtitle, imagePath, portalUrl, BillType.CreditCard, isPaid == "1", Convert.ToDateTime(dueDate));
                    this.Bill.Add(bill);
                }

                this.DataContext = this.Bill;

            }
            catch (FileNotFoundException)
            {
                this.Frame.Navigate(typeof(BillCategories));
            }
        }
		static string ToXmlString( string input )
		{
			var document = new XmlDocument();
			document.LoadXml( input.Trim(), new XmlLoadSettings { ElementContentWhiteSpace = false } );
			var result = document.GetXml();
			return result;
		}
示例#39
0
        public static void Reset()
        {
            var updater   = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();
            var scheduled = updater.GetScheduledTileNotifications();

            for (int i = 0; i < scheduled.Count; i++)
            {
                Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().RemoveFromSchedule(scheduled[i]);
            }

            string xml = "<tile>\n";

            xml += "<visual version=\"2\">\n";
            xml += "  <binding template=\"TileSquare150x150Image\" fallback=\"TileSquareImage\">\n";
            xml += "  <image id=\"1\" src=\"Assets/Square150x150Logo.png\" alt=\"alt text\"/>";
            xml += "  </binding>\n";
            xml += "  <binding template=\"TileWide310x150Image\" fallback=\"TileWideImage\">\n";
            xml += "  <image id=\"1\" src=\"Assets/Wide310x150Logo.png\" alt=\"alt text\"/>";
            xml += "  </binding>\n";
            xml += "  <binding template=\"TileSquare310x310Image\">\n";
            xml += "  <image id=\"1\" src=\"Assets/Square310x310Logo.png\" alt=\"alt text\"/>";
            xml += "  </binding>\n";
            xml += "</visual>\n";
            xml += "</tile>";

            Windows.Data.Xml.Dom.XmlDocument txml = new Windows.Data.Xml.Dom.XmlDocument();
            txml.LoadXml(xml);
            Windows.UI.Notifications.TileNotification tNotification = new Windows.UI.Notifications.TileNotification(txml);
            Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Update(tNotification);
        }
示例#40
0
        public override TileNotification GetNotificacion()
        {
            tile = new XmlDocument();            
            tile.LoadXml(stile);

            //System.Diagnostics.Debug.Write(tile.GetXml());

            var nodevisual = tile.GetElementsByTagName("binding");
            if (Title != null && Title != "")
            {
                ((XmlElement)nodevisual[1]).SetAttribute("displayName", this.Title);
            }

            var nodeImage = tile.GetElementsByTagName("image");
            ((Windows.Data.Xml.Dom.XmlElement)nodeImage[0]).SetAttribute("src", BackgroundImage.OriginalString);
            ((Windows.Data.Xml.Dom.XmlElement)nodeImage[1]).SetAttribute("src", BackgroundImage.OriginalString);
            //((Windows.Data.Xml.Dom.XmlElement)nodeImage[2]).SetAttribute("src", BackgroundImage.OriginalString);

            var nodeText = tile.GetElementsByTagName("text");
            nodeText[0].InnerText = BackTitle.ToString();
            nodeText[1].InnerText = BackContent.ToString();
            //nodeText[2].InnerText = BackContent.ToString();

            //System.Diagnostics.Debug.Write(this.tile.GetXml());
            var tileNotc = new TileNotification(this.tile);           
            return tileNotc;
        }
示例#41
0
        public static void PushNotification(string applicationName, string text)
        {
            Windows.Data.Xml.Dom.XmlDocument doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml($"<toast><visual><binding template=\"ToastImageAndText01\"><text id = \"1\" >{text}</text></binding></visual></toast>");
            var toast = new ToastNotification(doc);

            ToastNotificationManager.CreateToastNotifier(applicationName).Show(toast);
        }
示例#42
0
        private string Parse(string s, string name)
        {
            XMLDocument doc = new XMLDocument();

            doc.LoadXml(s);
            IXmlNode node = doc.SelectSingleNode(name);

            return(node.InnerText);
        }
示例#43
0
    public static DomXmlDocument ToDomXmlDocument(this XDocument xDocument)
    {
        var xmlDocument = new DomXmlDocument();

        using (var xmlReader = xDocument.CreateReader())
        {
            xmlDocument.LoadXml(xmlReader.ReadOuterXml());
        }
        return(xmlDocument);
    }
示例#44
0
        public static Windows.Data.Xml.Dom.XmlDocument CreateTiles(Todo newtodo, string pic_path)
        {
            XDocument xDoc = new XDocument(
                new XElement("tile", new XAttribute("version", 3),
                             new XElement("visual",
                                          // Small Tile
                                          new XElement("binding", new XAttribute("branding", "name"), new XAttribute("displayName", "myList"), new XAttribute("template", "TileSmall"),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", newtodo.Title, new XAttribute("hint-style", "caption")),
                                                                                 new XElement("text", newtodo.Detail, new XAttribute("hint-style", "captionsubtle")),
                                                                                 new XAttribute("hint-wrap", true),
                                                                                 new XAttribute("hint-maxLines", 3)
                                                                                 )
                                                                    )
                                                       ),
                                          // Medium Tile
                                          new XElement("binding", new XAttribute("branding", "name"), new XAttribute("displayName", "myList"), new XAttribute("template", "TileMedium"), new XElement("image", new XAttribute("placement", "background"), new XAttribute("src", pic_path)),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", newtodo.Title, new XAttribute("hint-style", "title")),
                                                                                 new XElement("text", newtodo.Detail, new XAttribute("hint-style", "base"),
                                                                                              new XAttribute("hint-wrap", true),
                                                                                              new XAttribute("hint-maxLines", 3))
                                                                                 )
                                                                    )
                                                       ),
                                          // Wide Tile
                                          new XElement("binding", new XAttribute("branding", "name"), new XAttribute("displayName", "myList"), new XAttribute("template", "TileWide"), new XElement("image", new XAttribute("placement", "background"), new XAttribute("src", pic_path)),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", newtodo.Title, new XAttribute("hint-style", "title")),
                                                                                 new XElement("text", newtodo.Detail, new XAttribute("hint-style", "base"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3)),
                                                                                 new XElement("text", newtodo.Date, new XAttribute("hint-style", "base"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
                                                                                 )
                                                                    )
                                                       ),
                                          //Large Tile
                                          new XElement("binding", new XAttribute("branding", "name"), new XAttribute("displayName", "myList"), new XAttribute("template", "TileLarge"), new XElement("image", new XAttribute("placement", "background"), new XAttribute("src", pic_path)),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", newtodo.Title, new XAttribute("hint-style", "title")),
                                                                                 new XElement("text", newtodo.Detail, new XAttribute("hint-style", "base"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3)),
                                                                                 new XElement("text", newtodo.Date, new XAttribute("hint-style", "base"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
                                                                                 )
                                                                    )
                                                       )
                                          )
                             )
                );

            Windows.Data.Xml.Dom.XmlDocument xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
            xmlDoc.LoadXml(xDoc.ToString());
            return(xmlDoc);
        }
示例#45
0
        public static Windows.Data.Xml.Dom.XmlDocument CreateTiles(PrimaryTile primaryTile)
        {
            XDocument xDoc = new XDocument(
                new XElement("tile", new XAttribute("version", 3),
                             new XElement("visual",
                                          // Small Tile
                                          new XElement("binding", new XAttribute("branding", primaryTile.branding), new XAttribute("displayName", primaryTile.appName), new XAttribute("template", "TileSmall"),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", primaryTile.time, new XAttribute("hint-style", "caption")),
                                                                                 new XElement("text", primaryTile.message, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
                                                                                 )
                                                                    )
                                                       ),

                                          // Medium Tile
                                          new XElement("binding", new XAttribute("branding", primaryTile.branding), new XAttribute("displayName", primaryTile.appName), new XAttribute("template", "TileMedium"),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", primaryTile.time, new XAttribute("hint-style", "caption")),
                                                                                 new XElement("text", primaryTile.message, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
                                                                                 )
                                                                    )
                                                       ),

                                          // Wide Tile
                                          new XElement("binding", new XAttribute("branding", primaryTile.branding), new XAttribute("displayName", primaryTile.appName), new XAttribute("template", "TileWide"),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", primaryTile.time, new XAttribute("hint-style", "caption")),
                                                                                 new XElement("text", primaryTile.message, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
                                                                                 )
                                                                    )
                                                       ),

                                          //Large Tile
                                          new XElement("binding", new XAttribute("branding", primaryTile.branding), new XAttribute("displayName", primaryTile.appName), new XAttribute("template", "TileLarge"),
                                                       new XElement("group",
                                                                    new XElement("subgroup",
                                                                                 new XElement("text", primaryTile.time, new XAttribute("hint-style", "caption")),
                                                                                 new XElement("text", primaryTile.message, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3)),
                                                                                 new XElement("text", primaryTile.message2, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
                                                                                 ),
                                                                    new XElement("subgroup", new XAttribute("hint-weight", 15),
                                                                                 new XElement("image", new XAttribute("placement", "inline"), new XAttribute("src", "Assets/StoreLogo.png"))
                                                                                 )
                                                                    )
                                                       )
                                          )
                             ));

            Windows.Data.Xml.Dom.XmlDocument xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
            xmlDoc.LoadXml(xDoc.ToString());
            return(xmlDoc);
        }
示例#46
0
        public bool CheckDoc(string temp)
        {
            if (doc != null)
            {
                return(true);
            }

            try
            {
                doc = new Windows.Data.Xml.Dom.XmlDocument();
                doc.LoadXml(temp);
            }
            catch (Exception)  //backup leverage html agility pack
            {
                try
                {
                    HtmlDocument hdoc = new HtmlDocument();
                    hdoc.LoadHtml(temp);
                    hdoc.OptionOutputAsXml    = true;
                    hdoc.OptionAutoCloseOnEnd = true;

                    MemoryStream stream = new MemoryStream();

                    XmlWriter xtw = XmlWriter.Create(stream, new XmlWriterSettings {
                        ConformanceLevel = ConformanceLevel.Fragment
                    });

                    hdoc.Save(xtw);

                    stream.Position = 0;

                    doc.LoadXml((new System.IO.StreamReader(stream)).ReadToEnd());
                }
                catch (Exception)
                {
                    return(false);
                }
            }

            return(true);
        }
示例#47
0
        public static void Update()
        {
            Day juce  = Year.year.months[DateTime.Now.AddDays(-1).Month - 1].days[DateTime.Now.AddDays(-1).Day - 1];
            Day danas = Year.year.months[DateTime.Now.Month - 1].days[DateTime.Now.Day - 1];
            Day sutra = Year.year.months[DateTime.Now.AddDays(1).Month - 1].days[DateTime.Now.AddDays(1).Day - 1];

            string tempStr = "";

            foreach (var it in danas.vakti)
            {
                if (it.time.DayOfWeek == DayOfWeek.Friday && it.rbr == 2)
                {
                    it.name = "Podne (Džuma)".ToLower();                                                       //Ako je petak i vakat podna, postavit dzumu
                }
                tempStr += "<text id=\"" + (it.rbr + 2).ToString() + "\">" + it.time.ToString("HH:mm") + " " + it.name.ToLower() + "</text>\n";
            }

            #region Lock screen details
            string row1 = "";
            string row2 = "";
            string row3 = "";
            row1 = danas.vakti[0].time.ToString("HH:mm") + " zora       " + " izl sunca " + danas.vakti[1].time.ToString("HH:mm");
            row2 = danas.vakti[2].time.ToString("HH:mm") + " podne   " + "    ikindija " + danas.vakti[3].time.ToString("HH:mm");
            row3 = danas.vakti[4].time.ToString("HH:mm") + " akšam   " + "        jacija " + danas.vakti[5].time.ToString("HH:mm") + "\n" + Memory.location.ime.ToLower();
            #endregion

            var nextPrayer = Get.Next_Prayer_Time();

            string xml = "<tile>\n";
            xml += "<visual version=\"2\">\n";
            xml += "  <binding template=\"TileWide310x150Text02\" fallback=\"TileWideText02\" hint-lockDetailedStatus1=\"" + row1.ToLower() + "\" hint-lockDetailedStatus2=\"" + row2.ToLower() + "\" hint-lockDetailedStatus3=\"" + row3.ToLower() + "\">\n";
            xml += "  <image id=\"1\" src=\"Assets/Wide310x150Logo.png\" alt=\"alt text\"/>";
            xml += tempStr;
            xml += "  <text id=\"1\">" + Memory.location.ime.ToLower() + "</text>\n";
            xml += "  </binding>\n";
            xml += "  <binding template=\"TileSquare150x150Text01\" fallback=\"TileSquareText01\">\n";
            xml += "  <text id=\"1\">" + nextPrayer.time.ToString("HH:mm") + "</text>";
            xml += "  <text id=\"2\">" + nextPrayer.name.ToLower() + "</text>";
            xml += "  </binding>\n";
            xml += "</visual>\n";
            xml += "</tile>";
            xml  = xml.Replace("izlazak sunca", "izl sunca");

            Windows.Data.Xml.Dom.XmlDocument txml = new Windows.Data.Xml.Dom.XmlDocument();
            txml.LoadXml(xml);
            Windows.UI.Notifications.TileNotification tNotification = new Windows.UI.Notifications.TileNotification(txml);
            Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Update(tNotification);

            RegisterLiveTiles();
        }
示例#48
0
        public async Task <List <TreeItem> > GetMenuStructureFromEtaAsync()
        {
            HttpClient client  = new HttpClient();
            var        content = (await client.GetStringAsync(new Uri($"{_etatouchUrl}/user/menu")));

            Windows.Data.Xml.Dom.XmlDocument doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml(content, new XmlLoadSettings()
            {
                ElementContentWhiteSpace = false
            });

            var result = new List <TreeItem>();

            ParseTree(doc.DocumentElement.ChildNodes.Single(d => d.NodeName == "menu"), result);
            return(result);
        }
示例#49
0
        private void Button_Click(System.Object sender, RoutedEventArgs e)
        {
            string tilexml = string.Format(TileTemplateXml, textbox1.Text, textbox2.Text, textbox3.Text);
            var    updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.EnableNotificationQueueForWide310x150(true);
            updater.EnableNotificationQueueForSquare150x150(true);
            updater.EnableNotificationQueueForSquare310x310(true);
            updater.EnableNotificationQueue(true);
            updater.Clear();
            var doc = new Windows.Data.Xml.Dom.XmlDocument();

            doc.LoadXml(WebUtility.HtmlDecode(tilexml), new XmlLoadSettings {
                ProhibitDtd = false, ValidateOnParse = false, ElementContentWhiteSpace = false, ResolveExternals = false
            });
            updater.Update(new TileNotification(doc));
        }
        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);
            }
        }
示例#51
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        static XmppSerializer()
        {
            var watch = Stopwatch.StartNew();

            var assembly = typeof(XmppSerializer).GetTypeInfo().Assembly;
            var resource = "Conversa.Net.Xmpp.Xml.Serializers.xml";
            var document = new Windows.Data.Xml.Dom.XmlDocument();

            document.LoadXml(ReadResource(assembly, resource));

            var list = document.SelectNodes("/serializers/serializer");

            Serializers = new List <XmppSerializer>();

            foreach (IXmlNode serializer in list)
            {
                var node = serializer.SelectSingleNode("namespace");

                string ename  = serializer.Attributes.Single(a => a.NodeName == "elementname").NodeValue.ToString();
                string prefix = node.SelectSingleNode("prefix").InnerText;
                string nsName = node.SelectSingleNode("namespace").InnerText;
                string tName  = serializer.SelectSingleNode("serializertype").InnerText;
                Type   type   = assembly.ExportedTypes.SingleOrDefault(x => x.FullName == tName);

                Serializers.Add(new XmppSerializer(ename, prefix, nsName, type));
            }

            XmlReaderSettings = new XmlReaderSettings
            {
                ConformanceLevel = ConformanceLevel.Fragment
            };

            XmlWriterSettings = new XmlWriterSettings
            {
                ConformanceLevel     = ConformanceLevel.Auto
                , Encoding           = XmppEncoding.Utf8
                , Indent             = false
                , NamespaceHandling  = NamespaceHandling.Default
                , OmitXmlDeclaration = true
            };

            watch.Stop();

            Debug.WriteLine(String.Format("XmppSerializer static constructor elapsed time: {0}", watch.Elapsed));
        }
示例#52
0
        private void load()
        {
            string titleString = File.ReadAllText("title.xml");

            Windows.Data.Xml.Dom.XmlDocument doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml(titleString);
            Windows.Data.Xml.Dom.XmlNodeList titles = doc.GetElementsByTagName("text");
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            for (int i = 0; i < ViewModel.AllItems.Count; i++)
            {
                titles[0].InnerText = titles[2].InnerText = titles[4].InnerText = ViewModel.AllItems[i].title;
                titles[1].InnerText = titles[3].InnerText = titles[5].InnerText = ViewModel.AllItems[i].description;
                var         tileNotification = new TileNotification(doc);
                TileUpdater updater          = TileUpdateManager.CreateTileUpdaterForApplication();
                updater.Update(tileNotification);
            }
        }
        public GameOver()
        {
            this.InitializeComponent();
            tblk_score.Text = Data.score.ToString();
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            Windows.Data.Xml.Dom.XmlDocument doc = new Windows.Data.Xml.Dom.XmlDocument();
            var xml = String.Format(TileTemplateXml, Data.score.ToString());

            doc.LoadXml(WebUtility.HtmlDecode(xml), new XmlLoadSettings
            {
                ProhibitDtd              = false,
                ValidateOnParse          = false,
                ElementContentWhiteSpace = false,
                ResolveExternals         = false
            });

            updater.Update(new TileNotification(doc));
        }
示例#54
0
        //磁铁创建函数
        private void tileCreate()
        {
            Windows.Data.Xml.Dom.XmlDocument document = new Windows.Data.Xml.Dom.XmlDocument();
            document.LoadXml(System.IO.File.ReadAllText("XMLFile1.xml"));
            Windows.Data.Xml.Dom.XmlNodeList Texttitle = document.GetElementsByTagName("text");

            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            for (int i = 0; i < ViewModel.AllRecords.Count; i++)
            {
                if (i < 5)
                {
                    Texttitle[0].InnerText = Texttitle[2].InnerText = Texttitle[4].InnerText = ViewModel.AllRecords[i].score.ToString();
                    Texttitle[1].InnerText = Texttitle[3].InnerText = Texttitle[5].InnerText = ViewModel.AllRecords[i].date.ToString();
                    TileNotification newTile = new TileNotification(document);
                    TileUpdateManager.CreateTileUpdaterForApplication().Update(newTile);
                }
            }
        }
示例#55
0
        public Alarm(string Name)
        {
            string toastXmlString = "<toast>"
                                    + "<audio />"
                                    + "<commands scenario='alarm'>"
                                    + "<command id='snooze' />"
                                    + "<command id='dismiss' />"
                                    + "</commands>"
                                    + "<visual version='1'>"
                                    + "<binding template='ToastText02'>"
                                    + "<text id='1'></text>"
                                    + "<text id='2'></text>"
                                    + "</binding>"
                                    + "</visual>"
                                    + "</toast>";

            toastDOM = new Windows.Data.Xml.Dom.XmlDocument();
            toastDOM.LoadXml(toastXmlString);
        }
示例#56
0
        private async Task UpdateTile()
        {
            try
            {
                var kd_list = await GetKD();

                var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                updater.EnableNotificationQueueForWide310x150(true);
                updater.EnableNotificationQueueForSquare150x150(true);
                updater.EnableNotificationQueueForSquare310x310(true);
                updater.EnableNotificationQueue(true);
                updater.Clear();
                foreach (var kd in kd_list)
                {
                    var kd_net = new KD_Model_Net(kd);
                    await kd_net.Load();

                    if (kd_net.message == "ok" && kd_net.ischeck == "0")
                    {
                        var tilexml = string.Format(TileTemplateXml, kd_net.name, kd_net.com_cn, kd_net.newdata.context, kd_net.newdata.time_s);
                        var doc     = new Windows.Data.Xml.Dom.XmlDocument();
                        doc.LoadXml(WebUtility.HtmlDecode(tilexml), new XmlLoadSettings
                        {
                            ProhibitDtd              = false,
                            ValidateOnParse          = false,
                            ElementContentWhiteSpace = false,
                            ResolveExternals         = false
                        });
                        updater.Update(new TileNotification(doc));
                        if (await isNew(kd_net))
                        {
                            ShowToast(kd_net);
                        }
                    }
                }
                //string tilexml = "<tile><binding template=\"TileMedium\"><text hint-style=\"subtitle\" id=\"0\">{0} {1} "+time_s+ "</text><text hint-wrap='true' id=\"1\">{2}</text></binding><binding template=\"TileWide\"><text hint-style=\"subtitle\">{0} {1} " + time_s + "</text><text hint-wrap='true'>{2}</text></binding><binding template=\"TileLarge\"><text hint-style=\"subtitle\">{0} {1} " + time_s + "</text><text hint-wrap='true'>{2}</text></binding></tile>";
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
示例#57
0
        public void tile()
        {
            Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument();
            xdoc.LoadXml(File.ReadAllText("tile.xml"));
            Windows.Data.Xml.Dom.XmlNodeList tilelist = xdoc.GetElementsByTagName("text");
            tilelist[0].InnerText = title.Text;
            tilelist[2].InnerText = title.Text;
            tilelist[4].InnerText = title.Text;
            tilelist[1].InnerText = describe.Text;
            tilelist[3].InnerText = describe.Text;
            tilelist[5].InnerText = describe.Text;
            tilelist[6].InnerText = title.Text;
            tilelist[7].InnerText = describe.Text;
            TileNotification notification = new TileNotification(xdoc);

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

            updater.Update(notification);
        }
示例#58
0
        private void LoadDoc(string xmpXmlDoc)
        {
            doc = new XmlDocument();

            try
            {
                doc.LoadXml(xmpXmlDoc);

                NamespaceManager = new XmlNamespaceManager(new NameTable());
                NamespaceManager.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                NamespaceManager.AddNamespace("exif", "http://ns.adobe.com/exif/1.0/");
                NamespaceManager.AddNamespace("x", "adobe:ns:meta/");
                NamespaceManager.AddNamespace("xap", "http://ns.adobe.com/xap/1.0/");
                NamespaceManager.AddNamespace("tiff", "http://ns.adobe.com/tiff/1.0/");
                NamespaceManager.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured while loading XML metadata from image. The error was: " + ex.Message);
            }
        }
示例#59
0
        public static void GenerateToast(string update)
        {
            string toastXmlString = "<toast>"
                                    + "<visual version='1'>"
                                    + "<binding template='ToastText01'>"
                                    + "<text id='1'>" + update + "</text>"
                                    + "</binding>"
                                    + "</visual>"
                                    + "</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
            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);
        }
        private void WriteOnTile(string p)
        {
            // create a string with the tile template xml
            string tileXmlString = "<tile>"
                                   + "<visual version='2'>"
                                   + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                                   + "<text id='1'>" + p + "</text>"
                                   + "</binding>"
                                   + "<binding template='TileWide310x150Text03' fallback='TileWideText03'>"
                                   + "<text id='1'>" + p + "</text>"
                                   + "</binding>"
                                   + "<binding template='TileSquare310x310Text05'>"
                                   + "<text id='1'>" + p + "</text>"
                                   + "</binding>"
                                   + "<binding template='TileWide310x150BlockAndText01'>"
                                   + "<text id='1'>" + p + "</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, catching any invalid xml characters
            tileDOM.LoadXml(tileXmlString);

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

                // Enter expiry time
                tile.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);

                // send the notification to the app's application tile
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
            }
            catch (System.Exception ex)
            {
            }
        }