示例#1
0
        void TranslateImportFile(object words)
        {
            List <string> WordsBook  = new List <string>(File.ReadAllLines("WordBookAll.wordbok"));
            List <string> newImport  = (List <string>)words;
            List <string> import     = new List <string>();
            List <string> errorWords = new List <string>();

            isWork = true;
            for (int i = 0; i < newImport.Count && isWork; i++)
            {
                Action action1 = () => { SetValueProgress((int)Math.Round((double)i / (double)newImport.Count * (double)100), false); };
                Dispatcher.Invoke(action1);
                if (TextFileRedactor.GetValueNF(WordsBook, newImport[i] + " ") != "error 2")
                {
                    import.Add(newImport[i] + " - " + TextFileRedactor.GetValueNF(WordsBook, newImport[i] + " "));
                }
                else
                {
                    errorWords.Add(newImport[i] + " - " + TextFileRedactor.GetValueNF(WordsBook, newImport[i] + " "));
                }
            }

            if (isWork)
            {
                Action action2 = () => { SetValueProgress(100, true); };
                Dispatcher.Invoke(action2);
                File.Delete("Import/" + WillNameIF + ".txt");
                File.WriteAllLines("Import/" + WillNameIF + ".txt", import);

                File.Delete("Import/" + WillNameIF + "_Error" + ".txt");
                File.WriteAllLines("Import/" + WillNameIF + "_Error" + ".txt", errorWords);
            }
        }
示例#2
0
        private void test()
        {
            List <string> worbook  = new List <string>(File.ReadAllLines("WordBookAll.wordbok"));
            List <string> words    = new List <string>(File.ReadAllLines("Statistic/16 тысяч строк.txt"));
            List <string> worbook2 = new List <string>();

            string str = TextFileRedactor.GetValueNF(worbook, TextFileRedactor.GetNameOfLine(words[3] + " "));

            WindowProgress wndp = new WindowProgress(new WindowSettings(this));

            wndp.Show();

            for (int i = 0; i < words.Count; i++)
            {
                wndp.ProgBar.Value = Math.Round((double)i / (double)words.Count * (double)100);
                for (int j = 0; j < worbook.Count; j++)
                {
                    if (TextFileRedactor.DeleteSpace(TextFileRedactor.GetNameOfLine(words[i])) == TextFileRedactor.DeleteSpace(TextFileRedactor.GetNameOfLine(worbook[j])))
                    {
                        Console.WriteLine(TextFileRedactor.DeleteSpace(TextFileRedactor.GetNameOfLine(words[i])) + "\n" + TextFileRedactor.DeleteSpace(TextFileRedactor.GetNameOfLine(worbook[j])));
                        break;
                    }
                }
            }
        }
示例#3
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();
            }
        }
示例#4
0
        void InspectionAnswer(string answer, int NumberBtn)
        {
            if (TextFileRedactor.GetValueNF(FileWords, labelWord.Content.ToString()) == answer)
            {
                ActivBtn             = false;
                labelMain.Background = new SolidColorBrush(Color.FromRgb(22, 95, 22));
                labelMain.Content    = "Верно!";
            }
            else
            {
                ActivBtn             = false;
                labelMain.Background = new SolidColorBrush(Color.FromRgb(95, 22, 22));
                labelMain.Content    = "Не верно!";
                labelAnswer.Content  = labelWord.Content + " - " + TextFileRedactor.GetValueNF(FileWords, labelWord.Content.ToString());
            }

            ResoultCount();
        }
示例#5
0
        void PostClick(int NumberBtn)
        {
            if (CountAnswer < 0)
            {
                CountAnswer = 0;
            }

            if (TextFileRedactor.GetValueNF(FileWords, labelWord.Content.ToString()) == ButtonsAns[NumberBtn].Content.ToString())
            {
                for (int i = 1; i < 7; i++)
                {
                    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));
                }

                ButtonsAns[NumberBtn].Background = new LinearGradientBrush(Color.FromRgb(0, 210, 0), Color.FromRgb(0, 150, 0), new Point(0.5, 1), new Point(0.5, 0));
                ButtonsAns[NumberBtn].Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));

                CountAnswer += 1;
            }
            else if (TextFileRedactor.GetValueNF(FileWords, labelWord.Content.ToString()) != ButtonsAns[NumberBtn].Content.ToString())
            {
                for (int i = 1; i < 7; i++)
                {
                    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));
                }

                ButtonsAns[NumberBtn].Background = new LinearGradientBrush(Color.FromRgb(80, 10, 10), Color.FromRgb(120, 40, 40), new Point(0.5, 1), new Point(0.5, 0));
                ButtonsAns[NumberBtn].Foreground = new SolidColorBrush(Color.FromRgb(250, 250, 250));

                CountAnswer -= 1;
            }

            if (ActivBtn)
            {
                InspectionAnswer(ButtonsAns[NumberBtn].Content.ToString(), NumberBtn);
            }

            if (CountAnswer == 2)
            {
                GenerateQuestion();
            }
        }
示例#6
0
        public void LoadFile()
        {
            if (File.Exists("Settings.txt"))
            {
                FileSettings = new List <string>(File.ReadAllLines("Settings.txt"));

                string nameLine = "";

                nameLine            = TextFileRedactor.GetNameOfLine(FileSettings[0]);
                ValueShowWrods      = Convert.ToInt32(TextFileRedactor.DeleteSpace(TextFileRedactor.GetValueNF(FileSettings, nameLine)));
                nameLine            = TextFileRedactor.GetNameOfLine(FileSettings[1]);
                ValueMustTrueAnswer = Convert.ToInt32(TextFileRedactor.DeleteSpace(TextFileRedactor.GetValueNF(FileSettings, nameLine)));
                strFI     = FileSettings[2];
                strFIsafe = FileSettings[3];
            }
            else
            {
                FileSettings.Add("ValueShowWrods-" + ValueShowWrods + ";");
                FileSettings.Add("ValeMustTrueAnswer-" + ValueMustTrueAnswer + ";");
                FileSettings.Add(strFI);
                FileSettings.Add(strFIsafe);

                File.WriteAllLines("Settings.txt", FileSettings);
            }

            StrFI     = FileSettings[2];
            FileWords = new List <string>(File.ReadAllLines(strFI));

            for (int i = 0; i < FileWords.Count; i++)
            {
                FileWords[i] = TextFileRedactor.LineConctructor(FileWords[i], ValueMustTrueAnswer);
            }

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