Fixed| bug si on ferme un livre en le lisant
ReFixed|faire fonctionner le seek, même quand play n'est pas activer
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;
using Iri.Modernisation.Data.Models;
namespace Iri.Modernisation.Data.LDTClass
{
/// <summary>
/// Fichier .ldt
/// </summary>
public class LDTFile
{
public String Path { get; set; }
/// <summary>
/// Element
/// </summary>
public LDTProject Project { get; set; }
/// <summary>
/// Elements
/// </summary>
public List<LDTMedia> Medias { get; set; }
/// <summary>
/// Elements
/// </summary>
public List<LDTAnnotationsContent> Annotations { get; set; }
/// <summary>
/// Elements
/// </summary>
public List<LDTDisplay> Displays { get; set; }
/// <summary>
/// Elements
/// </summary>
public List<LDTEditing> Edits { get; set; }
public List<LDTRelation> BasicRelations { get; set; }
public List<LDTRelation> PolemicRelations { get; set; }
public LDTFile()
{
Project = new LDTProject();
Medias = new List<LDTMedia>();
Annotations = new List<LDTAnnotationsContent>();
Displays = new List<LDTDisplay>();
Edits = new List<LDTEditing>();
BasicRelations = new List<LDTRelation>();
PolemicRelations = new List<LDTRelation>();
}
public void Load(String _path)
{
Path = _path;
// Load();
}
public void Load(XDocument xdoc)
{
/*if(Path == String.Empty)
{
throw new Exception("Load Path Needed");
}
= 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));
}
if(xdoc.Root.Element("basicRelations")!=null)
{
foreach (XElement Elem in xdoc.Root.Element("basicRelations").Elements())
{
BasicRelations.Add(new LDTRelation(Elem));
}
}
if (xdoc.Root.Element("polemicRelations") != null)
{
foreach (XElement Elem in xdoc.Root.Element("polemicRelations").Elements())
{
PolemicRelations.Add(new LDTRelation(Elem));
}
}
}
static public LDTFile FromXML(XDocument xdoc)
{
LDTFile returnFile = new LDTFile();
returnFile.Project = new LDTProject(xdoc.Root.Element("project"));
foreach (XElement Elem in xdoc.Root.Element("medias").Elements())
{
returnFile.Medias.Add(new LDTMedia(Elem));
}
foreach (XElement Elem in xdoc.Root.Element("annotations").Elements())
{
returnFile.Annotations.Add(new LDTAnnotationsContent(Elem));
}
foreach (XElement Elem in xdoc.Root.Element("displays").Elements())
{
returnFile.Displays.Add(new LDTDisplay(Elem));
}
foreach (XElement Elem in xdoc.Root.Element("edits").Elements())
{
returnFile.Edits.Add(new LDTEditing(Elem));
}
if (xdoc.Root.Element("basicRelations") != null)
{
foreach (XElement Elem in xdoc.Root.Element("basicRelations").Elements())
{
returnFile.BasicRelations.Add(new LDTRelation(Elem));
}
}
if (xdoc.Root.Element("polemicRelations") != null)
{
foreach (XElement Elem in xdoc.Root.Element("polemicRelations").Elements())
{
returnFile.PolemicRelations.Add(new LDTRelation(Elem));
}
}
return returnFile;
}
public XDocument XMLFile
{
get
{
return new XDocument(XML);
}
}
public override String ToString()
{
return XML.ToString();
}
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("annotations");
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);
//
XElement XBasicRelations = new XElement("basicRelations");
foreach (LDTRelation relation in BasicRelations)
{
XBasicRelations.Add(relation.XML);
}
temp.Add(XBasicRelations);
//
XElement XPolemicRelations = new XElement("polemicRelations");
foreach (LDTRelation relation in PolemicRelations)
{
XPolemicRelations.Add(relation.XML);
}
temp.Add(XPolemicRelations);
return temp;
}
}
}
}