diff -r 000000000000 -r 249d70e7b32d client/src/Iri.Modernisation.Data/Ldt/LDTFile.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/Iri.Modernisation.Data/Ldt/LDTFile.cs Wed Nov 18 15:30:31 2009 +0100 @@ -0,0 +1,145 @@ +using System; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Shapes; +using System.Collections.Generic; +using System.Xml.Linq; +namespace Iri.Modernisation.Data.LDTClass +{ + /// + /// Fichier .ldt + /// + public class LDTFile + { + + public String Path { get; set; } + /// + /// Element + /// + public LDTProject Project { get; set; } + + /// + /// Elements + /// + public List Medias { get; set; } + + /// + /// Elements + /// + public List Annotations { get; set; } + + /// + /// Elements + /// + public List Displays { get; set; } + + + /// + /// Elements + /// + public List Edits { get; set; } + + public LDTFile() + { + Project = new LDTProject(); + Medias = new List(); + Annotations = new List(); + Displays = new List(); + Edits = new List(); + } + public void Load(String _path) + { + Path = _path; + Load(); + } + public void Load() + { + if(Path == String.Empty) + { + throw new Exception("Load Path Needed"); + } + XDocument xdoc = XDocument.Load(Path); + + Project = new LDTProject(xdoc.Root.Element("project")); + foreach (XElement Elem in xdoc.Root.Element("medias").Elements()) + { + Medias.Add(new LDTMedia(Elem)); + } + + foreach (XElement Elem in xdoc.Root.Element("annotations").Elements()) + { + Annotations.Add(new LDTAnnotationsContent(Elem)); + } + + foreach (XElement Elem in xdoc.Root.Element("displays").Elements()) + { + Displays.Add(new LDTDisplay(Elem)); + } + + foreach (XElement Elem in xdoc.Root.Element("edits").Elements()) + { + Edits.Add(new LDTEditing(Elem)); + } + } + public XDocument XMLFile + { + get + { + return new XDocument(XML); + + } + + } + public XElement XML + { + get + { + + XElement temp = new XElement("iri", + new XAttribute(XNamespace.Xmlns+"dc",@"http://dublincore.org/documents/dcmi-namespace/"), + Project.XML + ); + + // + XElement XMedias = new XElement("medias"); + foreach (LDTMedia media in Medias) + { + XMedias.Add(media.XML); + } + temp.Add(XMedias); + + // + XElement XAnnotations = new XElement("annotation"); + foreach (LDTAnnotationsContent annotation in Annotations) + { + XAnnotations.Add(annotation.XML); + } + temp.Add(XAnnotations); + + // + XElement XDisplays = new XElement("displays"); + foreach(LDTDisplay display in Displays) + { + XDisplays.Add(display.XML); + } + temp.Add(XDisplays); + + // + XElement XEdits = new XElement("edits"); + foreach (LDTEditing edit in Edits) + { + XEdits.Add(edit.XML); + } + temp.Add(XEdits); + return temp; + } + } + + } +}