private void CleanCase(int CordX, int CordY)
        {
            CaseNormal newCase = App.MainVM.Terrain.Cases[CordX, CordY].AdapteurNormal();

            newCase.Fourmis.Clear();
            App.MainVM.Terrain.Cases[CordX, CordY] = newCase;
        }
        private void OuvrirFichier()
        {
            App.MainVM.stop();
            while (App.MainVM.Runnin)
            {
            }

            OpenFileDialog OFDialog = new OpenFileDialog();

            OFDialog.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
            OFDialog.DefaultExt       = "xml";
            OFDialog.Filter           = "XML Files|*.xml|All Files|*.*";
            OFDialog.FilterIndex      = 1;
            if (OFDialog.ShowDialog() == true && OFDialog.FileName.Length > 0)
            {
                // CHARGER LE FICHIER ET VERIFIER SA VALIDITE
                XmlDocument Chargement = new XmlDocument();
                Chargement.Load(OFDialog.FileName);
                XmlNode MainVMXML;
                if ((MainVMXML = Chargement.SelectSingleNode("MainVM")) == null)
                {
                    System.Media.SystemSounds.Beep.Play();
                    MessageBox.Show("Fichier incompatible !", "Chargement", MessageBoxButton.OK);
                    return;
                }

                // RECUPERER DATA DE MAINVM
                int    Dim = int.Parse(MainVMXML.SelectSingleNode("Dim").InnerText);
                String TitreApplication = MainVMXML.SelectSingleNode("TitreApplication").InnerText;
                int    VitesseExec      = int.Parse(MainVMXML.SelectSingleNode("VitesseExec").InnerText);
                bool   Runnin           = bool.Parse(MainVMXML.SelectSingleNode("Runnin").InnerText);

                Terrain Terrain = new Terrain(Dim);

                // RECUPERER DATA DE TERRAIN
                XmlNode TerrainXML     = MainVMXML.SelectSingleNode("Terrain");
                int     NbToursTerrain = int.Parse(TerrainXML.SelectSingleNode("NbTours").InnerText);
                XmlNode CasesXML       = TerrainXML.SelectSingleNode("Cases");
                foreach (XmlNode CaseXML in CasesXML.SelectNodes("Case"))
                {
                    CaseAbstrait Case;
                    String       CaseClass           = CaseXML.SelectSingleNode("Class").InnerText;
                    int          CordX               = int.Parse(CaseXML.SelectSingleNode("CordX").InnerText);
                    int          CordY               = int.Parse(CaseXML.SelectSingleNode("CordY").InnerText);
                    int          PheromoneMaison     = int.Parse(CaseXML.SelectSingleNode("PheromoneMaison").InnerText);
                    int          PheromoneNourriture = int.Parse(CaseXML.SelectSingleNode("PheromoneNourriture").InnerText);
                    int          NbToursCase         = int.Parse(CaseXML.SelectSingleNode("NbTours").InnerText);

                    if (CaseClass == "CaseNourriture")
                    {
                        Case = new CaseNourriture(Terrain, CordX, CordY);
                        int        NourriturePoids = int.Parse(CaseXML.SelectSingleNode("Nourriture/Poids").InnerText);
                        Nourriture Nourriture      = new Nourriture(Case, NourriturePoids);
                        ((CaseNourriture)Case).Nourriture = Nourriture;
                    }
                    else if (CaseClass == "CaseFourmiliere")
                    {
                        Case = new CaseFourmiliere(Terrain, CordX, CordY);
                        int         NombreNourritures      = int.Parse(CaseXML.SelectSingleNode("Fourmiliere/NombreNourritures").InnerText);
                        int         NombreToursFourmiliere = int.Parse(CaseXML.SelectSingleNode("Fourmiliere/NombreTours").InnerText);
                        Fourmiliere Fourmiliere            = new Fourmiliere(Case, 0);
                        Fourmiliere.NombreNourritures       = NombreNourritures;
                        Fourmiliere.NombreTours             = NombreToursFourmiliere;
                        ((CaseFourmiliere)Case).Fourmiliere = Fourmiliere;
                    }
                    else if (CaseClass == "CaseNormal")
                    {
                        Case = new CaseNormal(Terrain, CordX, CordY);
                    }
                    else
                    {
                        System.Media.SystemSounds.Beep.Play();
                        MessageBox.Show("Erreur au chargement", "Chargement", MessageBoxButton.OK);
                        return;
                    }
                    Case.PheromoneMaison     = PheromoneMaison;
                    Case.PheromoneNourriture = PheromoneNourriture;
                    Case.NbTours             = NbToursCase;

                    XmlNode FourmisXML = CaseXML.SelectSingleNode("Fourmis");
                    foreach (XmlNode FourmiXML in FourmisXML.SelectNodes("Fourmi"))
                    {
                        int    Vie             = int.Parse(FourmiXML.SelectSingleNode("Vie").InnerText);
                        String StrategieFourmi = FourmiXML.SelectSingleNode("StrategieFourmi").InnerText;
                        Fourmi Fourmi          = new Fourmi(Case);
                        Fourmi.Vie = Vie;
                        if (StrategieFourmi == "StrategieRetourMaison")
                        {
                            Fourmi.StrategieFourmi = new StrategieRetourMaison();
                        }
                        Case.Fourmis.Add(Fourmi);
                    }
                    Terrain.Cases[Case.CordX, Case.CordY] = Case;
                }
                Terrain.NbTours = NbToursTerrain;

                XmlNode StatistiqueXML         = MainVMXML.SelectSingleNode("Statistique");
                int     NombreFourmis          = int.Parse(StatistiqueXML.SelectSingleNode("NombreFourmis").InnerText);
                int     NombreToursStatistique = int.Parse(StatistiqueXML.SelectSingleNode("NombreTours").InnerText);

                Statistique Statistique = new Statistique(Terrain);
                Statistique.NombreFourmis = NombreFourmis;
                Statistique.NombreTours   = NombreToursStatistique;

                App.MainVM.Dim              = Dim;
                App.MainVM.Terrain          = Terrain;
                App.MainVM.TitreApplication = TitreApplication;
                App.MainVM.VitesseExec      = VitesseExec;
                App.MainVM.Statistique      = Statistique;
                DessinePlateau();
                System.Media.SystemSounds.Beep.Play();
                MessageBox.Show("Fichier Chargé !", "Chargement", MessageBoxButton.OK);
            }
        }