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 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); }
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); } } } }
public static XmlDocument CreateTileTemplate(Wallpaper wallpaper) { XmlDocument document = new XmlDocument(); // tile 根节点。 XmlElement tile = document.CreateElement("tile"); document.AppendChild(tile); // visual 元素。 XmlElement visual = document.CreateElement("visual"); tile.AppendChild(visual); // Medium,150x150。 { // binding XmlElement binding = document.CreateElement("binding"); binding.SetAttribute("template", "TileMedium"); visual.AppendChild(binding); // image XmlElement image = document.CreateElement("image"); image.SetAttribute("src", wallpaper.GetOriginalUrl(new WallpaperSize(150, 150))); image.SetAttribute("placement", "background"); binding.AppendChild(image); // text XmlElement text = document.CreateElement("text"); text.AppendChild(document.CreateTextNode(wallpaper.Archive.Info)); text.SetAttribute("hint-wrap", "true"); binding.AppendChild(text); } // Wide,310x150。 { // binding XmlElement binding = document.CreateElement("binding"); binding.SetAttribute("template", "TileWide"); visual.AppendChild(binding); // image XmlElement image = document.CreateElement("image"); image.SetAttribute("src", wallpaper.GetOriginalUrl(new WallpaperSize(310, 150))); image.SetAttribute("placement", "background"); binding.AppendChild(image); // text XmlElement text = document.CreateElement("text"); text.AppendChild(document.CreateTextNode(wallpaper.Archive.Info)); text.SetAttribute("hint-wrap", "true"); binding.AppendChild(text); } return document; }
private void ShowToastNotification(string title, string content) { ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier(); Windows.Data.Xml.Dom.XmlDocument toastDoc = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02); XmlNodeList toastNodeList = toastDoc.GetElementsByTagName("text"); toastNodeList.Item(0).AppendChild(toastDoc.CreateTextNode(title)); toastNodeList.Item(1).AppendChild(toastDoc.CreateTextNode(content)); ToastNotification toast = new ToastNotification(toastDoc); toast.ExpirationTime = DateTime.Now.AddSeconds(4); }
public ToastText(string message, ToastTemplateType type) { xmlDoc = ToastNotificationManager.GetTemplateContent(type); var textTag = xmlDoc.GetElementsByTagName("text").First(); textTag.AppendChild(xmlDoc.CreateTextNode(message)); }
public static void CompleteToastOrTileTemplate(XmlDocument xml, string[] text, string[] images) { XmlNodeList slots = xml.SelectNodes("descendant-or-self::image"); int index = 0; if (images != 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 ((index < text.Length) && (index < slots.Length)) { slots[index].AppendChild(xml.CreateTextNode(text[index])); index++; } } }
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); }
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); } }
public static void Show(string header, string text) { XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); //Fill in the text elements XmlNodeList stringElements = toastXml.GetElementsByTagName("text"); stringElements[0].AppendChild(toastXml.CreateTextNode(header)); stringElements[1].AppendChild(toastXml.CreateTextNode(text)); // Create the toast and attach event listeners ToastNotification toast = new ToastNotification(toastXml); // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut! ToastNotificationManager.CreateToastNotifier("ELO").Show(toast); }
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); }
public void notification(string notificationText) { Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText01); Windows.Data.Xml.Dom.XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode(notificationText)); Windows.Data.Xml.Dom.XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image"); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "notificationPhoto.png"); ((Windows.Data.Xml.Dom.XmlElement)toastImageAttributes[0]).SetAttribute("src", path); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier("Computer Monitor").Show(toast); }
public void Notifica(string mensagem1) { Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText03); // Fill in the text elements Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text"); stringElements[0].AppendChild(toastXml.CreateTextNode("Beba Água APP")); stringElements[1].AppendChild(toastXml.CreateTextNode(mensagem1)); // Specify the absolute path to an image String imagePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location); Windows.Data.Xml.Dom.XmlNodeList imageElements = toastXml.GetElementsByTagName("image"); imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath; // Create the toast and attach event listeners ToastNotification toast = new ToastNotification(toastXml); // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut! ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast); }
private void ShowToastNotification() { for (int i = 0; i < ViewModel.AllItems.Count; i++) { if (ViewModel.AllItems[i].date.Day == DateTime.Now.Day) { 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(ViewModel.AllItems[i].title + "\n" + ViewModel.AllItems[i].description)); Windows.Data.Xml.Dom.XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image"); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((Windows.Data.Xml.Dom.XmlElement)toastImageAttributes[0]).SetAttribute("src", "Assets//2015071504.jpg"); Windows.Data.Xml.Dom.XmlElement audio = toastXml.CreateElement("audio"); ((Windows.Data.Xml.Dom.XmlElement)toastNode).SetAttribute("duration", "long"); audio.SetAttribute("silent", "true"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } }
private async void SaveAsync(object sender, Windows.UI.Xaml.RoutedEventArgs e) { if (Validate()) { if (comp != null) { comp.Naam = Naam.Text; comp.Openingsuur = Openingsuur.Text; comp.Sluituur = Sluitsuur.Text; comp.Categorie = await categorieViewModel.getCategorie(Categorie.SelectedValue.ToString()); comp.Gemeente = Gemeente.Text; comp.Straat = Straat.Text; comp.Land = Land.Text; comp.Website = Website.Text; comp.Telefooonnummer = Telefoonnummer.Text; comp.Information = Beschrijving.Text; var ondernemingAnswer = await ondernemingenViewModel.bewerkOnderneming(comp); if (ondernemingAnswer) { this.Frame.Navigate(typeof(BeheerOndernemenPage_Mobile)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Onderneming")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(comp.Naam + " werd aangepast")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } else { var categorie = await categorieViewModel.getCategorie(Categorie.SelectedValue.ToString()); Onderneming onderneming = new Onderneming( Naam.Text, Openingsuur.Text, Sluitsuur.Text, categorie.Id, Gemeente.Text, Straat.Text, Land.Text, Website.Text, Telefoonnummer.Text, Beschrijving.Text, ((App)Application.Current).gebruiker.Id ); var ondernemingAnswer = await ondernemingenViewModel.addOnderneming(onderneming); if (ondernemingAnswer) { this.Frame.Navigate(typeof(BeheerOndernemenPage_Mobile)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Onderneming")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(onderneming.Naam + " werd toegevoegd aan je ondernemingen")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } } }
public static async void UpdateTile(List<ClassList> tempList1, List<Transaction> tempList2, int nowWeek, string weekDay) { //为应用创建磁贴更新 var updater = TileUpdateManager.CreateTileUpdaterForApplication(); //这里设置的是所以磁贴都可以为动态 updater.EnableNotificationQueue(true); updater.Clear(); int itemCount = 0; List<int> correctCount = new List<int>(0); #region 创建动态磁贴XML文档 //1:创建动态磁贴模板 string tileXml = "<tile>" + "<visual>" + //中磁贴 "<binding template=\"TileMedium\">" + "<text hint-wrap=\"true\"></text>" + "<text></text>" + "<text hint-wrap=\"true\"></text>" + "</binding>" + //宽磁贴 "<binding template=\"TileWide\">" + "<text hint-style=\"subtitle\"></text>" + "<text></text>" + "<text hint-wrap=\"true\"></text>" + "</binding>" + //大磁贴 "<binding template=\"TileLarge\">" + "<text></text>" + "<group>" + "<subgroup>" + "<text hint-wrap=\"true\" hint-style=\"subtitle\"></text>" + "<text></text>" + "<text hint-wrap=\"true\"></text>" + "</subgroup>" + "</group>" + "<text>" + "\n" + "</text>" + "<group>" + "<subgroup>" + "<text hint-wrap=\"true\" hint-style=\"subtitle\"></text>" + "<text></text>" + "<text hint-wrap=\"true\"></text>" + "</subgroup>" + "</group>" + "</binding>" + "</visual>" + "</tile>"; #endregion for (int i = 0; i < tempList1.Count; i++) { int[] weeks = tempList1[i].Week; //判断课程是否为本周课程 for (int j = 0; j < weeks.Length; j++) { if (weeks[j] == nowWeek && tempList1[i].Day.Equals(weekDay)) { //满足条件的课程编号存入correctCount correctCount.Add(i); //微软规定动态磁贴的队列数目小于5个 if (itemCount++ > 5) { break; } } } } //为XML对象赋值并推送更新 for (int i = 0; i < correctCount.Count; i++) { XmlDocument doc = new XmlDocument(); doc.LoadXml(tileXml); XmlNodeList elements = doc.GetElementsByTagName("text"); //中磁贴 elements[0].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Course)); elements[1].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Teacher)); elements[2].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Lesson)); elements[2].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Classroom)); //宽磁贴 elements[3].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Course)); elements[4].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Teacher)); elements[5].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Lesson)); elements[5].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Classroom)); //大磁贴 elements[7].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Course)); elements[8].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Teacher)); elements[9].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Lesson)); elements[9].AppendChild(doc.CreateTextNode(tempList1[correctCount[i]].Classroom)); try { elements[11].AppendChild(doc.CreateTextNode("提醒:" + tempList2[i].Title)); elements[12].AppendChild(doc.CreateTextNode(tempList2[i].Content)); for (int j = 0; j < tempList2[i].Date[0].Week.Length; j++) { elements[13].AppendChild(doc.CreateTextNode("第" + tempList2[i].Date[0].Week[j].ToString() + "周" + " ")); } } catch (ArgumentOutOfRangeException) { Debug.WriteLine("事项数组越界"); elements[11].AppendChild(doc.CreateTextNode("暂无待办事项")); elements[12].AppendChild(doc.CreateTextNode("记得好好复习哟~")); } finally { updater.Update(new TileNotification(doc)); } } }
private static void SetToastText(XmlDocument xml,string msg) { var nodes = xml.GetElementsByTagName("text"); nodes[0].AppendChild(xml.CreateTextNode(msg)); }
private static void SetText(XmlDocument doc, string title, string subtext, string subsubtext) { // Fill in the text elements var stringElements = doc.GetElementsByTagName("text"); for (var i = 0; i < stringElements.Length; i++) { string txt = null; if (i == 0) txt = title; else if (i == 1) txt = subtext; else if (i == 2) txt = subsubtext; if (txt != null) stringElements[i].AppendChild(doc.CreateTextNode(txt)); } }