Esempio n. 1
0
        private static void LoadDictionaryFromXmlNode(Dictionary <decimal, string> dict, EnhancedXmlDocument xmlDoc, string xpath)
        {
            var nodes = xmlDoc.SelectNodes(xpath);

            foreach (XmlElement nodeEl in nodes)
            {
                decimal val   = 0;
                string  title = "";

                if (nodeEl.HasAttribute("value"))
                {
                    val = Convert.ToDecimal(nodeEl.GetAttribute("value"));
                }

                if (nodeEl.HasAttribute("title"))
                {
                    title = nodeEl.GetAttribute("title");
                }

                if (title == "")
                {
                    title = val.ToString("N0");
                }

                dict.Add(val, title);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the configuration.
        /// </summary>
        /// <param name='path'>
        /// Path to xml config file
        /// </param>
        public static void Load(string filename)
        {
            OpenWithApplications = new List <string>();
            VideoCodecs          = new List <MediaCodec> ();
            AudioCodecs          = new List <MediaCodec> ();
            Containers           = new List <MediaContainer> ();

            DefaultVideoBitRates = new Dictionary <decimal, string> ();
            DefaultSamplingRates = new Dictionary <decimal, string> ();
            DefaultAudioBitrates = new Dictionary <decimal, string> ();

            if (!Path.IsPathRooted(filename))
            {
                // adding app path
                filename = Path.Combine(SupportMethods.AppPath + Path.DirectorySeparatorChar, filename);
            }

            if (!File.Exists(filename))
            {
                // creating default configuration
                Save(filename);
            }

            var xmlDoc = new EnhancedXmlDocument();

            xmlDoc.Load(filename);

            var appOpenWithNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/Applications/OpenWith/Application");

            foreach (XmlNode appNode in appOpenWithNodes)
            {
                OpenWithApplications.Add(appNode.InnerText);
            }

            var codecNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/AvailableCodecs/Video/Codec");

            foreach (XmlElement codecNode in codecNodes)
            {
                VideoCodecs.Add(MediaCodec.CreateFromXmlnode(codecNode));
            }

            var audioCodecNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/AvailableCodecs/Audio/Codec");

            foreach (XmlElement codecNode in audioCodecNodes)
            {
                AudioCodecs.Add(MediaCodec.CreateFromXmlnode(codecNode));
            }

            var contNodes = xmlDoc.SelectNodes("//MediaConvertGUIConfiguration/AvailableContainers/Container");

            foreach (XmlElement cont in contNodes)
            {
                Containers.Add(MediaContainer.CreateFromXmlnode(cont));
            }

            MediaInfoPath = xmlDoc.GetSingleNodeValue("//MediaConvertGUIConfiguration/MediaInfoPath", "mediainfo");
            FFMpegPath    = xmlDoc.GetSingleNodeValue("//MediaConvertGUIConfiguration/FFMpegPath", "ffmpeg");


            LoadDictionaryFromXmlNode(DefaultVideoBitRates, xmlDoc, "//MediaConvertGUIConfiguration/DefaultVideoBitrates/Bitrate");
            LoadDictionaryFromXmlNode(DefaultSamplingRates, xmlDoc, "//MediaConvertGUIConfiguration/DefaultSamplingRates/Rate");
            LoadDictionaryFromXmlNode(DefaultAudioBitrates, xmlDoc, "//MediaConvertGUIConfiguration/DefaultAudioBitrates/Bitrate");

            // Saving
            Save(filename);
        }