本文整理匯總了C#中Windows.Data.Xml.Dom.XmlDocument.CreateTextNode方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.CreateTextNode方法的具體用法?C# XmlDocument.CreateTextNode怎麽用?C# XmlDocument.CreateTextNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.Data.Xml.Dom.XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.CreateTextNode方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: actionsToast
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);
}
示例2: CreateTileTemplate
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;
}
示例3: CompleteTemplate
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);
}
}
示例4: ToastText
public ToastText(string message, ToastTemplateType type)
{
xmlDoc = ToastNotificationManager.GetTemplateContent(type);
var textTag = xmlDoc.GetElementsByTagName("text").First();
textTag.AppendChild(xmlDoc.CreateTextNode(message));
}
示例5: CompleteToastOrTileTemplate
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++;
}
}
}
示例6: SetText
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));
}
}
示例7: SetToastText
private static void SetToastText(XmlDocument xml,string msg)
{
var nodes = xml.GetElementsByTagName("text");
nodes[0].AppendChild(xml.CreateTextNode(msg));
}
示例8: UpdateTile
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("記得好好複習喲~"));
//.........這裏部分代碼省略.........