Example #1
0
        private void btnValideEtape_Click(object sender, EventArgs e)
        {
            numinitial = Convert.ToInt32(textBox1.Text);
            numfinal   = Convert.ToInt32(textBox2.Text);
            lbFerme.Items.Add(txtBFerme.Text);
            lbOuvert.Items.Add(txtBOuvert.Text);
            justeOuPas = new List <bool>();
            SearchTree validation = new SearchTree();
            Node2      N0         = new Node2();

            N0.numero = numinitial;

            // On vérifie si les ouverts et les fermés donnés sont bien les mêmes à l'étape donné
            if (validation.RechercheSolutionAEtoileValidation(N0, etapeCorrection, txtBOuvert.Text, txtBFerme.Text))
            {
                justeOuPas.Add(true);
            }
            else
            {
                justeOuPas.Add(false);
                justeEnsembles = false;
            }
            // à définir !!!
            //verification();

            /*
             * si verification donne que le resultat est juste : justeoupas.append(true) sinon justeoupas.append(false);
             */
            etapeCorrection++;    //existe pour donner au correcteur le moyen de savoir à quelle ligne il doit comparer.
            txtBFerme.Text  = ""; // On nettoie la zone de travail
            txtBOuvert.Text = "";
        }
Example #2
0
        private void treeViewVide_Click(object sender, EventArgs e)
        {
            //Créer et afficher un treeView vide qui est répondu à A* :
            SearchTree gVide  = new SearchTree();
            Node2      N0Vide = new Node2();

            N0Vide.numero = numinitial;
            // Recherche du meilleur chemin à partir de ce noeud initial et final :
            List <GenericNode> solutionVide = gVide.RechercheSolutionAEtoile(N0Vide);

            gVide.GetSearchTreeVide(treeView_toComplete2);

            verifTree_btn.Show();
            treeViewVide_btn.Hide();
        }
Example #3
0
        //Vérifie les fermés et ouverts de l'utilisateur et affiche correction si nécessaire
        private void valider_btn_Click(object sender, EventArgs e)
        {
            SearchTree g  = new SearchTree();
            Node2      N0 = new Node2();

            N0.numero = numinitial;
            // Recherche du meilleur chemin à partir de ce noeud initial et final :
            List <GenericNode> solution = g.RechercheSolutionAEtoile(N0);

            string fermesUser  = F_txtBox.Text;
            string ouvertsUser = O_txtBox.Text;
            bool   correct;

            //Comparer la liste des fermés du user avec celui qui est correct :
            correct = VérifListe(g.ListeFermes, fermesUser, nbValider);
            if (correct == true)
            {
                F_txtBox.ForeColor = Color.Green;
                correctionFermes_lbl.Hide();
            }
            else
            {
                F_txtBox.ForeColor = Color.Red;
                correctionFermes_lbl.Show();
                correctionFermes_lbl.Text      = g.ListeFermes[nbValider];
                correctionFermes_lbl.ForeColor = Color.Green;
                Erreur = true;
            }
            //Comparer la liste des ouverts du user avec celui qui est correct :
            correct = VérifListe(g.ListeOuverts, ouvertsUser, nbValider);
            if (correct == true)
            {
                O_txtBox.ForeColor = Color.Green;
                correctionOuverts_lbl.Hide();
            }
            else
            {
                O_txtBox.ForeColor = Color.Red;
                correctionOuverts_lbl.Show();
                correctionOuverts_lbl.Text      = g.ListeOuverts[nbValider];
                correctionOuverts_lbl.ForeColor = Color.Green;
                Erreur = true;
            }

            nbValider++;
            valider_btn.Hide();
            suivant_btn.Show();
        }
Example #4
0
        //Affichage automatique des solutions correctes dans le txtBox à la prochaine étape :
        private void suivant_btn_Click(object sender, EventArgs e)
        {
            SearchTree g  = new SearchTree();
            Node2      N0 = new Node2();

            N0.numero = numinitial;
            // Recherche du meilleur chemin à partir de ce noeud initial et final :
            List <GenericNode> solution = g.RechercheSolutionAEtoile(N0);

            if ((F_txtBox.ForeColor == Color.Red) || (F_txtBox.Text == ""))
            {
                F_txtBox.Text = correctionFermes_lbl.Text;
            }
            F_txtBox.ForeColor = Color.Black;

            if ((O_txtBox.ForeColor == Color.Red) || (O_txtBox.Text == ""))
            {
                O_txtBox.Text = correctionOuverts_lbl.Text;
            }
            O_txtBox.ForeColor = Color.Black;

            //Gestion des boutons :
            if (nbValider == g.etapeDij)
            {
                correctionFermes_lbl.Hide();
                correctionOuverts_lbl.Hide();
                suivant_btn.Hide();
                valider_btn.Hide();
                treeViewFinal_btn.Show();
            }
            else
            {
                correctionFermes_lbl.Hide();
                correctionOuverts_lbl.Hide();
                suivant_btn.Hide();
                valider_btn.Show();
            }
            if (Erreur == true)
            {
                Note1 = 0;
            }
            else
            {
                Note1 = 2;
            }
        }
Example #5
0
        //Calcul et affichage de l'arbre avec le meilleur chemin (bouton TreeView final) :
        private void treeViewFinal_btn_Click(object sender, EventArgs e)
        {
            SearchTree g  = new SearchTree();
            Node2      N0 = new Node2();

            N0.numero = numinitial;
            // Recherche du meilleur chemin à partir de ce noeud initial et final :
            List <GenericNode> solution = g.RechercheSolutionAEtoile(N0);

            //Affichage de ce meilleur chemin dans listBox1
            Node2 N1 = N0;

            for (int i = 1; i < solution.Count; i++)
            {
                Node2 N2 = (Node2)solution[i];
                listBox1.Items.Add(Convert.ToString(N1.numero)
                                   + "--->" + Convert.ToString(N2.numero)
                                   + "   : " + Convert.ToString(matrice[N1.numero, N2.numero]));
                N1 = N2;
            }
            g.GetSearchTree(treeView1);
        }
Example #6
0
        private void btnCorrection_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            numinitial = Convert.ToInt32(textBox1.Text);
            numfinal   = Convert.ToInt32(textBox2.Text);
            SearchTree g  = new SearchTree();
            Node2      N0 = new Node2();

            N0.numero = numinitial;
            List <GenericNode> solution = g.RechercheSolutionAEtoile(N0);
            Node2 N1 = N0;

            for (int i = 1; i < solution.Count; i++)
            {
                Node2 N2 = (Node2)solution[i];
                listBox1.Items.Add(Convert.ToString(N1.numero)
                                   + "--->" + Convert.ToString(N2.numero)
                                   + "   : " + Convert.ToString(matrice[N1.numero, N2.numero]));
                N1 = N2;
            }
            g.GetSearchTree(treeView1);

            CompareTreeNodes(trvTravail, treeView1);
        }