public WordListDialog(WordList w) : this() { FormMaintenance.GetInstance().RegisterWordListDialog(this); bIsUpdated = false; bIsNormalFlow = true; wl = w; // Add entries to list foreach (WordEntry we in wl) { lstWordList.Items.Add(we.GetWord()); } lblCount.Text = wl.GetCount().ToString(); }
protected override void load(WordList wl) { fileReader = new StreamReader(strFilename); String strLine = null; while (!fileReader.EndOfStream) { WordEntry we = new WordEntry(); strLine = fileReader.ReadLine(); String[] fields = strLine.Split(delimiter); // First entry is the word we.setWord(fields[0]); // Second come the meanings.Here,we have to parse again String[] attrs = fields[1].Split(newline); foreach (String str in attrs) { we.addMeaning(str); } // Third come the usages. if (fields.Length > 2) { attrs = fields[2].Split(newline); foreach (String str in attrs) { we.addUsage(str); } } // Fourth come the Other info. if (fields.Length > 3) { attrs = fields[3].Split(newline); foreach (String str in attrs) { we.addOtherInfo(str); } } // Now we have the entry ready. Add it to the word list wl.addEntry(we); } fileReader.Close(); fileReader = null; }
protected override void Save(WordList wl) { XmlTextWriter xtw = new XmlTextWriter(strFilename, null); xtw.WriteStartDocument(); xtw.WriteStartElement(strWordListMoniker); foreach (WordEntry we in wl) { xtw.WriteStartElement(strWordEntryMoniker); xtw.WriteStartElement(strWordMoniker); xtw.WriteString(we.GetWord()); xtw.WriteEndElement(); foreach (String strMeaning in we.GetMeanings()) { xtw.WriteStartElement(strMeaningMoniker); xtw.WriteString(strMeaning); xtw.WriteEndElement(); } foreach (String strUsage in we.GetUsages()) { xtw.WriteStartElement(strUsageMoniker); xtw.WriteString(strUsage); xtw.WriteEndElement(); } foreach (String strOtherInfo in we.GetOtherInfo()) { xtw.WriteStartElement(strOtherInfoMoniker); xtw.WriteString(strOtherInfo); xtw.WriteEndElement(); } xtw.WriteEndElement(); } xtw.WriteEndElement(); xtw.WriteEndDocument(); xtw.Close(); }
// abstract method implementation protected override void Load(WordList wl) { XmlDocument xd = new XmlDocument(); XmlTextReader xtr = new XmlTextReader(strFilename); xtr.Read(); xd.Load(xtr); XmlNodeList xnl = xd.GetElementsByTagName(strWordEntryMoniker); iTotalWords = xnl.Count; foreach (XmlNode xn in xnl) { WordEntry we = new WordEntry(); foreach (XmlNode xnSubElements in xn.ChildNodes) { if (xnSubElements.Name == strWordMoniker) { we.SetWord(xnSubElements.InnerText.Trim()); } else if (xnSubElements.Name == strMeaningMoniker) { we.AddMeaning(xnSubElements.InnerText.Trim()); } else if (xnSubElements.Name == strUsageMoniker) { we.AddUsage(xnSubElements.InnerText.Trim()); } else if (xnSubElements.Name == strOtherInfoMoniker) { we.AddOtherInfo(xnSubElements.InnerText.Trim()); } } wl.AddEntry(we); iWordsLoaded++; } }
public Test GetTest(WordList w, String strTestType, String strCriteria) { // Create the filtered wordlist WordList wl = new WordList(); if (strCriteria != "All") { if (strCriteria.Length > 1) { String[] strArray = strCriteria.Split(','); String strFrom = strArray[0]; String strTo = strArray[1]; Boolean bStarted = false; foreach (WordEntry we in w) { if ((we.GetWord() != strFrom.ToLower())) { if (!bStarted) { continue; } } else { bStarted = true; } if (we.GetWord() == strTo.ToLower()) { wl.AddEntry(we); break; } wl.AddEntry(we); } } else { foreach (WordEntry we in w) { if (we.GetWord()[0] == strCriteria.ToLower()[0]) { wl.AddEntry(we); } } } } else { wl = w; } if (strTestType == "Meaning->Word") { return(new MeaningToWordTest(wl)); } else if (strTestType == "Word->Meaning") { return(new WordToMeaningTest(wl)); } return(null); }
// Constructors public WordToMeaningTest(WordList w) : base(w) { }
abstract protected void save(WordList wl);
abstract protected void load(WordList wl);
// Constructors public Test(WordList w) { wl = w; generatedIndexList = new ArrayList(); }
// Constructors public MeaningToWordTest(WordList w) : base(w) { }