src/FingersDance/MainSurfaceWindow.xaml.cs
changeset 191 8a25a85f2656
parent 190 619ca3ae13c7
child 192 11083c390ce4
equal deleted inserted replaced
190:619ca3ae13c7 191:8a25a85f2656
     1 using System;
     1 using System;
     2 using System.Collections.Generic;
     2 using System.Collections.Generic;
     3 using System.Linq;
     3 using System.Linq;
       
     4 using System.Xml;
       
     5 using System.Xml.Linq;
     4 using System.Text;
     6 using System.Text;
     5 using System.Windows;
     7 using System.Windows;
     6 using System.Windows.Controls;
     8 using System.Windows.Controls;
     7 using System.Windows.Data;
     9 using System.Windows.Data;
     8 using System.Windows.Documents;
    10 using System.Windows.Documents;
   399         //Button Submit du control SessionInput
   401         //Button Submit du control SessionInput
   400         private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e)
   402         private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e)
   401         {
   403         {
   402             try
   404             try
   403             {
   405             {
   404                 //1-Suppression du UC Screen
   406                 // We get UserControlScreen's instance and content
   405                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
   407                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
       
   408                 // We remove the UserControlScreen's instance
   406                 root.Children.Remove(((UserControlScreen)sender));
   409                 root.Children.Remove(((UserControlScreen)sender));
   407                 
   410                 
   408                 if (((UserControlScreen)sender).Cutting != null)
   411                 if (((UserControlScreen)sender).Cutting != null)
   409                 {
   412                 {
   410                     //2-Creation du User Panel
   413                     //2-Creation du User Panel
   424                         if (Panel4.Cutting.Title == newCutting.Title)
   427                         if (Panel4.Cutting.Title == newCutting.Title)
   425                             return;
   428                             return;
   426 
   429 
   427                     // We add the new cutting to the _mainviewmodel's datas
   430                     // We add the new cutting to the _mainviewmodel's datas
   428                     _mainviewmodel.Project.Cuttings.Add(newCutting);
   431                     _mainviewmodel.Project.Cuttings.Add(newCutting);
   429                     _mainviewmodel.Project.CuttingsDict.Add("User " + ((UserControlScreen)sender).id, newCutting);
   432                     _mainviewmodel.Project.CuttingsDict.Add(newCutting.Title, newCutting);
   430 
   433 
   431                     // And now we build the new UserPanel
   434                     // And now we build the new UserPanel
   432                     Random c = new Random();
   435                     Random c = new Random();
   433                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   436                     uint color = (uint)c.Next(12) + 1; // for the number to be >0
   434                     switch (((UserControlScreen)sender).id)
   437                     switch (((UserControlScreen)sender).id)
   529                 Panel2.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
   532                 Panel2.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
   530             if (Panel3 != null)
   533             if (Panel3 != null)
   531                 Panel3.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
   534                 Panel3.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
   532             if (Panel4 != null)
   535             if (Panel4 != null)
   533                 Panel4.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
   536                 Panel4.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
   534         }
   537 
       
   538             // We save datas
       
   539             saveDatas();
       
   540 
       
   541         }
       
   542 
       
   543         //
       
   544         // Enable to save datas in a xml file with LDT format
       
   545         //
       
   546         private void saveDatas()
       
   547         {
       
   548             //XDocument d = new XDocument(
       
   549             //    new XComment("This is a comment."),
       
   550             //    new XProcessingInstruction("xml-stylesheet",
       
   551             //        "href='mystyle.css' title='Compact' type='text/css'"),
       
   552             //    new XElement("Pubs",
       
   553             //        new XElement("Book",
       
   554             //            new XElement("Title", "Artifacts of Roman Civilization"),
       
   555             //            new XElement("Author", "Moreno, Jordao")
       
   556             //        ),
       
   557             //        new XElement("Book",
       
   558             //            new XElement("Title", "Midieval Tools and Implements"),
       
   559             //            new XElement("Author", "Gazit, Inbar")
       
   560             //        )
       
   561             //    ),
       
   562             //    new XComment("This is another comment.")
       
   563             //);
       
   564             //d.Declaration = new XDeclaration("1.0", "utf-8", "true");
       
   565             //Console.WriteLine(d);
       
   566 
       
   567             XDocument d = new XDocument(
       
   568                 new XElement("iri",
       
   569                     new XElement("project",
       
   570                         new XAttribute("id", "1"),
       
   571                         new XAttribute("user", "IRI-Strate-EFREI"),
       
   572                         new XAttribute("title", _mainviewmodel.Project.Name),
       
   573                         new XAttribute("abstract", _mainviewmodel.Project.Description)
       
   574                     ),
       
   575                     new XElement("medias",
       
   576                         new XElement("media",
       
   577                             new XAttribute("id","for_oneflat"),
       
   578                             new XAttribute("src","srcIri"),
       
   579                             new XAttribute("video",""),
       
   580                             new XAttribute("extra",""),
       
   581                             new XAttribute("pict","")
       
   582                         )
       
   583                     ),
       
   584                     new XElement("annotations",
       
   585                         new XElement("content",
       
   586                             new XAttribute("id", "for_oneflat"),
       
   587                             new XAttribute("title", "Déc. personnels"),
       
   588                             new XAttribute("author", "perso"),
       
   589                             new XAttribute("abstract", "Ensemble de découpages définis par un utilisateur")
       
   590                         )
       
   591                     ),
       
   592                     new XElement("displays"),
       
   593                     new XElement("edits")
       
   594                 )
       
   595             );
       
   596             // We add each cutting
       
   597             XElement annotContent = (XElement)(d.Root.Elements().ToList()[2]).FirstNode;
       
   598             foreach (Cutting cut in _mainviewmodel.Project.Cuttings)
       
   599             {
       
   600                 XElement cutNode = new XElement("decoupage", new XAttribute("id", "c_" + System.Guid.NewGuid()), new XAttribute("author", "perso"),
       
   601                                                 new XElement("title",cut.Title),
       
   602                                                 new XElement("abstract",""));
       
   603                 XElement cutElmts = new XElement("elements");
       
   604                 cutNode.Add(cutElmts);
       
   605                 foreach (Annotation annot in cut.AnnotList)
       
   606                 {
       
   607                     cutElmts.Add(new XElement("element", new XAttribute("id", "s_" + System.Guid.NewGuid()),
       
   608                                                          new XAttribute("begin", annot.TcBegin),
       
   609                                                          new XAttribute("dur", annot.Dur),
       
   610                                                          new XAttribute("author", cut.Title),
       
   611                                                          new XAttribute("date", DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString()),
       
   612                                                          new XAttribute("color", annot.Color),
       
   613                                                          new XAttribute("src", ""),
       
   614                                                          new XElement("title", annot.GestureType),
       
   615                                                          new XElement("abstract"),
       
   616                                                          new XElement("audio"),
       
   617                                                          new XElement("tags"),
       
   618                                                          new XElement("gestureType", annot.GestureType)));
       
   619                 }
       
   620                 annotContent.Add(cutNode);
       
   621             }
       
   622 
       
   623             d.Declaration = new XDeclaration("1.0", "utf-8", "true");
       
   624             Console.WriteLine(d);
       
   625 
       
   626             d.Save(_mainviewmodel.Project.Name + ".ldt");
       
   627 
       
   628         }
       
   629 
       
   630 
   535         //On Tag Visualisation Mute all the other Players
   631         //On Tag Visualisation Mute all the other Players
   536         private void Panel_OnTagVisualisation(object sender, EventArgs e)
   632         private void Panel_OnTagVisualisation(object sender, EventArgs e)
   537         {
   633         {
   538             UserControlUserPanel PanelMaster = (UserControlUserPanel)sender;
   634             UserControlUserPanel PanelMaster = (UserControlUserPanel)sender;
   539             if (Panel1 != null)
   635             if (Panel1 != null)