/// <summary> /// This is the click handler for the 'Scenario1BtnDefault' button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Scenario1BtnDefault_Click(object sender, RoutedEventArgs e) { String rss = scenario1RssInput.Text; if (null != rss && "" != rss) { try { String xml; var doc = new Windows.Data.Xml.Dom.XmlDocument(); scenario1OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml); doc.LoadXml(xml); // create a rss CDataSection and insert into DOM tree var cdata = doc.CreateCDataSection(rss); var element = doc.GetElementsByTagName("content").Item(0); element.AppendChild(cdata); Scenario.RichEditBoxSetMsg(scenario1Result, doc.GetXml(), true); } catch (Exception exp) { Scenario.RichEditBoxSetError(scenario1Result, exp.Message); } } else { Scenario.RichEditBoxSetError(scenario1Result, "Please type in RSS content in the [RSS Content] box firstly."); } }
async void XsltInit() { try { Windows.Storage.StorageFolder storageFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("xsltTransform"); Windows.Storage.StorageFile xmlFile = await storageFolder.GetFileAsync("xmlContent.xml"); Windows.Storage.StorageFile xsltFile = await storageFolder.GetFileAsync("xslContent.xml"); // load xml file Windows.Data.Xml.Dom.XmlDocument doc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xmlFile); Scenario.RichEditBoxSetMsg(scenario5Xml, doc.GetXml(), false); // load xslt file doc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xsltFile); // Display xml and xslt file content in the input fields Scenario.RichEditBoxSetMsg(scenario5Xslt, doc.GetXml(), false); Scenario.RichEditBoxSetMsg(scenario5Result, "", true); } catch { Scenario.RichEditBoxSetMsg(scenario5Xml, "", false); Scenario.RichEditBoxSetMsg(scenario5Xslt, "", false); Scenario.RichEditBoxSetError(scenario5Result, Scenario.LoadFileErrorMsg); } }
async void XsltInit() { try { Windows.Storage.StorageFolder storageFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("xsltTransform"); Windows.Storage.StorageFile xmlFile = await storageFolder.GetFileAsync("xmlContent.xml"); Windows.Storage.StorageFile xsltFile = await storageFolder.GetFileAsync("xslContent.xml"); // load xml file Windows.Data.Xml.Dom.XmlDocument doc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xmlFile); Scenario.RichEditBoxSetMsg(scenario5Xml, doc.GetXml(), false); // load xslt file doc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xsltFile); // Display xml and xslt file content in the input fields Scenario.RichEditBoxSetMsg(scenario5Xslt, doc.GetXml(), false); Scenario.RichEditBoxSetMsg(scenario5Result, "", true); } catch (Exception exp) { Scenario.RichEditBoxSetMsg(scenario5Xml, "", false); Scenario.RichEditBoxSetMsg(scenario5Xslt, "", false); Scenario.RichEditBoxSetError(scenario5Result, exp.Message); rootPage.NotifyUser("Exception occured while loading xml file!", NotifyType.ErrorMessage); } }
public static async void CreateAlarm(this Todo item) { var doc = new Windows.Data.Xml.Dom.XmlDocument(); doc.LoadXml(await FileIO.ReadTextAsync(await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///XMLs/AlarmToast.xml")))); doc.LoadXml(doc.GetXml().Replace("Header", item.Subject)); doc.LoadXml(doc.GetXml().Replace("Detail", item.Detail)); DateTimeOffset offset = item.StartTime; var toast = new ScheduledToastNotification(doc, offset); toast.Id = item.Id.ToString(); ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); }
void UpdateTileWithImageWithStringManipulation_Click(object sender, RoutedEventArgs e) { // Create a string with the tile template xml. // Note that the version is set to "2" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes. // This is so that the notification can be understood by a Windows 8 machine as well. string tileXmlString = "<tile>" + "<visual version='2'>" + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>" + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>" + "</binding>" + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>" + "<image id='1' src='ms-appx:///images/redWide310x150.png' alt='Red image'/>" + "<text id='1'>This tile notification uses ms-appx images</text>" + "</binding>" + "<binding template='TileSquare310x310Image'>" + "<image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/>" + "</binding>" + "</visual>" + "</tile>"; // Create a DOM. Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); // Load the xml string into the DOM. tileDOM.LoadXml(tileXmlString); // Create a tile notification. TileNotification tile = new TileNotification(tileDOM); // Send the notification to the application’s tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); }
private void UpdateTileWithTextWithStringManipulation_Click(object sender, RoutedEventArgs e) { // Create a string with the tile template xml. // Note that the version is set to "3" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes. // This is so that the notification can be understood by Windows 8 and Windows 8.1 machines as well. string tileXmlString = "<tile>" + "<visual version='3'>" + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>" + "<text id='1'>Hello World! My very own tile notification</text>" + "</binding>" + "<binding template='TileWide310x150Text03' fallback='TileWideText03'>" + "<text id='1'>Hello World! My very own tile notification</text>" + "</binding>" + "<binding template='TileSquare310x310Text09'>" + "<text id='1'>Hello World! My very own tile notification</text>" + "</binding>" + "</visual>" + "</tile>"; // Create a DOM. Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); // Load the xml string into the DOM. tileDOM.LoadXml(tileXmlString); // Create a tile notification. TileNotification tile = new TileNotification(tileDOM); // Send the notification to the application? tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); rootPage.NotifyUser("Tile notification with text sent", NotifyType.StatusMessage); }
void UpdateTileWithImageWithStringManipulation_Click(object sender, RoutedEventArgs e) { // create a string with the tile template xml string tileXmlString = "<tile>" + "<visual>" + "<binding template='TileWideImageAndText01'>" + "<text id='1'>This tile notification uses ms-appx images</text>" + "<image id='1' src='ms-appx:///images/redWide.png' alt='Red image'/>" + "</binding>" + "<binding template='TileSquareImage'>" + "<image id='1' src='ms-appx:///images/graySquare.png' alt='Gray image'/>" + "</binding>" + "</visual>" + "</tile>"; // create a DOM Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); // load the xml string into the DOM, catching any invalid xml characters tileDOM.LoadXml(tileXmlString); // create a tile notification TileNotification tile = new TileNotification(tileDOM); // send the notification to the app's application tile TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); }
void UpdateTileWithWebImageWithStringManipulation_Click(object sender, RoutedEventArgs e) { // create a string with the tile template xml string tileXmlString = "<tile>" + "<visual>" + "<binding template='TileWideImageAndText01'>" + "<text id='1'>This tile notification uses web images</text>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "</binding>" + "<binding template='TileSquareImage'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "</binding>" + "</visual>" + "</tile>"; // create a DOM Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { // load the xml string into the DOM, catching any invalid xml characters tileDOM.LoadXml(tileXmlString); // create a tile notification TileNotification tile = new TileNotification(tileDOM); // send the notification to the app's application tile TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); } catch (Exception) { OutputTextBlock.Text = "Error loading the xml, check for invalid characters in the input"; } }
void DisplayAudioToastWithStringManipulation(string audioSrc) { string toastXmlString = String.Empty; if (audioSrc.Equals("Silent")) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='ToastText02'>" + "<text id='1'>Sound:</text>" + "<text id='2'>" + audioSrc + "</text>" + "</binding>" + "</visual>" + "<audio silent='true'/>" + "</toast>"; } else if (audioSrc.Equals("Default")) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='ToastText02'>" + "<text id='1'>Sound:</text>" + "<text id='2'>" + audioSrc + "</text>" + "</binding>" + "</visual>" + "</toast>"; } else { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='ToastText02'>" + "<text id='1'>Sound:</text>" + "<text id='2'>" + audioSrc + "</text>" + "</binding>" + "</visual>" + "<audio src='ms-winsoundevent:Notification." + audioSrc + "'/>" + "</toast>"; } Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { toastDOM.LoadXml(toastXmlString); rootPage.NotifyUser(toastDOM.GetXml(), NotifyType.StatusMessage); // Create a toast, then create a ToastNotifier object to show // the toast ToastNotification toast = new ToastNotification(toastDOM); // If you have other applications in your package, you can specify the AppId of // the app to create a ToastNotifier for that application ToastNotificationManager.CreateToastNotifier().Show(toast); } catch (Exception) { rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage); } }
void UpdateBadgeWithGlyphWithStringManipulation() { // Create a string with the badge template xml. string badgeXmlString = "<badge value='" + ((TileGlyph)GlyphList.SelectedItem).Name.ToString() + "'/>"; Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { // Create a DOM. badgeDOM.LoadXml(badgeXmlString); // Load the xml string into the DOM, catching any invalid xml characters. BadgeNotification badge = new BadgeNotification(badgeDOM); // Create a badge notification and send it to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge); OutputTextBlock.Text = badgeDOM.GetXml(); rootPage.NotifyUser("Badge sent", NotifyType.StatusMessage); } catch (Exception) { OutputTextBlock.Text = string.Empty; rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage); } }
/// <summary> /// This is the click handler for the 'Scenario2BtnDefault' button. /// This function will look up products and mark hot products. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Scenario2BtnDefault_Click(object sender, RoutedEventArgs e) { try { String xml; scenario2OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml); var doc = new Windows.Data.Xml.Dom.XmlDocument(); doc.LoadXml(xml); // Mark 'hot' attribute to '1' if 'sell10days' is greater than 'InStore' var xpath = "/products/product[Sell10day>InStore]/@hot"; var hotAttributes = doc.SelectNodes(xpath); for (uint index = 0; index < hotAttributes.Length; index++) { hotAttributes.Item(index).NodeValue = "1"; } Scenario.RichEditBoxSetMsg(scenario2Result, doc.GetXml(), true); scenario2BtnSave.IsEnabled = true; // enable Save button } catch (Exception exp) { Scenario.RichEditBoxSetError(scenario2Result, exp.Message); } }
/// <summary> /// This is the click handler for the 'scenario3BtnBuffer' button. You would replace this with your own handler /// if you have a button or buttons on this page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Scenario3BtnBuffer_Click(object sender, RoutedEventArgs e) { try { // Get load settings var loadSettings = new Windows.Data.Xml.Dom.XmlLoadSettings(); if (true == scenario3RB1.IsChecked) { loadSettings.ProhibitDtd = true; // DTD is prohibited loadSettings.ResolveExternals = false; // Disable the resolve to external definitions such as external DTD } else if (true == scenario3RB2.IsChecked) { loadSettings.ProhibitDtd = false; // DTD is not prohibited loadSettings.ResolveExternals = false; // Disable the resolve to external definitions such as external DTD } else if (true == scenario3RB3.IsChecked) { loadSettings.ProhibitDtd = false; // DTD is not prohibited loadSettings.ResolveExternals = true; // Enable the resolve to external definitions such as external DTD } String xml; scenario3OriginalData.Document.GetText(Windows.UI.Text.TextGetOptions.None, out xml); // Set external dtd file path if (loadSettings.ResolveExternals == true && loadSettings.ProhibitDtd == false) { Windows.Storage.StorageFolder storageFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("loadExternaldtd"); String dtdPath = storageFolder.Path + "\\dtd.txt"; xml = xml.Replace("dtd.txt", dtdPath); } var dataWriter = new Windows.Storage.Streams.DataWriter(); dataWriter.WriteString(xml); Windows.Storage.Streams.IBuffer ibuffer = dataWriter.DetachBuffer(); var doc = new Windows.Data.Xml.Dom.XmlDocument(); doc.LoadXmlFromBuffer(ibuffer, loadSettings); Scenario.RichEditBoxSetMsg(scenario3Result, doc.GetXml(), true); } catch (Exception) { // After loadSettings.ProhibitDtd is set to true, the exception is expected as the sample XML contains DTD Scenario.RichEditBoxSetError(scenario3Result, "Error: DTD is prohibited"); } }
private async void Scenario1Init() { try { Windows.Data.Xml.Dom.XmlDocument doc = await Scenario.LoadXmlFile("buildRss", "rssTemplate.xml"); Scenario.RichEditBoxSetMsg(scenario1OriginalData, doc.GetXml(), true); } catch { Scenario.RichEditBoxSetError(scenario1Result, Scenario.LoadFileErrorMsg); } }
async void Scenario3Init() { try { Windows.Data.Xml.Dom.XmlDocument doc = await Scenario.LoadXmlFile("loadExternaldtd", "xmlWithExternaldtd.xml"); Scenario.RichEditBoxSetMsg(scenario3OriginalData, doc.GetXml(), true); } catch { Scenario.RichEditBoxSetError(scenario3Result, Scenario.LoadFileErrorMsg); } }
async void Scenario4Init() { try { Windows.Data.Xml.Dom.XmlDocument doc = await Scenario.LoadXmlFile("giftDispatch", "employees.xml"); Scenario.RichEditBoxSetMsg(scenario4OriginalData, doc.GetXml(), true); } catch { Scenario.RichEditBoxSetError(scenario4Result, Scenario.LoadFileErrorMsg); } }
private async void Scenario2Init() { try { Windows.Data.Xml.Dom.XmlDocument doc = await Scenario.LoadXmlFile("markHotProducts", "products.xml"); Scenario.RichEditBoxSetMsg(scenario2OriginalData, doc.GetXml(), true); } catch { Scenario.RichEditBoxSetError(scenario2Result, Scenario.LoadFileErrorMsg); } }
async void Scenario3Init() { try { Windows.Data.Xml.Dom.XmlDocument doc = await Scenario.LoadXmlFile("loadExternaldtd", "xmlWithExternaldtd.xml"); Scenario.RichEditBoxSetMsg(scenario3OriginalData, doc.GetXml(), true); } catch (Exception exp) { Scenario.RichEditBoxSetError(scenario3Result, exp.Message); rootPage.NotifyUser("Exception occured while loading xml file!", NotifyType.ErrorMessage); } }
async void Scenario4Init() { try { Windows.Data.Xml.Dom.XmlDocument doc = await Scenario.LoadXmlFile("giftDispatch", "employees.xml"); Scenario.RichEditBoxSetMsg(scenario4OriginalData, doc.GetXml(), true); } catch (Exception exp) { Scenario.RichEditBoxSetError(scenario4Result, exp.Message); rootPage.NotifyUser("Exception occured while loading xml file!", NotifyType.ErrorMessage); } }
private async void Scenario1Init() { try { Windows.Data.Xml.Dom.XmlDocument doc = await Scenario.LoadXmlFile("buildRss", "rssTemplate.xml"); Scenario.RichEditBoxSetMsg(scenario1OriginalData, doc.GetXml(), true); } catch (Exception exp) { Scenario.RichEditBoxSetError(scenario1Result, exp.Message); rootPage.NotifyUser("Exception occured while loading xml file!", NotifyType.ErrorMessage); } }
private async void InitXML() { try { //Create a XMLFile folder in your project and add you xml file to this folder doc = await LoadXmlFile("XMLFile", "CXmlC.xml"); RichEditBoxSetMsg(ShowXMLResult, doc.GetXml(), true); } catch (Exception exp) { await new Windows.UI.Popups.MessageDialog(exp.ToString()).ShowAsync(); } }
public static void CreateNotification(this Todo item) { var xml = @"<toast> <visual> <binding template=""ToastGeneric""> <text>Header</text> <text>Detail</text> <text placement='attribution'>Right now</text> </binding> </visual> </toast>"; var doc = new Windows.Data.Xml.Dom.XmlDocument(); doc.LoadXml(xml); doc.LoadXml(doc.GetXml().Replace("Header", item.Subject)); doc.LoadXml(doc.GetXml().Replace("Detail", item.Detail)); var offset = item.StartTime.ToLocalTime(); var toast = new ScheduledToastNotification(doc, offset); toast.Id = item.Id; ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); }
void UpdateTileWithWebImageWithStringManipulation_Click(object sender, RoutedEventArgs e) { // Create a string with the tile template xml. // Note that the version is set to "3" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes. // This is so that the notification can be understood by Windows 8 and Windows 8.1 machines as well. string tileXmlString = "<tile>" + "<visual version='3' addImageQuery='true'>" + "<binding template='TileSquare71x71Image'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "</binding>" + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "</binding>" + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "<text id='1'>This tile notification uses web images.</text>" + "</binding>" + "<binding template='TileSquare310x310Image'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "</binding>" + "</visual>" + "</tile>"; // Create a DOM. Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { // Load the xml string into the DOM, catching any invalid xml characters. tileDOM.LoadXml(tileXmlString); // Create a tile notification. TileNotification tile = new TileNotification(tileDOM); // Send the notification to the application’s tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); rootPage.NotifyUser("Tile notification with web images sent", NotifyType.StatusMessage); } catch (Exception) { OutputTextBlock.Text = string.Empty; rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage); } }
private async void BtnXmlWrite_Click(object sender, RoutedEventArgs e) { String input1value = TxtInput.Text; if (null != input1value && "" != input1value) { var value = doc.CreateTextNode(input1value); //find input1 tag in header where id=1 var xpath = "//header[@id='1']/user_input/input1"; var input1nodes = doc.SelectNodes(xpath); for (uint index = 0; index < input1nodes.Length; index++) { input1nodes.Item(index).AppendChild(value); } RichEditBoxSetMsg(ShowXMLResult, doc.GetXml(), true); } else { await new Windows.UI.Popups.MessageDialog("Please type in content in the box firstly.").ShowAsync(); } }
protected virtual async Task <XmlDocument> Send(string method, string etag, HttpAsyncRequestFilter filter, string contentType, XmlDocument doc, string encoding, string filename, bool ignoreResponse, XmlRequestResult result) { if (!String.IsNullOrEmpty(filename)) { return(MultipartSend(method, etag, filter, contentType, doc, encoding, filename, ignoreResponse, result)); } string absUri = UrlHelper.SafeToAbsoluteUri(result.uri); Debug.WriteLine("XML Request to " + absUri + ":\r\n" + doc.GetXml()); SendFactory sf = new SendFactory(etag, method, filter, contentType, doc, encoding); var response = await RedirectHelper.GetResponse(absUri, new RedirectHelper.RequestFactory(sf.Create)); try { result.responseHeaders = response.Headers; result.uri = response.RequestMessage.RequestUri; if (ignoreResponse || response.StatusCode == Windows.Web.Http.HttpStatusCode.NoContent) { return(null); } else { XmlDocument xmlDocResponse = await ParseXmlResponse(response); return(xmlDocResponse); } } finally { if (response != null) { response.Dispose(); } } }
void UpdateBadgeWithNumberWithStringManipulation(int number) { // create a string with the badge template xml string badgeXmlString = "<badge value='" + number + "'/>"; Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { // create a DOM badgeDOM.LoadXml(badgeXmlString); // load the xml string into the DOM, catching any invalid xml characters BadgeNotification badge = new BadgeNotification(badgeDOM); // create a badge notification BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge); OutputTextBlock.Text = badgeDOM.GetXml(); } catch (Exception) { OutputTextBlock.Text = "Error loading the xml, check for invalid characters in the input"; } }
void DisplayLongToastWithStringManipulation(bool loopAudio) { string toastXmlString = String.Empty; if (loopAudio) { toastXmlString = "<toast duration='long'>" + "<visual version='1'>" + "<binding template='ToastText02'>" + "<text id='1'>Long Duration Toast</text>" + "<text id='2'>Looping audio</text>" + "</binding>" + "</visual>" + "<audio loop='true' src='ms-winsoundevent:Notification.Looping.Alarm'/>" + "</toast>"; } else { toastXmlString = "<toast duration='long'>" + "<visual version='1'>" + "<binding template='ToastText02'>" + "<text id='1'>Long Toast</text>" + "</binding>" + "</visual>" + "<audio loop='true' src='ms-winsoundevent:Notification.IM'/>" + "</toast>"; } Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument(); toastDOM.LoadXml(toastXmlString); // Create a toast, then create a ToastNotifier object to show // the toast scenario6Toast = new ToastNotification(toastDOM); ToastNotificationManager.CreateToastNotifier().Show(scenario6Toast); rootPage.NotifyUser(toastDOM.GetXml(), NotifyType.StatusMessage); }
void DisplayPackageImageToastWithStringManipulation(ToastTemplateType templateType) { string toastXmlString = String.Empty; if (templateType == ToastTemplateType.ToastImageAndText01) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText01'>" + "<text id='1'>Body text that wraps over three lines</text>" + "<image id='1' src='" + TOAST_IMAGE_SRC + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastImageAndText02) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText02'>" + "<text id='1'>Heading text</text>" + "<text id='2'>Body text that wraps over two lines</text>" + "<image id='1' src='" + TOAST_IMAGE_SRC + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastImageAndText03) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText03'>" + "<text id='1'>Heading text that wraps over two lines</text>" + "<text id='2'>Body text</text>" + "<image id='1' src='" + TOAST_IMAGE_SRC + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastImageAndText04) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText04'>" + "<text id='1'>Heading text</text>" + "<text id='2'>First body text</text>" + "<text id='3'>Second body text</text>" + "<image id='1' src='" + TOAST_IMAGE_SRC + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument(); toastDOM.LoadXml(toastXmlString); rootPage.NotifyUser(toastDOM.GetXml(), NotifyType.StatusMessage); // Create a toast, then create a ToastNotifier object to show // the toast ToastNotification toast = new ToastNotification(toastDOM); // If you have other applications in your package, you can specify the AppId of // the app to create a ToastNotifier for that application ToastNotificationManager.CreateToastNotifier().Show(toast); }
private void UpdateTileWithTextWithStringManipulation_Click(object sender, RoutedEventArgs e) { // Create a string with the tile template xml. // Note that the version is set to "2" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes. // This is so that the notification can be understood by a Windows 8 machine as well. string tileXmlString = "<tile>" + "<visual version='2'>" + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>" + "<text id='1'>Hello World! My very own tile notification</text>" + "</binding>" + "<binding template='TileWide310x150Text03' fallback='TileWideText03'>" + "<text id='1'>Hello World! My very own tile notification</text>" + "</binding>" + "<binding template='TileSquare310x310Text09'>" + "<text id='1'>Hello World! My very own tile notification</text>" + "</binding>" + "</visual>" + "</tile>"; // Create a DOM. Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); // Load the xml string into the DOM. tileDOM.LoadXml(tileXmlString); // Create a tile notification. TileNotification tile = new TileNotification(tileDOM); // Send the notification to the application’s tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); }
void UpdateTileWithImageWithStringManipulation_Click(object sender, RoutedEventArgs e) { // Create a string with the tile template xml. // Note that the version is set to "3" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes. // This is so that the notification can be understood by Windows 8 and Windows 8.1 machines as well. string tileXmlString = "<tile>" + "<visual version='3'>" + "<binding template='TileSquare71x71Image'>" + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>" + "</binding>" + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>" + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>" + "</binding>" + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>" + "<image id='1' src='ms-appx:///images/redWide310x150.png' alt='Red image'/>" + "<text id='1'>This tile notification uses ms-appx images</text>" + "</binding>" + "<binding template='TileSquare310x310Image'>" + "<image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/>" + "</binding>" + "</visual>" + "</tile>"; // Create a DOM. Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); // Load the xml string into the DOM. tileDOM.LoadXml(tileXmlString); // Create a tile notification. TileNotification tile = new TileNotification(tileDOM); // Send the notification to the application’s tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); rootPage.NotifyUser("Tile notification with local images sent", NotifyType.StatusMessage); }
void UpdateTileWithWebImageWithStringManipulation_Click(object sender, RoutedEventArgs e) { // Create a string with the tile template xml. // Note that the version is set to "2" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes. // This is so that the notification can be understood by a Windows 8 machine as well. string tileXmlString = "<tile>" + "<visual version='2' addImageQuery='true'>" + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "</binding>" + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "<text id='1'>This tile notification uses web images.</text>" + "</binding>" + "<binding template='TileSquare310x310Image'>" + "<image id='1' src='" + ImageUrl.Text + "' alt='Web image'/>" + "</binding>" + "</visual>" + "</tile>"; // Create a DOM. Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { // Load the xml string into the DOM, catching any invalid xml characters. tileDOM.LoadXml(tileXmlString); // Create a tile notification. TileNotification tile = new TileNotification(tileDOM); // Send the notification to the application’s tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml()); } catch (Exception) { OutputTextBlock.Text = "Error loading the xml, check for invalid characters in the input"; } }
void DisplayWebImageToastWithStringManipulation(ToastTemplateType templateType) { string toastXmlString = String.Empty; string toastImageSrc = Scenario3ImageUrl.Text; if (templateType == ToastTemplateType.ToastImageAndText01) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText01'>" + "<text id='1'>Body text that wraps over three lines</text>" + "<image id='1' src='" + toastImageSrc + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastImageAndText02) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText02'>" + "<text id='1'>Heading text</text>" + "<text id='2'>Body text that wraps over two lines</text>" + "<image id='1' src='" + toastImageSrc + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastImageAndText03) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText03'>" + "<text id='1'>Heading text that wraps over two lines</text>" + "<text id='2'>Body text</text>" + "<image id='1' src='" + toastImageSrc + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } else if (templateType == ToastTemplateType.ToastImageAndText04) { toastXmlString = "<toast>" + "<visual version='1'>" + "<binding template='toastImageAndText04'>" + "<text id='1'>Heading text</text>" + "<text id='2'>First body text</text>" + "<text id='3'>Second body text</text>" + "<image id='1' src='" + toastImageSrc + "' alt='" + ALT_TEXT + "'/>" + "</binding>" + "</visual>" + "</toast>"; } Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { toastDOM.LoadXml(toastXmlString); rootPage.NotifyUser(toastDOM.GetXml(), NotifyType.StatusMessage); // Create a toast, then create a ToastNotifier object to show // the toast ToastNotification toast = new ToastNotification(toastDOM); // If you have other applications in your package, you can specify the AppId of // the app to create a ToastNotifier for that application ToastNotificationManager.CreateToastNotifier().Show(toast); } catch (Exception) { rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage); } }
public async Task <HttpRequestMessage> Create(string uri) { var request = HttpRequestHelper.CreateHttpWebRequest(uri, true); request.Method = new HttpMethod(_method); // request.KeepAlive = true; // request.Pipelined = true; if (_etag != null && _etag != "") { request.Headers["If-match"] = _etag; } request.Content = new HttpStringContent(_doc.DocumentElement.GetXml()); if (_contentType != null) { if (request.Content.Headers.ContentType != null) { request.Content.Headers.ContentType.MediaType = _contentType; } } if (_filter != null) { await _filter(request); } Debug.WriteLine( string.Format(CultureInfo.InvariantCulture, "XML REST request:\r\n{0} {1}\r\n{2}\r\n{3}", _method, uri, (_etag != null && _etag != "") ? "If-match: " + _etag : "(no etag)", _doc.GetXml())); //using (Stream s = await request.GetRequestStreamAsync()) //{ // var writer = System.Xml.XmlWriter.Create(s, new XmlWriterSettings() {Encoding = _encodingToUse, Indent = true, IndentChars = " "}); // await writer.WriteRawAsync(_doc.DocumentElement.GetXml()); // await writer.FlushAsync(); //} return(request); }
void UpdateBadgeWithGlyphWithStringManipulation() { // Create a string with the badge template xml. string badgeXmlString = "<badge value='" + ((ComboBoxItem)GlyphList.SelectedItem).Content.ToString() + "'/>"; Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { // Create a DOM. badgeDOM.LoadXml(badgeXmlString); // Load the xml string into the DOM, catching any invalid xml characters. BadgeNotification badge = new BadgeNotification(badgeDOM); // Create a badge notification and send it to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge); OutputTextBlock.Text = badgeDOM.GetXml(); } catch (Exception) { OutputTextBlock.Text = "Error loading the xml, check for invalid characters in the input"; } }