|
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 System.Collections.Generic; |
|
30
|
12 |
using System.Xml.Linq; |
|
|
13 |
using System.Threading; |
|
|
14 |
using Iri.Modernisation.Data.LDTClass; |
|
0
|
15 |
namespace Iri.Modernisation.Data.Models |
|
|
16 |
{ |
|
|
17 |
/// <summary> |
|
|
18 |
/// Classe VideoLivre |
|
|
19 |
/// </summary> |
|
|
20 |
public class VideoBook |
|
|
21 |
{ |
|
|
22 |
/// <summary> |
|
|
23 |
/// Titre du VideoLivre |
|
|
24 |
/// </summary> |
|
|
25 |
public String Title { get; set; } |
|
|
26 |
|
|
|
27 |
/// <summary> |
|
|
28 |
/// Auteur du VideoLivre |
|
|
29 |
/// </summary> |
|
|
30 |
public User Author { get; set; } |
|
|
31 |
|
|
|
32 |
/// <summary> |
|
|
33 |
/// Chapitre du VideoLivre |
|
|
34 |
/// </summary> |
|
|
35 |
public VideoChapter[] Chapters { get; set; } |
|
|
36 |
|
|
|
37 |
/// <summary> |
|
|
38 |
/// Durée du VideoLivre |
|
|
39 |
/// </summary> |
|
|
40 |
public TimeSpan Duration { get; set; } |
|
|
41 |
|
|
|
42 |
/// <summary> |
|
|
43 |
/// Chemin de la vidéo fini |
|
|
44 |
/// </summary> |
|
|
45 |
public String MediaPath { get; set; } |
|
|
46 |
|
|
|
47 |
/// <summary> |
|
|
48 |
/// Constructeur par défaut |
|
|
49 |
/// </summary> |
|
|
50 |
public VideoBook() |
|
|
51 |
{ |
|
27
|
52 |
Chapters = new VideoChapter[FactoryVideoLivre.VideoChapterDescriptions.Length]; |
|
|
53 |
for (int nbChapitre = 0; nbChapitre < FactoryVideoLivre.VideoChapterDescriptions.Length; nbChapitre++) |
|
|
54 |
{ |
|
|
55 |
Chapters[nbChapitre] = new VideoChapter(this, |
|
|
56 |
FactoryVideoLivre.VideoChapterDescriptions[nbChapitre].Id, |
|
|
57 |
FactoryVideoLivre.VideoChapterDescriptions[nbChapitre].Title, |
|
|
58 |
FactoryVideoLivre.VideoChapterDescriptions[nbChapitre].Color); |
|
|
59 |
|
|
|
60 |
} |
|
0
|
61 |
|
|
|
62 |
} |
|
|
63 |
|
|
30
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
0
|
68 |
|
|
|
69 |
} |
|
30
|
70 |
public class VideoBookLoaderHelper |
|
|
71 |
{ |
|
|
72 |
private WebClient webclient; |
|
|
73 |
private List<VideoBook> returnVideoBookList; |
|
|
74 |
private int nbOfBook; |
|
|
75 |
public VideoBookLoaderHelper(String path) |
|
|
76 |
{ |
|
|
77 |
nbOfBook = 0; |
|
|
78 |
returnVideoBookList = new List<VideoBook>(); |
|
|
79 |
webclient = new WebClient(); |
|
|
80 |
webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted); |
|
|
81 |
webclient.DownloadStringAsync(new Uri(path,UriKind.RelativeOrAbsolute )); |
|
|
82 |
} |
|
0
|
83 |
|
|
30
|
84 |
void webclient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) |
|
|
85 |
{ |
|
|
86 |
XDocument XDoc = XDocument.Parse(e.Result); |
|
|
87 |
List<VideoBook> ListReturn = new List<VideoBook>(); |
|
|
88 |
|
|
|
89 |
foreach (XElement XVideoBook in XDoc.Root.Elements()) |
|
|
90 |
{ |
|
|
91 |
Loader<VideoBook> LoaderVideoBook = new Loader<VideoBook>(LDTFileReader.ConvertToVideoBook); |
|
|
92 |
LoaderVideoBook.LoaderFinished += new EventHandler<LoaderEventArgs<VideoBook>>(LoaderVideoBook_LoaderFinished); |
|
|
93 |
|
|
|
94 |
LoaderVideoBook.LoadAvailableVideoBooks(XVideoBook.Attribute("metafile").Value); |
|
|
95 |
|
|
|
96 |
nbOfBook++; |
|
|
97 |
|
|
|
98 |
} |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
} |
|
|
102 |
|
|
|
103 |
void LoaderVideoBook_LoaderFinished(object sender, LoaderEventArgs<VideoBook> e) |
|
|
104 |
{ |
|
|
105 |
returnVideoBookList.Add(e.CreatedObject); |
|
|
106 |
if(returnVideoBookList.Count == nbOfBook) |
|
|
107 |
{ |
|
|
108 |
if(LoaderFinished!=null) |
|
|
109 |
{ |
|
|
110 |
LoaderFinished(this,new LoaderEventArgs<List<VideoBook>>(returnVideoBookList)); |
|
|
111 |
} |
|
|
112 |
} |
|
|
113 |
} |
|
|
114 |
public event EventHandler<LoaderEventArgs<List<VideoBook>>> LoaderFinished; |
|
|
115 |
/*public List<VideoBook> LoadFromXml(XDocument XDoc) |
|
|
116 |
{ |
|
|
117 |
|
|
|
118 |
|
|
|
119 |
}*/ |
|
|
120 |
|
|
|
121 |
} |
|
0
|
122 |
/// <summary> |
|
|
123 |
/// Comparateur pour Trier les livres |
|
|
124 |
/// </summary> |
|
|
125 |
public class VideoBookComparer : IComparer<VideoBook> |
|
|
126 |
{ |
|
|
127 |
public int Compare(VideoBook x, VideoBook y) |
|
|
128 |
{ |
|
|
129 |
return x.Title.CompareTo(y.Title); |
|
|
130 |
} |
|
|
131 |
} |
|
30
|
132 |
|
|
0
|
133 |
} |