コード例 #1
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
 }
コード例 #2
0
 /// <summary>
 /// delete sound from filesystem and db, set btns and reset picturebox
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DeleteSoundBtn_Click(object sender, EventArgs e)
 {
     toolStripStatusLabel1.Text = "Delete " + Vocab.soundpath; //set tooltip
     WMPbox.close();                                           //clear soundbox
     WMPbox.Dispose();
     if (!Utility.FileDelete(Vocab.soundpath))
     {
         MessageBox.Show("Unable to delete File (invalid path or file not found)!",
                         "Vocabulator", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     db.DeleteSound(Vocab);              //delete path from db
     Vocab.soundpath            = "";
     DeleteSoundBtn.Enabled     = false; //set btns
     AddChangeSoundBtn.Text     = "Add";
     toolStripStatusLabel1.Text = "";    //refresh tooltip
 }
コード例 #3
0
        /// <summary>
        /// fill window with data from db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TeacherForm_Load(object sender, EventArgs e)
        {
            Utility = new Util();   //io helper, filecopy function from Util.cs --> this maybe go online on server fileupload, for sync
            Vocab   = new Vocab();  //Vocab obj
            try
            {
                db = new Database();    //database init
            }
            catch
            {
                MessageBox.Show("Unable to load database.",
                                "Vocabulator", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            UnitSelectBox.Items.Clear();    //setup design specific, Lessons
            foreach (string unit in db.getunits())
            {
                UnitSelectBox.Items.Add(unit); //add from db
            }
            UnitSelectBox.Items.Add("Add..."); //add last entry
            UnitSelectBox.SelectedIndex = 0;   // set first entry
            GroupSelectBox.Items.Clear();      //Groups
            foreach (string group in db.getgroups(UnitSelectBox.SelectedIndex + 1))
            {
                GroupSelectBox.Items.Add(group); //add from db
            }
            VocabSelectBox.Items.Add("Add...");  //add last entry
            GroupSelectBox.SelectedIndex = 0;    // set to first entry
            VocabSelectBox.Items.Clear();        //Vocab
            foreach (Vocab German in db.GetVocabs((GroupSelectBox.SelectedIndex + 1), db.getuserid("admin")))
            {
                VocabSelectBox.Items.Add(German.german);                      //add from db
            }
            VocabSelectBox.Items.Add("Add...");                               //add last entry
            VocabSelectBox.SelectedIndex = 0;                                 //set to first entry
            Vocab = (db.GetVocabs((GroupSelectBox.SelectedIndex + 1),         //load Vocab
                                  db.getuserid("admin")))[VocabSelectBox.SelectedIndex];
            QuestionTextBox.Text = Vocab.german;                              //set Vocab atttib
            AnswerTextBox.Text   = Vocab.english;
            if (Vocab.picturepath != "")                                      //Picturebox init
            {
                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 != "") //Soundbox init, 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"; //set btns
                DeleteSoundBtn.Enabled = false;
            }
        }