28 |
28 |
29 public event EventHandler DragStarted; |
29 public event EventHandler DragStarted; |
30 public event EventHandler DragCompleted; |
30 public event EventHandler DragCompleted; |
31 public event EventHandler TimerTick; |
31 public event EventHandler TimerTick; |
32 |
32 |
|
33 private double totalmilliseconds; |
|
34 |
33 private List<Annotation> annotList = new List<Annotation>(); |
35 private List<Annotation> annotList = new List<Annotation>(); |
34 private float annotWidth = 40; |
36 private float annotWidth = 40+1; |
35 private CuttingViewModel cutvm; |
37 private CuttingViewModel cutvm; |
36 private int numAnnot = 1; |
|
37 |
38 |
38 #region Properties |
39 #region Properties |
39 |
40 |
40 public SurfaceSlider Slider |
41 public SurfaceSlider Slider |
41 { |
42 { |
95 |
96 |
96 // Insert code required on object creation below this point. |
97 // Insert code required on object creation below this point. |
97 |
98 |
98 } |
99 } |
99 |
100 |
100 public void initslider(double totalmilliseconds) |
101 public void initslider(double totalmillisecondsPar) |
101 { |
102 { |
|
103 totalmilliseconds = totalmillisecondsPar; |
102 slider.Maximum = totalmilliseconds; |
104 slider.Maximum = totalmilliseconds; |
103 |
105 // When the timeline is resized, we catch the resize event to define TimelineView's good scale |
|
106 this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
104 |
107 |
105 // TEMP FOR DATA BINDING |
108 // TEMP FOR DATA BINDING |
106 annotList = new List<Annotation>(); |
109 annotList = new List<Annotation>(); |
107 annotList.Add(new Annotation(0, 10, "Axe Cam 1")); |
110 annotList.Add(new Annotation(0, 10, "Axe Cam 1")); |
108 annotList.Add(new Annotation(20 - (1 * annotWidth), 30, "Mvt Cam 2")); |
111 //annotList.Add(new Annotation(20 - (1 * annotWidth), 30, "Mvt Cam 2")); |
109 annotList.Add(new Annotation(50 - (2 * annotWidth), 60, "Saut 3")); |
112 //annotList.Add(new Annotation(50 - (2 * annotWidth), 60, "Saut 3")); |
110 annotList.Add(new Annotation(100 - (3 * annotWidth), 20, "Saut 4")); |
113 //annotList.Add(new Annotation(100 - (3 * annotWidth), 20, "Saut 4")); |
111 annotList.Add(new Annotation(120 - (4 * annotWidth), 50, "Saut 5")); |
114 //annotList.Add(new Annotation(120 - (4 * annotWidth), 50, "Saut 5")); |
112 Cutting cut = new Cutting("titre de cutting", annotList); |
115 Cutting cut = new Cutting("titre de cutting", annotList); |
113 cutvm = new CuttingViewModel(cut); |
116 cutvm = new CuttingViewModel(cut); |
114 tv.DataContext = cutvm; |
117 tv.DataContext = cutvm; |
115 |
118 |
116 numAnnot = 6; |
|
117 slider_ContactTapGesture(this,null); |
119 slider_ContactTapGesture(this,null); |
118 /* |
120 /* |
119 cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 - (5 * annotWidth), 10, "6"))); |
121 cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 - (5 * annotWidth), 10, "6"))); |
120 tv.DataContext = null; |
122 tv.DataContext = null; |
121 tv.DataContext = cutvm; |
123 tv.DataContext = cutvm; |
122 numAnnot = 7; |
|
123 */ |
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 / (totalmilliseconds / 1000); |
|
131 //Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP |
|
132 tv.RenderTransform = new ScaleTransform(futurScale,1); |
|
133 Console.WriteLine("futurScale = " + futurScale); |
|
134 |
124 } |
135 } |
125 |
136 |
126 #region Timer |
137 #region Timer |
127 public void initTimer() |
138 public void initTimer() |
128 { |
139 { |
191 //addAnnotation(); |
202 //addAnnotation(); |
192 } |
203 } |
193 |
204 |
194 public void addAnnotation() |
205 public void addAnnotation() |
195 { |
206 { |
196 cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 + (numAnnot - 6) * 20 - ((numAnnot - 1) * annotWidth), 10, numAnnot.ToString()))); |
207 if (cutvm!=null) |
197 tv.DataContext = null; |
208 { |
198 tv.DataContext = cutvm; |
209 float currentTimecode = (float)slider.Value / 1000; |
199 numAnnot++; |
210 cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(currentTimecode - (cutvm.AnnotList.Count * annotWidth), 10, cutvm.AnnotList.Count.ToString()))); |
|
211 Console.WriteLine("currentTimecode = " + currentTimecode + ", nb = " + cutvm.AnnotList.Count + ", res = " + (currentTimecode - (cutvm.AnnotList.Count * annotWidth))); |
|
212 tv.DataContext = null; |
|
213 tv.DataContext = cutvm; |
|
214 } |
200 } |
215 } |
201 |
216 |
202 } |
217 } |
203 } |
218 } |