diff --git a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs index 76b747c..24a09ff 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/GestionFichiersSorties.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +using JeuHoy_WPF; +using System; +using System.Collections.Generic; +using System.IO; namespace JeuHoy_WPF_Natif.Model { @@ -10,12 +13,55 @@ namespace JeuHoy_WPF_Natif.Model public List ChargerCoordonnees(string fichier) { - throw new System.NotImplementedException(); - } + StreamReader lecteur = new StreamReader(fichier); + string sLigne = ""; + List lstSql = new List(); + string[] sTabElements = null; + + if (!lecteur.EndOfStream) { + sLigne = lecteur.ReadLine(); + int nbElements = Convert.ToInt32(sLigne); + + sLigne = lecteur.ReadLine(); + int nbAttributs = Convert.ToInt32(sLigne); + + for (int i = 0; i < nbElements; i++) { + double[] doubles = new double[nbElements - 1]; + sLigne = lecteur.ReadLine(); + sTabElements = sLigne.Split('\t'); + for (int j = 0; j < sTabElements.Length - 1; j++) { + doubles[j] = Convert.ToDouble(sTabElements[j]); + } + string rep = Convert.ToInt32(sTabElements[sTabElements.Length - 1]).ToString(); + lstSql.Add(new Squelette(doubles, rep)); + } + } + return lstSql; + } public int SauvegarderCoordonnees(string fichier, List lstData) { - throw new System.NotImplementedException(); + StreamWriter sw = new StreamWriter(fichier); + + sw.WriteLine(lstData.Count); + sw.WriteLine(CstApplication.SKELETONCOUNT); + + try { + foreach (Squelette s in lstData) { + foreach (double point in s.Points) { + sw.Write(point.ToString() + "\t"); + } + sw.Write(s.Reponse + "\r\n"); + } + } catch { + sw.Close(); + return CstApplication.ERREUR; + } + + 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 c6bed4a..bf80195 100644 --- a/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/Squelette.cs +++ b/JeuHoyEtudiants/JeuHoy_WPF_Natif/Model/Squelette.cs @@ -43,6 +43,11 @@ namespace JeuHoy_WPF_Natif.Model { _rep = reponse; } + public Squelette(double[] body, string reponse) { + _sque = body; + _rep = reponse; + } + private Point GetPoint(KinectSensor sensor, CameraSpacePoint position, Vector trans) { Point point = new System.Windows.Point(); @@ -57,7 +62,5 @@ namespace JeuHoy_WPF_Natif.Model { return Point.Subtract(point, trans); } - - } }