client/src/Iri.Modernisation.Data/Ldt/LDTElement.cs
changeset 38 bd33267300aa
parent 34 4d9ebc6fbbe8
child 39 0f2bde8fdfeb
equal deleted inserted replaced
37:beb938b4fb76 38:bd33267300aa
     8 using System.Windows.Media;
     8 using System.Windows.Media;
     9 using System.Windows.Media.Animation;
     9 using System.Windows.Media.Animation;
    10 using System.Windows.Shapes;
    10 using System.Windows.Shapes;
    11 using System.Collections.Generic;
    11 using System.Collections.Generic;
    12 using System.Xml.Linq;
    12 using System.Xml.Linq;
       
    13 using Iri.Modernisation.Data.Models;
    13 namespace Iri.Modernisation.Data.LDTClass
    14 namespace Iri.Modernisation.Data.LDTClass
    14 {
    15 {
    15     /// <summary>
    16     /// <summary>
    16     /// Balise Element
    17     /// Balise Element
    17     /// </summary>
    18     /// </summary>
    38         /// </summary>
    39         /// </summary>
    39         public DateTime Date { get; set; }
    40         public DateTime Date { get; set; }
    40         /// <summary>
    41         /// <summary>
    41         /// Attribut
    42         /// Attribut
    42         /// </summary>
    43         /// </summary>
    43         public int Color { get; set; }
    44         public double Color { get; set; }
    44         /// <summary>
    45         /// <summary>
    45         /// Attribut
    46         /// Attribut
    46         /// </summary>
    47         /// </summary>
    47         public String Src { get; set; }
    48         public String Src { get; set; }
    48         /// <summary>
    49         /// <summary>
    61         /// Elements
    62         /// Elements
    62         /// </summary>
    63         /// </summary>
    63         public List<String> Tags { get; set; }
    64         public List<String> Tags { get; set; }
    64 
    65 
    65         /// <summary>
    66         /// <summary>
       
    67         /// Attribute
       
    68         /// </summary>
       
    69         public int Type { get; set; }
       
    70 
       
    71         /// <summary>
    66         /// Elements
    72         /// Elements
    67         /// </summary>
    73         /// </summary>
    68         public String Video { get; set; }
    74         public String Video { get; set; }
       
    75 
       
    76         public LDTElement(Annotation annotation)
       
    77         {
       
    78             Id = annotation.Id;
       
    79             Title = annotation.Title;
       
    80             Abstract = annotation.Description;
       
    81             Begin = annotation.TimerIn.TotalMilliseconds;
       
    82             Dur = annotation.TimerOut.TotalMilliseconds - annotation.TimerIn.TotalMilliseconds;
       
    83             Tags = annotation.Tags;
       
    84             Date = DateTime.Now;
       
    85             Src = String.Empty;
       
    86             Author = String.Empty;
       
    87             Audio = String.Empty;
       
    88             Video = String.Empty;
       
    89         
       
    90             Color = double.Parse(annotation.Type.Color.A.ToString() + annotation.Type.Color.R.ToString() + annotation.Type.Color.G.ToString() + annotation.Type.Color.B.ToString());
       
    91             Type = 0;
       
    92             
       
    93         }
    69 
    94 
    70         public LDTElement(XElement e)
    95         public LDTElement(XElement e)
    71         {
    96         {
    72             Tags = new List<String>();
    97             Tags = new List<String>();
    73 
    98 
    74             Id = e.Attribute("id").Value;
    99             Id = e.Attribute("id").Value;
    75             Begin = Double.Parse(e.Attribute("begin").Value);
   100             Begin = Double.Parse(e.Attribute("begin").Value);
    76             Dur = Double.Parse(e.Attribute("dur").Value);
   101             Dur = Double.Parse(e.Attribute("dur").Value);
    77             Author = e.Attribute("author").Value;
   102             Author = e.Attribute("author").Value;
    78             Date = DateTime.Parse(e.Attribute("date").Value);
   103             Date = DateTime.Parse(e.Attribute("date").Value);
    79             Color = int.Parse(e.Attribute("color").Value);
   104             Color = double.Parse(e.Attribute("color").Value);
    80             Src = e.Attribute("src").Value;
   105             Src = e.Attribute("src").Value;
    81             Title = e.Element("title").Value;
   106             Title = e.Element("title").Value;
    82             Abstract = e.Element("abstract").Value;
   107             Abstract = e.Element("abstract").Value;
    83             Audio = e.Element("audio").Value;
   108             Audio = e.Element("audio").Value;
    84             if (e.Element("video")==null)
   109             if (e.Element("video")==null)
    87             }
   112             }
    88             else
   113             else
    89             {
   114             {
    90                 Video = e.Element("video").Value;
   115                 Video = e.Element("video").Value;
    91             }
   116             }
       
   117             if(e.Attribute("type")==null)
       
   118             {
       
   119                 Type = 0;
       
   120             }
       
   121             else
       
   122             {
       
   123                 Type = int.Parse(e.Attribute("type").Value);
       
   124             }
    92             foreach (XElement Str in e.Element("tags").Elements())
   125             foreach (XElement Str in e.Element("tags").Elements())
    93             {
   126             {
    94                 Tags.Add(Str.Value);
   127                 Tags.Add(Str.Value);
    95             }
   128             }
    96         }
   129         }
    97         public LDTElement()
   130         public LDTElement()
    98         {
   131         {
    99             Id = String.Empty;
   132             Id = System.Guid.NewGuid().ToString();
       
   133             Type = 0;
   100             Begin = 0;
   134             Begin = 0;
   101             Dur = 0;
   135             Dur = 0;
   102             Author = String.Empty;
   136             Author = String.Empty;
   103             Date = DateTime.Now;
   137             Date = DateTime.Now;
   104             Color = 0;
   138             Color = 0;
   120                     new XAttribute("dur",Dur),
   154                     new XAttribute("dur",Dur),
   121                     new XAttribute("author",Author),
   155                     new XAttribute("author",Author),
   122                     new XAttribute("date",Date.ToString("")),
   156                     new XAttribute("date",Date.ToString("")),
   123                     new XAttribute("color",Color),
   157                     new XAttribute("color",Color),
   124                     new XAttribute("src",Src),
   158                     new XAttribute("src",Src),
       
   159                     new XAttribute("type",Type.ToString()),
   125                     new XElement("title",Title),
   160                     new XElement("title",Title),
   126                     new XElement("abstract",Abstract),
   161                     new XElement("abstract",Abstract),
   127                     new XElement("audio",Audio),
   162                     new XElement("audio",Audio),
   128                     new XElement("video",Video)
   163                     new XElement("video",Video)
   129                     );
   164                     );