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); }
public static async void GenerateQuickAction() { System.Diagnostics.Debug.WriteLine("Hello From Quick actions caller"); 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); }
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); }
public async Task <Dictionary <string, string> > getItems(Book book) { Dictionary <String, String> itemDict = new Dictionary <string, string>(); try { String currentBookFolder = book.Location; Windows.Data.Xml.Dom.XmlDocument doc = await Routines.GetFile(book.Location + "\\META-INF", "container.xml"); var opfPathinit = doc.GetElementsByTagName("rootfile").Item(0).Attributes.GetNamedItem("full-path").NodeValue; String[] opfPath_tmp = Routines.parseString(opfPathinit.ToString()); String opfPath = opfPath_tmp[0]; String opfFile = opfPath_tmp[1]; String opfFileFolder = currentBookFolder + "/" + opfPath; doc = await Routines.GetFile(opfFileFolder, opfFile); var itemcount = doc.GetElementsByTagName("item").Count; for (uint index1 = 0; index1 < itemcount; index1++) { if (doc.GetElementsByTagName("item").Item(index1).Attributes.GetNamedItem("media-type").NodeValue.ToString().Equals("application/xhtml+xml")) { itemDict.Add(doc.GetElementsByTagName("item").Item(index1).Attributes.GetNamedItem("id").NodeValue.ToString().ToLower(), doc.GetElementsByTagName("item").Item(index1).Attributes.GetNamedItem("href").NodeValue.ToString()); } } } catch { } return(itemDict); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { rootPage = MainPage.Current; listBox.Items.Add("Index"); StorageFile storageFile; file = "history.xml"; storageFile= await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(file); XmlLoadSettings loadSettings = new XmlLoadSettings(); loadSettings.ProhibitDtd = false; loadSettings.ResolveExternals = false; doc = await XmlDocument.LoadFromFileAsync(storageFile, loadSettings); var results = doc.SelectNodes("descendant::result"); int num_results = 1; foreach (var result in results) { listBox.Items.Add(num_results.ToString()); num_results += 1; } if (num_results > 1) //show the first history result { listBox.SelectedIndex = 1; select_item(0); } //rootPage.NotifyUser(doc.InnerText.ToString(), NotifyType.StatusMessage); }
/// <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; }
public override XmlElement CreateCategoryElement(XmlDocument ownerDoc, string category, string categoryScheme, string categoryLabel) { XmlElement element = ownerDoc.CreateElementNS(DC_URI, "dc:subject"); element.InnerText = category; return(element); }
private async void SaveMatch(object sender, RoutedEventArgs e) { FolderPicker folderPicker = new FolderPicker(); folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary; folderPicker.FileTypeFilter.Add("*"); StorageFolder folder = await folderPicker.PickSingleFolderAsync(); ((Matchimpro)list_of_matches.SelectedItem).Save(folder); ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier(); Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); Windows.Data.Xml.Dom.XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text"); var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(resourceLoader.GetString("ExportTitle"))); toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(resourceLoader.GetString("ExportMessage"))); Windows.Data.Xml.Dom.IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ToastNotification toast = new ToastNotification(toastXml); toast.ExpirationTime = DateTime.Now.AddSeconds(1); ToastNotifier.Show(toast); }
public static void Hack() { var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); XmlDocument document = new XmlDocument(); document.LoadXml(xml); tileUpdater.Update(new TileNotification(document)); }
private static void UpdateTile(SyndicationFeed feed) { // Create a tile update manager for the specified syndication feed. var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.EnableNotificationQueue(true); updater.Clear(); // Keep track of the number feed items that get tile notifications. int itemCount = 0; // Create a tile notification for each feed item. foreach (var item in feed.Items) { Windows.Data.Xml.Dom.XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text03); var title = item.Title; string titleText = title.Text == null ? String.Empty : title.Text; tileXml.GetElementsByTagName(textElementName)[0].InnerText = titleText; // Create a new tile notification. updater.Update(new TileNotification(tileXml)); // Don't create more than 5 notifications. if (itemCount++ > 5) { break; } } }
/// <summary> /// Retrieves the PackageReferences from the given XmlDocument. If a package is present multiple time, only the first version will be returned. /// </summary> /// <param name="document"></param> /// <returns>A Dictionary where the key is the id of a package and the value its version.</returns> public static PackageIdentity[] GetPackageReferences(this XmlDocument document) { var references = new List <PackageIdentity>(); var packageReferences = document.SelectElements("PackageReference"); var dotnetCliReferences = document.SelectElements("DotNetCliToolReference"); foreach (var packageReference in packageReferences.Concat(dotnetCliReferences)) { var packageId = new[] { "Include", "Update", "Remove" } .Select(packageReference.GetAttribute) .FirstOrDefault(x => !string.IsNullOrEmpty(x)); var packageVersion = packageReference.GetAttribute("Version"); if (packageVersion.HasValue()) { references.Add(CreatePackageIdentity(packageId, packageReference.GetAttribute("Version"))); } else { var node = packageReference.SelectNode("Version"); if (node != null) { references.Add(CreatePackageIdentity(packageId, node.InnerText)); } } } return(references .Trim() .ToArray()); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { rootPage = MainPage.Current; file = "status.xml"; StorageFile storageFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(file); XmlLoadSettings loadSettings = new XmlLoadSettings(); loadSettings.ProhibitDtd = false; loadSettings.ResolveExternals = false; doc = await XmlDocument.LoadFromFileAsync(storageFile, loadSettings); try { var results = doc.SelectNodes("descendant::result"); int num_results = 1; foreach (var result in results) { String id = results[num_results - 1].SelectSingleNode("descendant::id").FirstChild.NodeValue.ToString(); String status = results[num_results-1].SelectSingleNode("descendant::status").FirstChild.NodeValue.ToString(); listBox.Items.Add("ID: "+id+" "+ status); num_results += 1; } if (num_results==1) listBox.Items.Add("You don't have pending jobs."); } catch(Exception) { listBox.Items.Add("You don't have pending jobs."); } }
/// <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 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; }
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); }
static async Task<bool?> ShowCore(XmlDocument rpDocument) { var rCompletionSource = new TaskCompletionSource<bool?>(); var rNotification = new ToastNotification(rpDocument); TypedEventHandler<ToastNotification, object> rActivated = (s, e) => rCompletionSource.SetResult(true); rNotification.Activated += rActivated; TypedEventHandler<ToastNotification, ToastDismissedEventArgs> rDismissed = (s, e) => rCompletionSource.SetResult(false); rNotification.Dismissed += rDismissed; TypedEventHandler<ToastNotification, ToastFailedEventArgs> rFailed = (s, e) => rCompletionSource.SetResult(null); rNotification.Failed += rFailed; r_Notifier.Show(rNotification); var rResult = await rCompletionSource.Task; rNotification.Activated -= rActivated; rNotification.Dismissed -= rDismissed; rNotification.Failed -= rFailed; return rResult; }
public ToastText(string message, ToastTemplateType type) { xmlDoc = ToastNotificationManager.GetTemplateContent(type); var textTag = xmlDoc.GetElementsByTagName("text").First(); textTag.AppendChild(xmlDoc.CreateTextNode(message)); }
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; }
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); }
/// <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 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); } }
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); } }
public static ToastNotification DownloadToast(string filename, DownloadResult result) { ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); switch (result) { case DownloadResult.Success: toastTextElements[0].AppendChild(toastXml.CreateTextNode("下载完成!")); toastTextElements[1].AppendChild(toastXml.CreateTextNode("文件:" + filename + "下载完成")); break; case DownloadResult.Failure: toastTextElements[0].AppendChild(toastXml.CreateTextNode("下载失败!")); toastTextElements[1].AppendChild(toastXml.CreateTextNode("文件:" + filename + "下载失败")); break; default: break; } var doc = new Windows.Data.Xml.Dom.XmlDocument(); ToastNotification toast = new ToastNotification(toastXml); return(toast); }
/// <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); }
public static void Toast(string msg) { //1. create element ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); //2.设置消息文本 XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode(msg)); //3. 图标 Windows.Data.Xml.Dom.XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image"); ((XmlElement)toastImageAttributes[0]).SetAttribute("src", $"ms-appx:///Assets/StoreLogo.png"); ((XmlElement)toastImageAttributes[0]).SetAttribute("alt", "logo"); // 4. duration IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "short"); // 5. audio XmlElement audio = toastXml.CreateElement("audio"); audio.SetAttribute("src", $"ms-winsoundevent:Notification.SMS"); toastNode.AppendChild(audio); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); }
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 { } }
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); }
public static void CompleteTemplate(XmlDocument xml, string[] text, string[] images = null, string sound = null) { XmlNodeList slots = xml.SelectNodes("descendant-or-self::image"); int index = 0; if ((images != null) && (slots != null)) { while ((index < images.Length) && (index < slots.Length)) { ((XmlElement)slots[index]).SetAttribute("src", images[index]); index++; } } if (text != null) { slots = xml.SelectNodes("descendant-or-self::text"); index = 0; while ((slots != null) && ((index < text.Length) && (index < slots.Length))) { slots[index].AppendChild(xml.CreateTextNode(text[index])); index++; } } if (!string.IsNullOrEmpty(sound)) { var audioElement = xml.CreateElement("audio"); audioElement.SetAttribute("src", sound); xml.DocumentElement.AppendChild(audioElement); } }
/// <summary> /// Set the application's tile to display a local image file. /// After clicking, go back to the start screen to watch your application's tile update. /// </summary> private void SetTileImageButtonClick(object sender, RoutedEventArgs e) { // It is possible to start from an existing template and modify what is needed. // Alternatively you can construct the XML from scratch. var tileXml = new XmlDocument(); var title = tileXml.CreateElement("title"); var visual = tileXml.CreateElement("visual"); visual.SetAttribute("version", "1"); visual.SetAttribute("lang", "en-US"); // The template is set to be a TileSquareImage. This tells the tile update manager what to expect next. var binding = tileXml.CreateElement("binding"); binding.SetAttribute("template", "TileSquareImage"); // An image element is then created under the TileSquareImage XML node. The path to the image is specified var image = tileXml.CreateElement("image"); image.SetAttribute("id", "1"); image.SetAttribute("src", @"ms-appx:///Assets/DemoImage.png"); // All the XML elements are chained up together. title.AppendChild(visual); visual.AppendChild(binding); binding.AppendChild(image); tileXml.AppendChild(title); // The XML is used to create a new TileNotification which is then sent to the TileUpdateManager var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
public virtual async Task <BlogPostCategory[]> GetCategories(string blogId) { ArrayList categoryList = new ArrayList(); XmlDocument xmlDoc = await GetCategoryXml(blogId); foreach (XmlElement categoriesNode in xmlDoc.DocumentElement.SelectNodesNS("app:categories", _pubNS.Uri)) { string categoriesScheme = categoriesNode.GetAttribute("scheme"); foreach (XmlElement categoryNode in categoriesNode.SelectNodesNS("atom:category", _atomNS.Uri)) { string categoryScheme = categoryNode.GetAttribute("scheme"); if (categoryScheme == "") { categoryScheme = categoriesScheme; } if (CategoryScheme == categoryScheme) { string categoryName = categoryNode.GetAttribute("term"); string categoryLabel = categoryNode.GetAttribute("label"); if (categoryLabel == "") { categoryLabel = categoryName; } categoryList.Add(new BlogPostCategory(categoryName, categoryLabel)); } } } return((BlogPostCategory[])categoryList.ToArray(typeof(BlogPostCategory))); }
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)); }
protected virtual async Task <XmlDocument> GetCategoryXml(string blogId) { // Get the service document Login(); FixupBlogId(ref blogId); XmlRestRequestHelper.XmlRequestResult result = new XmlRestRequestHelper.XmlRequestResult(); result.uri = FeedServiceUrl; var xmlDoc = await xmlRestRequestHelper.Get(RequestFilter, result); foreach (XmlElement entryEl in xmlDoc.SelectNodesNS("app:service/app:workspace/app:collection", _nsMgr.ToNSMethodFormat())) { string href = XmlHelper.GetUrl(entryEl, "@href", result.uri); if (blogId == href) { XmlDocument results = new XmlDocument(); XmlElement rootElement = results.CreateElement("categoryInfo"); results.AppendChild(rootElement); foreach (XmlElement categoriesNode in entryEl.SelectNodesNS("app:categories", _nsMgr.ToNSMethodFormat())) { await AddCategoriesXml(categoriesNode, rootElement, result); } return(results); } } //Debug.Fail("Couldn't find collection in service document:\r\n" + xmlDoc.OuterXml); return(new XmlDocument()); }
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 async Task AddCategoriesXml(XmlElement categoriesNode, XmlElement containerNode, XmlRestRequestHelper.XmlRequestResult result) { if (categoriesNode.Attributes.Any(a => a.NodeName == "href")) { string href = XmlHelper.GetUrl(categoriesNode, "@href", result.uri); if (href != null && href.Length > 0) { Uri uri = new Uri(href); if (result.uri == null || !uri.Equals(result.uri)) // detect simple cycles { XmlDocument doc = await xmlRestRequestHelper.Get(RequestFilter, result); XmlElement categories = (XmlElement)doc.SelectSingleNodeNS(@"app:categories", _nsMgr.ToNSMethodFormat()); if (categories != null) { await AddCategoriesXml(categories, containerNode, result); } } } } else { containerNode.AppendChild(containerNode.OwnerDocument.ImportNode(categoriesNode, true)); } }
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; }
public async Task <BlogPost> GetPost(string blogId, string postId) { Login(); FixupBlogId(ref blogId); XmlRestRequestHelper.XmlRequestResult result = new XmlRestRequestHelper.XmlRequestResult(); result.uri = PostIdToPostUri(postId); result.responseHeaders = new HttpResponseMessage().Headers; var doc = await xmlRestRequestHelper.Get(RequestFilter, result); XmlDocument remotePost = (XmlDocument)doc.CloneNode(true); XmlElement entryNode = doc.SelectSingleNodeNS("/atom:entry", _nsMgr.ToNSMethodFormat()) as XmlElement; if (entryNode == null) { throw new BlogClientInvalidServerResponseException("GetPost", "No post entry returned from server", doc.GetXml()); } BlogPost post = Parse(entryNode, true, result.uri); post.Id = postId; post.ETag = FilterWeakEtag(result.responseHeaders["ETag"]); post.AtomRemotePost = remotePost; return(post); }
private static void SetTileImages(XmlDocument xmlDocument, params string[] images) { if (images != null) { try { var imageElements = xmlDocument.GetElementsByTagName("image").ToArray(); for (int n = 0; n < images.Length; n++) { var imageElement = imageElements[n] as XmlElement; if (images[n].StartsWith("ms-appx:", StringComparison.OrdinalIgnoreCase) || images[n].StartsWith("ms-appdata:", StringComparison.OrdinalIgnoreCase)) { imageElement.SetAttribute("src", images[n]); } else { imageElement.SetAttribute("src", String.Format("ms-appx:///Assets/{0}", images[n])); } } } catch (Exception ex) { Debug.WriteLine(ex); } } }
private static void SetToatAudio(XmlDocument xml) { var node = xml.SelectSingleNode("/toast"); var audio = xml.CreateElement("audio"); audio.SetAttribute("src", "ms-winsoundevent:Notification.IM"); node.AppendChild(audio); }
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); }
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; } }
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); }
static string ToXmlString( string input ) { var document = new XmlDocument(); document.LoadXml( input.Trim(), new XmlLoadSettings { ElementContentWhiteSpace = false } ); var result = document.GetXml(); return result; }
// 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 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 } }
public override XmlElement CreateCategoryElement(XmlDocument ownerDoc, string category, string categoryScheme, string categoryLabel) { // Blogger doesn't support category labels and will error out if you pass them XmlElement el = base.CreateCategoryElement(ownerDoc, category, categoryScheme, categoryLabel); el.RemoveAttribute("label"); return(el); }
public override XmlElement PlaintextToTextNode(XmlDocument ownerDoc, string text) { XmlElement el = ownerDoc.CreateElementNS(NamespaceUri, "atom:content"); el.SetAttribute("type", "text"); el.InnerText = text; return(el); }
public override XmlElement HtmlToTextNode(XmlDocument ownerDoc, string html) { XmlElement el = ownerDoc.CreateElementNS(NamespaceUri, "atom:content"); el.SetAttribute("type", "html"); el.InnerText = html; return(el); }
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); }
private async void SaveAsync(object sender, Windows.UI.Xaml.RoutedEventArgs e) { var actieAnswer = false; if (Validate()) { if (actieObject != null) { actieObject.Beschrijving = Beschrijving.Text; var dateObject = Datum.Date.Date.ToString().Substring(0, 10) + " " + Time.Time.ToString(); DateTime myDateObject = DateTime.Parse(dateObject); actieObject.GeldigTot = myDateObject; actieAnswer = await actieViewModel.bewerkActieAsync(actieObject); if (actieAnswer) { this.Frame.Navigate(typeof(BeheerOndernemerPage)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Actie")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(actieObject.Beschrijving + " aangepast")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } else { var date = Datum.Date.Date.ToString().Substring(0, 10) + " " + Time.Time.ToString(); DateTime myDate = DateTime.Parse(date); Actie actie = new Actie( Beschrijving.Text, myDate, Int32.Parse(bedrijf) ); actieAnswer = await actieViewModel.addActieAsync(actie); if (actieAnswer) { this.Frame.Navigate(typeof(BeheerOndernemerPage)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Actie")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(actie.Beschrijving + " werd toegevoegd aan je acties")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } } }
private string Parse(string s, string name) { XMLDocument doc = new XMLDocument(); doc.LoadXml(s); IXmlNode node = doc.SelectSingleNode(name); return(node.InnerText); }
public static DomXmlDocument ToDomXmlDocument(this XDocument xDocument) { var xmlDocument = new DomXmlDocument(); using (var xmlReader = xDocument.CreateReader()) { xmlDocument.LoadXml(xmlReader.ReadOuterXml()); } return(xmlDocument); }
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); }
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); }
void ToastNotifier() { ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; Windows.Data.Xml.Dom.XmlDocument toastxml = ToastNotificationManager.GetTemplateContent(toastTemplate); Windows.Data.Xml.Dom.XmlNodeList toastTextElements = toastxml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastxml.CreateTextNode("You are near a room")); ToastNotification toast = new ToastNotification(toastxml); ToastNotificationManager.CreateToastNotifier().Show(toast); }
private void UpdateTile(string infoString) { var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.EnableNotificationQueue(true); updater.Clear(); Windows.Data.Xml.Dom.XmlDocument xml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text04); xml.GetElementsByTagName("text")[0].InnerText = infoString; updater.Update(new TileNotification(xml)); }
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); } }
/// <summary> /// Gets the concatenated values of the node and all its child nodes. /// </summary> /// <param name="target">The xml document</param> /// <param name="nodePath">A node path separated by /</param> /// <returns>The concatenated values of the node and all its child nodes.</returns> public static string GetNodeInnerText(this Windows.Data.Xml.Dom.XmlDocument target, string nodePath) { var val = target.SelectSingleNode(nodePath); if (val == null) { return(""); } else { return(val.InnerText); } }