| author | Matthieu Totet |
| Fri, 18 Dec 2009 16:45:30 +0100 | |
| changeset 25 | a9c815025a1b |
| parent 10 | 12515e11b357 |
| child 27 | f292db96b050 |
| permissions | -rw-r--r-- |
| 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> |
|
|
10
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
191 |
public object Type |
| 0 | 192 |
{ |
193 |
get |
|
194 |
{ |
|
195 |
if (_element is Annotation) |
|
196 |
{ |
|
197 |
return ((Annotation)_element).Type; |
|
198 |
} |
|
|
10
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
199 |
else if(_element is SegmentIndex) |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
200 |
{ |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
201 |
return ((SegmentIndex)_element).Chapter.Type; |
|
12515e11b357
Update PolemicElement View : Can Display Correct Color of VideoChapter
Matthieu Totet
parents:
0
diff
changeset
|
202 |
} |
| 0 | 203 |
else |
204 |
{ |
|
205 |
return PolemicElementType.Basic; |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
private PolemicElement _element { get; set; } |
|
210 |
||
211 |
/// <summary> |
|
212 |
/// Constructeur |
|
213 |
/// </summary> |
|
214 |
/// <param name="element">PolémicElement</param> |
|
215 |
public PolemicElementVM(PolemicElement element) |
|
216 |
:base() |
|
217 |
{ |
|
218 |
_element = element; |
|
219 |
TimerIn = _element.TimerIn; |
|
220 |
TimerOut = _element.TimerOut; |
|
221 |
Title = _element.Title; |
|
222 |
Description = _element.Description; |
|
223 |
Tags = _element.Tags; |
|
224 |
Chapter = _element.Chapter; |
|
225 |
DisplayTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); |
|
226 |
DisplayTimer.Tick += new EventHandler(myDispatcherTimer_Tick); |
|
227 |
} |
|
228 |
|
|
229 |
/// <summary> |
|
230 |
/// Lors d'un Tick,c'est à dire, lors d'un appuie long sur un élément |
|
231 |
/// </summary> |
|
232 |
/// <param name="sender"></param> |
|
233 |
/// <param name="e"></param> |
|
234 |
void myDispatcherTimer_Tick(object sender, EventArgs e) |
|
235 |
{ |
|
236 |
DisplayTimer.Stop(); |
|
237 |
Commands.PolemicElement.ElementSelected.Execute(_selectedCoord, _element); |
|
238 |
} |
|
239 |
||
240 |
|
|
241 |
public override void MenuableUserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
242 |
{ |
|
243 |
||
244 |
_selectedCoord = e; |
|
245 |
Commands.PolemicElement.SelectPolemicElement.Execute(_element); |
|
246 |
DisplayTimer.Start(); |
|
247 |
|
|
248 |
||
249 |
} |
|
250 |
public override void MenuableUserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
251 |
{ |
|
252 |
DisplayTimer.Stop(); |
|
253 |
Commands.ContextualBinderLayer.EndBind.Execute(Type, _element); |
|
254 |
||
255 |
} |
|
256 |
public override void MenuableUserControl_MouseLeave(object sender, MouseEventArgs e) |
|
257 |
{ |
|
258 |
Commands.ContextualBinderLayer.UnSelectBind.Execute(); |
|
259 |
} |
|
260 |
public override void MenuableUserControl_MouseEnter(object sender, MouseEventArgs e) |
|
261 |
{ |
|
262 |
Commands.ContextualBinderLayer.SelectBind.Execute(Type, _element); |
|
263 |
} |
|
264 |
|
|
265 |
} |
|
266 |
||
267 |
} |