public void Help(object newDesign)
        {
            var numberOfDeletedTexts = 0;
            var controls             = ((Button)newDesign).Parent.Parent.Controls;

            for (var i = 0; i < controls.Count; i++)
            {
                if (controls[i] is Panel panel)
                {
                    foreach (Control c in panel.Controls)
                    {
                        if (!(c is Label label))
                        {
                            continue;
                        }
                        if (label.Name.Contains("answer") &&
                            !GUIGame.IsAnswerCorrect(label.Text) &&
                            numberOfDeletedTexts < 2)
                        {
                            label.Text = "";
                            numberOfDeletedTexts++;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void start_btn_Click(object sender, EventArgs e)
 {
     GUIGame.NewGame();
     VTForm.SetAnswersAndVocable();
     VTForm.ShowGameMenu();
     VTForm.SetPointLabel(0);
 }
 public void CodeAfterAnswerButtonPress(mfrm_VocTrainerForm form)
 {
     form.SetLabelColor();
     form.SetPointLabel(pointsInstance.Right);
     GUIGame.Next();
     form.SetAnswersAndVocable();
 }
Ejemplo n.º 4
0
 public static GUIGame GetInstance()
 {
     if (instance == null)
     {
         instance = new GUIGame();
         instance.NewRandom();
     }
     return(instance);
 }
Ejemplo n.º 5
0
        static void Main()
        {
            //GUIHandler.GetInstance();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new mfrm_VocTrainerForm());
            GUIGame game = GUIGame.GetInstance();

            Console.ReadLine();
        }
Ejemplo n.º 6
0
        public void GUIGameTestetObAntwortRichtigIst()
        {
            //Arrange
            GUIGame g = GUIGame.GetInstance();

            g.Solution = "korrekt";
            //Act & Assert
            Assert.IsTrue(GUIGame.IsAnswerCorrect("korrekt"));
            Assert.IsFalse(GUIGame.IsAnswerCorrect("falsch"));
        }
Ejemplo n.º 7
0
        public void SetAnswersAndVocable()
        {
            var instance = GUIGame.GetInstance();


            vgui_VocGui.lbl_answer1.Text   = instance.Answer1;
            vgui_VocGui.lbl_answer2.Text   = instance.Answer2;
            vgui_VocGui.lbl_answer3.Text   = instance.Answer3;
            vgui_VocGui.lbl_answer4.Text   = instance.Answer4;
            vgui_VocGui.vocable_label.Text = instance.Question;
        }
Ejemplo n.º 8
0
        public void GUIGameErstelltNeueAntworten()
        {
            //Arrange
            GUIGame g = GUIGame.GetInstance();

            g.Answer1 = "Anwort1";
            //Act
            GUIGame.Next();
            //Assert
            Assert.IsFalse(g.Answer1.Equals("Antwort1"));
        }
Ejemplo n.º 9
0
        public void QuestionGeneratorPrueftAntwortMoeglichkeitenAufDubletten()
        {
            //Arrange
            GUIGame gg = GUIGame.GetInstance();

            gg.Answer1 = "Antwort1";
            gg.Answer2 = "Antwort2";
            gg.Answer3 = "Antwort3";
            gg.Answer4 = "Antwort4";
            //Act
            bool istdoppelt = QuestionGenerator.CheckOnDouble("Antwort1");

            //Assert
            Assert.IsTrue(istdoppelt);
        }
Ejemplo n.º 10
0
        public void AnswerClick(Label label, VocableGui gui)
        {
            var controls = label?.Parent?.Parent?.Controls;

            if (controls == null)
            {
                throw new ArgumentException(nameof(label));
            }

            var answerLabels = controls
                               .Cast <Control>()
                               .Where(e => e is Panel panel && panel.Name.Equals("pnl_Antworten"))
                               .Cast <Panel>()
                               .SelectMany(e => e.Controls.Cast <Control>())
                               .Where(e => e is Label answerLabel && answerLabel.Name.Contains("answer"))
                               .ToList();

            var correctLabels = answerLabels
                                .Where(e => GUIGame.IsAnswerCorrect(e.Text))
                                .ToList();

            if (correctLabels.Count != 1)
            {
                throw new Exception("Only one answer can be correct");
            }

            if (correctLabels.Any(e => e == label))
            {
                pointsInstance.AnswerIsRight();
            }

            var correctLabel = correctLabels.FirstOrDefault();

            if (correctLabel != null)
            {
                correctLabel.ForeColor = Color.Green;
            }

            var incorrectLabels = answerLabels
                                  .Where(e => !correctLabels.Contains(e));

            foreach (var answerLabel in incorrectLabels)
            {
                answerLabel.ForeColor = Color.Red;
            }
            gui.timer.Interval = 950;
            gui.timer.Start();
        }
Ejemplo n.º 11
0
 public void Skip(mfrm_VocTrainerForm form)
 {
     GUIGame.Next();
     form.SetAnswersAndVocable();
 }