diff -r 8a25a85f2656 -r 11083c390ce4 src/FingersDance/MainSurfaceWindow.xaml.cs --- a/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Nov 10 13:47:58 2009 +0100 +++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Thu Nov 12 16:15:19 2009 +0100 @@ -427,9 +427,12 @@ if (Panel4.Cutting.Title == newCutting.Title) return; - // We add the new cutting to the _mainviewmodel's datas - _mainviewmodel.Project.Cuttings.Add(newCutting); - _mainviewmodel.Project.CuttingsDict.Add(newCutting.Title, newCutting); + // We add the new cutting to the _mainviewmodel's datas IF THE CUTTING IS NEW (if not it means that it is from a loaded project) + if (!_mainviewmodel.Project.CuttingsDict.ContainsKey(newCutting.Title)) + { + _mainviewmodel.Project.Cuttings.Add(newCutting); + _mainviewmodel.Project.CuttingsDict.Add(newCutting.Title, newCutting); + } // And now we build the new UserPanel Random c = new Random(); @@ -545,25 +548,7 @@ // 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); - + // We build the xml to be saved, with the ldt format XDocument d = new XDocument( new XElement("iri", new XElement("project", @@ -597,19 +582,19 @@ 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"), + XElement cutNode = new XElement("decoupage", new XAttribute("id", cut.Id), 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()), + cutElmts.Add(new XElement("element", new XAttribute("id", annot.Id), 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("color", "0x" + annot.Color.ToString().Substring(3)), // Color.ToString() return #AARRGGBB and we keep only 0xRRGGBB new XAttribute("src", ""), new XElement("title", annot.GestureType), new XElement("abstract"), @@ -621,8 +606,7 @@ } d.Declaration = new XDeclaration("1.0", "utf-8", "true"); - Console.WriteLine(d); - + //Console.WriteLine(d); d.Save(_mainviewmodel.Project.Name + ".ldt"); }