12 using Microsoft.Surface.Presentation.Controls; |
12 using Microsoft.Surface.Presentation.Controls; |
13 using System.Windows.Threading; |
13 using System.Windows.Threading; |
14 |
14 |
15 using FingersDance.Data; |
15 using FingersDance.Data; |
16 using FingersDance.ViewModels; |
16 using FingersDance.ViewModels; |
|
17 using FingersDance.Views; |
17 |
18 |
18 namespace FingersDance.Control.TimeLine |
19 namespace FingersDance.Control.TimeLine |
19 { |
20 { |
20 public partial class UserControlTimeLine |
21 public partial class UserControlTimeLine |
21 { |
22 { |
116 //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); |
117 //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); |
117 Cutting cut = new Cutting("titre de cutting", AnnotList); |
118 Cutting cut = new Cutting("titre de cutting", AnnotList); |
118 CuttingVM = new CuttingViewModel(cut, AnnotWidth); |
119 CuttingVM = new CuttingViewModel(cut, AnnotWidth); |
119 tv.DataContext = CuttingVM; |
120 tv.DataContext = CuttingVM; |
120 |
121 |
121 slider_ContactTapGesture(this,null); |
122 UserControlTimeLine_SizeChanged(null, null); |
|
123 |
|
124 slider_ContactTapGesture(this, null); |
|
125 |
122 |
126 |
123 } |
127 } |
124 |
128 |
125 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
129 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
126 { |
130 { |
180 { |
184 { |
181 if (DragStarted != null) |
185 if (DragStarted != null) |
182 DragStarted(this, new EventArgs()); |
186 DragStarted(this, new EventArgs()); |
183 } |
187 } |
184 |
188 |
185 private void sliderPosition_DragCompleted( |
189 private void sliderPosition_DragCompleted(object sender, DragCompletedEventArgs e) |
186 object sender, DragCompletedEventArgs e) |
|
187 { |
190 { |
188 finishedDragging = true; |
191 finishedDragging = true; |
189 OnDragCompleted(); |
192 OnDragCompleted(); |
190 } |
193 } |
191 protected virtual void OnDragCompleted() |
194 protected virtual void OnDragCompleted() |
194 DragCompleted(this, new EventArgs()); |
197 DragCompleted(this, new EventArgs()); |
195 } |
198 } |
196 |
199 |
197 private void slider_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
200 private void slider_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
198 { |
201 { |
199 //addAnnotation(); |
202 //startOrEndAnnotation(); |
200 } |
203 } |
201 |
204 |
202 public void addAnnotation() |
205 public void addAnnotation(AnnotationViewModel avm) |
|
206 { |
|
207 Console.WriteLine("addAnnotation = " + avm.TcBegin + ", " + avm.Dur + ", " + avm.GestureType); |
|
208 Boolean annotOk = true; |
|
209 // We check if the annotation's begin and end timecodes allow a new annotation creation |
|
210 if (CuttingVM != null && AnnotWaiting == false) |
|
211 { |
|
212 foreach (Annotation a in AnnotList) |
|
213 { |
|
214 //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
|
215 // Check begin TC |
|
216 if (a.TcBegin <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur)) |
|
217 { |
|
218 annotOk = false; |
|
219 } |
|
220 // Check end tc and if the new annotation will not cover any other |
|
221 float endTC = avm.TcBegin + avm.Dur; |
|
222 //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
|
223 if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC)) |
|
224 { |
|
225 annotOk = false; |
|
226 } |
|
227 } |
|
228 // If everything's fine, we create the new one |
|
229 if (annotOk == true) |
|
230 { |
|
231 AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType)); |
|
232 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
|
233 tv.DataContext = null; |
|
234 tv.DataContext = CuttingVM; |
|
235 AnnotWaiting = false; |
|
236 } |
|
237 |
|
238 } |
|
239 |
|
240 } |
|
241 |
|
242 public void startOrEndAnnotation() |
203 { |
243 { |
204 Boolean annotOk = true; |
244 Boolean annotOk = true; |
205 // We open a new annotation |
245 // We open a new annotation |
206 if (CuttingVM != null && AnnotWaiting == false) |
246 if (CuttingVM != null && AnnotWaiting == false) |
207 { |
247 { |