示例#1
0
        private XElement MenuSoundToXElement(MenuSound sound)
        {
            XElement soundItem = new XElement("Sound");

            if (sound != null)
            {
                string fileName = Path.GetFileName(sound.File);
                soundItem.Add(new XElement("SoundFile", fileName));
                if (sound.Volume != MenuSound.DefaultVolume)
                {
                    soundItem.Add(new XElement("Volume", sound.Volume));
                }
            }

            return(soundItem);
        }
示例#2
0
        private MenuSound ReadXmlSound(XElement section)
        {
            MenuSound sound = new MenuSound();

            // Backward compatibility
            if (section.Element("Sound") != null)
            {
                sound.File   = section.Element("Sound")?.Element("SoundFile")?.Value ?? "";
                sound.Volume = int.Parse(section.Element("Sound")?.Element("Volume")?.Value ?? MenuSound.DefaultVolume.ToString());
            }
            else
            {
                sound.File   = section.Element("SoundFile")?.Value ?? "";
                sound.Volume = int.Parse(section.Element("Volume")?.Value ?? MenuSound.DefaultVolume.ToString());
            }

            return(sound);
        }
示例#3
0
 public MenuSound(MenuSound sound)
 {
     File   = sound.File;
     Volume = sound.Volume;
 }