author | cavaliet |
Wed, 25 Nov 2009 10:49:44 +0100 | |
changeset 231 | 4eff6b0c9215 |
parent 226 | c0661ecf943e |
permissions | -rw-r--r-- |
3 | 1 |
using System; |
2 |
using System.IO; |
|
3 |
using System.Net; |
|
4 |
using System.Windows; |
|
5 |
using System.Windows.Controls; |
|
6 |
using System.Windows.Data; |
|
7 |
using System.Windows.Media; |
|
8 |
using System.Windows.Media.Imaging; |
|
9 |
using System.Windows.Media.Animation; |
|
10 |
using System.Windows.Navigation; |
|
11 |
using System.ComponentModel; |
|
49 | 12 |
using System.Reflection; |
143 | 13 |
using System.Collections.Generic; |
14 |
||
15 |
using Microsoft.Surface.Presentation; |
|
16 |
using Microsoft.Surface.Presentation.Controls; |
|
156
e16c8c913c65
Color Factory et application des couleurs au pivot
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
146
diff
changeset
|
17 |
using FingersDance.Factory; |
143 | 18 |
using FingersDance.Actions; |
19 |
using FingersDance.Control.TimeLine; |
|
20 |
using FingersDance.Views; |
|
21 |
using FingersDance.ViewModels; |
|
174 | 22 |
using GestureControl; |
3 | 23 |
|
24 |
namespace FingersDance.Control.Player |
|
25 |
{ |
|
26 |
public partial class UserControlPlayer |
|
27 |
{ |
|
34 | 28 |
#region Variables |
29 |
private bool isPlaying = false; |
|
30 |
#endregion |
|
3 | 31 |
|
34 | 32 |
public event EventHandler PlayerOpened; |
165 | 33 |
public event EventHandler PlayerStopOrPause; |
195
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
34 |
public event EventHandler NewGestureRegognized; |
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
35 |
|
215
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
36 |
double _Time = 0; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
37 |
double _StartAnnotation = -1; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
38 |
List<Gesture> _Gestures = new List<Gesture>(); |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
39 |
|
193 | 40 |
public double Time |
41 |
{ |
|
42 |
get { return gestureControl.time; } |
|
215
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
43 |
set |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
44 |
{ |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
45 |
gestureControl.time = value; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
46 |
_Time = value; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
47 |
} |
193 | 48 |
} |
49 |
||
170 | 50 |
#region constructors |
119 | 51 |
public UserControlPlayer() |
52 |
{ |
|
53 |
this.InitializeComponent(); |
|
121
32611257e99f
Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
119
diff
changeset
|
54 |
MediaElementVideo.LoadedBehavior = MediaState.Manual; |
32611257e99f
Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
119
diff
changeset
|
55 |
MediaElementVideo.UnloadedBehavior = MediaState.Manual; |
173
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
56 |
//SAR |
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
57 |
//Control User Info |
224 | 58 |
usercontrolInfoUser.LabelSession.Content = "";//"Seance Test"; |
59 |
usercontrolInfoUser.LabelUser.Content = "";//"User Test"; |
|
215
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
60 |
MediaElementVideo.Volume = 0; |
119 | 61 |
} |
174 | 62 |
|
170 | 63 |
#endregion |
64 |
||
34 | 65 |
#region Properties |
66 |
public double TotalMilliseconds |
|
67 |
{ |
|
68 |
get |
|
69 |
{ |
|
70 |
return MediaElementVideo.NaturalDuration.TimeSpan.TotalMilliseconds; |
|
71 |
} |
|
72 |
} |
|
73 |
public MediaElement Player |
|
74 |
{ |
|
75 |
get |
|
76 |
{ |
|
77 |
return MediaElementVideo; |
|
78 |
} |
|
79 |
set |
|
80 |
{ |
|
81 |
MediaElementVideo= value; |
|
82 |
} |
|
83 |
} |
|
84 |
#endregion |
|
85 |
||
86 |
||
87 |
#region Methodes |
|
3 | 88 |
|
119 | 89 |
public void initPlayer(string path) |
90 |
{ |
|
91 |
//init player |
|
92 |
isPlaying = false; |
|
121
32611257e99f
Link PLayer - SessionInput
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
119
diff
changeset
|
93 |
MediaElementVideo.Source = new Uri(path); |
119 | 94 |
MediaElementVideo.ScrubbingEnabled = true; |
95 |
} |
|
96 |
||
34 | 97 |
public void playerPause() |
98 |
{ |
|
99 |
MediaElementVideo.Pause(); |
|
165 | 100 |
if (PlayerStopOrPause != null) |
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
101 |
PlayerStopOrPause(false, new EventArgs()); |
34 | 102 |
} |
103 |
public void playerPlay() |
|
104 |
{ |
|
105 |
MediaElementVideo.Play(); |
|
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
106 |
if (PlayerStopOrPause != null) |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
107 |
PlayerStopOrPause(true, new EventArgs()); |
34 | 108 |
} |
109 |
public void playerStop() |
|
110 |
{ |
|
111 |
MediaElementVideo.Stop(); |
|
165 | 112 |
if (PlayerStopOrPause != null) |
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
113 |
PlayerStopOrPause(false, new EventArgs()); |
34 | 114 |
} |
188
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
115 |
|
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
116 |
public void setSound(double val) |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
117 |
{ |
199 | 118 |
if ((val < 1) && (val > 0)) |
119 |
MediaElementVideo.Volume = val; |
|
200 | 120 |
else if (val >= 1) |
188
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
121 |
MediaElementVideo.Volume = 1; |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
122 |
else |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
123 |
MediaElementVideo.Volume = 0; |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
124 |
} |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
125 |
|
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
126 |
public void setMute(bool b) |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
127 |
{ |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
128 |
if (b) MediaElementVideo.IsMuted = true; |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
129 |
else MediaElementVideo.IsMuted = false; |
e642ad0c366b
Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened
ARIAS Santiago
parents:
174
diff
changeset
|
130 |
} |
34 | 131 |
#endregion |
132 |
||
173
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
133 |
#region GestureEvents |
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
134 |
|
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
135 |
public void GestureDetected(object sender, GestureControl.GestureRoutedEventArgs e) |
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
136 |
{ |
195
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
137 |
try |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
138 |
{ |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
139 |
/* |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
140 |
* e.Gesture.Name = Nom de la gesture |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
141 |
* e.Gesture.Start = Valeur de la timeline au début de l'annotation |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
142 |
* e.Gesture.End = Valeur de la timeline à la fin de l'annotation |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
143 |
* |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
144 |
*/ |
226
c0661ecf943e
debug visual bug for "too far" annotation and simplify gesture handler in player.
cavaliet
parents:
224
diff
changeset
|
145 |
usercontrolInfoUser.LabelSession.Content = e.Gesture.Name + " !"; |
c0661ecf943e
debug visual bug for "too far" annotation and simplify gesture handler in player.
cavaliet
parents:
224
diff
changeset
|
146 |
if(e.Gesture.Name.Equals("PLAY-PAUSE")){ |
c0661ecf943e
debug visual bug for "too far" annotation and simplify gesture handler in player.
cavaliet
parents:
224
diff
changeset
|
147 |
ButtonPlayPause_ContactDown(null, null); |
195
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
148 |
} |
226
c0661ecf943e
debug visual bug for "too far" annotation and simplify gesture handler in player.
cavaliet
parents:
224
diff
changeset
|
149 |
else |
215
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
150 |
_Gestures.Add(e.Gesture); |
173
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
151 |
} |
195
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
152 |
catch { } |
173
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
153 |
} |
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
154 |
#endregion |
e99fe78cd168
Gesture Control Integration in the Control Player
ARIAS Santiago
parents:
170
diff
changeset
|
155 |
|
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
156 |
#region Button Simple Player Actions |
3 | 157 |
private void ButtonPlayPause_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
158 |
{ |
|
34 | 159 |
if (!isPlaying)//Play |
3 | 160 |
{ |
34 | 161 |
isPlaying = true; |
3 | 162 |
try |
163 |
{ |
|
164 |
MediaElementVideo.Play(); |
|
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
165 |
if (PlayerStopOrPause != null) |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
166 |
PlayerStopOrPause(true, new EventArgs()); |
3 | 167 |
} |
168 |
catch (Exception ex) { } |
|
169 |
} |
|
170 |
else//Pause |
|
171 |
{ |
|
34 | 172 |
isPlaying = false; |
3 | 173 |
try |
174 |
{ |
|
175 |
MediaElementVideo.Pause(); |
|
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
176 |
if (PlayerStopOrPause != null) |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
177 |
PlayerStopOrPause(false, new EventArgs()); |
3 | 178 |
} |
34 | 179 |
catch (Exception exx) { } |
3 | 180 |
} |
181 |
||
182 |
} |
|
183 |
||
193 | 184 |
/* |
185 |
|
|
3 | 186 |
private void ButtonPlayPause_Click(object sender, RoutedEventArgs e) |
187 |
{ |
|
34 | 188 |
if (!isPlaying)//Play |
3 | 189 |
{ |
34 | 190 |
isPlaying = true; |
3 | 191 |
try |
192 |
{ |
|
193 |
MediaElementVideo.Play(); |
|
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
194 |
if (PlayerStopOrPause != null) |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
195 |
PlayerStopOrPause(true, new EventArgs()); |
3 | 196 |
} |
34 | 197 |
catch (Exception ex) { } |
198 |
||
3 | 199 |
} |
200 |
else//Pause |
|
201 |
{ |
|
34 | 202 |
isPlaying = false; |
3 | 203 |
try |
204 |
{ |
|
205 |
MediaElementVideo.Pause(); |
|
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
206 |
if (PlayerStopOrPause != null) |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
165
diff
changeset
|
207 |
PlayerStopOrPause(false, new EventArgs()); |
3 | 208 |
} |
34 | 209 |
catch (Exception exx) { } |
210 |
//ButtonPlayPause.Background = FindResource("[Skin_1]_Play_button_xaml") as Brush; |
|
211 |
} |
|
212 |
} |
|
213 |
||
214 |
private void ButtonFastForward_Click(object sender, RoutedEventArgs e) |
|
215 |
{ |
|
216 |
if (MediaElementVideo.SpeedRatio <= 3) |
|
217 |
MediaElementVideo.SpeedRatio += 1; |
|
218 |
} |
|
219 |
||
220 |
private void ButtonFastForward_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
|
221 |
{ |
|
222 |
if (MediaElementVideo.SpeedRatio <= 3) |
|
223 |
MediaElementVideo.SpeedRatio += 1; |
|
224 |
} |
|
225 |
||
226 |
private void ButtonRewind_Click(object sender, RoutedEventArgs e) |
|
227 |
{ |
|
228 |
//TimeSpan ts = new TimeSpan(0, 0, 0, 0); |
|
229 |
if (MediaElementVideo.SpeedRatio > 1) |
|
230 |
{ |
|
231 |
MediaElementVideo.SpeedRatio -= 1; |
|
3 | 232 |
} |
34 | 233 |
else |
234 |
{ |
|
235 |
MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5)); |
|
236 |
} |
|
237 |
} |
|
238 |
||
239 |
private void ButtonRewind_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
|
240 |
{ |
|
241 |
||
242 |
//TimeSpan ts = new TimeSpan(0, 0, 0,0); |
|
243 |
if (MediaElementVideo.SpeedRatio > 1) |
|
244 |
{ |
|
245 |
MediaElementVideo.SpeedRatio -= 1; |
|
246 |
} |
|
247 |
else |
|
248 |
{ |
|
249 |
MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5)); |
|
250 |
} |
|
251 |
} |
|
193 | 252 |
|
253 |
*/ |
|
34 | 254 |
|
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
255 |
#endregion |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
256 |
|
34 | 257 |
private void MediaElementVideo_MediaOpened(object sender, RoutedEventArgs e) |
258 |
{ |
|
259 |
OnPlayerOpened(); |
|
260 |
} |
|
261 |
protected virtual void OnPlayerOpened() |
|
262 |
{ |
|
263 |
if(PlayerOpened!=null) |
|
264 |
PlayerOpened(this, new EventArgs()); |
|
3 | 265 |
} |
143 | 266 |
|
267 |
private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e) |
|
268 |
{ |
|
269 |
//Console.WriteLine("Enter"); |
|
270 |
||
271 |
// If the TimelineAnnotationView comes from a user control different from the current one, |
|
272 |
// it means that we want to add the annotation to the current list. |
|
273 |
// So we check if the dragged annotation can be dragged or if it will recover any existant annotation (in this case it will not be accepted) |
|
274 |
// e.Cursor.DragSource is the SurfaceListBox where the drag started from |
|
275 |
SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource; |
|
276 |
// We get the instance of the UserControlSyncSource |
|
277 |
UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent; |
|
278 |
// and its UserControlTimeline |
|
279 |
UserControlTimeLine tl = (UserControlTimeLine)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0]; |
|
280 |
if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl) |
|
281 |
{ |
|
282 |
// e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView |
|
283 |
AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; |
|
193 | 284 |
//Play_Pause_area.Background = tl.isAnnotationAccepted(annotationDataVM) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red); |
143 | 285 |
} |
286 |
else |
|
287 |
{ |
|
193 | 288 |
//Play_Pause_area.Background = new SolidColorBrush(Colors.White); |
143 | 289 |
} |
193 | 290 |
//Play_Pause_area.Opacity = 0.3; |
143 | 291 |
|
292 |
} |
|
293 |
||
294 |
private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e) |
|
295 |
{ |
|
296 |
//Console.WriteLine("Leave"); |
|
193 | 297 |
//Play_Pause_area.Opacity = 0; |
143 | 298 |
} |
299 |
||
300 |
private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e) |
|
301 |
{ |
|
302 |
//Console.WriteLine("Over"); |
|
303 |
} |
|
304 |
||
305 |
private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e) |
|
306 |
{ |
|
307 |
//Console.WriteLine("Drop"); |
|
193 | 308 |
//Play_Pause_area.Opacity = 0; |
143 | 309 |
// e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView |
310 |
AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; |
|
311 |
int nbSeconds = (int)annotationDataVM.TcBegin; |
|
312 |
int nbMilliSec = (int)((annotationDataVM.TcBegin * 1000)%1000); |
|
313 |
MediaElementVideo.Position = new TimeSpan(0, 0, 0, nbSeconds, nbMilliSec); |
|
314 |
||
315 |
||
316 |
// If the TimelineAnnotationView comes from a user control different from the current one, |
|
317 |
// it means that we want to add the annotation to the current list. |
|
318 |
// So we generate the ActionAddAnnotation |
|
319 |
// e.Cursor.DragSource is the SurfaceListBox where the drag started from |
|
320 |
SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource; |
|
321 |
// We get the instance of the UserControlSyncSource |
|
322 |
UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent; |
|
323 |
// and its UserControlTimeline |
|
324 |
UserControl tl = (UserControl)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0]; |
|
325 |
if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl) |
|
326 |
{ |
|
327 |
// Now we build the action arguments : a list holding the timeline and the annotation view models |
|
328 |
List<Object> actionsArgs = new List<Object>(); |
|
329 |
actionsArgs.Add(tl); |
|
330 |
actionsArgs.Add(annotationDataVM); |
|
331 |
||
332 |
ActionGenerator ag = new ActionGenerator(); |
|
333 |
ActionBase ab = ag.GetAction("ActionAddAnnotation", actionsArgs); |
|
334 |
if (ab != null) |
|
335 |
ab.Execute(); |
|
336 |
} |
|
337 |
||
338 |
} |
|
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
339 |
|
195
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
340 |
public void ApplyColor(List<Color> colors) |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
341 |
{ |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
342 |
try |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
343 |
{ |
197
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
344 |
Object o = null; |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
345 |
rect1.Fill = new SolidColorBrush(Colors.Black); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
346 |
o = rect1.FindResource("Rect1Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
347 |
rect1.BeginStoryboard((Storyboard)o); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
348 |
rect2.Fill = new SolidColorBrush(Colors.Black); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
349 |
o = rect2.FindResource("Rect2Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
350 |
rect2.BeginStoryboard((Storyboard)o); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
351 |
rect3.Fill = new SolidColorBrush(Colors.Black); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
352 |
o = rect3.FindResource("Rect3Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
353 |
rect3.BeginStoryboard((Storyboard)o); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
354 |
rect4.Fill = new SolidColorBrush(Colors.Black); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
355 |
o = rect4.FindResource("Rect4Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
356 |
rect4.BeginStoryboard((Storyboard)o); |
195
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
357 |
for (int i = 1; i <= colors.Count; i++) |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
358 |
displayStackPanelAnnotations(i, new SolidColorBrush(colors[i - 1])); |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
359 |
} |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
360 |
catch { } |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
361 |
} |
48b3139bb182
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
193
diff
changeset
|
362 |
|
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
363 |
//This function Sets a brush in a specific rectangle of the StackPanelAnnotation |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
364 |
public void displayStackPanelAnnotations(int id, Brush brushAnnotation) |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
365 |
{ |
197
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
366 |
Object o = null; |
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
367 |
switch (id) |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
368 |
{ |
163 | 369 |
case 1: |
370 |
rect1.Fill = brushAnnotation; |
|
197
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
371 |
o = rect1.FindResource("Rect1Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
372 |
rect1.BeginStoryboard((Storyboard)o); |
163 | 373 |
break; |
197
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
374 |
case 2: rect2.Fill = brushAnnotation; |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
375 |
o = rect2.FindResource("Rect2Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
376 |
rect2.BeginStoryboard((Storyboard)o); |
163 | 377 |
break; |
197
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
378 |
case 3: rect3.Fill = brushAnnotation; |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
379 |
o = rect3.FindResource("Rect3Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
380 |
rect3.BeginStoryboard((Storyboard)o); |
163 | 381 |
break; |
197
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
382 |
case 4: rect4.Fill = brushAnnotation; |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
383 |
o = rect4.FindResource("Rect4Annotation"); |
3455e574e096
Dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
195
diff
changeset
|
384 |
rect4.BeginStoryboard((Storyboard)o); |
163 | 385 |
break; |
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
386 |
default: break; |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
387 |
} |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
156
diff
changeset
|
388 |
} |
215
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
389 |
|
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
390 |
private void AnnotationButton_ContactLeave(object sender, ContactEventArgs e) |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
391 |
{ |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
392 |
try |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
393 |
{ |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
394 |
if (_StartAnnotation == -1) |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
395 |
{ |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
396 |
_StartAnnotation = _Time; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
397 |
AnnotationLabel.Content = "Annotation en cours"; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
398 |
} |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
399 |
else |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
400 |
{ |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
401 |
if (NewGestureRegognized != null) |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
402 |
NewGestureRegognized(null, new GestureEventArg(_Gestures, _StartAnnotation, _Time)); |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
403 |
_Gestures.Clear(); |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
404 |
_StartAnnotation = -1; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
405 |
AnnotationLabel.Content = ""; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
406 |
AnnotationButton.IsChecked = false; |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
407 |
} |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
408 |
} |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
409 |
catch { } |
d13dbcf861d7
BOutton annotation, tag volume, chargement des annotations sauvegardées du projet dans le dictionnaire de données
PAMPHILE Jonathan <pamphile@efrei.fr>
parents:
200
diff
changeset
|
410 |
} |
3 | 411 |
} |
412 |
} |