public override XmlElement VToXML() { var componentDoc = new XmlDocument(); var componentData = componentDoc.CreateElement(GetComponentName <Cv_SoundEmitterComponent>()); var sound = componentDoc.CreateElement("SoundEffect"); var volume = componentDoc.CreateElement("Volume"); var pan = componentDoc.CreateElement("Pan"); var pitch = componentDoc.CreateElement("Pitch"); var looping = componentDoc.CreateElement("Looping"); var positional = componentDoc.CreateElement("IsPositional"); var autoPlay = componentDoc.CreateElement("AutoPlay"); sound.SetAttribute("resource", SoundResource); volume.SetAttribute("value", Volume.ToString(CultureInfo.InvariantCulture)); pan.SetAttribute("value", Pan.ToString(CultureInfo.InvariantCulture)); pitch.SetAttribute("value", Pitch.ToString(CultureInfo.InvariantCulture)); looping.SetAttribute("status", Looping.ToString(CultureInfo.InvariantCulture)); positional.SetAttribute("status", IsPositional.ToString(CultureInfo.InvariantCulture)); autoPlay.SetAttribute("status", AutoPlay.ToString(CultureInfo.InvariantCulture)); componentData.AppendChild(sound); componentData.AppendChild(volume); componentData.AppendChild(pan); componentData.AppendChild(pitch); componentData.AppendChild(looping); componentData.AppendChild(positional); componentData.AppendChild(autoPlay); return(componentData); }
//--- Methods --- internal override XDoc AsXDoc() { return(new XDoc("html").Start("body").Start("span").Start("embed") .Attr("width", AsSize(Width)) .Attr("height", AsSize(Height)) .Attr("hidden", ((Width == 0) && (Height == 0)) ? "true" : null) .Attr("src", Uri.With("autoStart", Convert.ToInt32(AutoPlay).ToString())) .Attr("autoplay", AutoPlay.ToString()) .Attr("autostart", AutoPlay.ToString()) .Attr("scale", "tofit") .Attr("wmode", "opaque") .Attr("allowFullScreen", "true") .End().End().End()); }
//----------------------------------------------------------------------------- // Preferences //----------------------------------------------------------------------------- public static void SavePreferences() { try { XmlDocument doc = new XmlDocument(); XmlElement element; XmlElement root = doc.CreateElement("PGPlayer"); doc.AppendChild(root); element = doc.CreateElement("ShowSoundVisualizer"); element.AppendChild(doc.CreateTextNode(ShowSoundVisualizer.ToString())); root.AppendChild(element); element = doc.CreateElement("MediumIncrement"); element.AppendChild(doc.CreateTextNode(MediumIncrement.ToString())); root.AppendChild(element); element = doc.CreateElement("LargeIncrement"); element.AppendChild(doc.CreateTextNode(LargeIncrement.ToString())); root.AppendChild(element); element = doc.CreateElement("VideoScale"); element.AppendChild(doc.CreateTextNode(VideoScale.ToString())); root.AppendChild(element); element = doc.CreateElement("ForceNearestNeighbor"); element.AppendChild(doc.CreateTextNode(ForceNearestNeighbor.ToString())); root.AppendChild(element); element = doc.CreateElement("Volume"); element.AppendChild(doc.CreateTextNode(Volume.ToString())); root.AppendChild(element); element = doc.CreateElement("IsMuted"); element.AppendChild(doc.CreateTextNode(IsMuted.ToString())); root.AppendChild(element); element = doc.CreateElement("AutoPlay"); element.AppendChild(doc.CreateTextNode(AutoPlay.ToString())); root.AppendChild(element); element = doc.CreateElement("ShowBookmarkTimes"); element.AppendChild(doc.CreateTextNode(ShowBookmarkTimes.ToString())); root.AppendChild(element); doc.Save(PreferencesFile); } catch (Exception) { } }
/// <summary> /// Creates a script block which loads a Flash object at runtime. /// </summary> /// <param name="additionalParams">Additional parameters for the script</param> /// <returns>Script block that will load a Flash object</returns> private string BuildScriptBlock(string additionalParams) { string scriptBlock = string.Format(@"LoadFlash('FlashPlaceholder_{0}', '{1}', {2}, {3}, {4}, '{5}', '{6}', {7}, {8}, {9}, {10})", ltlScript.ClientID, HTMLHelper.HTMLEncode(ResolveUrl(FlashURL)), Width, Height, AllowFullScreen.ToString().ToLowerCSafe(), HTMLHelper.HTMLEncode(Quality), HTMLHelper.HTMLEncode(Scale), AutoPlay.ToString().ToLowerCSafe(), Loop.ToString().ToLowerCSafe(), ScriptHelper.GetString(NotSupportedText), string.IsNullOrEmpty(additionalParams) ? "''" : additionalParams); return(ScriptHelper.GetScript(scriptBlock)); }