| author | totetm <> |
| Fri, 12 Feb 2010 16:22:57 +0100 | |
| changeset 47 | 9b26023b8c83 |
| parent 40 | 581829b5ddd9 |
| permissions | -rw-r--r-- |
| 0 | 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; |
|
11 |
using Iri.Modernisation.Data.Models; |
|
| 30 | 12 |
using System.Xml.Linq; |
| 39 | 13 |
using System.Collections.Generic; |
| 0 | 14 |
namespace Iri.Modernisation.Data.LDTClass |
15 |
{ |
|
16 |
public class LDTFileReader |
|
17 |
{ |
|
| 30 | 18 |
public static VideoBook ConvertToVideoBook(XDocument Path) |
| 0 | 19 |
{ |
| 30 | 20 |
LDTFile _ldtFile = new LDTFile(); |
21 |
_ldtFile.Load(Path); |
|
| 35 | 22 |
|
| 30 | 23 |
VideoBook _videoBook = new VideoBook(); |
| 35 | 24 |
|
| 0 | 25 |
if (_ldtFile != null) |
26 |
{ |
|
27 |
// Initialisation du VideoBook |
|
28 |
_videoBook = new VideoBook() |
|
29 |
{ |
|
30 |
Title = _ldtFile.Project.Title, |
|
31 |
Author = new User() |
|
32 |
{ |
|
33 |
UserName = _ldtFile.Project.User, |
|
34 |
|
|
35 |
}, |
|
| 34 | 36 |
Duration = new TimeSpan(), |
37 |
IriPath = _ldtFile.Medias[0].Src, |
|
| 35 | 38 |
LdtPath = _ldtFile.Path, |
| 0 | 39 |
|
40 |
}; |
|
41 |
||
42 |
// Initialisation des index |
|
43 |
foreach (LDTAnnotationsContent LDTAC in _ldtFile.Annotations) |
|
44 |
{ |
|
|
10
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
45 |
int count=0; |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
46 |
int decoupage = LDTAC.Content[2].Elements.Count/4; |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
47 |
int selectedChapter = 0; |
| 0 | 48 |
foreach(LDTElement LDTE in LDTAC.Content[2].Elements) |
49 |
{ |
|
|
10
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
50 |
|
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
51 |
|
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
52 |
_videoBook.Chapters[selectedChapter].Index.Add(new SegmentIndex(_videoBook.Chapters[selectedChapter]) |
| 0 | 53 |
{ |
| 34 | 54 |
Id= LDTE.Id, |
| 0 | 55 |
Title = LDTE.Title, |
56 |
Description = LDTE.Abstract, |
|
57 |
Tags = LDTE.Tags, |
|
58 |
TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin), |
|
59 |
Duration = new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur), |
|
|
10
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
60 |
|
| 0 | 61 |
}); |
|
10
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
62 |
count++; |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
63 |
if (count % decoupage == 0) |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
64 |
{ |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
65 |
selectedChapter++; |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
66 |
if (selectedChapter >= 4) |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
67 |
{ |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
68 |
selectedChapter = 3; |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
69 |
} |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
70 |
} |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
71 |
|
| 0 | 72 |
_videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur)); |
73 |
} |
|
74 |
foreach (LDTElement LDTE in LDTAC.Content[3].Elements) |
|
75 |
{ |
|
76 |
_videoBook.Chapters[0].Annotations.Add(new Annotation(_videoBook.Chapters[0]) |
|
77 |
{ |
|
| 34 | 78 |
Id = LDTE.Id, |
| 0 | 79 |
Title = LDTE.Title, |
80 |
Description = LDTE.Abstract, |
|
81 |
Tags = LDTE.Tags, |
|
82 |
TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin), |
|
83 |
Duration = new TimeSpan(0, 0, 0, 0, (int)(LDTE.Dur+5000)), |
|
| 28 | 84 |
Type = FactoryVideoLivre.AnnotationDescriptions[0] |
| 0 | 85 |
}); |
86 |
// _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)(LDTE.Dur))); |
|
87 |
} |
|
88 |
foreach (LDTElement LDTE in LDTAC.Content[1].Elements) |
|
89 |
{ |
|
90 |
_videoBook.Chapters[0].Annotations.Add(new Annotation(_videoBook.Chapters[0]) |
|
91 |
{ |
|
92 |
Title = LDTE.Title, |
|
93 |
Description = LDTE.Abstract, |
|
94 |
Tags = LDTE.Tags, |
|
95 |
TimerIn = new TimeSpan(0, 0, 0, 0, (int)LDTE.Begin), |
|
96 |
Duration = new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur), |
|
| 28 | 97 |
Type = FactoryVideoLivre.AnnotationDescriptions[1] |
| 0 | 98 |
}); |
99 |
// _videoBook.Duration = _videoBook.Duration.Add(new TimeSpan(0, 0, 0, 0, (int)LDTE.Dur)); |
|
100 |
} |
|
101 |
||
102 |
} |
|
| 30 | 103 |
return _videoBook; |
| 0 | 104 |
// Initialisation des Annotations |
105 |
//Initialisation des Liens |
|
106 |
} |
|
107 |
else |
|
108 |
{ |
|
109 |
throw new Exception("Fichier LDT Null"); |
|
110 |
} |
|
111 |
||
112 |
} |
|
| 35 | 113 |
public static VideoBook ConvertToVideoBook(LDTFile ldt, IRIFile iri) |
114 |
{ |
|
| 38 | 115 |
|
| 40 | 116 |
Dictionary<String,PolemicElement> polemicElement = new Dictionary<string,PolemicElement>(); |
| 35 | 117 |
// Initialisation du VideoBook |
| 38 | 118 |
VideoBook _videoBook = new VideoBook() |
| 35 | 119 |
{ |
120 |
Title = ldt.Project.Title, |
|
121 |
Author = new User() |
|
122 |
{ |
|
123 |
UserName = ldt.Project.User, |
|
124 |
||
125 |
}, |
|
126 |
Duration = new TimeSpan(), |
|
127 |
IriPath = ldt.Medias[0].Src, |
|
128 |
LdtPath = ldt.Path, |
|
| 38 | 129 |
MediaPath = iri.Body.Medias[0].Videos[0].Src |
| 35 | 130 |
|
131 |
}; |
|
132 |
||
133 |
// Initialisation des index |
|
| 38 | 134 |
TimeSpan totalDur = TimeSpan.Zero; |
135 |
foreach(IRIEnsemble Iens in iri.Body.Ensembles) |
|
136 |
{ |
|
137 |
int chapter = 0; |
|
138 |
|
|
139 |
foreach (IRIElement elem in Iens.Decoupages[0].Elements) |
|
140 |
{ |
|
| 40 | 141 |
SegmentIndex Si = new SegmentIndex(_videoBook.Chapters[chapter]) |
| 38 | 142 |
{ |
143 |
Id = elem.Id, |
|
144 |
Title = elem.Title, |
|
145 |
Description = elem.Abstract, |
|
146 |
Tags = elem.Tags, |
|
147 |
TimerIn = elem.Begin, |
|
148 |
Duration = elem.Dur |
|
149 |
||
| 40 | 150 |
}; |
151 |
_videoBook.Chapters[chapter].Index.Add(Si); |
|
| 38 | 152 |
totalDur += elem.Dur; |
| 40 | 153 |
polemicElement.Add(Si.Id, Si); |
| 38 | 154 |
} |
155 |
chapter++; |
|
156 |
} |
|
| 39 | 157 |
|
158 |
Dictionary<String, String> BasicRelation = new Dictionary<string, string>(); |
|
159 |
foreach (LDTRelation LDTR in ldt.BasicRelations) |
|
160 |
{ |
|
161 |
BasicRelation.Add(LDTR.IdElementTo, LDTR.Type); |
|
162 |
} |
|
163 |
||
| 35 | 164 |
foreach (LDTAnnotationsContent LDTAC in ldt.Annotations) |
165 |
{ |
|
| 38 | 166 |
int chapterIndex = 0; |
167 |
foreach(LDTAnnotationsDecoupage LDTAD in LDTAC.Content) |
|
168 |
{ |
|
169 |
User author = new User() {UserName = LDTAD.Author }; |
|
| 39 | 170 |
LDTElement elem = LDTAD.Elements[0]; |
| 40 | 171 |
Annotation an = new Annotation(_videoBook.Chapters[chapterIndex]) |
172 |
{ |
|
173 |
Id = elem.Id, |
|
174 |
Title = elem.Title, |
|
175 |
Description = elem.Abstract, |
|
176 |
Tags = elem.Tags, |
|
177 |
TimerIn = new TimeSpan(0, 0, 0, 0, (int)elem.Begin), |
|
178 |
Duration = new TimeSpan(0, 0, 0, 0, (int)elem.Dur), |
|
179 |
Type = FactoryVideoLivre.DictionaryAnnotationDescriptions[BasicRelation[elem.Id]], |
|
180 |
Contributer = author |
|
| 35 | 181 |
|
| 40 | 182 |
}; |
183 |
_videoBook.Chapters[chapterIndex].Annotations.Add(an |
|
184 |
); |
|
185 |
polemicElement.Add(an.Id,an); |
|
| 39 | 186 |
|
| 38 | 187 |
|
188 |
} |
|
189 |
chapterIndex++; |
|
| 35 | 190 |
} |
| 40 | 191 |
foreach (LDTRelation Rel in ldt.BasicRelations) |
192 |
{ |
|
193 |
_videoBook.BasicLinks.Add(new PolemicLink() |
|
194 |
{ |
|
195 |
FromElement = (polemicElement[Rel.IdElementFrom]), |
|
196 |
ToElement = polemicElement[Rel.IdElementTo], |
|
197 |
Title = Rel.Title, |
|
198 |
Type = FactoryVideoLivre.DictionaryAnnotationDescriptions[Rel.Type] |
|
199 |
|
|
200 |
}); |
|
201 |
} |
|
| 38 | 202 |
_videoBook.Duration = iri.Body.Medias[0].Videos[0].Dur; |
203 |
_videoBook.LdtPath = ldt.Path; |
|
| 35 | 204 |
return _videoBook; |
205 |
} |
|
| 0 | 206 |
} |
207 |
} |