Example #1
0
 private bool containWord(IrregularVerb ir)
 {
     foreach (var item in BufferWords)
     {
         if (item.Word1 == ir.Word1 && item.Word2 == ir.Word2 && item.Word3 == ir.Word3)
         {
             return(true);
         }
     }
     return(false);
 }
Example #2
0
 private void textBox4_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         IrregularVerb verb = new IrregularVerb()
         {
             PerCent = 50, Word1 = textBox1.Text, Word2 = textBox2.Text, Word3 = textBox3.Text, Translete = textBox4.Text
         };
         Add(verb);
         ReloadList();
         textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = String.Empty;
     }
 }
Example #3
0
 public void AddWord(IrregularVerb word)
 {
     if (!containWord(word))
     {
         word.path  = Path;
         word.Index = BufferWords.Count + 1;
         word.Url1  = word.AddAudio(word.Word1);
         word.Url2  = word.AddAudio(word.Word2);
         word.Url3  = word.AddAudio(word.Word3);
         File.AppendAllText(Path, word.ToString());
         BufferWords.Add(word);
         CountLocalWords++;
     }
 }
Example #4
0
        private void LoadFromFile()
        {
            StartLoad(this.Path);
            BufferWords.Clear();
            CountLocalWords = 0;
            StreamReader stream = new StreamReader(Path);

            while (!stream.EndOfStream)
            {
                BufferWords.Add(IrregularVerb.Parse(stream.ReadLine(), this.Path));
                CountLocalWords++;
            }
            stream.Close();
            StopLoad(this.Path);
        }
Example #5
0
        public void Next()
        {
            int n = rand.Next(0, Iterator);

            if (WorkWords.Count == 0)
            {
                throw new Exception(String.Format("Result All={0},F1={1},Correct={2}", AmountWord, AmountF1, AmountCorrectAnswer));
            }
            else
            {
                CurrentWord = WorkWords[n];
                WorkWords.RemoveAt(n);
                if (Iterator - 1 != -1)
                {
                    Iterator--;
                }
            }
        }
        public static IrregularVerb Parse(string src, string path)
        {
            IrregularVerb temp = new IrregularVerb();

            string[] m = src.Split('%');
            temp.Index     = Convert.ToInt32(m[0]);
            temp.path      = path;
            temp.Word1     = m[1];
            temp.Word2     = m[2];
            temp.Word3     = m[3];
            temp.Translete = m[4];
            temp.PerCent   = Convert.ToInt32(m[5]);
            if (m.Length > 6)
            {
                temp.Url1 = m[6];
                temp.Url2 = m[7];
                temp.Url3 = m[8];
                if (temp.Url1 == string.Empty)
                {
                    temp.Url1 = temp.AddAudio(temp.Word1);
                }
                if (temp.Url2 == string.Empty)
                {
                    temp.Url2 = temp.AddAudio(temp.Word2);
                }
                if (temp.Url3 == string.Empty)
                {
                    temp.Url3 = temp.AddAudio(temp.Word3);
                }
            }
            else
            {
                temp.Url1 = temp.AddAudio(temp.Word1);
                temp.Url2 = temp.AddAudio(temp.Word2);
                temp.Url3 = temp.AddAudio(temp.Word3);
            }
            return(temp);
        }
Example #7
0
        public void ReplaceWord(IrregularVerb word)
        {
            int index = word.Index;

            BufferWords[index].Word1 = word.Word1;
            BufferWords[index].Word2 = word.Word2;
            BufferWords[index].Word3 = word.Word3;

            BufferWords[index].Translete = word.Translete;
            BufferWords[index].PerCent   = word.PerCent;
            if (BufferWords[index].Url1 != word.Url1)
            {
                BufferWords[index].Audio(1, word.Url1);
            }
            if (BufferWords[index].Url2 != word.Url2)
            {
                BufferWords[index].Audio(2, word.Url2);
            }
            if (BufferWords[index].Url3 != word.Url3)
            {
                BufferWords[index].Audio(3, word.Url3);
            }
        }
 public static void SaveInFile(string path, IrregularVerb verbs)
 {
     File.AppendAllText(path, verbs.ToString());
 }