private void btnNewAnswer_Click(object sender, EventArgs e)
        {
            var answer = new AnswerEntity(_currentConfiguration);
            answer.Id = _currentConfiguration.GetNextAnswerId();
            var EditView = new AnswerView(answer);
            var dialogResult = EditView.ShowDialog();
            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                var slide = _currentConfiguration.SlideAssociated;
                var top = _currentConfiguration.TopLastQuestion;

                if (!_currentConfiguration.IsNew)
                {
                    int index;
                    var ansObj = PowerPointHelper.CreateTextboxOn(slide, 50, top, 600, 35,
                                                answer.TextToShow, 24,
                                                Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft, out index);
                    answer.AnswerTextBox = ansObj;
                    answer.AnswerTextBoxIndex = index;
                }

                _currentConfiguration.TopLastQuestion += 50;
                grdQuestions.DataSource = null;
                _currentConfiguration.Answers.Add(answer);
                grdQuestions.DataSource = _currentConfiguration.Answers;
            }
        }
 private void DecrementId(AnswerEntity answer, int refId)
 {
     if (answer.Id > refId)
         answer.Id--;
 }
        internal List<Hardware.VotesFlat> GetVotesFromCorrectAnswer(out AnswerEntity correctAnswer)
        {
            correctAnswer = this.Answers.OrderByDescending(x => x.Points).FirstOrDefault();
            if (correctAnswer == null)
                return new List<Hardware.VotesFlat>();

            return correctAnswer.Votes;
        }
        internal void DeleteAnswer(AnswerEntity answer)
        {
            if (answer.AnswerTextBox != null)
                answer.AnswerTextBox.Delete();

            Answers.ForEach(x => DecrementId(x, answer.Id));

            Answers.Remove(answer);
        }
Esempio n. 5
0
 public AnswerView(AnswerEntity answer)
 {
     _currentAnswer = answer;
     InitializeComponent();
     InitAnswer();
 }
        internal double GetCoincidencesFor(AnswerEntity toCompare)
        {
            double count = 0;

            foreach (var local in this.Votes)
            {
                foreach (var item in toCompare.Votes)
                {
                    if (local.KeyId == item.KeyId)
                        count += 1;
                }
            }

            return count;
        }