Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Validate if we have atleast the word
            if (txtWord.Text.Length > 0)
            {
                // Create a WordEntry object from input
                WordEntry we = new WordEntry();
                we.SetWord(txtWord.Text);

                // Meanings
                String[] strMeanings = txtMeanings.Lines;
                foreach (String str in strMeanings)
                {
                    if (str.Length > 0)
                    {
                        we.AddMeaning(str);
                    }
                }
                // Usages
                String[] strUsages = txtUsages.Lines;
                foreach (String str in strUsages)
                {
                    if (str.Length > 0)
                    {
                        we.AddUsage(str);
                    }
                }
                // Other info
                String[] strOther = txtOtherInfo.Lines;
                foreach (String str in strOther)
                {
                    if (str.Length > 0)
                    {
                        we.AddOtherInfo(str);
                    }
                }

                // Now, we have the entry. Add it to the ArrayWordList
                Boolean ret = wl.AddEntry(we);

                // Update the UI.
                if (ret)
                {
                    lstWordList.Items.Add(we.GetWord());
                }

                Clear();
            }
            FormMaintenance.GetInstance().GetGREMasterInstance().GetSerializer().SetChanged(true);
        }
Example #2
0
        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.
                attrs = fields[2].Split(newline);
                foreach (String str in attrs)
                {
                    we.AddUsage(str);
                }

                // Fourth come the Other info.
                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;
        }
Example #3
0
        // 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++;
            }
        }
Example #4
0
        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);
        }