示例#1
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            //string path = this.textBox_FileName.Text.Trim();
            string path    = m_strCurrentPathAndFileName;
            bool   enabled = this.chkEnabled.Checked;

            if (String.IsNullOrEmpty(path))
            {
                MessageBox.Show(String.Format("音频文件名不能为空!"));
                return;
            }
            if (!File.Exists(path))
            {
                MessageBox.Show(String.Format("音频文件{0}不存在!", path));
                return;
            }

            if (VoiceXmlHelper.WriteToXML(path, enabled))
            {
                MessageBox.Show("保存成功!");
            }
        }
示例#2
0
        public static void ReadFromXML(out string path, out bool enabled)
        {
            string filename = "Config/sounds.xml";

            path    = string.Empty;
            enabled = false;
            if (File.Exists(filename))
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(filename);
                var root = xmlDoc.DocumentElement;

                XmlNode singleChild = xmlDoc.SelectSingleNode("sound/enable");
                enabled = Boolean.Parse(singleChild.InnerText);

                singleChild = xmlDoc.SelectSingleNode("sound/source");
                path        = singleChild.InnerText.ToString();
            }
            else
            {
                VoiceXmlHelper.WriteToXML("default.wav", true);
                ReadFromXML(out path, out enabled);
            }
        }