|
27
|
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.Xml.Linq; |
|
|
12 |
using System.Collections.Generic; |
|
|
13 |
namespace Iri.Modernisation.Data.Models |
|
|
14 |
{ |
|
|
15 |
public static class FactoryVideoLivre |
|
|
16 |
{ |
|
|
17 |
public static WebClient xmlClient = new WebClient(); |
|
36
|
18 |
private static XDocument _configDoc; |
|
27
|
19 |
public static VideoChapterDescription[] VideoChapterDescriptions {get;private set;} |
|
28
|
20 |
public static PolemicTypeDescription[] AnnotationDescriptions { get; private set; } |
|
32
|
21 |
public static String VideoBookListPath; |
|
36
|
22 |
public static String ProductionVideoPath; |
|
27
|
23 |
public static int NumberOfChapters |
|
|
24 |
{ |
|
|
25 |
get |
|
|
26 |
{ |
|
|
27 |
return VideoChapterDescriptions.Length; |
|
|
28 |
} |
|
|
29 |
} |
|
|
30 |
static FactoryVideoLivre() |
|
|
31 |
{ |
|
|
32 |
|
|
|
33 |
|
|
|
34 |
} |
|
|
35 |
static public void Initialize() |
|
|
36 |
{ |
|
30
|
37 |
// LoadXMLFile(); |
|
27
|
38 |
} |
|
30
|
39 |
public static void LoadXMLFile(String path) |
|
27
|
40 |
{ |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded); |
|
30
|
45 |
Uri uri = new Uri(path, UriKind.RelativeOrAbsolute); |
|
|
46 |
xmlClient.DownloadStringAsync(uri); |
|
27
|
47 |
|
|
|
48 |
|
|
|
49 |
} |
|
|
50 |
|
|
|
51 |
static void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e) |
|
|
52 |
{ |
|
|
53 |
|
|
|
54 |
if (e.Error == null) |
|
|
55 |
{ |
|
|
56 |
|
|
|
57 |
_configDoc = XDocument.Parse(e.Result); |
|
|
58 |
List<VideoChapterDescription> temp = new List<VideoChapterDescription>(); |
|
30
|
59 |
List<PolemicTypeDescription> temp_an = new List<PolemicTypeDescription>(); |
|
27
|
60 |
int nb = 0; |
|
32
|
61 |
VideoBookListPath = _configDoc.Root.Attribute("VideoBookList").Value; |
|
36
|
62 |
ProductionVideoPath = _configDoc.Root.Attribute("ProductionVideo").Value; |
|
27
|
63 |
foreach (XElement XChapter in _configDoc.Root.Element("VideoBook").Elements()) |
|
|
64 |
{ |
|
|
65 |
temp.Add(new VideoChapterDescription(nb, XChapter.Attribute("name").Value, XChapter.Attribute("color").Value)); |
|
|
66 |
nb++; |
|
|
67 |
} |
|
38
|
68 |
int annotatinIndex=0; |
|
30
|
69 |
foreach (XElement XAnnotation in _configDoc.Root.Element("PolemicTypes").Elements()) |
|
|
70 |
{ |
|
38
|
71 |
temp_an.Add(new PolemicTypeDescription(annotatinIndex, XAnnotation.Attribute("name").Value, XAnnotation.Attribute("color").Value)); |
|
|
72 |
annotatinIndex++; |
|
30
|
73 |
} |
|
|
74 |
|
|
27
|
75 |
VideoChapterDescriptions = temp.ToArray(); |
|
30
|
76 |
AnnotationDescriptions = temp_an.ToArray(); |
|
|
77 |
FactoryReady(null, new EventArgs()); |
|
27
|
78 |
} |
|
|
79 |
else |
|
|
80 |
{ |
|
30
|
81 |
MessageBox.Show(e.Error.Message); |
|
27
|
82 |
} |
|
30
|
83 |
|
|
27
|
84 |
|
|
|
85 |
} |
|
30
|
86 |
public static event EventHandler FactoryReady; |
|
27
|
87 |
static public void Load(string path) |
|
|
88 |
{ |
|
30
|
89 |
|
|
27
|
90 |
_configDoc = XDocument.Load(path); |
|
28
|
91 |
List<VideoChapterDescription> temp_vl = new List<VideoChapterDescription>(); |
|
|
92 |
|
|
|
93 |
List<PolemicTypeDescription> temp_an = new List<PolemicTypeDescription>(); |
|
27
|
94 |
int nb = 0; |
|
|
95 |
foreach (XElement XChapter in _configDoc.Root.Element("VideoBook").Elements()) |
|
|
96 |
{ |
|
28
|
97 |
temp_vl .Add(new VideoChapterDescription(nb,XChapter.Attribute("name").Value, XChapter.Attribute("color").Value)); |
|
27
|
98 |
nb++; |
|
|
99 |
} |
|
38
|
100 |
int annotatinIndex = 0; |
|
28
|
101 |
foreach (XElement XAnnotation in _configDoc.Root.Element("PolemicTypes").Elements()) |
|
|
102 |
{ |
|
38
|
103 |
temp_an.Add(new PolemicTypeDescription(annotatinIndex, XAnnotation.Attribute("name").Value, XAnnotation.Attribute("color").Value)); |
|
|
104 |
annotatinIndex++; |
|
28
|
105 |
} |
|
|
106 |
VideoChapterDescriptions = temp_vl .ToArray(); |
|
|
107 |
AnnotationDescriptions = temp_an.ToArray(); |
|
27
|
108 |
} |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
} |
|
|
115 |
} |