Beispiel #1
0
 private void Initialize()
 {
     using (var context = new WordContext())
     {
     }
     ShowNextWord();
 }
Beispiel #2
0
        public void AddWord(object sender, RoutedEventArgs e)
        {
            using (var context = new WordContext())
            {
                ResetFieldColor();
                Word word = new Word();

                if (context.Words.Count() > 0)
                {
                    word.WordId = (from element in context.Words select element.WordId).ToList().Last() + 1;
                }
                else
                {
                    word.WordId = 1;
                }

                word.FirstForm  = mainWord.Text.ToLower();
                word.Translate  = translate.Text.ToLower();
                word.SecondForm = secondForm.Text.ToLower();
                word.ThirdForm  = thirdForm.Text.ToLower();

                if (context.Words.Any(element => element.FirstForm == word.FirstForm))
                {
                    MessageBox.Show($"Слово {word.FirstForm} уже числится в словаре");
                    return;
                }

                if (CheckUserInput())
                {
                    ClearField();
                    context.Words.Add(word);
                    context.SaveChanges();
                }
            }
        }
 private void ShowWords()
 {
     using (var context = new WordContext())
     {
         foreach (var word in context.Words)
         {
             wordsList.Items.Add(word);
         }
     }
 }
Beispiel #4
0
 private void mainWord_TextChanged(object sender, TextChangedEventArgs e)
 {
     using (var context = new WordContext())
     {
         if (context.Words.Any(word => word.FirstForm == ((TextBox)sender).Text))
         {
             mainWord.Background = Brushes.Red;
         }
         else
         {
             mainWord.Background = Brushes.White;
         }
     }
 }
Beispiel #5
0
        private void ShowNextWord()
        {
            ResetColorTextBox();
            ResetRightAnswerLabel();
            ResetContentTextBox();

            checkButton.Visibility = Visibility.Visible;
            nextButton.Visibility  = Visibility.Hidden;
            using (var context = new WordContext())
            {
                if (context.Words.Count() == 0)
                {
                    return;
                }

                Random random = new Random((int)DateTime.Now.Ticks);
                currentWord = context.Words.ToList()[random.Next(context.Words.Count())];

                mainWord.Content = currentWord.FirstForm;
            }
        }