First step of data saving in a ldt/xml file. First step of displaying the existing ldt files (not loaded yet)
authorcavaliet
Tue, 10 Nov 2009 13:47:58 +0100
changeset 191 8a25a85f2656
parent 190 619ca3ae13c7
child 192 11083c390ce4
First step of data saving in a ldt/xml file. First step of displaying the existing ldt files (not loaded yet)
src/FingersDance.Control.Screen/UserControlScreen.xaml.cs
src/FingersDance.Control.SessionInput/UserControlNewCuttingForm.xaml.cs
src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
src/FingersDance/MainSurfaceWindow.xaml.cs
--- a/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
+++ b/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Tue Nov 10 13:47:58 2009 +0100
@@ -41,7 +41,7 @@
                     //2-Ajout de la ListVideo au ControlScreen
                     this.AddToGrid(ListVideo);
                     //3-Creation des Events pour chaque item de la video
-                    ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(this.ListVideo_EH_ItemVideo_ContactDown);
+                    ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(ListVideo_EH_ItemVideo_ContactDown);
                 }
                 else
                     OpenProject();
@@ -105,7 +105,13 @@
             // Does nothing because for the moment we do not load sessions when we know the video path, we just create a new session
             try
             {
-                return new List<Project>();
+                List<Project> lp = new List<Project>();
+                foreach (String filename in Directory.GetFiles("./"))
+                {
+                    if (filename.Substring(filename.Length-4).ToLower()==".ldt")
+                        lp.Add(new Project(filename.Substring(2,filename.Length - 6), "", ""));
+                }
+                return lp;
             }
             catch (Exception) 
             {
@@ -153,7 +159,7 @@
                 //MainViewModel.Project.Alias = ((UserControlNewProjectForm)sender).Alias;
                 //MainViewModel.Project.Email = ((UserControlNewProjectForm)sender).Email;
                 _mainViewModel.Project.Description = ((UserControlNewProjectForm)sender).Description;
-                _mainViewModel.Project.Name = ((UserControlNewProjectForm)sender).SessionName;
+                _mainViewModel.Project.Name = ((UserControlNewProjectForm)sender).SessionName.Trim();
                 
                 
                 //2-Suppression UCSession Input
--- a/src/FingersDance.Control.SessionInput/UserControlNewCuttingForm.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
+++ b/src/FingersDance.Control.SessionInput/UserControlNewCuttingForm.xaml.cs	Tue Nov 10 13:47:58 2009 +0100
@@ -37,15 +37,14 @@
 
         private void SurfaceButtonSubmit_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
         {
-            Cutting = new Cutting(_User.Name, new List<Annotation>());   
+            Cutting = new Cutting(ST_CuttingName.Text.Trim(), new List<Annotation>());   
             if (EH_NewCuttingForm_ContactDown != null)
                 EH_NewCuttingForm_ContactDown(this, new EventArgs());
         }
 
         private void SurfaceButtonSubmit_Click(object sender, RoutedEventArgs e)
         {
-            //Project = new Project(ST_ProjectName.Text, ST_Date.Text, ST_Desc.Text, _User, new Cutting());
-            Cutting = new Cutting(_User.Name, new List<Annotation>());
+            Cutting = new Cutting(ST_CuttingName.Text.Trim(), new List<Annotation>());
             if (EH_NewCuttingForm_ContactDown != null)
                 EH_NewCuttingForm_ContactDown(this, new EventArgs());   
         }
--- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
+++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Tue Nov 10 13:47:58 2009 +0100
@@ -25,7 +25,6 @@
         public event EventHandler OnTagVisualisation; //Event to Mute all Players
         public int id = 0;
         public uint idcolor = 0;    //The color of the Pivot Button
-        //Project _Project = new Project();
         private Cutting cut;
 
         //variables for TagSound Control
@@ -44,14 +43,6 @@
         }
         #endregion
 
-        //#region Properties
-        //public Project Project
-        //{
-        //    get { return _Project; }
-        //    set { _Project = value; }
-        //}
-        //#endregion
-
         #region Constructors
         public UserControlUserPanel()
 		{
@@ -64,7 +55,6 @@
         {
             this.InitializeComponent();
             id = idPar;
-            //_Project = p;
             cut = cutPar;
             this.UserControlSyncSource.Load(path, col, cut);
             UserControlSyncSource.OnSuccessAnnotation+=new EventHandler(UserControlSyncSource_OnSuccessAnnotation);
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs	Mon Nov 09 12:11:42 2009 +0100
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs	Tue Nov 10 13:47:58 2009 +0100
@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Xml;
+using System.Xml.Linq;
 using System.Text;
 using System.Windows;
 using System.Windows.Controls;
@@ -401,8 +403,9 @@
         {
             try
             {
-                //1-Suppression du UC Screen
+                // We get UserControlScreen's instance and content
                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
+                // We remove the UserControlScreen's instance
                 root.Children.Remove(((UserControlScreen)sender));
                 
                 if (((UserControlScreen)sender).Cutting != null)
@@ -426,7 +429,7 @@
 
                     // We add the new cutting to the _mainviewmodel's datas
                     _mainviewmodel.Project.Cuttings.Add(newCutting);
-                    _mainviewmodel.Project.CuttingsDict.Add("User " + ((UserControlScreen)sender).id, newCutting);
+                    _mainviewmodel.Project.CuttingsDict.Add(newCutting.Title, newCutting);
 
                     // And now we build the new UserPanel
                     Random c = new Random();
@@ -531,7 +534,100 @@
                 Panel3.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
             if (Panel4 != null)
                 Panel4.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
+
+            // We save datas
+            saveDatas();
+
         }
+
+        //
+        // Enable to save datas in a xml file with LDT format
+        //
+        private void saveDatas()
+        {
+            //XDocument d = new XDocument(
+            //    new XComment("This is a comment."),
+            //    new XProcessingInstruction("xml-stylesheet",
+            //        "href='mystyle.css' title='Compact' type='text/css'"),
+            //    new XElement("Pubs",
+            //        new XElement("Book",
+            //            new XElement("Title", "Artifacts of Roman Civilization"),
+            //            new XElement("Author", "Moreno, Jordao")
+            //        ),
+            //        new XElement("Book",
+            //            new XElement("Title", "Midieval Tools and Implements"),
+            //            new XElement("Author", "Gazit, Inbar")
+            //        )
+            //    ),
+            //    new XComment("This is another comment.")
+            //);
+            //d.Declaration = new XDeclaration("1.0", "utf-8", "true");
+            //Console.WriteLine(d);
+
+            XDocument d = new XDocument(
+                new XElement("iri",
+                    new XElement("project",
+                        new XAttribute("id", "1"),
+                        new XAttribute("user", "IRI-Strate-EFREI"),
+                        new XAttribute("title", _mainviewmodel.Project.Name),
+                        new XAttribute("abstract", _mainviewmodel.Project.Description)
+                    ),
+                    new XElement("medias",
+                        new XElement("media",
+                            new XAttribute("id","for_oneflat"),
+                            new XAttribute("src","srcIri"),
+                            new XAttribute("video",""),
+                            new XAttribute("extra",""),
+                            new XAttribute("pict","")
+                        )
+                    ),
+                    new XElement("annotations",
+                        new XElement("content",
+                            new XAttribute("id", "for_oneflat"),
+                            new XAttribute("title", "Déc. personnels"),
+                            new XAttribute("author", "perso"),
+                            new XAttribute("abstract", "Ensemble de découpages définis par un utilisateur")
+                        )
+                    ),
+                    new XElement("displays"),
+                    new XElement("edits")
+                )
+            );
+            // We add each cutting
+            XElement annotContent = (XElement)(d.Root.Elements().ToList()[2]).FirstNode;
+            foreach (Cutting cut in _mainviewmodel.Project.Cuttings)
+            {
+                XElement cutNode = new XElement("decoupage", new XAttribute("id", "c_" + System.Guid.NewGuid()), new XAttribute("author", "perso"),
+                                                new XElement("title",cut.Title),
+                                                new XElement("abstract",""));
+                XElement cutElmts = new XElement("elements");
+                cutNode.Add(cutElmts);
+                foreach (Annotation annot in cut.AnnotList)
+                {
+                    cutElmts.Add(new XElement("element", new XAttribute("id", "s_" + System.Guid.NewGuid()),
+                                                         new XAttribute("begin", annot.TcBegin),
+                                                         new XAttribute("dur", annot.Dur),
+                                                         new XAttribute("author", cut.Title),
+                                                         new XAttribute("date", DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString()),
+                                                         new XAttribute("color", annot.Color),
+                                                         new XAttribute("src", ""),
+                                                         new XElement("title", annot.GestureType),
+                                                         new XElement("abstract"),
+                                                         new XElement("audio"),
+                                                         new XElement("tags"),
+                                                         new XElement("gestureType", annot.GestureType)));
+                }
+                annotContent.Add(cutNode);
+            }
+
+            d.Declaration = new XDeclaration("1.0", "utf-8", "true");
+            Console.WriteLine(d);
+
+            d.Save(_mainviewmodel.Project.Name + ".ldt");
+
+        }
+
+
         //On Tag Visualisation Mute all the other Players
         private void Panel_OnTagVisualisation(object sender, EventArgs e)
         {