public void OnParticipantKeyDown(object sender, ParticipantKey key) { if (_answers.ContainsKey(key.ParticipantNo) && _answers[key.ParticipantNo].QuestionChoice == null) { if (_question.Choices.Count >= key.AnswerNo) { var answer = _answers[key.ParticipantNo]; var choice = _question.Choices[key.AnswerNo - 1]; answer.QuestionChoice = choice; answer.CompetitionParticipant.Unanswered -= 1; if (choice.IsAnswer) { answer.Score = choice.Question.Score; answer.CompetitionParticipant.Score += answer.Score; answer.CompetitionParticipant.AnsweredCorrect += 1; } else { answer.CompetitionParticipant.AnsweredIncorrect += 1; } answer.TimeTaken = (DateTime.Now - _startTime).TotalSeconds; Answered?.Invoke(answer); ParticipantAnswer.Text += _answers.Values.Count(t => t.QuestionChoice != null) > 1 ? $" {key.ParticipantNo}号选手已回答" : $"{key.ParticipantNo}号选手已抢答"; } } }
protected virtual void OnAnswered(AnswerEventArgs e) { Answered?.Invoke(this, e); if (e.invalid) { Console.WriteLine("Invalid Answer"); Execute(); } }
private void SubmitButton_Click(object sender, EventArgs e) { RadioButton checkedButton; //Checks to see if the user has selected an answer if (AnswerRadioButton1.Checked == true) { checkedButton = AnswerRadioButton1; } else if (AnswerRadioButton2.Checked == true) { checkedButton = AnswerRadioButton2; } else if (AnswerRadioButton3.Checked == true) { checkedButton = AnswerRadioButton3; } else if (AnswerRadioButton4.Checked == true) { checkedButton = AnswerRadioButton4; } else { return; } //Answer selected is compared against the correct answer //A message is displayed telling the user their result and their result is returned if (checkedButton.Text == CurrentQuestion.CorrectAns) { MessageBox.Show("Correct", "Well Done", MessageBoxButtons.OK); Answered?.Invoke(this, true); } else { MessageBox.Show("Incorrect", "Try Again", MessageBoxButtons.OK); Answered?.Invoke(this, false); } this.Close(); //Form is closed }
protected void OnAnswered(string str) { Answered?.Invoke(this, str); }
protected virtual void OnAnswered() { Answered?.Invoke(this, EventArgs.Empty); }
protected internal virtual void OnAnswered(EventArgs <T> e) { Answered?.Invoke(this, e); }
private void SendAnswer(IMolfarAnswer answer) { Answered?.Invoke(this, answer); }
private void SendAnswer(string message) { Answered?.Invoke(this, new MolfarAnswer(message)); }
protected virtual void OnAnswered(iFruitContact sender) { Answered?.Invoke(this); }