author | cavaliet |
Thu, 12 Nov 2009 16:15:19 +0100 | |
changeset 192 | 11083c390ce4 |
parent 190 | 619ca3ae13c7 |
child 194 | d96cd2bce653 |
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; |
|
143 | 8 |
using System.Windows.Input; |
10 | 9 |
using System.Windows.Media; |
10 |
using System.Windows.Media.Animation; |
|
11 |
using System.Windows.Navigation; |
|
34 | 12 |
using System.Windows.Controls.Primitives; |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
13 |
using Microsoft.Surface.Presentation; |
34 | 14 |
using Microsoft.Surface.Presentation.Controls; |
15 |
using System.Windows.Threading; |
|
10 | 16 |
|
69 | 17 |
using FingersDance.Data; |
18 |
using FingersDance.ViewModels; |
|
143 | 19 |
using FingersDance.Views; |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
20 |
using FingersDance.Control.Close; |
69 | 21 |
|
10 | 22 |
namespace FingersDance.Control.TimeLine |
23 |
{ |
|
24 |
public partial class UserControlTimeLine |
|
34 | 25 |
{ |
26 |
||
27 |
#region Variables |
|
28 |
private DispatcherTimer timer; |
|
29 |
private bool isDragging = false; |
|
30 |
private bool finishedDragging = false; |
|
31 |
#endregion |
|
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
32 |
|
34 | 33 |
public event EventHandler DragStarted; |
34 |
public event EventHandler DragCompleted; |
|
35 |
public event EventHandler TimerTick; |
|
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
160
diff
changeset
|
36 |
//SAR |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
160
diff
changeset
|
37 |
public event EventHandler OnSuccessAnnotation; |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
160
diff
changeset
|
38 |
//ENDSAR |
34 | 39 |
|
124 | 40 |
private double totalmilliseconds; |
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
41 |
|
166
33c2e634df13
update drag and drop for dragged annotation to be well displayed and avoid DnD problems
cavaliet
parents:
162
diff
changeset
|
42 |
private float AnnotWidth = 850 + 15; // The surfaceListBox adds 15 pixels between each item |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
43 |
private Cutting cut; |
143 | 44 |
private Boolean AnnotWaiting = false; |
45 |
private float AnnotTcBegin; |
|
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
46 |
private Color CurrentColor; |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
47 |
|
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
48 |
private AnnotationViewModel canceledAnnotationVM; |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
49 |
|
34 | 50 |
#region Properties |
51 |
||
52 |
public SurfaceSlider Slider |
|
10 | 53 |
{ |
34 | 54 |
get |
55 |
{ |
|
56 |
return slider; |
|
10 | 57 |
} |
34 | 58 |
set |
59 |
{ |
|
60 |
slider = value; |
|
10 | 61 |
} |
62 |
} |
|
63 |
|
|
34 | 64 |
public bool IsDragging |
65 |
{ |
|
66 |
get |
|
67 |
{ |
|
68 |
return isDragging; |
|
69 |
} |
|
70 |
set |
|
71 |
{ |
|
72 |
isDragging = value; |
|
73 |
} |
|
74 |
} |
|
75 |
||
76 |
public bool FinishedDragging |
|
77 |
{ |
|
78 |
get |
|
79 |
{ |
|
80 |
return finishedDragging; |
|
81 |
} |
|
82 |
set |
|
83 |
{ |
|
84 |
finishedDragging = value; |
|
85 |
} |
|
86 |
} |
|
87 |
||
88 |
public DispatcherTimer Timer |
|
89 |
{ |
|
90 |
get |
|
91 |
{ |
|
92 |
return timer; |
|
93 |
} |
|
94 |
set |
|
95 |
{ |
|
96 |
timer = value; |
|
97 |
} |
|
98 |
} |
|
99 |
#endregion |
|
100 |
||
101 |
||
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
102 |
#region Constructors |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
103 |
|
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
104 |
public UserControlTimeLine() |
143 | 105 |
{ |
10 | 106 |
this.InitializeComponent(); |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
107 |
|
10 | 108 |
// Insert code required on object creation below this point. |
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
109 |
|
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
110 |
} |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
111 |
#endregion |
10 | 112 |
|
124 | 113 |
public void initslider(double totalmillisecondsPar) |
34 | 114 |
{ |
124 | 115 |
totalmilliseconds = totalmillisecondsPar; |
34 | 116 |
slider.Maximum = totalmilliseconds; |
124 | 117 |
// When the timeline is resized, we catch the resize event to define TimelineView's good scale |
118 |
this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
|
167
206f07a8d887
Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents:
166
diff
changeset
|
119 |
|
143 | 120 |
tv.listview.PreviewContactDown += listview_PreviewContactDown; |
121 |
SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled); |
|
122 |
||
123 |
UserControlTimeLine_SizeChanged(null, null); |
|
124 |
||
125 |
slider_ContactTapGesture(this, null); |
|
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. |
|
167
206f07a8d887
Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents:
166
diff
changeset
|
132 |
tv.ScaleX = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
133 |
//tv.Width = this.ActualWidth - 30; |
124 | 134 |
|
135 |
} |
|
136 |
||
34 | 137 |
#region Timer |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
138 |
public void initTimer(Color col, Cutting cutPar) |
34 | 139 |
{ |
140 |
timer = new DispatcherTimer(); |
|
141 |
timer.Interval = new TimeSpan(0, 0, 0, 0, 100); |
|
142 |
timer.Tick += new EventHandler(timer_Tick); |
|
150
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
143 |
|
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
144 |
CurrentColor = col; |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
145 |
|
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
146 |
// DATA BINDING from the cutting sent in parameter (initialised before by the userPanel with the global project) |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
147 |
cut = cutPar; |
192
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
148 |
//cut.AnnotList = new List<Annotation>(); |
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
149 |
//cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), 0, 10, "Axe Cam 1", CurrentColor)); |
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
150 |
//cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), 100 - (1 * AnnotWidth), 70, "Mvt Cam 2")); |
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
151 |
//cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), 200 - (2 * AnnotWidth), 50, "Saut 3")); |
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
152 |
//cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), 100 - (3 * AnnotWidth), 20, "Saut 4")); |
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
153 |
//cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), 120 - (4 * AnnotWidth), 50, "Saut 5")); |
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
154 |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
155 |
tv.DataContext = new CuttingViewModel(cut, AnnotWidth); |
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
156 |
|
34 | 157 |
} |
158 |
||
159 |
public void timerStart() |
|
160 |
{ |
|
161 |
if (timer != null) |
|
162 |
timer.Start(); |
|
163 |
} |
|
164 |
void timer_Tick(object sender, EventArgs e) |
|
10 | 165 |
{ |
34 | 166 |
OnTimerTick(); |
167 |
if (!isDragging) |
|
168 |
{ |
|
169 |
//slider.Value = media.Position.TotalMilliseconds; |
|
170 |
} |
|
171 |
if (finishedDragging) |
|
172 |
{ |
|
173 |
//int SliderValue = (int)slider.Value; |
|
174 |
//TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue); |
|
175 |
// media.Position = ts; |
|
176 |
// media.Play(); |
|
177 |
// isDragging = false; |
|
178 |
//finishedDragging = false; |
|
179 |
} |
|
180 |
} |
|
181 |
protected virtual void OnTimerTick() |
|
182 |
{ |
|
183 |
if (TimerTick != null) |
|
184 |
TimerTick(this, new EventArgs()); |
|
10 | 185 |
} |
34 | 186 |
|
187 |
#endregion |
|
188 |
||
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
189 |
#region SliderDrag |
143 | 190 |
private void sliderPosition_DragStarted(object sender, DragStartedEventArgs e) |
34 | 191 |
{ |
192 |
isDragging = true; |
|
193 |
OnDragStarted(); |
|
194 |
// media.Pause(); |
|
195 |
} |
|
196 |
protected virtual void OnDragStarted() |
|
197 |
{ |
|
198 |
if (DragStarted != null) |
|
199 |
DragStarted(this, new EventArgs()); |
|
200 |
} |
|
201 |
||
143 | 202 |
private void sliderPosition_DragCompleted(object sender, DragCompletedEventArgs e) |
34 | 203 |
{ |
204 |
finishedDragging = true; |
|
205 |
OnDragCompleted(); |
|
206 |
} |
|
207 |
protected virtual void OnDragCompleted() |
|
208 |
{ |
|
209 |
if (DragCompleted != null) |
|
210 |
DragCompleted(this, new EventArgs()); |
|
211 |
} |
|
212 |
||
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
213 |
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
|
214 |
{ |
143 | 215 |
//startOrEndAnnotation(); |
216 |
} |
|
160
e940ca798fe3
Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents:
150
diff
changeset
|
217 |
#endregion |
143 | 218 |
|
168
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
219 |
public void thumbRotation(bool isplaying) |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
220 |
{ |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
221 |
//Templateslider.Style.Setters["Template"] |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
222 |
if(isplaying) |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
223 |
slider.Style = FindResource("FingersDance.Control.Slider") as Style; |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
224 |
else |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
225 |
slider.Style = FindResource("SurfaceSliderStylePause") as Style; |
d70ee2002f75
Thumb Timeline Rotation and Debug Closing Panels
ARIAS Santiago
parents:
162
diff
changeset
|
226 |
} |
143 | 227 |
public Boolean isAnnotationAccepted(AnnotationViewModel avm) |
228 |
{ |
|
229 |
Boolean annotOk = true; |
|
230 |
// We check if the annotation's begin and end timecodes allow a new annotation creation |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
231 |
if (cut != null && AnnotWaiting == false) |
143 | 232 |
{ |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
233 |
foreach (Annotation a in cut.AnnotList) |
143 | 234 |
{ |
235 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
|
236 |
// Check begin TC |
|
237 |
if (a.TcBegin <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur)) |
|
238 |
{ |
|
239 |
annotOk = false; |
|
240 |
} |
|
241 |
// Check end tc and if the new annotation will not cover any other |
|
242 |
float endTC = avm.TcBegin + avm.Dur; |
|
243 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
|
244 |
if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC)) |
|
245 |
{ |
|
246 |
annotOk = false; |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
else |
|
251 |
{ |
|
252 |
annotOk = false; |
|
253 |
} |
|
254 |
return annotOk; |
|
255 |
||
75
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
256 |
} |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
257 |
|
143 | 258 |
public void addAnnotation(AnnotationViewModel avm) |
75
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
259 |
{ |
143 | 260 |
//Console.WriteLine("addAnnotation = " + avm.TcBegin + ", " + avm.Dur + ", " + avm.GestureType); |
261 |
Boolean annotOk = true; |
|
262 |
// We check if the annotation's begin and end timecodes allow a new annotation creation |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
263 |
if (cut != null && AnnotWaiting == false) |
143 | 264 |
{ |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
265 |
foreach (Annotation a in cut.AnnotList) |
143 | 266 |
{ |
267 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
|
268 |
// Check begin TC |
|
269 |
if (a.TcBegin <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur)) |
|
270 |
{ |
|
271 |
annotOk = false; |
|
272 |
} |
|
273 |
// Check end tc and if the new annotation will not cover any other |
|
274 |
float endTC = avm.TcBegin + avm.Dur; |
|
275 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
|
276 |
if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC)) |
|
277 |
{ |
|
278 |
annotOk = false; |
|
279 |
} |
|
280 |
} |
|
281 |
// If everything's fine, we create the new one |
|
282 |
if (annotOk == true) |
|
283 |
{ |
|
192
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
284 |
cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), avm.TcBegin, avm.Dur, avm.GestureType, avm.Color)); |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
285 |
tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX); |
143 | 286 |
AnnotWaiting = false; |
287 |
} |
|
288 |
||
289 |
} |
|
162
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
160
diff
changeset
|
290 |
//Raise Event to display Annotation in all Openned UserPanels |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
160
diff
changeset
|
291 |
if (annotOk) |
0b9f989bcb37
Display annotations in all opened UserPanels with the user's color
sarias
parents:
160
diff
changeset
|
292 |
OnSuccessAnnotation(this, new EventArgs()); |
143 | 293 |
|
294 |
} |
|
295 |
||
296 |
public void startOrEndAnnotation() |
|
297 |
{ |
|
298 |
Boolean annotOk = true; |
|
299 |
// We open a new annotation |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
300 |
if (cut != null && AnnotWaiting == false) |
124 | 301 |
{ |
143 | 302 |
AnnotTcBegin = (float)slider.Value / 1000; |
303 |
||
304 |
// First we check if the new annotation will not cover any |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
305 |
foreach (Annotation a in cut.AnnotList) |
143 | 306 |
{ |
307 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
|
308 |
if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur)) |
|
309 |
{ |
|
310 |
annotOk = false; |
|
311 |
} |
|
312 |
} |
|
313 |
// if not, we mark the beginning |
|
314 |
if (annotOk == true) |
|
315 |
{ |
|
192
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
316 |
cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, 0, cut.AnnotList.Count.ToString(), CurrentColor)); |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
317 |
tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX); |
143 | 318 |
AnnotWaiting = true; |
319 |
} |
|
320 |
} |
|
321 |
// We close the current opened annotation... |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
322 |
else if (cut != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin)) |
143 | 323 |
{ |
324 |
// ... by setting setting the good beginning and the good duration |
|
325 |
float currentTC = (float)slider.Value / 1000; |
|
326 |
float currentDuration = currentTC - AnnotTcBegin; |
|
327 |
||
328 |
// First we check if the new annotation will not cover any (AnnotTcBegin was already checked) |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
329 |
foreach (Annotation a in cut.AnnotList) |
143 | 330 |
{ |
331 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
|
332 |
if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC)) |
|
333 |
{ |
|
334 |
annotOk = false; |
|
335 |
} |
|
336 |
} |
|
337 |
||
338 |
if (annotOk == true) |
|
339 |
{ |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
340 |
cut.AnnotList.RemoveAt(cut.AnnotList.Count - 1); |
192
11083c390ce4
Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents:
190
diff
changeset
|
341 |
cut.AnnotList.Add(new Annotation("s_" + System.Guid.NewGuid(), AnnotTcBegin, currentDuration, cut.AnnotList.Count.ToString(), CurrentColor)); |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
342 |
//Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + cut.AnnotList.Count + ", res = " + (AnnotTcBegin - (cut.AnnotList.Count * AnnotWidth))); |
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
343 |
tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX); |
143 | 344 |
AnnotWaiting = false; |
345 |
} |
|
167
206f07a8d887
Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents:
166
diff
changeset
|
346 |
//Raise Event to display Annotation in all Openned UserPanels |
206f07a8d887
Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents:
166
diff
changeset
|
347 |
if (annotOk) |
206f07a8d887
Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents:
166
diff
changeset
|
348 |
OnSuccessAnnotation(this, new EventArgs()); |
124 | 349 |
} |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
350 |
} |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
351 |
|
143 | 352 |
private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
353 |
{ |
|
354 |
FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
|
355 |
SurfaceListBoxItem draggedElement = null; |
|
356 |
||
357 |
// Find the touched SurfaceListBoxItem object. |
|
358 |
while (draggedElement == null && findSource != null) |
|
359 |
{ |
|
360 |
if ((draggedElement = findSource as SurfaceListBoxItem) == null) |
|
361 |
{ |
|
362 |
findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement; |
|
363 |
} |
|
364 |
} |
|
365 |
||
366 |
if (draggedElement == null) |
|
367 |
{ |
|
368 |
return; |
|
369 |
} |
|
370 |
||
371 |
// Create the cursor visual. |
|
372 |
ContentControl cursorVisual = new ContentControl() |
|
373 |
{ |
|
374 |
Content = new TimelineAnnotationView() |
|
375 |
{ |
|
376 |
DataContext = findSource.DataContext |
|
377 |
} |
|
378 |
}; |
|
379 |
||
380 |
// We apply the current scale to the dragged annotation |
|
166
33c2e634df13
update drag and drop for dragged annotation to be well displayed and avoid DnD problems
cavaliet
parents:
162
diff
changeset
|
381 |
((TimelineAnnotationView)cursorVisual.Content).RenderTransform = new TransformGroup(); |
33c2e634df13
update drag and drop for dragged annotation to be well displayed and avoid DnD problems
cavaliet
parents:
162
diff
changeset
|
382 |
((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(tv.listview.RenderTransform); |
167
206f07a8d887
Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents:
166
diff
changeset
|
383 |
// We apply a translate transform to place correctly the dragged annotation |
166
33c2e634df13
update drag and drop for dragged annotation to be well displayed and avoid DnD problems
cavaliet
parents:
162
diff
changeset
|
384 |
((TransformGroup)((TimelineAnnotationView)cursorVisual.Content).RenderTransform).Children.Add(new TranslateTransform((AnnotWidth / 2) * (1 - ((ScaleTransform)tv.listview.RenderTransform).ScaleX), 0)); |
33c2e634df13
update drag and drop for dragged annotation to be well displayed and avoid DnD problems
cavaliet
parents:
162
diff
changeset
|
385 |
|
143 | 386 |
// Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
387 |
//SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
|
388 |
||
389 |
// Create a list of input devices. Add the contacts that |
|
390 |
// are currently captured within the dragged element and |
|
391 |
// the current contact (if it isn't already in the list). |
|
392 |
List<InputDevice> devices = new List<InputDevice>(); |
|
393 |
devices.Add(e.Contact); |
|
394 |
foreach (Contact contact in draggedElement.ContactsCapturedWithin) |
|
395 |
{ |
|
396 |
if (contact != e.Contact) |
|
397 |
{ |
|
398 |
devices.Add(contact); |
|
399 |
} |
|
400 |
} |
|
401 |
||
402 |
// Get the drag source object |
|
403 |
ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement); |
|
404 |
||
405 |
bool startDragOkay = |
|
406 |
SurfaceDragDrop.BeginDragDrop( |
|
407 |
dragSource, // The SurfaceListBox object that the cursor is dragged out from. |
|
408 |
draggedElement, // The SurfaceListBoxItem object that is dragged from the drag source. |
|
409 |
cursorVisual, // The visual element of the cursor. |
|
410 |
draggedElement.DataContext, // The data associated with the cursor. |
|
411 |
devices, // The input devices that start dragging the cursor. |
|
412 |
DragDropEffects.Move); // The allowed drag-and-drop effects of the operation. |
|
413 |
||
414 |
// If the drag began successfully, set e.Handled to true. |
|
415 |
// Otherwise SurfaceListBoxItem captures the contact |
|
416 |
// and causes the drag operation to fail. |
|
417 |
e.Handled = startDragOkay; |
|
418 |
} |
|
419 |
||
420 |
private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) |
|
421 |
{ |
|
422 |
// We check if the annotation is well one of the current annotations |
|
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
423 |
if (cut != null) |
143 | 424 |
{ |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
425 |
// e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
426 |
canceledAnnotationVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
427 |
confirmCancelPopup.Visibility = Visibility.Visible; |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
428 |
} |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
429 |
} |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
430 |
|
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
431 |
private void confirmCancelPopup_ConfirmYesOrNo(object sender, ConfirmEventArgs e) |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
432 |
{ |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
433 |
// We check if the annotation is well one of the current annotations |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
434 |
if (cut != null && canceledAnnotationVM != null && e.Confirmed == true) |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
435 |
{ |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
436 |
foreach (Annotation a in cut.AnnotList) |
143 | 437 |
{ |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
438 |
// Check begin TcBegin, duration and gesture type |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
439 |
if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) |
143 | 440 |
{ |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
441 |
// We found the good annotation so we can remove it |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
442 |
cut.AnnotList.Remove(a); |
143 | 443 |
// We redisplay the timeline |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
444 |
//CuttingVM.setListFromAnnotations(cut.AnnotList, AnnotWidth, tv.ScaleX); |
143 | 445 |
tv.DataContext = null; |
190
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
446 |
tv.DataContext = new CuttingViewModel(cut, AnnotWidth, tv.ScaleX); |
619ca3ae13c7
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents:
186
diff
changeset
|
447 |
// We close the popup and return as soon as we removed the annotation to avoid an error on cut.AnnotList, which is just modified |
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
448 |
confirmCancelPopup.Visibility = Visibility.Hidden; |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
449 |
canceledAnnotationVM = null; |
143 | 450 |
return; |
451 |
} |
|
452 |
} |
|
453 |
} |
|
140
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
454 |
confirmCancelPopup.Visibility = Visibility.Hidden; |
fc7c12f9da30
Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event.
cavaliet
parents:
136
diff
changeset
|
455 |
canceledAnnotationVM = null; |
143 | 456 |
} |
457 |
||
458 |
||
10 | 459 |
} |
460 |
} |