Esempio n. 1
0
        private void ReadConfig()
        {
            // Read app config from Config.xml
            config = new Config();

            if (File.Exists("config.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Config));

                StreamReader reader = new StreamReader("config.xml");
                config = (Config)serializer.Deserialize(reader);
                reader.Close();

                serializer = null;
                reader = null;
            }
            else
            {
                // Create Default config.xml values
                Config.Definition[] defaultDefinitions = new Config.Definition[3];
                defaultDefinitions[0] = new Config.Definition { Type = "1080p", Active = true };
                defaultDefinitions[1] = new Config.Definition { Type = "720p", Active = true };
                defaultDefinitions[2] = new Config.Definition { Type = "360p", Active = true };

                config.DefinitionsCollection = defaultDefinitions;

                Config.Provider[] defaultProviders = new Config.Provider[2];
                defaultProviders[0] = new Config.Provider { Name = "TheMovieDB.org", Active = true };
                defaultProviders[1] = new Config.Provider { Name = "Trakt.tv", Active = true };

                config.ProvidersCollection = defaultProviders;

                // Create and Write Default config.xml
                config.WriteConfig(config);
            }
        }
        private void SaveDefintion()
        {
            for (var i = 0; i < checkedlistboxDefinitions.Items.Count; i++)
            {
                var def = new Config.Definition
                              {
                                  Type = checkedlistboxDefinitions.Items[i].ToString(),
                                  Active = checkedlistboxDefinitions.GetItemChecked(i)
                              };

                _def.Add(def);
            }

            ConfigFile.DefinitionsCollection = _def.ToArray();
        }