|
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 Iri.Modernisation.BaseMVVM; |
|
|
12 |
using Iri.Modernisation.BaseMVVM.ViewModel; |
|
|
13 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
|
14 |
using Iri.Modernisation.Data.Models; |
|
|
15 |
using System.Collections.Generic; |
|
|
16 |
namespace Iri.Modernisation.Controls.ViewModel |
|
|
17 |
{ |
|
|
18 |
/// <summary> |
|
|
19 |
/// ViewModel d'un PolemicElement |
|
|
20 |
/// </summary> |
|
|
21 |
public class PolemicElementVM : MenuableViewModel |
|
|
22 |
{ |
|
|
23 |
/// <summary> |
|
|
24 |
/// Timer lançant le ClickMenu |
|
|
25 |
/// </summary> |
|
|
26 |
private System.Windows.Threading.DispatcherTimer DisplayTimer = new System.Windows.Threading.DispatcherTimer(); |
|
|
27 |
private MouseButtonEventArgs _selectedCoord; |
|
|
28 |
|
|
|
29 |
/// <summary> |
|
|
30 |
/// Temps d'entrée |
|
|
31 |
/// </summary> |
|
|
32 |
private TimeSpan _timerIn; |
|
|
33 |
public TimeSpan TimerIn |
|
|
34 |
{ |
|
|
35 |
get |
|
|
36 |
{ |
|
|
37 |
return _timerIn; |
|
|
38 |
} |
|
|
39 |
set |
|
|
40 |
{ |
|
|
41 |
_timerIn = value; |
|
|
42 |
_element.TimerIn = value; |
|
|
43 |
OnPropertyChanged("TimerIn"); |
|
|
44 |
} |
|
|
45 |
} |
|
|
46 |
|
|
|
47 |
/// <summary> |
|
|
48 |
/// Temps de sortie |
|
|
49 |
/// </summary> |
|
|
50 |
private TimeSpan _timerOut; |
|
|
51 |
public TimeSpan TimerOut |
|
|
52 |
{ |
|
|
53 |
get |
|
|
54 |
{ |
|
|
55 |
return _timerOut; |
|
|
56 |
} |
|
|
57 |
set |
|
|
58 |
{ |
|
|
59 |
_timerOut = value; |
|
|
60 |
_element.TimerOut = value; |
|
|
61 |
OnPropertyChanged("TimerOut"); |
|
|
62 |
} |
|
|
63 |
} |
|
|
64 |
|
|
|
65 |
/// <summary> |
|
|
66 |
/// Durée de l'élément |
|
|
67 |
/// </summary> |
|
|
68 |
public TimeSpan Duration |
|
|
69 |
{ |
|
|
70 |
get |
|
|
71 |
{ |
|
|
72 |
return TimerOut - TimerIn; |
|
|
73 |
} |
|
|
74 |
set |
|
|
75 |
{ |
|
|
76 |
TimerOut = TimerIn + value; |
|
|
77 |
} |
|
|
78 |
} |
|
|
79 |
|
|
|
80 |
/// <summary> |
|
|
81 |
/// Titre de l'élément |
|
|
82 |
/// </summary> |
|
|
83 |
private String _title; |
|
|
84 |
public String Title |
|
|
85 |
{ |
|
|
86 |
get |
|
|
87 |
{ |
|
|
88 |
return _title; |
|
|
89 |
} |
|
|
90 |
set |
|
|
91 |
{ |
|
|
92 |
_title = value; |
|
|
93 |
_element.Title = value; |
|
|
94 |
OnPropertyChanged("Title"); |
|
|
95 |
} |
|
|
96 |
} |
|
|
97 |
|
|
|
98 |
/// <summary> |
|
|
99 |
/// Description de l'élément |
|
|
100 |
/// </summary> |
|
|
101 |
private String _description; |
|
|
102 |
public String Description |
|
|
103 |
{ |
|
|
104 |
get |
|
|
105 |
{ |
|
|
106 |
return _description; |
|
|
107 |
} |
|
|
108 |
set |
|
|
109 |
{ |
|
|
110 |
_description = value; |
|
|
111 |
_element.Description = value; |
|
|
112 |
OnPropertyChanged("Description"); |
|
|
113 |
} |
|
|
114 |
} |
|
|
115 |
|
|
|
116 |
/// <summary> |
|
|
117 |
/// Tags de l'élément |
|
|
118 |
/// </summary> |
|
|
119 |
private List<String> _tags; |
|
|
120 |
public List<String> Tags |
|
|
121 |
{ |
|
|
122 |
get |
|
|
123 |
{ |
|
|
124 |
return _tags; |
|
|
125 |
} |
|
|
126 |
set |
|
|
127 |
{ |
|
|
128 |
_tags = value; |
|
|
129 |
_element.Tags = value; |
|
|
130 |
OnPropertyChanged("Tags"); |
|
|
131 |
} |
|
|
132 |
} |
|
|
133 |
|
|
|
134 |
/// <summary> |
|
|
135 |
/// Chapitre référent de l'élément |
|
|
136 |
/// </summary> |
|
|
137 |
private VideoChapter _chapter; |
|
|
138 |
public VideoChapter Chapter |
|
|
139 |
{ |
|
|
140 |
get |
|
|
141 |
{ |
|
|
142 |
return _chapter; |
|
|
143 |
} |
|
|
144 |
set |
|
|
145 |
{ |
|
|
146 |
_chapter = value; |
|
|
147 |
_element.Chapter = value; |
|
|
148 |
OnPropertyChanged("Chapter"); |
|
|
149 |
} |
|
|
150 |
} |
|
|
151 |
|
|
|
152 |
/// <summary> |
|
|
153 |
/// Auteur de l'élément |
|
|
154 |
/// </summary> |
|
|
155 |
public User Contributer |
|
|
156 |
{ |
|
|
157 |
get |
|
|
158 |
{ |
|
|
159 |
try |
|
|
160 |
{ |
|
|
161 |
return ((Annotation)_element).Contributer; |
|
|
162 |
} |
|
|
163 |
catch |
|
|
164 |
{ |
|
|
165 |
return null; |
|
|
166 |
} |
|
|
167 |
} |
|
|
168 |
|
|
|
169 |
} |
|
|
170 |
|
|
|
171 |
public double Heigh |
|
|
172 |
{ |
|
|
173 |
get |
|
|
174 |
{ |
|
|
175 |
if(_element is SegmentIndex) |
|
|
176 |
{ |
|
|
177 |
return 20; |
|
|
178 |
} |
|
|
179 |
else |
|
|
180 |
{ |
|
|
181 |
return 10; |
|
|
182 |
} |
|
|
183 |
|
|
|
184 |
} |
|
|
185 |
|
|
|
186 |
} |
|
|
187 |
|
|
|
188 |
/// <summary> |
|
|
189 |
/// PolemicType de l'élément |
|
|
190 |
/// </summary> |
|
|
191 |
public PolemicElementType Type |
|
|
192 |
{ |
|
|
193 |
get |
|
|
194 |
{ |
|
|
195 |
if (_element is Annotation) |
|
|
196 |
{ |
|
|
197 |
return ((Annotation)_element).Type; |
|
|
198 |
} |
|
|
199 |
else |
|
|
200 |
{ |
|
|
201 |
return PolemicElementType.Basic; |
|
|
202 |
} |
|
|
203 |
} |
|
|
204 |
} |
|
|
205 |
private PolemicElement _element { get; set; } |
|
|
206 |
|
|
|
207 |
/// <summary> |
|
|
208 |
/// Constructeur |
|
|
209 |
/// </summary> |
|
|
210 |
/// <param name="element">PolémicElement</param> |
|
|
211 |
public PolemicElementVM(PolemicElement element) |
|
|
212 |
:base() |
|
|
213 |
{ |
|
|
214 |
_element = element; |
|
|
215 |
TimerIn = _element.TimerIn; |
|
|
216 |
TimerOut = _element.TimerOut; |
|
|
217 |
Title = _element.Title; |
|
|
218 |
Description = _element.Description; |
|
|
219 |
Tags = _element.Tags; |
|
|
220 |
Chapter = _element.Chapter; |
|
|
221 |
DisplayTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); |
|
|
222 |
DisplayTimer.Tick += new EventHandler(myDispatcherTimer_Tick); |
|
|
223 |
} |
|
|
224 |
|
|
|
225 |
/// <summary> |
|
|
226 |
/// Lors d'un Tick,c'est à dire, lors d'un appuie long sur un élément |
|
|
227 |
/// </summary> |
|
|
228 |
/// <param name="sender"></param> |
|
|
229 |
/// <param name="e"></param> |
|
|
230 |
void myDispatcherTimer_Tick(object sender, EventArgs e) |
|
|
231 |
{ |
|
|
232 |
DisplayTimer.Stop(); |
|
|
233 |
Commands.PolemicElement.ElementSelected.Execute(_selectedCoord, _element); |
|
|
234 |
} |
|
|
235 |
|
|
|
236 |
|
|
|
237 |
public override void MenuableUserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
|
238 |
{ |
|
|
239 |
|
|
|
240 |
_selectedCoord = e; |
|
|
241 |
Commands.PolemicElement.SelectPolemicElement.Execute(_element); |
|
|
242 |
DisplayTimer.Start(); |
|
|
243 |
|
|
|
244 |
|
|
|
245 |
} |
|
|
246 |
public override void MenuableUserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
|
247 |
{ |
|
|
248 |
DisplayTimer.Stop(); |
|
|
249 |
Commands.ContextualBinderLayer.EndBind.Execute(Type, _element); |
|
|
250 |
|
|
|
251 |
} |
|
|
252 |
public override void MenuableUserControl_MouseLeave(object sender, MouseEventArgs e) |
|
|
253 |
{ |
|
|
254 |
Commands.ContextualBinderLayer.UnSelectBind.Execute(); |
|
|
255 |
} |
|
|
256 |
public override void MenuableUserControl_MouseEnter(object sender, MouseEventArgs e) |
|
|
257 |
{ |
|
|
258 |
Commands.ContextualBinderLayer.SelectBind.Execute(Type, _element); |
|
|
259 |
} |
|
|
260 |
|
|
|
261 |
} |
|
|
262 |
|
|
|
263 |
} |