38 //ENDSAR |
38 //ENDSAR |
39 |
39 |
40 private double totalmilliseconds; |
40 private double totalmilliseconds; |
41 |
41 |
42 private List<Annotation> AnnotList = new List<Annotation>(); |
42 private List<Annotation> AnnotList = new List<Annotation>(); |
43 private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item |
43 private float AnnotWidth = 850 + 15; // The surfaceListBox adds 15 pixels between each item |
44 private CuttingViewModel CuttingVM; |
44 private CuttingViewModel CuttingVM; |
45 private Boolean AnnotWaiting = false; |
45 private Boolean AnnotWaiting = false; |
46 private float AnnotTcBegin; |
46 private float AnnotTcBegin; |
47 private Color CurrentColor; |
47 private Color CurrentColor; |
48 |
48 |
115 { |
115 { |
116 totalmilliseconds = totalmillisecondsPar; |
116 totalmilliseconds = totalmillisecondsPar; |
117 slider.Maximum = totalmilliseconds; |
117 slider.Maximum = totalmilliseconds; |
118 // When the timeline is resized, we catch the resize event to define TimelineView's good scale |
118 // When the timeline is resized, we catch the resize event to define TimelineView's good scale |
119 this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
119 this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
120 |
120 |
121 |
|
122 tv.listview.PreviewContactDown += listview_PreviewContactDown; |
121 tv.listview.PreviewContactDown += listview_PreviewContactDown; |
123 SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); |
122 SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); |
124 |
123 |
125 UserControlTimeLine_SizeChanged(null, null); |
124 UserControlTimeLine_SizeChanged(null, null); |
126 |
125 |
129 } |
128 } |
130 |
129 |
131 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
130 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
132 { |
131 { |
133 // When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. |
132 // When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. |
134 Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
133 tv.ScaleX = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
135 //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS |
|
136 tv.RenderTransform = new ScaleTransform(futurScale,1); |
|
137 //tv.Width = this.ActualWidth - 30; |
134 //tv.Width = this.ActualWidth - 30; |
138 |
135 |
139 } |
136 } |
140 |
137 |
141 #region Timer |
138 #region Timer |
284 } |
281 } |
285 // If everything's fine, we create the new one |
282 // If everything's fine, we create the new one |
286 if (annotOk == true) |
283 if (annotOk == true) |
287 { |
284 { |
288 AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color)); |
285 AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color)); |
289 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
286 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
290 tv.DataContext = null; |
287 tv.DataContext = null; |
291 tv.DataContext = CuttingVM; |
288 tv.DataContext = CuttingVM; |
292 AnnotWaiting = false; |
289 AnnotWaiting = false; |
293 } |
290 } |
294 |
291 |
318 } |
315 } |
319 // if not, we mark the beginning |
316 // if not, we mark the beginning |
320 if (annotOk == true) |
317 if (annotOk == true) |
321 { |
318 { |
322 AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor)); |
319 AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor)); |
323 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
320 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
324 tv.DataContext = null; |
321 tv.DataContext = null; |
325 tv.DataContext = CuttingVM; |
322 tv.DataContext = CuttingVM; |
326 AnnotWaiting = true; |
323 AnnotWaiting = true; |
327 } |
324 } |
328 } |
325 } |
345 |
342 |
346 if (annotOk == true) |
343 if (annotOk == true) |
347 { |
344 { |
348 AnnotList.RemoveAt(AnnotList.Count - 1); |
345 AnnotList.RemoveAt(AnnotList.Count - 1); |
349 AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor)); |
346 AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor)); |
350 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
347 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
351 //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
348 //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
352 tv.DataContext = null; |
349 tv.DataContext = null; |
353 tv.DataContext = CuttingVM; |
350 tv.DataContext = CuttingVM; |
354 AnnotWaiting = false; |
351 AnnotWaiting = false; |
355 } |
352 } |
356 } |
353 //Raise Event to display Annotation in all Openned UserPanels |
357 //Raise Event to display Annotation in all Openned UserPanels |
354 if (annotOk) |
358 if(annotOk) |
355 OnSuccessAnnotation(this, new EventArgs()); |
359 OnSuccessAnnotation(this, new EventArgs()); |
356 } |
360 } |
357 } |
361 |
358 |
362 private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
359 private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
363 { |
360 { |
364 FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
361 FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
386 DataContext = findSource.DataContext |
383 DataContext = findSource.DataContext |
387 } |
384 } |
388 }; |
385 }; |
389 |
386 |
390 // We apply the current scale to the dragged annotation |
387 // We apply the current scale to the dragged annotation |
391 ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform; |
388 ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = new TransformGroup(); |
392 |
389 ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(tv.listview.RenderTransform); |
|
390 // We apply a translate transform to place correctly the dragged annotation |
|
391 ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(new TranslateTransform((AnnotWidth / 2) * (1 - ((ScaleTransform)tv.listview.RenderTransform).ScaleX), 0)); |
|
392 |
393 // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
393 // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
394 //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
394 //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
395 |
395 |
396 // Create a list of input devices. Add the contacts that |
396 // Create a list of input devices. Add the contacts that |
397 // are currently captured within the dragged element and |
397 // are currently captured within the dragged element and |
446 if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) |
446 if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) |
447 { |
447 { |
448 // We found the good annotation so we can remove it |
448 // We found the good annotation so we can remove it |
449 AnnotList.Remove(a); |
449 AnnotList.Remove(a); |
450 // We redisplay the timeline |
450 // We redisplay the timeline |
451 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
451 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
452 tv.DataContext = null; |
452 tv.DataContext = null; |
453 tv.DataContext = CuttingVM; |
453 tv.DataContext = CuttingVM; |
454 // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified |
454 // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified |
455 confirmCancelPopup.Visibility = Visibility.Hidden; |
455 confirmCancelPopup.Visibility = Visibility.Hidden; |
456 canceledAnnotationVM = null; |
456 canceledAnnotationVM = null; |