Example #1
0
        private void QuestionSuivante()
        {
            // On retire les données de la question précédente
            ReponsesCLB.Items.Clear();
            if (QuestionEnCours != null && QuestionEnCours.Image != null)
            {
                ImageStream.Close();
                ImagePB.Image = null;
            }

            if (NoQuestion == NumeroQuestionDijkstra)
            {
                Dijkstra dijkstra = new Dijkstra();
                if (dijkstra.ShowDialog() == DialogResult.OK)
                {
                    NoQuestionLb.Text = $"Question {++NoQuestion} sur {NbQuestions + 1}";
                    BonnesReponses   += dijkstra.Score;
                    UpdateScore();
                }
                NoQuestion++;
            }

            // On affiche la question suivante
            QuestionEnCours   = Questions.Dequeue();
            NoQuestionLb.Text = $"Question {++NoQuestion} sur {NbQuestions + 1}";
            ConsigneLb.Text   = QuestionEnCours.Consigne;
            ReponsesCLB.Items.AddRange(QuestionEnCours.Reponses.ToArray());
            CodeLb.Text = QuestionEnCours.Code;

            if (QuestionEnCours.Image != null)
            {
                ImageStream = new MemoryStream(QuestionEnCours.Image);
                Image       = new Bitmap(ImageStream);
                float scaleHeight = ImagePB.Height / (float)Image.Height;
                float scaleWidth  = ImagePB.Width / (float)Image.Width;
                float scale       = Math.Min(scaleHeight, scaleWidth);

                ImagePB.Image = new Bitmap(Image, (int)(Image.Width * scale), (int)(Image.Height * scale));
            }
        }