1 using System; |
1 using System; |
|
2 using System.Collections.Generic; |
2 using System.IO; |
3 using System.IO; |
3 using System.Net; |
4 using System.Net; |
4 using System.Windows; |
5 using System.Windows; |
5 using System.Windows.Controls; |
6 using System.Windows.Controls; |
6 using System.Windows.Data; |
7 using System.Windows.Data; |
7 using System.Windows.Media; |
8 using System.Windows.Media; |
8 using System.Windows.Media.Animation; |
9 using System.Windows.Media.Animation; |
9 using System.Windows.Navigation; |
10 using System.Windows.Navigation; |
|
11 |
10 using FingersDance.Control.TimeLine; |
12 using FingersDance.Control.TimeLine; |
11 using FingersDance.Data; |
13 using FingersDance.Data; |
|
14 using FingersDance.ViewModels; |
12 using FingersDance.Factory; |
15 using FingersDance.Factory; |
13 using GestureControl; |
16 using GestureControl; |
14 |
17 |
15 namespace FingersDance.Control.SyncSource |
18 namespace FingersDance.Control.SyncSource |
16 { |
19 { |
17 public partial class UserControlSyncSource |
20 public partial class UserControlSyncSource |
18 { |
21 { |
19 #region Variables |
22 #region Variables |
20 public event EventHandler OnSuccessAnnotation; |
23 public event EventHandler OnSuccessAnnotation; |
|
24 |
|
25 private String AnnotationOrSearchMode; |
|
26 private Project searchedProject; |
21 #endregion |
27 #endregion |
22 |
28 |
23 public UserControlSyncSource() |
29 public UserControlSyncSource() |
24 { |
30 { |
25 this.InitializeComponent(); |
31 this.InitializeComponent(); |
26 |
32 |
27 // Insert code required on object creation below this point. |
33 // Insert code required on object creation below this point. |
28 } |
34 } |
29 |
35 |
30 public void Load(string path, Color col, Cutting cut) |
36 public void Load(string path, Color col, Cutting cut, String AnnotOrSearchMode, Project searchedProj) |
31 { |
37 { |
32 this.UserControlPlayer.initPlayer(path); |
38 this.UserControlPlayer.initPlayer(path); |
|
39 AnnotationOrSearchMode = AnnotOrSearchMode; |
|
40 searchedProject = searchedProj; |
33 //Initialisation du Timer |
41 //Initialisation du Timer |
34 UCTimeLine.initTimer(col, cut); |
42 UCTimeLine.initTimer(col, cut); |
35 this.UserControlPlayer.playerPlay(); |
43 UserControlPlayer.playerPlay(); |
36 this.userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation); |
44 userControlTimeLine.OnSuccessAnnotation += new EventHandler(userControlTimeLine_OnSuccessAnnotation); |
37 this.userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded); |
45 userControlTimeLine.AnnotationAdded += new EventHandler(userControlTimeLine_AnnotationAdded); |
38 this.userControlTimeLine.AnnotationRemoved += new EventHandler(userControlTimeLine_AnnotationRemoved); |
46 userControlTimeLine.AnnotationRemoved += new EventHandler(userControlTimeLine_AnnotationRemoved); |
39 this.UserControlPlayer.PlayerStopOrPause += new EventHandler(UserControlPlayer_PlayerStopOrPause); |
47 UserControlPlayer.PlayerStopOrPause += new EventHandler(UserControlPlayer_PlayerStopOrPause); |
40 UserControlPlayer.NewGestureRegognized += new EventHandler(UCTimeLine.UserControlPlayer_NewGestureRegognized); |
48 UserControlPlayer.NewGestureRegognized += new EventHandler(UserControlPlayer_NewGestureRegognized); |
|
49 UCTimeLine.NewGestureRecognized += new EventHandler<NewGestureRecognizedEventArg>(UCTimeLine_NewGestureRecognized); |
41 } |
50 } |
42 |
51 |
43 void userControlTimeLine_AnnotationRemoved(object sender, EventArgs e) |
52 void userControlTimeLine_AnnotationRemoved(object sender, EventArgs e) |
44 { |
53 { |
45 try |
54 try |
149 |
158 |
150 public void PlayerPause() |
159 public void PlayerPause() |
151 { |
160 { |
152 UserControlPlayer.playerPause(); |
161 UserControlPlayer.playerPause(); |
153 } |
162 } |
|
163 |
|
164 |
|
165 public void UserControlPlayer_NewGestureRegognized(object sender, EventArgs e) |
|
166 { |
|
167 try |
|
168 { |
|
169 GestureEventArg grea = (GestureEventArg)e; |
|
170 //Console.WriteLine("Timeline NewGestureRegognized " + grea.Gesture.Name + ", " + grea.Gesture.Start + ", " + grea.Gesture.End); |
|
171 if (AnnotationOrSearchMode == "Annotation") |
|
172 { |
|
173 // If the stroke has been drawed very fast, end and start can be the same, so we add a little length. |
|
174 float dur = (float)(grea.End - grea.Start); |
|
175 if (dur == 0) dur = (float)0.5; |
|
176 foreach (Gesture elt in grea.Gestures) |
|
177 UCTimeLine.addAnnotation((float)grea.Start, dur, elt.Name); |
|
178 } |
|
179 else |
|
180 { |
|
181 // We are in search mode. So we have to get all the searchedProject's annotation which have the wanted gesture |
|
182 List<Annotation> searchedAnnot = new List<Annotation>(); |
|
183 foreach(Cutting cut in searchedProject.Cuttings) |
|
184 { |
|
185 foreach (Annotation annot in cut.AnnotList) |
|
186 { |
|
187 foreach(Gesture gest in grea.Gestures) |
|
188 if (annot.GestureType == gest.Name) |
|
189 { |
|
190 // One of the gesture is enough for the annotation to be added |
|
191 searchedAnnot.Add(annot); |
|
192 break; |
|
193 } |
|
194 } |
|
195 } |
|
196 // The list was built. If the number of found annotations is >0, we send the list to the timeline |
|
197 UCTimeLine.updateAnnotationList(searchedAnnot); |
|
198 } |
|
199 } |
|
200 catch { } |
|
201 } |
|
202 |
|
203 public void searchAnnotations(String gestureName) |
|
204 { |
|
205 // We are in search mode. So we have to get all the searchedProject's annotation which have the wanted gesture |
|
206 List<Annotation> searchedAnnot = new List<Annotation>(); |
|
207 foreach (Cutting cut in searchedProject.Cuttings) |
|
208 { |
|
209 foreach (Annotation annot in cut.AnnotList) |
|
210 { |
|
211 if (annot.GestureType == gestureName) |
|
212 { |
|
213 // One of the gesture is enough for the annotation to be added |
|
214 searchedAnnot.Add(annot); |
|
215 } |
|
216 } |
|
217 } |
|
218 // The list was built. If the number of found annotations is >0, we send the list to the timeline |
|
219 UCTimeLine.updateAnnotationList(searchedAnnot); |
|
220 } |
|
221 |
|
222 void UCTimeLine_NewGestureRecognized(object sender, NewGestureRecognizedEventArg e) |
|
223 { |
|
224 searchAnnotations(e.GestureName); |
|
225 } |
154 } |
226 } |
155 } |
227 } |