Exemple #1
0
        private void LoadWebepgConfigFile()
        {
            if (File.Exists(_configFileDir + "\\WebEPG.xml"))
            {
                Log.Info("WebEPG Config: Loading Existing WebEPG.xml");

                XmlSerializer s = new XmlSerializer(typeof(WebepgConfigFile));
                TextReader    r = null;
                try
                {
                    r           = new StreamReader(_configFileDir + "\\WebEPG.xml");
                    _configFile = (WebepgConfigFile)s.Deserialize(r);
                    r.Close();
                }
                catch (InvalidOperationException ex)
                {
                    if (r != null)
                    {
                        r.Close();
                    }
                    Log.Error("WebEPG: Error loading config {0}: {1}", _configFileDir + "\\WebEPG.xml",
                              ex.Message);
                    LoadOldConfigFile();
                }
            }

            // no file found set defaults
            if (_configFile == null)
            {
                _configFile               = new WebepgConfigFile();
                _configFile.Channels      = new List <ChannelMap>();
                _configFile.RadioChannels = new List <ChannelMap>();
                _configFile.Info          = new WebepgInfo();
                _configFile.Info.GrabDays = 2;
            }

            TvMappings.ChannelMapping = new Dictionary <string, ChannelMap>();
            foreach (ChannelMap channel in _configFile.Channels)
            {
                TvMappings.ChannelMapping.Add(channel.displayName, channel);
                if (channel.merged != null && channel.merged.Count == 0)
                {
                    channel.merged = null;
                }
            }
            TvMappings.OnChannelMappingChanged();

            RadioMappings.ChannelMapping = new Dictionary <string, ChannelMap>();
            foreach (ChannelMap channel in _configFile.RadioChannels)
            {
                RadioMappings.ChannelMapping.Add(channel.displayName, channel);
                if (channel.merged != null && channel.merged.Count == 0)
                {
                    channel.merged = null;
                }
            }
            RadioMappings.OnChannelMappingChanged();

            nMaxGrab.Value = _configFile.Info.GrabDays;
        }
Exemple #2
0
        private void bAutoMap_Click(object sender, EventArgs e)
        {
            if (cbCountry.SelectedItem != null)
            {
                Cursor.Current        = Cursors.WaitCursor;
                tabMain.SelectedIndex = 1;
                if (TvMappings.ChannelMapping.Count == 0)
                {
                    TvMappings.DoImportChannels();
                }
                AutoMapChannels(TvMappings.ChannelMapping.Values);
                TvMappings.OnChannelMappingChanged();

                tabMain.SelectedIndex = 2;
                if (RadioMappings.ChannelMapping.Count == 0)
                {
                    RadioMappings.DoImportChannels();
                }
                AutoMapChannels(RadioMappings.ChannelMapping.Values);
                RadioMappings.OnChannelMappingChanged();
            }
            return;
        }