forked from microsoft/WPF-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyVideos.cs
67 lines (54 loc) · 1.7 KB
/
MyVideos.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// // Copyright (c) Microsoft. All rights reserved.
// // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;
// ObserverableCollection
// DirectoryInfo
// MessageBox
namespace VideoViewerDemo
{
// MyVideos is a collection of MyVideo objects
// This class has a Directory string property
// The Update() method takes all .wmv files from the specified directory
// and adds them as MyVideo objects into the collection
public class MyVideos : ObservableCollection<MyVideo>
{
private DirectoryInfo _directory;
public MyVideos()
{
}
public MyVideos(string directory)
{
Directory = directory;
}
public string Directory
{
set
{
// Don't set path if directory is invalid
if (!System.IO.Directory.Exists(value))
{
MessageBox.Show("No Such Directory");
}
_directory = new DirectoryInfo(value);
Update();
}
get { return _directory.FullName; }
}
private void Update()
{
// Don't update if no directory to get files from
if (_directory == null) return;
// Remove all MyVideo objects from this collection
Clear();
// Create MyVideo objects
foreach (var f in _directory.GetFiles("*.wmv"))
{
Add(new MyVideo(f.FullName, f.Name));
}
}
}
// MyVideo class
// Properties: VideoTitle and Source
}