123
|
1 |
using System; |
|
2 |
using System.IO; |
|
3 |
using System.Collections.Generic; |
|
4 |
using System.Linq; |
|
5 |
using System.Text; |
|
6 |
using System.Xml.Serialization; |
|
7 |
using System.Reflection; |
|
8 |
|
|
9 |
namespace FingersDance.Control.ListVideo |
|
10 |
{ |
|
11 |
public class ListVideo |
|
12 |
{ |
|
13 |
static Dictionary<string, ListVideoItem> _Videos; |
|
14 |
|
|
15 |
public ListVideo() |
|
16 |
{ } |
|
17 |
|
|
18 |
public Dictionary<string, ListVideoItem> GetVideos() |
|
19 |
{ |
|
20 |
if (_Videos == null) |
|
21 |
{ |
|
22 |
_Videos = new Dictionary<string, ListVideoItem>(); |
|
23 |
LoadList(); |
|
24 |
} |
|
25 |
return _Videos; |
|
26 |
} |
|
27 |
|
|
28 |
void LoadList() |
|
29 |
{ |
|
30 |
_Videos.Clear(); |
|
31 |
StreamReader reader = null; |
|
32 |
FileInfo assemblyPath = new FileInfo(Assembly.GetExecutingAssembly().Location); |
|
33 |
DirectoryInfo info = assemblyPath.Directory; |
|
34 |
try |
|
35 |
{ |
|
36 |
reader = new StreamReader(info.FullName.ToString() + "\\Resources\\videos.xml"); |
|
37 |
XmlSerializer serializer = new XmlSerializer(typeof(List<ListVideoItem>)); |
|
38 |
List<ListVideoItem> temp = (List<ListVideoItem>)serializer.Deserialize(reader); |
|
39 |
foreach (ListVideoItem elt in temp) |
|
40 |
if (!elt.Preview.Equals("") && !_Videos.ContainsKey(elt.Path)) |
|
41 |
_Videos.Add(elt.Path, elt); |
|
42 |
reader.Close(); |
|
43 |
} |
|
44 |
catch (Exception e) |
|
45 |
{ |
|
46 |
if (reader != null) |
|
47 |
reader.Close(); |
|
48 |
} |
|
49 |
} |
|
50 |
} |
|
51 |
} |