Exemplo 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();
            }
        }
Exemplo n.º 2
0
        void ResoultCount()
        {
            string lineOfFile   = "";
            int    LineIdOfFile = 0;

            foreach (var item in FileWords)
            {
                if (labelWord.Content.ToString() == TextFileRedactor.GetNameOfLine(item))
                {
                    lineOfFile = item;
                    break;
                }
                LineIdOfFile++;
            }

            float tAns = (float)Convert.ToInt32(TextFileRedactor.GetValueOfLine(lineOfFile, ",", ":"));
            float fAns = (float)Convert.ToInt32(TextFileRedactor.GetValueOfLine(lineOfFile, ":", "/"));

            //Console.WriteLine(Math.Round(tAns/fAns * 100));

            if (labelAnswer.Content.ToString().Length == 0 && (Math.Round(tAns / fAns * 100)) >= 100)
            {
                //Console.WriteLine(LineIdOfFile);
                FileWords = TextFileRedactor.SetValueOfLine(FileWords, LineIdOfFile, ",", ":", ((int)tAns) + 1 + "");
                FileWords = TextFileRedactor.SetValueOfLine(FileWords, LineIdOfFile, ";", ",", 2 + "");
                GenerateShowWords();
            }
            else if (labelAnswer.Content.ToString().Length == 0 && (Math.Round(tAns / fAns * 100)) < 100)
            {
                FileWords = TextFileRedactor.SetValueOfLine(FileWords, LineIdOfFile, ",", ":", ((int)tAns) + 1 + "");
            }
            else if (labelAnswer.Content.ToString().Length > 0)
            {
                FileWords = TextFileRedactor.SetValueOfLine(FileWords, LineIdOfFile, ":", "/", ((int)fAns) + 1 + "");
            }

            Sorting();

            File.Delete(strFI);
            File.WriteAllLines(strFI, FileWords);

            ShowStatistics();
        }