Exemple #1
0
    public static bool ConvertList(String fileName)
    {
      string path = System.IO.Path.GetDirectoryName(fileName);
      string saveName;
      int frequencyOffset = 0;
      List<DVBTTuning> _dvbtChannels = new List<DVBTTuning>();
      Dictionary<int, int> frequencies = new Dictionary<int, int>();
      XmlDocument doc = new XmlDocument();
      doc.Load(fileName);
      XmlNodeList countryList = doc.SelectNodes("/dvbt/country");
      if (countryList != null)
        foreach (XmlNode nodeCountry in countryList)
        {
          XmlNode nodeName = nodeCountry.Attributes.GetNamedItem("name");
          saveName = MakeDVBTName(nodeName.Value);
          XmlNode nodeOffset = nodeCountry.Attributes.GetNamedItem("offset");
          if (nodeOffset != null)
          {
            if (nodeOffset.Value != null)
            {
              if (Int32.TryParse(nodeOffset.Value, out frequencyOffset) == false)
              {
                frequencyOffset = 0;
              }
            }
          }
          XmlNodeList nodeFrequencyList = nodeCountry.SelectNodes("carrier");
          if (nodeFrequencyList != null)
            foreach (XmlNode nodeFrequency in nodeFrequencyList)
            {
              string frequencyText = nodeFrequency.Attributes.GetNamedItem("frequency").Value;
              string bandwidthText = "8";
              if (nodeFrequency.Attributes.GetNamedItem("bandwidth") != null)
              {
                bandwidthText = nodeFrequency.Attributes.GetNamedItem("bandwidth").Value;
              }
              int frequency = Int32.Parse(frequencyText);
              int bandWidth = Int32.Parse(bandwidthText);
              DVBTTuning tuning = new DVBTTuning(frequency, bandWidth, frequencyOffset);
              _dvbtChannels.Add(tuning);
            }

          String newPath = String.Format("{0}\\dvbt\\{1}.xml", System.IO.Path.GetDirectoryName(fileName), saveName);
          System.IO.TextWriter parFileXML = System.IO.File.CreateText(newPath);
          XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<DVBTTuning>));
          xmlSerializer.Serialize(parFileXML, _dvbtChannels);
          parFileXML.Close();

          _dvbtChannels.Clear();
        }

      return true;
    }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DVBTChannel"/> class.
 /// </summary>
 /// <param name="tuning">Tuning detail</param>
 public DVBTChannel(DVBTTuning tuning)
 {
   TuningInfo = tuning;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DVBTChannel"/> class.
 /// </summary>
 /// <param name="tuning">Tuning detail</param>
 public DVBTChannel(DVBTTuning tuning)
 {
     TuningInfo = tuning;
 }