|
34
|
1 |
using System; |
|
|
2 |
using System.Net; |
|
|
3 |
using System.Windows; |
|
|
4 |
using System.Windows.Controls; |
|
|
5 |
using System.Windows.Documents; |
|
|
6 |
using System.Windows.Ink; |
|
|
7 |
using System.Windows.Input; |
|
|
8 |
using System.Windows.Media; |
|
|
9 |
using System.Windows.Media.Animation; |
|
|
10 |
using System.Windows.Shapes; |
|
35
|
11 |
using System.Xml.Linq; |
|
|
12 |
using System.Collections.Generic; |
|
|
13 |
namespace Iri.Modernisation.Data.LDTClass |
|
34
|
14 |
{ |
|
|
15 |
public class IRIElement |
|
|
16 |
{ |
|
35
|
17 |
//<element id="elD_0" order="" prev="" next="" begin="0" dur="933" author="DDC - IRI" date="06/2006" title="plan 0" abstract="" src="testauthor_testtitle/thumbs/0_in.jpg"/> |
|
34
|
18 |
|
|
35
|
19 |
public String Id { get; set; } |
|
38
|
20 |
|
|
35
|
21 |
public DateTime Date { get; set; } |
|
|
22 |
public int Chapter { get; set; } |
|
38
|
23 |
|
|
35
|
24 |
public TimeSpan Begin { get; set; } |
|
|
25 |
public TimeSpan Dur { get; set; } |
|
|
26 |
public String Author { get; set; } |
|
|
27 |
public String Title { get; set; } |
|
|
28 |
public String Abstract { get; set; } |
|
|
29 |
public String Src { get; set; } |
|
|
30 |
public List<String> Tags { get; set; } |
|
|
31 |
|
|
|
32 |
public IRIElement() |
|
|
33 |
{ |
|
38
|
34 |
Id = System.Guid.NewGuid().ToString(); |
|
|
35 |
|
|
35
|
36 |
Chapter = 0; |
|
38
|
37 |
|
|
35
|
38 |
Begin = TimeSpan.Zero; |
|
|
39 |
Dur = TimeSpan.Zero; |
|
|
40 |
Author = String.Empty; |
|
|
41 |
Title = String.Empty; |
|
|
42 |
Abstract = String.Empty; |
|
|
43 |
Src = String.Empty; |
|
|
44 |
Tags = new List<string>(); |
|
|
45 |
} |
|
|
46 |
public IRIElement(XElement elem) |
|
|
47 |
{ |
|
38
|
48 |
|
|
35
|
49 |
Id = elem.Attribute("id").Value; |
|
38
|
50 |
|
|
35
|
51 |
Begin = TimeSpan.FromMilliseconds(double.Parse(elem.Attribute("begin").Value)); |
|
|
52 |
Dur = TimeSpan.FromMilliseconds(double.Parse(elem.Attribute("dur").Value)); |
|
|
53 |
Author = elem.Attribute("author").Value; |
|
38
|
54 |
Title = elem.Element("title").Value; |
|
|
55 |
Abstract = elem.Element("abstract").Value; |
|
35
|
56 |
Src = elem.Attribute("src").Value; |
|
|
57 |
if(elem.Element("tags")!=null) |
|
|
58 |
{ |
|
38
|
59 |
Tags = new List<string>(); |
|
35
|
60 |
foreach (XElement XTag in elem.Element("tags").Elements()) |
|
|
61 |
{ |
|
|
62 |
Tags.Add(XTag.Value); |
|
|
63 |
} |
|
|
64 |
} |
|
|
65 |
if(elem.Element("chapter")!=null) |
|
|
66 |
{ |
|
|
67 |
Chapter = int.Parse(elem.Element("chapter").Value); |
|
|
68 |
} |
|
|
69 |
if (elem.Element("date") != null) |
|
|
70 |
{ |
|
|
71 |
Date = DateTime.Parse(elem.Element("date").Value); |
|
|
72 |
} |
|
|
73 |
else |
|
|
74 |
{ |
|
|
75 |
Date = DateTime.Now; |
|
|
76 |
} |
|
|
77 |
} |
|
|
78 |
public XElement XML |
|
|
79 |
{ |
|
|
80 |
get |
|
|
81 |
{ |
|
|
82 |
XElement temp = new XElement("element", |
|
|
83 |
new XAttribute("id",Id), |
|
|
84 |
new XAttribute("date",Date.ToString("dd/MM/yyyy")), |
|
|
85 |
new XAttribute("chapter",Chapter), |
|
38
|
86 |
|
|
35
|
87 |
new XAttribute("begin",Begin.TotalMilliseconds), |
|
|
88 |
new XAttribute("dur",Dur.TotalMilliseconds), |
|
|
89 |
new XAttribute("author",Author), |
|
|
90 |
new XElement("title",Title), |
|
|
91 |
new XElement("abstract", Abstract), |
|
|
92 |
new XAttribute("src",Src) |
|
|
93 |
); |
|
|
94 |
XElement Xtags = new XElement("tags"); |
|
38
|
95 |
|
|
35
|
96 |
foreach (String tag in Tags) |
|
|
97 |
{ |
|
|
98 |
Xtags.Add(new XElement("tag", tag)); |
|
|
99 |
} |
|
|
100 |
temp.Add(Xtags); |
|
|
101 |
|
|
|
102 |
|
|
|
103 |
return temp; |
|
|
104 |
} |
|
|
105 |
} |
|
34
|
106 |
} |
|
|
107 |
} |