示例#1
0
        public TakeTestWindow(WordObject[] qs)
        {
            InitializeComponent();

            this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, this.Height);
            questions = Utils.Shuffle<WordObject>(qs);

            UpdateQuestion();
        }
示例#2
0
        public AddNewWordWindow(CreateOrEditTestWindow owner)
        {
            InitializeComponent();

            isCancel = false;
            result = new WordObject();
            _owner = owner;

            this.MaximumSize = new Size(Screen.PrimaryScreen.Bounds.Width, this.Height);
        }
示例#3
0
 public static string GetPartOfSpeechString(WordObject.PartOfSpeechKind pof)
 {
     switch (pof) {
         case WordObject.PartOfSpeechKind.Noun: return "Noun";
         case WordObject.PartOfSpeechKind.Verb: return "Verb";
         case WordObject.PartOfSpeechKind.Adjective: return "Adjective";
         case WordObject.PartOfSpeechKind.Article: return "Article";
         case WordObject.PartOfSpeechKind.Pronoun: return "Pronoun";
         case WordObject.PartOfSpeechKind.Numeral: return "Numeral";
         case WordObject.PartOfSpeechKind.Adverb: return "Adverb";
         case WordObject.PartOfSpeechKind.Preposition: return "Preposition";
         case WordObject.PartOfSpeechKind.Conjunction: return "Conjunction";
         case WordObject.PartOfSpeechKind.Interjection: return "Interjection";
         default: return "Неизвестное";
     }
 }
示例#4
0
 private void button1_Click(object sender, EventArgs e)
 {
     string sError = "";
     textBox1.Text = textBox1.Text.Trim();
     textBox2.Text = textBox2.Text.Trim();
     if (textBox1.Text == "") sError += "Поле \"Слово\" должно быть заполнено!";
     if (textBox2.Text == "") sError += Environment.NewLine + "Поле \"Перевод\" должно быть заполнено!";
     if (comboBox1.SelectedItem == null) sError += Environment.NewLine + "Не указана часть речи!";
     if (sError != "") MessageBox.Show(sError.Trim(), "LinguaTest", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     else
     {
         if (this.Text == "Добавить слово")
         {
             _owner.dataGridView1.Rows.Add(Utils.FormalWord(textBox1.Text.Trim()), Utils.FormalWord(textBox2.Text.Trim()),
                 WordObject.GetPartOfSpeech(comboBox1.SelectedItem.ToString()));
             _owner.isSave = false;
             textBox1.Clear();
             textBox2.Clear();
             comboBox1.SelectedItem = null;
         }
         else
         {
             result = new WordObject(Utils.FormalWord(textBox1.Text.Trim()), Utils.FormalWord(textBox2.Text.Trim()),
                 WordObject.GetPartOfSpeech(comboBox1.SelectedItem.ToString()));
             this.Close();
         }
     }
 }
示例#5
0
 private void пройтиToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WordObject[] words = new WordObject[wordsTable.Rows.Count];
     for (int i = 0; i < wordsTable.Rows.Count; ++i) {
         DataGridViewCellCollection cc = wordsTable.Rows[i].Cells;
         words[i] = new WordObject(cc[0].Value as string, cc[1].Value as string,
             WordObject.GetPartOfSpeech(cc[2].Value as string));
     }
     TakeTestWindow tw = new TakeTestWindow(words);
     EnableControls(false);
     startLabel.Text = "Идёт прохождение теста...";
     UpdateStartLabel();
     tw.ShowDialog();
     EnableControls(true);
     startLabel.Text = "Для начала работы создайте новый тест или откройте существующий...";
     UpdateStartLabel();
 }
示例#6
0
        private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();
            d.Filter = "Файлы тестов LinguaTest (*.ltt)|*.ltt";

            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                string fStr = File.ReadAllText(d.FileName, Encoding.Default);
                string[] sWords = fStr.Trim().Split(new string[] { Environment.NewLine, "\r", "\n" }, StringSplitOptions.None);
                WordObject[] words = new WordObject[sWords.Length];
                wordsTable.Rows.Clear();
                for (int i = 0; i < sWords.Length; ++i) {
                    string[] parts = sWords[i].Split(new string[] { ":::" }, StringSplitOptions.None);
                    words[i] = new WordObject(parts[0], parts[1], WordObject.GetPartOfSpeech(parts[2]));
                    wordsTable.Rows.Add(words[i].Word, words[i].Translate,
                        WordObject.GetPartOfSpeechString(words[i].PartOfSpeech));
                }
                EnableControls(true);

                /* При прокрутке элементов таблицы стрелкой вниз
                проявляется баг в контроле DataGridView. Единственный известный мне
                фикс - изменение размера таблицы. */
                wordsTable.Width++;
                wordsTable.Width--;
            }
        }