public void AddWord(TransleteWord word, bool newfile = false)
 {
     if (Path != String.Empty)
     {
         if (containWord(word.Word) == false)
         {
             if (BufferWords.Count + 1 <= 100 || newfile == false)
             {
                 word.Index = BufferWords.Count + 1;
                 File.AppendAllText(Path, word.ToString());
                 BufferWords.Add(word);
                 CountLocalWords++;
             }
             else
             {
                 BufferWords.Clear();
                 CountLocalWords = 0;
                 this.Path       = GetFileName();
                 word.Index      = 1;
                 File.AppendAllText(Path, word.ToString());
                 BufferWords.Add(word);
                 throw new Exception(this.Path);
             }
         }
     }
     else
     {
         throw new Exception("Selected File");
     }
 }
        public static TransleteWord Parse(string src)
        {
            TransleteWord temp = new TransleteWord();

            string[] m = src.Split('%');
            temp.Index         = Convert.ToInt32(m[0]);
            temp.Word          = m[1];
            temp.Transcription = m[2];
            temp.Translete     = m[3];
            try
            {
                temp.PerCent = Convert.ToInt32(m[4]);
            }
            catch
            {
                temp.PerCent = 0;
            }
            if (m.Length > 5)
            {
                temp.Url = m[5];
            }
            else
            {
                temp.Url = TransleteWord.AddAudio(temp);
            }
            return(temp);
        }
        public void Next()
        {
            int n = rand.Next(0, Iterator);

            if (WorkWords.Count == 0)
            {
                if (NewWords.Count == 0)
                {
                    throw new Exception(String.Format("Result All={0},F1={1},Correct={2}", AmountWord, AmountF1, AmountCorrectAnswer));
                }
                else
                {
                    //StartTraires();
                    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 TransleteWord(TransleteWord word)
 {
     this.Word          = word.Word;
     this.Translete     = word.Translete;
     this.Transcription = word.Transcription;
     this.PerCent       = word.PerCent;
     this.Url           = word.Url;
 }
        public void RemoveWord(TransleteWord word)
        {
            BufferWords.RemoveAt(word.Index - 1);
            CountLocalWords--;
            int i = 1;

            foreach (var item in BufferWords)
            {
                item.Index = i;
                i++;
            }
        }
        private void LoadFromFile()
        {
            BufferWords.Clear();
            CountLocalWords = 0;
            StreamReader stream = new StreamReader(Path);

            while (!stream.EndOfStream)
            {
                BufferWords.Add(TransleteWord.Parse(stream.ReadLine()));
                CountLocalWords++;
            }
            stream.Close();
        }
        public void ReplaceWord(TransleteWord word)
        {
            int index = word.Index - 1;

            BufferWords[index].Word          = word.Word;
            BufferWords[index].Translete     = word.Translete;
            BufferWords[index].Transcription = word.Transcription;
            BufferWords[index].PerCent       = word.PerCent;
            if (BufferWords[index].Url != word.Url)
            {
                BufferWords[index].Audio(word.Url);
            }
        }
        private void FromByteArray(byte[] data)
        {
            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream(data))
            {
                object        obj  = bf.Deserialize(ms);
                TransleteWord temp = (TransleteWord)obj;
                this.Word          = temp.Word;
                this.Translete     = temp.Translete;
                this.Transcription = temp.Transcription;
                this.Index         = temp.Index;
                this.PerCent       = temp.PerCent;
            }
        }
        public static string AddAudio(TransleteWord word)
        {
            string Url      = string.Format("https://myefe.ru/data/sw/words/us/{0}/{1}__us_1.mp3", word.Word[0], word.Word);
            string filename = "F:\\EnglishWords\\sound\\" + word.Word + ".mp3";

            if (File.Exists(filename) == false)
            {
                try
                {
                    client.DownloadFile(Url, filename);
                }
                catch
                {
                    Translator.addError(word.Word);
                    return("");
                }
            }
            return(filename);
        }
 public void Add(String word)
 {
     this.LocalWords.Add(TransleteWord.Parse(word));
 }
 public void Add(TransleteWord word)
 {
     word.Offset = GetOffset();
     this.LocalWords.Add(word);
 }