114 { |
114 { |
115 totalmilliseconds = totalmillisecondsPar; |
115 totalmilliseconds = totalmillisecondsPar; |
116 slider.Maximum = totalmilliseconds; |
116 slider.Maximum = totalmilliseconds; |
117 // When the timeline is resized, we catch the resize event to define TimelineView's good scale |
117 // When the timeline is resized, we catch the resize event to define TimelineView's good scale |
118 this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
118 this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
119 |
119 |
120 |
|
121 tv.listview.PreviewContactDown += listview_PreviewContactDown; |
120 tv.listview.PreviewContactDown += listview_PreviewContactDown; |
122 SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); |
121 SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); |
123 |
122 |
124 UserControlTimeLine_SizeChanged(null, null); |
123 UserControlTimeLine_SizeChanged(null, null); |
125 |
124 |
128 } |
127 } |
129 |
128 |
130 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
129 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
131 { |
130 { |
132 // When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. |
131 // When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. |
133 Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
132 tv.ScaleX = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
134 //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS |
|
135 tv.listview.RenderTransform = new ScaleTransform(futurScale,1); |
|
136 //tv.Width = this.ActualWidth - 30; |
133 //tv.Width = this.ActualWidth - 30; |
137 |
134 |
138 } |
135 } |
139 |
136 |
140 #region Timer |
137 #region Timer |
275 } |
272 } |
276 // If everything's fine, we create the new one |
273 // If everything's fine, we create the new one |
277 if (annotOk == true) |
274 if (annotOk == true) |
278 { |
275 { |
279 AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color)); |
276 AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color)); |
280 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
277 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
281 tv.DataContext = null; |
278 tv.DataContext = null; |
282 tv.DataContext = CuttingVM; |
279 tv.DataContext = CuttingVM; |
283 AnnotWaiting = false; |
280 AnnotWaiting = false; |
284 } |
281 } |
285 |
282 |
309 } |
306 } |
310 // if not, we mark the beginning |
307 // if not, we mark the beginning |
311 if (annotOk == true) |
308 if (annotOk == true) |
312 { |
309 { |
313 AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor)); |
310 AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), CurrentColor)); |
314 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
311 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
315 tv.DataContext = null; |
312 tv.DataContext = null; |
316 tv.DataContext = CuttingVM; |
313 tv.DataContext = CuttingVM; |
317 AnnotWaiting = true; |
314 AnnotWaiting = true; |
318 } |
315 } |
319 } |
316 } |
336 |
333 |
337 if (annotOk == true) |
334 if (annotOk == true) |
338 { |
335 { |
339 AnnotList.RemoveAt(AnnotList.Count - 1); |
336 AnnotList.RemoveAt(AnnotList.Count - 1); |
340 AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor)); |
337 AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor)); |
341 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
338 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
342 //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
339 //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
343 tv.DataContext = null; |
340 tv.DataContext = null; |
344 tv.DataContext = CuttingVM; |
341 tv.DataContext = CuttingVM; |
345 AnnotWaiting = false; |
342 AnnotWaiting = false; |
346 } |
343 } |
347 } |
344 //Raise Event to display Annotation in all Openned UserPanels |
348 //Raise Event to display Annotation in all Openned UserPanels |
345 if (annotOk) |
349 if(annotOk) |
346 OnSuccessAnnotation(this, new EventArgs()); |
350 OnSuccessAnnotation(this, new EventArgs()); |
347 } |
351 } |
348 } |
352 |
349 |
353 private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
350 private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
354 { |
351 { |
355 FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
352 FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
379 }; |
376 }; |
380 |
377 |
381 // We apply the current scale to the dragged annotation |
378 // We apply the current scale to the dragged annotation |
382 ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = new TransformGroup(); |
379 ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = new TransformGroup(); |
383 ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(tv.listview.RenderTransform); |
380 ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(tv.listview.RenderTransform); |
384 // We apply a translate translate transform to place correctly the dragged annotation |
381 // We apply a translate transform to place correctly the dragged annotation |
385 ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(new TranslateTransform((AnnotWidth / 2) * (1 - ((ScaleTransform)tv.listview.RenderTransform).ScaleX), 0)); |
382 ((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(new TranslateTransform((AnnotWidth / 2) * (1 - ((ScaleTransform)tv.listview.RenderTransform).ScaleX), 0)); |
386 |
383 |
387 // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
384 // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
388 //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
385 //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
389 |
386 |
440 if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) |
437 if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) |
441 { |
438 { |
442 // We found the good annotation so we can remove it |
439 // We found the good annotation so we can remove it |
443 AnnotList.Remove(a); |
440 AnnotList.Remove(a); |
444 // We redisplay the timeline |
441 // We redisplay the timeline |
445 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
442 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth, tv.ScaleX); |
446 tv.DataContext = null; |
443 tv.DataContext = null; |
447 tv.DataContext = CuttingVM; |
444 tv.DataContext = CuttingVM; |
448 // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified |
445 // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified |
449 confirmCancelPopup.Visibility = Visibility.Hidden; |
446 confirmCancelPopup.Visibility = Visibility.Hidden; |
450 canceledAnnotationVM = null; |
447 canceledAnnotationVM = null; |