示例#1
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == (Keys.F4 | Keys.Alt))
     {
         this.Close();
     }
     if ((keyData == Keys.Q) ||
         (keyData == Keys.W) ||
         (keyData == Keys.E) ||
         (keyData == Keys.R) ||
         (keyData == Keys.A) ||
         (keyData == Keys.S) ||
         (keyData == Keys.D) ||
         (keyData == Keys.F))
     {
         if (spellTextBox.Text == "")
         {
             spellTimer = new Stopwatch();
             spellTimer.Start();
         }
         handleSpell((char)keyData);
         displayElements();
     }
     if ((keyData == Keys.Return) || (keyData == Keys.Space) || (keyData == Keys.Back))
     {
         if (spellTextBox.Text != "")
         {
             spellTimer.Stop();
             if (Magick.AttemptMagick(spell, spellTextBox.Text.Count(), spellTimer.ElapsedMilliseconds))
             {
                 getMagick();
                 SoundManager.PlayCorrectSound();
                 magickPicture.Image = ImageLoader.correctSign;
             }
             else
             {
                 SoundManager.PlayWrongSound();
                 magickPicture.Image = ImageLoader.wrongSign;
             }
             spellTimer        = null;
             spellTextBox.Text = "";
             spell.Clear();
             displayElements();
             Thread ansThread = new Thread(hideAnswer);
             ansThread.Start();
         }
     }
     return(true);
 }
示例#2
0
 private void getMagick()
 {
     currentMagick = Magick.GetNextMagick();
     magickPicture.BackgroundImage = ImageLoader.magicksPictures[currentMagick];
 }