private void button_add_Click(object sender, EventArgs e)
 {
     if (textBox_word_1lang.Text == "" || textBox_word_2lang.Text == "")
     {
         Data.messageBox("Warnung!", "Bitte beide sprachen eingeben!");
     }
     else
     {
         VocWord word = new VocWord(textBox_word_1lang.Text, textBox_word_2lang.Text, textBox_word_desc.Text);
         vocab.words.Add(word);
         textBox_word_1lang.Text = "";
         textBox_word_2lang.Text = "";
         textBox_word_desc.Text = "";
         updateList();
     }
 }
Example #2
0
        public static Vocabulary xmlToVocab(string xml)
        {
            StringReader s = new StringReader(xml);
            XmlReader xmlr = XmlReader.Create(s);
            Vocabulary current = null;

            while (xmlr.Read())
            {
                if (xmlr.Name == "Vocabulary" && xmlr.NodeType == XmlNodeType.Element)
                {
                    current = new Vocabulary("","",new List<VocWord>(), "","","","");
                }
                if (xmlr.Name == "item" && xmlr.NodeType == XmlNodeType.Element)
                {
                    string nodekey = xmlr.GetAttribute("key");
                    Type ptype = current.GetType().GetProperty(nodekey).PropertyType;
                    current.GetType().GetProperty(nodekey).SetValue(current,
                        Convert.ChangeType(xmlr.ReadElementContentAsString(),ptype),
                        null);
                }
                if (xmlr.Name == "word")
                {
                    VocWord currentWord = new VocWord(
                        xmlr.GetAttribute("fromVal"),
                        xmlr.GetAttribute("toVal"),
                        xmlr.GetAttribute("desc")
                        );
                    current.words.Add(currentWord);
                }
                if (xmlr.Name == "Vocabulary" && xmlr.NodeType == XmlNodeType.EndElement)
                {
                    return current;
                }
            }

            return new Vocabulary();
        }
 private string getWordIdentifier(VocWord word)
 {
     return word.fromVal + "," + word.toVal + "," + word.desc;
 }