コード例 #1
0
 public MpeStringDesigner(MediaPortalEditor mpe, MpeStringTable referenceTable, MpeStringTable stringTable)
 {
   this.mpe = mpe;
   InitializeComponent();
   if (referenceTable == null)
   {
     throw new DesignerException("Invalid reference string table");
   }
   this.referenceTable = referenceTable;
   this.stringTable = stringTable;
   dataSet = new MpeData();
   dataTable = new MpeData.MpeDbStringDataTable();
 }
コード例 #2
0
ファイル: MpeParser.cs プロジェクト: arangas/MediaPortal-1
    public void SaveStringTable(MpeStringTable stringTable)
    {
      MpeLog.Error("Saveing the stringtable is disabled");
      return;
      if (stringTable == null)
      {
        return;
      }
      MpeLog.Debug("MpeParser.SaveStringTable(" + stringTable.Language + ")");
      XmlTextWriter writer = null;
      try
      {
        FileInfo file = GetLanguageFile(stringTable.Language);
        if (file == null || file.Exists == false)
        {
          throw new MpeParserException("Could not open language file for <" + stringTable.Language + ">");
        }

        XmlDocument doc = new XmlDocument();
        XmlElement strings = doc.CreateElement("strings");
        doc.AppendChild(strings);

        SetInt(doc, strings, "characters", 255);

        int[] keys = stringTable.Keys;
        for (int i = 0; i < keys.Length; i++)
        {
          XmlElement s = doc.CreateElement("string");
          SetInt(doc, s, "id", keys[i]);
          SetValue(doc, s, "value", stringTable[keys[i]]);
          strings.AppendChild(s);
        }

        writer = new XmlTextWriter(file.FullName, Encoding.UTF8);
        writer.Formatting = Formatting.Indented;
        writer.Indentation = 3;
        doc.WriteTo(writer);
        writer.Close();
      }
      catch (Exception e)
      {
        MpeLog.Debug(e);
        throw new MpeParserException("Error saving control: " + e.Message, e);
      }
      finally
      {
        if (writer != null)
        {
          writer.Close();
        }
      }
    }
コード例 #3
0
ファイル: MpeParser.cs プロジェクト: arangas/MediaPortal-1
    private MpeStringTable CreateStringTable(string language, FileInfo file)
    {
      MpeStringTable table = new MpeStringTable(language);
      try
      {
        XmlDocument doc = new XmlDocument();
        XmlTextReader reader = new XmlTextReader(file.FullName);
        //docencoding = reader.Encoding;
        doc.Load(reader);
        if (doc.DocumentElement == null) return table;
        string strRoot = doc.DocumentElement.Name;
        if (strRoot != "Language") return table;
        XmlNodeList list = doc.DocumentElement.SelectNodes("Section/String");
        foreach (XmlNode node in list)
        {
          table.Add(int.Parse(node.Attributes["id"].Value), node.InnerText);
        }
        reader.Close();
        return table;

        /*
        XPathDocument doc = new XPathDocument(file.FullName);
        XPathNavigator nav = doc.CreateNavigator();
        XPathNodeIterator iterator = nav.Select("/Language/Section/String");
        XPathNodeIterator i, j;
        MpeStringTable table = new MpeStringTable(language);
        while (iterator.MoveNext())
        {
          //i = iterator.Current.SelectChildren("id", "");
          //j = iterator.Current.SelectChildren("value", "");
          //if (i.MoveNext() && j.MoveNext())
          //{
            try
            {
              System.Windows.Forms.MessageBox.Show(iterator.Current.GetAttribute("Id","/Language/Section/String")+iterator.Current.Value.Trim());
              table.Add(int.Parse(iterator.Current.GetAttribute("Id","")), iterator.Current.Value.Trim());
            }
            catch (Exception ee)
            {
              MpeLog.Warn("Language=[" + language + "] " + ee.Message);
            }
          //}
        }
        return table;
         */ 
      }
      catch (Exception e)
      {
        throw new MpeParserException(e.Message);
      }
    }