33 public event EventHandler DragStarted; |
33 public event EventHandler DragStarted; |
34 public event EventHandler DragCompleted; |
34 public event EventHandler DragCompleted; |
35 public event EventHandler TimerTick; |
35 public event EventHandler TimerTick; |
36 |
36 |
37 private double totalmilliseconds; |
37 private double totalmilliseconds; |
38 |
38 |
39 private List<Annotation> AnnotList = new List<Annotation>(); |
39 private List<Annotation> AnnotList = new List<Annotation>(); |
40 private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item |
40 private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item |
41 private CuttingViewModel CuttingVM; |
41 private CuttingViewModel CuttingVM; |
42 private Boolean AnnotWaiting = false; |
42 private Boolean AnnotWaiting = false; |
43 private float AnnotTcBegin; |
43 private float AnnotTcBegin; |
44 private UInt32 IntColor; |
44 private Color CurrentColor; |
45 |
45 |
46 private AnnotationViewModel canceledAnnotationVM; |
46 private AnnotationViewModel canceledAnnotationVM; |
47 |
47 |
48 #region Properties |
48 #region Properties |
49 |
49 |
112 totalmilliseconds = totalmillisecondsPar; |
112 totalmilliseconds = totalmillisecondsPar; |
113 slider.Maximum = totalmilliseconds; |
113 slider.Maximum = totalmilliseconds; |
114 // When the timeline is resized, we catch the resize event to define TimelineView's good scale |
114 // When the timeline is resized, we catch the resize event to define TimelineView's good scale |
115 this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
115 this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
116 |
116 |
117 // TEMP FOR DATA BINDING |
117 |
|
118 tv.listview.PreviewContactDown += listview_PreviewContactDown; |
|
119 SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); |
|
120 |
|
121 UserControlTimeLine_SizeChanged(null, null); |
|
122 |
|
123 slider_ContactTapGesture(this, null); |
|
124 |
|
125 } |
|
126 |
|
127 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
|
128 { |
|
129 // When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. |
|
130 Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
|
131 //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS |
|
132 tv.RenderTransform = new ScaleTransform(futurScale,1); |
|
133 //tv.Width = this.ActualWidth - 30; |
|
134 |
|
135 } |
|
136 |
|
137 #region Timer |
|
138 public void initTimer(Color col, Cutting cutPar) |
|
139 { |
|
140 timer = new DispatcherTimer(); |
|
141 timer.Interval = new TimeSpan(0, 0, 0, 0, 100); |
|
142 timer.Tick += new EventHandler(timer_Tick); |
|
143 |
|
144 CurrentColor = col; |
|
145 |
|
146 // DATA BINDING from the cutting sent in parameter (initialised before by the userPanel with the global project) |
118 AnnotList = new List<Annotation>(); |
147 AnnotList = new List<Annotation>(); |
119 AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", IntColor)); |
148 AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", CurrentColor)); |
120 //AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2")); |
149 //AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2")); |
121 //AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3")); |
150 //AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3")); |
122 //AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4")); |
151 //AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4")); |
123 //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); |
152 //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); |
124 Cutting cut = new Cutting("titre de cutting", AnnotList); |
153 cutPar = new Cutting("titre de cutting", AnnotList); |
125 CuttingVM = new CuttingViewModel(cut, AnnotWidth); |
154 CuttingVM = new CuttingViewModel(cutPar, AnnotWidth); |
126 tv.DataContext = CuttingVM; |
155 tv.DataContext = CuttingVM; |
127 |
156 |
128 tv.listview.PreviewContactDown += listview_PreviewContactDown; |
|
129 SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); |
|
130 |
|
131 UserControlTimeLine_SizeChanged(null, null); |
|
132 |
|
133 slider_ContactTapGesture(this, null); |
|
134 |
|
135 |
|
136 } |
|
137 |
|
138 void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
|
139 { |
|
140 // When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. |
|
141 Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
|
142 //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS |
|
143 tv.RenderTransform = new ScaleTransform(futurScale,1); |
|
144 //Console.WriteLine("futurScale = " + futurScale); |
|
145 |
|
146 } |
|
147 |
|
148 #region Timer |
|
149 public void initTimer(UInt32 intColorPar) |
|
150 { |
|
151 timer = new DispatcherTimer(); |
|
152 timer.Interval = new TimeSpan(0, 0, 0, 0, 100); |
|
153 timer.Tick += new EventHandler(timer_Tick); |
|
154 |
|
155 IntColor = intColorPar; |
|
156 } |
157 } |
157 |
158 |
158 public void timerStart() |
159 public void timerStart() |
159 { |
160 { |
160 if (timer != null) |
161 if (timer != null) |
327 } |
329 } |
328 |
330 |
329 if (annotOk == true) |
331 if (annotOk == true) |
330 { |
332 { |
331 AnnotList.RemoveAt(AnnotList.Count - 1); |
333 AnnotList.RemoveAt(AnnotList.Count - 1); |
332 AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), IntColor)); |
334 AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), CurrentColor)); |
333 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
335 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
334 //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
336 //Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
335 tv.DataContext = null; |
337 tv.DataContext = null; |
336 tv.DataContext = CuttingVM; |
338 tv.DataContext = CuttingVM; |
337 AnnotWaiting = false; |
339 AnnotWaiting = false; |
338 } |
340 } |
339 } |
341 } |
340 } |
342 } |
341 |
|
342 |
343 |
343 private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
344 private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
344 { |
345 { |
345 FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
346 FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
346 SurfaceListBoxItem draggedElement = null; |
347 SurfaceListBoxItem draggedElement = null; |
405 e.Handled = startDragOkay; |
406 e.Handled = startDragOkay; |
406 } |
407 } |
407 |
408 |
408 private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) |
409 private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) |
409 { |
410 { |
410 Console.WriteLine("onDragCanceled = " + sender + ", ((ContentControl)e.Cursor.Visual).Content = " + ((ContentControl)e.Cursor.Visual).Content); |
|
411 // We check if the annotation is well one of the current annotations |
411 // We check if the annotation is well one of the current annotations |
412 if (CuttingVM != null) |
412 if (CuttingVM != null) |
413 { |
413 { |
414 // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView |
414 // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView |
415 canceledAnnotationVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; |
415 canceledAnnotationVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; |