diff --git a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs index 24a09ff..c34288a 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs @@ -3,19 +3,14 @@ using System; using System.Collections.Generic; using System.IO; -namespace JeuHoy_WPF_Natif.Model -{ - public class GestionFichiersSorties : IGestionFichiers - { - public GestionFichiersSorties() - { - } +namespace JeuHoy_WPF_Natif.Model { + public class GestionFichiersSorties : IGestionFichiers { + public GestionFichiersSorties(){} - public List ChargerCoordonnees(string fichier) - { + public List ChargerCoordonnees(string fichier) { StreamReader lecteur = new StreamReader(fichier); - string sLigne = ""; List lstSql = new List(); + string sLigne = ""; string[] sTabElements = null; if (!lecteur.EndOfStream) { @@ -39,14 +34,16 @@ namespace JeuHoy_WPF_Natif.Model return lstSql; } - public int SauvegarderCoordonnees(string fichier, List lstData) - { - StreamWriter sw = new StreamWriter(fichier); - - sw.WriteLine(lstData.Count); - sw.WriteLine(CstApplication.SKELETONCOUNT); - + public int SauvegarderCoordonnees(string fichier, List lstData) { + StreamWriter sw = null; try { + sw = new StreamWriter(fichier); + } catch { + return CstApplication.ERREUR; + } + try { + sw.WriteLine(lstData.Count); + sw.WriteLine(CstApplication.SKELETONCOUNT); foreach (Squelette s in lstData) { foreach (double point in s.Points) { sw.Write(point.ToString() + "\t"); @@ -61,7 +58,6 @@ namespace JeuHoy_WPF_Natif.Model sw.Flush(); sw.Close(); return CstApplication.OK; - } } } \ No newline at end of file diff --git a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/Squelette.cs b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/Squelette.cs index 94d45e8..e593c23 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/Squelette.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/Squelette.cs @@ -22,7 +22,7 @@ namespace JeuHoy_WPF_Natif.Model { JointType.Neck }; - private double[] _sque = new double[CstApplication.SKELETONCOUNT * 2]; + private double[] _sque; private string _rep = "?"; public string Reponse { get => _rep; set => _rep = value; } @@ -30,8 +30,12 @@ namespace JeuHoy_WPF_Natif.Model { public double[] Points => _sque; public Squelette(double[] body, string reponse) { - _sque = body; - _rep = reponse; + if (body.Length != CstApplication.SKELETONCOUNT * 2) { + _sque = new double[CstApplication.SKELETONCOUNT * 2]; + } else { + _sque = body; + _rep = reponse; + } } } }