|
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 SLExtensions.Input; |
|
|
12 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
|
13 |
using Iri.Modernisation.BaseMVVM.ViewModel; |
|
|
14 |
using Iri.Modernisation.Data.Models; |
|
|
15 |
using System.Collections.Generic; |
|
|
16 |
using System.Linq; |
|
|
17 |
namespace Iri.Modernisation.Controls.ViewModel |
|
|
18 |
{ |
|
|
19 |
public class ConsultMenuVM : BaseMVVM.ViewModel.ViewModel |
|
|
20 |
{ |
|
|
21 |
private List<VideoBook> _videoBooks = new List<VideoBook>(); |
|
|
22 |
private List<VideoBook> list = new List<VideoBook>(); |
|
25
|
23 |
/// <summary> |
|
|
24 |
/// VideoBooks Disponible |
|
|
25 |
/// </summary> |
|
0
|
26 |
public List<VideoBook> VideoBooks |
|
|
27 |
{ |
|
|
28 |
get |
|
|
29 |
{ |
|
|
30 |
_videoBooks.Sort(new VideoBookComparer()); |
|
|
31 |
if (SearchWord != String.Empty) |
|
|
32 |
{ |
|
|
33 |
return list; |
|
|
34 |
} |
|
|
35 |
else |
|
|
36 |
{ |
|
|
37 |
return _videoBooks; |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
} |
|
|
41 |
set |
|
|
42 |
{ |
|
|
43 |
list = value; |
|
|
44 |
OnPropertyChanged("VideoBooks"); |
|
|
45 |
} |
|
|
46 |
} |
|
25
|
47 |
private bool _searchAuthor; |
|
|
48 |
/// <summary> |
|
|
49 |
/// Recherche par Auteur activée |
|
|
50 |
/// </summary> |
|
|
51 |
public bool SearchAuthor |
|
|
52 |
{ |
|
|
53 |
get |
|
|
54 |
{ |
|
|
55 |
return _searchAuthor; |
|
|
56 |
} |
|
|
57 |
set |
|
|
58 |
{ |
|
|
59 |
_searchAuthor = value; |
|
|
60 |
OnPropertyChanged("SearchAuthor"); |
|
|
61 |
} |
|
0
|
62 |
|
|
25
|
63 |
} |
|
|
64 |
|
|
|
65 |
private bool _searchContributer; |
|
|
66 |
/// <summary> |
|
|
67 |
/// Recherche par Contributeur activée |
|
|
68 |
/// </summary> |
|
|
69 |
public bool SearchContributer |
|
|
70 |
{ |
|
|
71 |
get |
|
|
72 |
{ |
|
|
73 |
return _searchContributer; |
|
|
74 |
} |
|
|
75 |
set |
|
|
76 |
{ |
|
|
77 |
_searchContributer = value; |
|
|
78 |
OnPropertyChanged("SearchContributer"); |
|
|
79 |
} |
|
|
80 |
} |
|
|
81 |
|
|
|
82 |
private bool _searchTag; |
|
|
83 |
/// <summary> |
|
|
84 |
/// Recherche par Tag |
|
|
85 |
/// </summary> |
|
|
86 |
public bool SearchTag |
|
|
87 |
{ |
|
|
88 |
get |
|
|
89 |
{ |
|
|
90 |
return _searchTag; |
|
|
91 |
} |
|
|
92 |
set |
|
|
93 |
{ |
|
|
94 |
_searchTag = value; |
|
|
95 |
OnPropertyChanged("SearchTag"); |
|
|
96 |
} |
|
|
97 |
} |
|
0
|
98 |
|
|
|
99 |
private String _searchWord= ""; |
|
|
100 |
public String SearchWord |
|
|
101 |
{ |
|
|
102 |
get |
|
|
103 |
{ |
|
|
104 |
return _searchWord; |
|
|
105 |
} |
|
|
106 |
|
|
|
107 |
set |
|
|
108 |
{ |
|
|
109 |
_searchWord = value; |
|
|
110 |
OnPropertyChanged("SearchWord"); |
|
|
111 |
} |
|
|
112 |
} |
|
|
113 |
|
|
|
114 |
public ConsultMenuVM() |
|
|
115 |
{ |
|
|
116 |
SearchAuthor = true; |
|
|
117 |
InitializeCommands(); |
|
|
118 |
} |
|
|
119 |
|
|
|
120 |
private void InitializeCommands() |
|
|
121 |
{ |
|
|
122 |
Commands.ConsultMenu.GetBook.Executed += new EventHandler<ExecutedEventArgs>(GetBook_Executed); |
|
|
123 |
} |
|
|
124 |
public ConsultMenuVM(List<VideoBook> argList) |
|
|
125 |
{ |
|
|
126 |
_videoBooks = argList; |
|
|
127 |
SearchAuthor = true; |
|
|
128 |
InitializeCommands(); |
|
|
129 |
} |
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
void GetBook_Executed(object sender, ExecutedEventArgs e) |
|
|
134 |
{ |
|
|
135 |
|
|
|
136 |
if (SearchAuthor) |
|
|
137 |
{ |
|
|
138 |
var query = from c in _videoBooks |
|
|
139 |
where c.Author.UserName.Contains(_searchWord) |
|
|
140 |
select c; |
|
|
141 |
VideoBooks = query.ToList(); |
|
|
142 |
} |
|
|
143 |
if (SearchContributer) |
|
|
144 |
{ |
|
|
145 |
List<VideoBook> temp = new List<VideoBook>(); |
|
|
146 |
foreach (VideoBook Book in _videoBooks) |
|
|
147 |
{ |
|
|
148 |
foreach (VideoChapter Chapter in Book.Chapters) |
|
|
149 |
{ |
|
|
150 |
foreach (Annotation Annotation in Chapter.Annotations) |
|
|
151 |
{ |
|
|
152 |
if ( Annotation.Contributer.UserName.Contains(_searchWord)) |
|
|
153 |
{ |
|
|
154 |
temp.Add(Book); |
|
|
155 |
} |
|
|
156 |
} |
|
|
157 |
} |
|
|
158 |
} |
|
|
159 |
VideoBooks = temp; |
|
|
160 |
} |
|
|
161 |
if(SearchTag) |
|
|
162 |
{ |
|
|
163 |
List<VideoBook> temp = new List<VideoBook>(); |
|
|
164 |
foreach (VideoBook Book in _videoBooks) |
|
|
165 |
{ |
|
|
166 |
foreach (VideoChapter Chapter in Book.Chapters) |
|
|
167 |
{ |
|
|
168 |
foreach (Annotation Annotation in Chapter.Annotations) |
|
|
169 |
{ |
|
|
170 |
if (Annotation.Tags.Contains(_searchWord)) |
|
|
171 |
{ |
|
|
172 |
temp.Add(Book); |
|
|
173 |
} |
|
|
174 |
} |
|
|
175 |
foreach (SegmentIndex Segment in Chapter.Index) |
|
|
176 |
{ |
|
|
177 |
if (Segment.Tags.Contains(_searchWord)) |
|
|
178 |
{ |
|
|
179 |
temp.Add(Book); |
|
|
180 |
} |
|
|
181 |
} |
|
|
182 |
} |
|
|
183 |
} |
|
|
184 |
VideoBooks = temp; |
|
|
185 |
} |
|
|
186 |
} |
|
|
187 |
|
|
|
188 |
} |
|
|
189 |
} |