author | cavaliet |
Wed, 07 Oct 2009 17:16:46 +0200 | |
changeset 135 | 84b3bf5ee3d2 |
parent 130 | 192da585bee5 |
child 136 | 8b513df1b446 |
permissions | -rw-r--r-- |
10 | 1 |
using System; |
69 | 2 |
using System.Collections.Generic; |
10 | 3 |
using System.IO; |
4 |
using System.Net; |
|
5 |
using System.Windows; |
|
6 |
using System.Windows.Controls; |
|
7 |
using System.Windows.Data; |
|
8 |
using System.Windows.Media; |
|
9 |
using System.Windows.Media.Animation; |
|
10 |
using System.Windows.Navigation; |
|
34 | 11 |
using System.Windows.Controls.Primitives; |
12 |
using Microsoft.Surface.Presentation.Controls; |
|
13 |
using System.Windows.Threading; |
|
10 | 14 |
|
69 | 15 |
using FingersDance.Data; |
16 |
using FingersDance.ViewModels; |
|
135
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
17 |
using FingersDance.Views; |
69 | 18 |
|
10 | 19 |
namespace FingersDance.Control.TimeLine |
20 |
{ |
|
21 |
public partial class UserControlTimeLine |
|
34 | 22 |
{ |
23 |
||
24 |
#region Variables |
|
25 |
private DispatcherTimer timer; |
|
26 |
private bool isDragging = false; |
|
27 |
private bool finishedDragging = false; |
|
28 |
#endregion |
|
29 |
||
30 |
public event EventHandler DragStarted; |
|
31 |
public event EventHandler DragCompleted; |
|
32 |
public event EventHandler TimerTick; |
|
33 |
||
124 | 34 |
private double totalmilliseconds; |
35 |
||
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
36 |
private List<Annotation> AnnotList = new List<Annotation>(); |
128
90c29e979ef4
Drag and drop of annotations from timeline, first step
cavaliet
parents:
125
diff
changeset
|
37 |
private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
38 |
private CuttingViewModel CuttingVM; |
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
39 |
private Boolean AnnotWaiting = false; |
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
40 |
private float AnnotTcBegin; |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
41 |
|
34 | 42 |
#region Properties |
43 |
||
44 |
public SurfaceSlider Slider |
|
10 | 45 |
{ |
34 | 46 |
get |
47 |
{ |
|
48 |
return slider; |
|
10 | 49 |
} |
34 | 50 |
set |
51 |
{ |
|
52 |
slider = value; |
|
10 | 53 |
} |
54 |
} |
|
55 |
|
|
34 | 56 |
public bool IsDragging |
57 |
{ |
|
58 |
get |
|
59 |
{ |
|
60 |
return isDragging; |
|
61 |
} |
|
62 |
set |
|
63 |
{ |
|
64 |
isDragging = value; |
|
65 |
} |
|
66 |
} |
|
67 |
||
68 |
public bool FinishedDragging |
|
69 |
{ |
|
70 |
get |
|
71 |
{ |
|
72 |
return finishedDragging; |
|
73 |
} |
|
74 |
set |
|
75 |
{ |
|
76 |
finishedDragging = value; |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
public DispatcherTimer Timer |
|
81 |
{ |
|
82 |
get |
|
83 |
{ |
|
84 |
return timer; |
|
85 |
} |
|
86 |
set |
|
87 |
{ |
|
88 |
timer = value; |
|
89 |
} |
|
90 |
} |
|
91 |
#endregion |
|
92 |
|
|
93 |
||
94 |
||
95 |
|
|
10 | 96 |
public UserControlTimeLine() |
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
97 |
{ |
10 | 98 |
this.InitializeComponent(); |
99 |
||
100 |
// Insert code required on object creation below this point. |
|
69 | 101 |
|
10 | 102 |
} |
103 |
||
124 | 104 |
public void initslider(double totalmillisecondsPar) |
34 | 105 |
{ |
124 | 106 |
totalmilliseconds = totalmillisecondsPar; |
34 | 107 |
slider.Maximum = totalmilliseconds; |
124 | 108 |
// When the timeline is resized, we catch the resize event to define TimelineView's good scale |
109 |
this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
|
69 | 110 |
|
111 |
// TEMP FOR DATA BINDING |
|
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
112 |
AnnotList = new List<Annotation>(); |
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
113 |
AnnotList.Add(new Annotation(0, 10, "Axe Cam 1")); |
128
90c29e979ef4
Drag and drop of annotations from timeline, first step
cavaliet
parents:
125
diff
changeset
|
114 |
//AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2")); |
90c29e979ef4
Drag and drop of annotations from timeline, first step
cavaliet
parents:
125
diff
changeset
|
115 |
//AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3")); |
90c29e979ef4
Drag and drop of annotations from timeline, first step
cavaliet
parents:
125
diff
changeset
|
116 |
//AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4")); |
90c29e979ef4
Drag and drop of annotations from timeline, first step
cavaliet
parents:
125
diff
changeset
|
117 |
//AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
118 |
Cutting cut = new Cutting("titre de cutting", AnnotList); |
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
119 |
CuttingVM = new CuttingViewModel(cut, AnnotWidth); |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
120 |
tv.DataContext = CuttingVM; |
69 | 121 |
|
135
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
122 |
UserControlTimeLine_SizeChanged(null, null); |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
123 |
|
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
124 |
slider_ContactTapGesture(this, null); |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
125 |
|
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
126 |
|
34 | 127 |
} |
128 |
||
124 | 129 |
void UserControlTimeLine_SizeChanged(object sender, SizeChangedEventArgs e) |
130 |
{ |
|
131 |
// When scaleX = 1, 1 second = 1 pixel. To calculate the new scale, we take the real width in account. |
|
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
132 |
Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
133 |
//Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS |
124 | 134 |
tv.RenderTransform = new ScaleTransform(futurScale,1); |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
135 |
//Console.WriteLine("futurScale = " + futurScale); |
124 | 136 |
|
137 |
} |
|
138 |
||
34 | 139 |
#region Timer |
140 |
public void initTimer() |
|
141 |
{ |
|
142 |
timer = new DispatcherTimer(); |
|
143 |
timer.Interval = new TimeSpan(0, 0, 0, 0, 100); |
|
144 |
timer.Tick += new EventHandler(timer_Tick); |
|
145 |
} |
|
146 |
||
147 |
public void timerStart() |
|
148 |
{ |
|
149 |
if (timer != null) |
|
150 |
timer.Start(); |
|
151 |
} |
|
152 |
void timer_Tick(object sender, EventArgs e) |
|
10 | 153 |
{ |
34 | 154 |
OnTimerTick(); |
155 |
if (!isDragging) |
|
156 |
{ |
|
157 |
//slider.Value = media.Position.TotalMilliseconds; |
|
158 |
} |
|
159 |
if (finishedDragging) |
|
160 |
{ |
|
161 |
//int SliderValue = (int)slider.Value; |
|
162 |
//TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue); |
|
163 |
// media.Position = ts; |
|
164 |
// media.Play(); |
|
165 |
// isDragging = false; |
|
166 |
//finishedDragging = false; |
|
167 |
} |
|
168 |
} |
|
169 |
protected virtual void OnTimerTick() |
|
170 |
{ |
|
171 |
if (TimerTick != null) |
|
172 |
TimerTick(this, new EventArgs()); |
|
10 | 173 |
} |
34 | 174 |
|
175 |
#endregion |
|
176 |
||
128
90c29e979ef4
Drag and drop of annotations from timeline, first step
cavaliet
parents:
125
diff
changeset
|
177 |
private void sliderPosition_DragStarted(object sender, DragStartedEventArgs e) |
34 | 178 |
{ |
179 |
isDragging = true; |
|
180 |
OnDragStarted(); |
|
181 |
// media.Pause(); |
|
182 |
} |
|
183 |
protected virtual void OnDragStarted() |
|
184 |
{ |
|
185 |
if (DragStarted != null) |
|
186 |
DragStarted(this, new EventArgs()); |
|
187 |
} |
|
188 |
||
135
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
189 |
private void sliderPosition_DragCompleted(object sender, DragCompletedEventArgs e) |
34 | 190 |
{ |
191 |
finishedDragging = true; |
|
192 |
OnDragCompleted(); |
|
193 |
} |
|
194 |
protected virtual void OnDragCompleted() |
|
195 |
{ |
|
196 |
if (DragCompleted != null) |
|
197 |
DragCompleted(this, new EventArgs()); |
|
198 |
} |
|
199 |
||
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
200 |
private void slider_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
201 |
{ |
135
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
202 |
//startOrEndAnnotation(); |
75
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
203 |
} |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
204 |
|
135
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
205 |
public void addAnnotation(AnnotationViewModel avm) |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
206 |
{ |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
207 |
Console.WriteLine("addAnnotation = " + avm.TcBegin + ", " + avm.Dur + ", " + avm.GestureType); |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
208 |
Boolean annotOk = true; |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
209 |
// We check if the annotation's begin and end timecodes allow a new annotation creation |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
210 |
if (CuttingVM != null && AnnotWaiting == false) |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
211 |
{ |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
212 |
foreach (Annotation a in AnnotList) |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
213 |
{ |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
214 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
215 |
// Check begin TC |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
216 |
if (a.TcBegin <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur)) |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
217 |
{ |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
218 |
annotOk = false; |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
219 |
} |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
220 |
// Check end tc and if the new annotation will not cover any other |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
221 |
float endTC = avm.TcBegin + avm.Dur; |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
222 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
223 |
if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC)) |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
224 |
{ |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
225 |
annotOk = false; |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
226 |
} |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
227 |
} |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
228 |
// If everything's fine, we create the new one |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
229 |
if (annotOk == true) |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
230 |
{ |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
231 |
AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType)); |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
232 |
CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
233 |
tv.DataContext = null; |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
234 |
tv.DataContext = CuttingVM; |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
235 |
AnnotWaiting = false; |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
236 |
} |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
237 |
|
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
238 |
} |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
239 |
|
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
240 |
} |
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
241 |
|
84b3bf5ee3d2
First step of drag and drop annotation from a timeline to an other player
cavaliet
parents:
130
diff
changeset
|
242 |
public void startOrEndAnnotation() |
75
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
243 |
{ |
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
244 |
Boolean annotOk = true; |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
245 |
// We open a new annotation |
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
246 |
if (CuttingVM != null && AnnotWaiting == false) |
124 | 247 |
{ |
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
248 |
AnnotTcBegin = (float)slider.Value / 1000; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
249 |
|
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
250 |
// First we check if the new annotation will not cover any |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
251 |
foreach (Annotation a in AnnotList) |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
252 |
{ |
130
192da585bee5
debug for adding annotations on timeline. Data AnnotationViewModel and TimelineAnnotationView changed to keep annotation TcBegin from visual margin.
cavaliet
parents:
129
diff
changeset
|
253 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
254 |
if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur)) |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
255 |
{ |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
256 |
annotOk = false; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
257 |
} |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
258 |
} |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
259 |
// if not, we mark the beginning |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
260 |
if (annotOk == true) |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
261 |
{ |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
262 |
AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString())); |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
263 |
CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
264 |
//Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
265 |
tv.DataContext = null; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
266 |
tv.DataContext = CuttingVM; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
267 |
AnnotWaiting = true; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
268 |
} |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
269 |
} |
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
270 |
// We close the current opened annotation... |
130
192da585bee5
debug for adding annotations on timeline. Data AnnotationViewModel and TimelineAnnotationView changed to keep annotation TcBegin from visual margin.
cavaliet
parents:
129
diff
changeset
|
271 |
else if (CuttingVM != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin)) |
125
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
272 |
{ |
fab494cd9da7
Now to define an annotation we define its begin then its end.
cavaliet
parents:
124
diff
changeset
|
273 |
// ... by setting setting the good beginning and the good duration |
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
274 |
float currentTC = (float)slider.Value / 1000; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
275 |
float currentDuration = currentTC - AnnotTcBegin; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
276 |
|
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
277 |
// First we check if the new annotation will not cover any (AnnotTcBegin was already checked) |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
278 |
foreach (Annotation a in AnnotList) |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
279 |
{ |
130
192da585bee5
debug for adding annotations on timeline. Data AnnotationViewModel and TimelineAnnotationView changed to keep annotation TcBegin from visual margin.
cavaliet
parents:
129
diff
changeset
|
280 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
129
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
281 |
if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC)) |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
282 |
{ |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
283 |
annotOk = false; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
284 |
} |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
285 |
} |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
286 |
|
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
287 |
if (annotOk == true) |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
288 |
{ |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
289 |
AnnotList.RemoveAt(AnnotList.Count - 1); |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
290 |
AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString())); |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
291 |
CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
292 |
//Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
293 |
tv.DataContext = null; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
294 |
tv.DataContext = CuttingVM; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
295 |
AnnotWaiting = false; |
1f37ef03ebee
scale change improved and now annotations can not recover any of them.
cavaliet
parents:
128
diff
changeset
|
296 |
} |
124 | 297 |
} |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
298 |
} |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
299 |
|
10 | 300 |
} |
301 |
} |