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