static void SetSound(IXmlDocument xmldoc, PredefinedSound sound) { string soundXml = "ms-winsoundevent:" + sound.ToString().Replace("_", "."); IXmlElement soundElement; ComFunctions.CheckHRESULT(xmldoc.CreateElement("audio", out soundElement)); if (sound == PredefinedSound.NoSound) { ComFunctions.CheckHRESULT(soundElement.SetAttribute("silent", "true")); } else { ComFunctions.CheckHRESULT(soundElement.SetAttribute("src", soundXml)); ComFunctions.CheckHRESULT(soundElement.SetAttribute("loop", IsLoopingSound(sound).ToString().ToLower())); } var asNode = (IXmlNode)xmldoc; IXmlNode appendedChild; IXmlNodeList nodes; ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("toast", out nodes)); IXmlNode toastNode; ComFunctions.CheckHRESULT(nodes.Item(0, out toastNode)); ComFunctions.CheckHRESULT(toastNode.AppendChild((IXmlNode)soundElement, out appendedChild)); }
static void SetSound(IXmlDocument xmldoc, PredefinedSound sound) { string soundXml = "ms-winsoundevent:" + sound.ToString().Replace("_", "."); IXmlElement soundElement = CreateElement(xmldoc, "audio"); if (sound == PredefinedSound.NoSound) { SetAttribute(soundElement, "silent", "true"); } else { SetAttribute(soundElement, "src", soundXml); SetAttribute(soundElement, "loop", IsLoopingSound(sound).ToString().ToLower()); } IXmlNode toastNode = GetNode(xmldoc, "toast"); AppendNode(toastNode, (IXmlNode)soundElement); }
static void SetSound(IXmlDocument xmldoc, PredefinedSound sound) { string soundXml = "ms-winsoundevent:" + sound.ToString().Replace("_", "."); IXmlElement soundElement; ComFunctions.CheckHRESULT(xmldoc.CreateElement("audio", out soundElement)); if(sound == PredefinedSound.NoSound) { ComFunctions.CheckHRESULT(soundElement.SetAttribute("silent", "true")); } else { ComFunctions.CheckHRESULT(soundElement.SetAttribute("src", soundXml)); ComFunctions.CheckHRESULT(soundElement.SetAttribute("loop", IsLoopingSound(sound).ToString().ToLower())); } var asNode = (IXmlNode)xmldoc; IXmlNode appendedChild; IXmlNodeList nodes; ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("toast", out nodes)); IXmlNode toastNode; ComFunctions.CheckHRESULT(nodes.Item(0, out toastNode)); ComFunctions.CheckHRESULT(toastNode.AppendChild((IXmlNode)soundElement, out appendedChild)); }