Esempio n. 1
0
        void GenerateQuestion()
        {
            CountAnswer = 0;

            if (TextFileRedactor.GetCountLinesOfValue(FileWords, 2) == FileWords.Count)
            {
                ActivBtn = false;
                ShowEndStady();
            }
            else
            {
                ResetProgress.Visibility = Visibility.Hidden;

                foreach (Button item in ButtonsAns)
                {
                    item.Visibility = Visibility.Visible;
                }

                ActivBtn = true;
                Random rand = new Random();

                for (int i = 1; i < 7; i++)
                {
                    int r = rand.Next(TextFileRedactor.GetCountLinesOfValue(FileWords, 2), FileWords.Count - 1 - TextFileRedactor.GetCountLinesOfValue(FileWords, 0));

                    if (TextFileRedactor.IsEmptyString(TextFileRedactor.GetValueOfLine(FileWords[r])) == true)
                    {
                        MessageBox.Show("В файле иморта допущена ошибка! Номер строки: " + r, "Ошибка");
                    }

                    ButtonsAns[i].Content    = TextFileRedactor.GetValueOfLine(FileWords[r]);
                    ButtonsAns[i].Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
                    ButtonsAns[i].Background = new LinearGradientBrush(Color.FromRgb(90, 90, 90), Color.FromRgb(190, 190, 190), new Point(0, 0.5), new Point(0.5, 1));
                    labelMain.Foreground     = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    labelMain.Background     = new SolidColorBrush(Color.FromRgb(55, 55, 55));
                    labelMain.Content        = "";
                    labelAnswer.Content      = "";
                }

                int minRand = TextFileRedactor.GetCountLinesOfValue(FileWords, 2);
                int maxRand = minRand + (TextFileRedactor.GetCountLinesOfValue(FileWords, 1));

                labelWord.Content = TextFileRedactor.GetNameOfLine(FileWords[rand.Next(minRand, maxRand)]);
                ButtonsAns[rand.Next(1, 6)].Content = TextFileRedactor.GetValueNF(FileWords, labelWord.Content.ToString());

                ShowStatistics();
            }
        }