Example #1
0
 private void RenderMsg(string msg)
 {
     PrintRBot();
     MessagesTextBox.AppendText(msg + "\r\n\r\n");
     MessagesTextBox.ScrollToCaret();             //позволяет прокрутить окно чата до конца
     QuestionTextBox.Clear();
 }
Example #2
0
 /// <summary>
 /// /// if vocab index changed reinit affected data (vocab,pic,sound,btns)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void VocabSelectBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (VocabSelectBox.Text == "Add...")
     {
         QuestionTextBox.Clear();
         AnswerTextBox.Clear();
         PicBox.Image = null;
         AddChangePictureBtn.Enabled = true;
         AddChangeSoundBtn.Enabled   = true;
         DeleteVocabBtn.Enabled      = false;
         NextSaveButton.Text         = "Save";
     }
     else
     {
         Vocab = (db.GetVocabs((GroupSelectBox.SelectedIndex + 1),
                               db.getuserid("admin")))[VocabSelectBox.SelectedIndex]; //load vocab
         QuestionTextBox.Text = Vocab.german;
         AnswerTextBox.Text   = Vocab.english;
         if (Vocab.picturepath != "")                                      //load picture
         {
             PicBox.Image             = Image.FromFile(Vocab.picturepath); //picbox load image
             PicBox.SizeMode          = PictureBoxSizeMode.Zoom;           //autosize
             AddChangePictureBtn.Text = "Change";
             DeletePictureBtn.Enabled = true;
         }
         else
         {
             PicBox.Image             = null;
             AddChangePictureBtn.Text = "Add";
             DeletePictureBtn.Enabled = false;
         }
         if (Vocab.soundpath != "")   //load sound
         {
             WMPLib.IWMPMedia media = WMPbox.newMedia(Vocab.soundpath);
             WMPbox.currentPlaylist.appendItem(media);
             AddChangeSoundBtn.Text = "Change";
             DeleteSoundBtn.Enabled = true;
         }
         else
         {
             WMPbox.close();                 //clear soundbox
             AddChangeSoundBtn.Text = "Add";
             DeleteSoundBtn.Enabled = false; //set btns
         }
         NextSaveButton.Text         = "Next";
         AddChangePictureBtn.Enabled = true;
         AddChangeSoundBtn.Enabled   = true;
         DeleteVocabBtn.Enabled      = true;
     }
     if (VocabSelectBox.SelectedIndex == 0)  //set to previous btn
     {
         PrevBtn.Enabled = false;
     }
     else
     {
         PrevBtn.Enabled = true;
     }
     toolStripStatusLabel1.Text = "";    //refresh tooltip
 }
 private void questionLabel_Click_1(object sender, EventArgs e)
 {
     QuestionTextBox.Visible = true;
     QuestionLabel.Visible   = false;
     answerPanel.Location    = new Point(0, 120);
     this.Height             = 120 + answerPanel.Height;
     ExamScorePanel.Location = new Point(520, (this.Height - ExamScorePanel.Height) / 2);
     DeleteButton.Location   = new Point(605, (this.Height - DeleteButton.Height) / 2);
     QuestionTextBox.Focus();
 }
 private void questionLabel_Click_1(object sender, EventArgs e)
 {
     QuestionTextBox.Visible = true;
     QuestionLabel.Visible   = false;
     addButton.Location      = new Point(420, 110);
     moveListItems(0);
     ExamScorePanel.Location = new Point(520, (this.Height - ExamScorePanel.Height) / 2);
     DeleteButton.Location   = new Point(605, (this.Height - DeleteButton.Height) / 2);
     QuestionTextBox.Focus();
 }
Example #5
0
 /**
  * Purpose: Clears all the boxes on the question form
  */
 private void ClearBoxes()
 {
     numTextBox.Clear();
     QuestionTextBox.Clear();
     questionPictureBox.InitialImage = null;
     opALabel.Text = "";
     opBLabel.Text = "";
     opCLabel.Text = "";
     opDLabel.Text = "";
     opELabel.Text = "";
 }
Example #6
0
 private void questionLabel_Click_1(object sender, EventArgs e)
 {
     this.Height             = QuestionTextBox.Height;
     oButton.Location        = new Point(460, 8);
     xButton.Location        = new Point(490, 8);
     ExamScorePanel.Location = new Point(520, 8);
     DeleteButton.Location   = new Point(605, 8);
     QuestionTextBox.Visible = true;
     QuestionLabel.Visible   = false;
     QuestionTextBox.Focus();
 }
Example #7
0
 /// <summary>
 /// Get next vocab or save new generated vocab to db (toogle "next"/"save" btn)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NextSaveButton_Click(object sender, EventArgs e)
 {
     if (NextSaveButton.Text == "Save")
     {
         //get filepaths if allrdy set
         string picturepath = Vocab.picturepath;
         string soundpath   = Vocab.soundpath;
         Vocab         = new Vocab();                                                                      //generate new Vocab
         Vocab.english = AnswerTextBox.Text;                                                               //read text box, set Vocab propertys
         Vocab.german  = QuestionTextBox.Text;
         db.SaveNewVocab(Vocab, GroupSelectBox.SelectedIndex + 1, picturepath, soundpath);                 //save to db
         toolStripStatusLabel1.Text = "Q: " + QuestionTextBox.Text + "A: " + AnswerTextBox.Text + "saved"; //settooltip
         VocabSelectBox.Items.Clear();                                                                     //clear vocablist
         foreach (Vocab German in db.GetVocabs((GroupSelectBox.SelectedIndex + 1), db.getuserid("admin"))) //reload vocablist
         {
             VocabSelectBox.Items.Add(German.german);
         }
         VocabSelectBox.Items.Add("Add...");                            //add last entry
         VocabSelectBox.SelectedIndex = VocabSelectBox.Items.Count - 2; //set index to last vocab
         NextSaveButton.Text          = "Next";
         AddChangePictureBtn.Enabled  = true;
         AddChangeSoundBtn.Enabled    = true;
     }
     else
     {
         if (VocabSelectBox.SelectedIndex + 1 < VocabSelectBox.Items.Count) //check if we have a next vocab
         {
             Vocab = (db.GetVocabs((GroupSelectBox.SelectedIndex + 1),
                                   db.getuserid("admin")))[VocabSelectBox.SelectedIndex]; //load next vocab in Textbox
             VocabSelectBox.SelectedIndex++;                                              //set VocabSelectBox
         }
         else //no next vocab
         {
             //clear text box
             QuestionTextBox.Clear();
             AnswerTextBox.Clear();
             //clear picturebox
             PicBox.Image = null;
             //set btns
             DeletePictureBtn.Enabled = false;
             AddChangePictureBtn.Text = "Add";
             NextSaveButton.Text      = "Save";
         }
     }
 }
Example #8
0
        //обработчик кнопки "Отправить"
        private void BtnSend_Click(object sender, EventArgs e)
        {
            if (QuestionTextBox.Text != "")
            {
                ShowUserMessage();

                CurrentUserMessage = QuestionTextBox.Text;
                ClearCurrentMessageFromSymbols();

                //обработка поиска в браузере
                if (CurrentUserMessage.Contains("что такое"))
                {
                    var stringToFind = CurrentUserMessage.Replace("что такое", "");

                    System.Diagnostics.Process.Start("https://yandex.ru/search/?text=" + stringToFind);

                    PrintRBot();
                    MessagesTextBox.AppendText("Открываю поиск по запросу \"" + stringToFind + "\"\r\n\r\n");

                    MessagesTextBox.ScrollToCaret(); //позволяет прокрутить окно чата до конца.
                    QuestionTextBox.Clear();

                    return;
                }

                //ищем сообщение пользователя в базе
                FindCurrentQuestionIndex();

                if (CurrentQuestionIndex == -1) //если не нашли - показываем ответ по умолчанию
                {
                    ShowDefaultAnswer();
                }
                else
                {
                    ShowAnswer();
                }
            }
            else
            {
                MessageBox.Show("Вы пытаетесь отправить пустое сообщение. Вам не ответят.");
            }

            MessagesTextBox.ScrollToCaret(); //позволяет прокрутить окно чата до конца.
            QuestionTextBox.Clear();
        }
 private void SetupTextBoxes()
 {
     AnswerTextBox.Clear();
     QuestionTextBox.Focus();
     AnswerTextBox.Focus();
 }