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 SaveProviders() { for (var i = 0; i < checkedListBoxProviders.Items.Count; i++) { var provider = new Config.Provider { Name = checkedListBoxProviders.Items[i].ToString(), Active = checkedListBoxProviders.GetItemChecked(i) }; _provider.Add(provider); } ConfigFile.ProvidersCollection = _provider.ToArray(); }