author | cavaliet |
Wed, 14 Oct 2009 17:08:43 +0200 | |
changeset 150 | 569925b65604 |
parent 146 | dd8ed4d3beb6 |
child 160 | e940ca798fe3 |
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; |
|
36 |
||
124 | 37 |
private double totalmilliseconds; |
38 |
||
143 | 39 |
private List<Annotation> AnnotList = new List<Annotation>(); |
40 |
private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item |
|
41 |
private CuttingViewModel CuttingVM; |
|
42 |
private Boolean AnnotWaiting = false; |
|
43 |
private float AnnotTcBegin; |
|
150
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
44 |
private UInt32 IntColor; |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
45 |
|
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
|
46 |
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
|
47 |
|
34 | 48 |
#region Properties |
49 |
||
50 |
public SurfaceSlider Slider |
|
10 | 51 |
{ |
34 | 52 |
get |
53 |
{ |
|
54 |
return slider; |
|
10 | 55 |
} |
34 | 56 |
set |
57 |
{ |
|
58 |
slider = value; |
|
10 | 59 |
} |
60 |
} |
|
61 |
|
|
34 | 62 |
public bool IsDragging |
63 |
{ |
|
64 |
get |
|
65 |
{ |
|
66 |
return isDragging; |
|
67 |
} |
|
68 |
set |
|
69 |
{ |
|
70 |
isDragging = value; |
|
71 |
} |
|
72 |
} |
|
73 |
||
74 |
public bool FinishedDragging |
|
75 |
{ |
|
76 |
get |
|
77 |
{ |
|
78 |
return finishedDragging; |
|
79 |
} |
|
80 |
set |
|
81 |
{ |
|
82 |
finishedDragging = value; |
|
83 |
} |
|
84 |
} |
|
85 |
||
86 |
public DispatcherTimer Timer |
|
87 |
{ |
|
88 |
get |
|
89 |
{ |
|
90 |
return timer; |
|
91 |
} |
|
92 |
set |
|
93 |
{ |
|
94 |
timer = value; |
|
95 |
} |
|
96 |
} |
|
97 |
#endregion |
|
98 |
|
|
99 |
||
100 |
||
101 |
|
|
10 | 102 |
public UserControlTimeLine() |
143 | 103 |
{ |
10 | 104 |
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
|
105 |
|
10 | 106 |
// Insert code required on object creation below this point. |
69 | 107 |
|
10 | 108 |
} |
109 |
||
124 | 110 |
public void initslider(double totalmillisecondsPar) |
34 | 111 |
{ |
124 | 112 |
totalmilliseconds = totalmillisecondsPar; |
34 | 113 |
slider.Maximum = totalmilliseconds; |
124 | 114 |
// When the timeline is resized, we catch the resize event to define TimelineView's good scale |
115 |
this.SizeChanged += new SizeChangedEventHandler(UserControlTimeLine_SizeChanged); |
|
69 | 116 |
|
117 |
// TEMP FOR DATA BINDING |
|
143 | 118 |
AnnotList = new List<Annotation>(); |
150
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
119 |
AnnotList.Add(new Annotation(0, 10, "Axe Cam 1", IntColor)); |
143 | 120 |
//AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2")); |
121 |
//AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3")); |
|
122 |
//AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4")); |
|
123 |
//AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); |
|
124 |
Cutting cut = new Cutting("titre de cutting", AnnotList); |
|
125 |
CuttingVM = new CuttingViewModel(cut, AnnotWidth); |
|
126 |
tv.DataContext = CuttingVM; |
|
69 | 127 |
|
143 | 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 |
||
34 | 136 |
} |
137 |
||
124 | 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. |
|
143 | 141 |
Double futurScale = (this.ActualWidth-30) / (totalmilliseconds / 1000); |
142 |
//Double futurScale = this.ActualWidth / ((totalmilliseconds<30000) ? (totalmilliseconds/10) : (totalmilliseconds / 1000)); // TEMP FOR SHORT CONTENTS |
|
124 | 143 |
tv.RenderTransform = new ScaleTransform(futurScale,1); |
143 | 144 |
//Console.WriteLine("futurScale = " + futurScale); |
124 | 145 |
|
146 |
} |
|
147 |
||
34 | 148 |
#region Timer |
150
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
149 |
public void initTimer(UInt32 intColorPar) |
34 | 150 |
{ |
151 |
timer = new DispatcherTimer(); |
|
152 |
timer.Interval = new TimeSpan(0, 0, 0, 0, 100); |
|
153 |
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
|
154 |
|
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
155 |
IntColor = intColorPar; |
34 | 156 |
} |
157 |
||
158 |
public void timerStart() |
|
159 |
{ |
|
160 |
if (timer != null) |
|
161 |
timer.Start(); |
|
162 |
} |
|
163 |
void timer_Tick(object sender, EventArgs e) |
|
10 | 164 |
{ |
34 | 165 |
OnTimerTick(); |
166 |
if (!isDragging) |
|
167 |
{ |
|
168 |
//slider.Value = media.Position.TotalMilliseconds; |
|
169 |
} |
|
170 |
if (finishedDragging) |
|
171 |
{ |
|
172 |
//int SliderValue = (int)slider.Value; |
|
173 |
//TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue); |
|
174 |
// media.Position = ts; |
|
175 |
// media.Play(); |
|
176 |
// isDragging = false; |
|
177 |
//finishedDragging = false; |
|
178 |
} |
|
179 |
} |
|
180 |
protected virtual void OnTimerTick() |
|
181 |
{ |
|
182 |
if (TimerTick != null) |
|
183 |
TimerTick(this, new EventArgs()); |
|
10 | 184 |
} |
34 | 185 |
|
186 |
#endregion |
|
187 |
||
143 | 188 |
private void sliderPosition_DragStarted(object sender, DragStartedEventArgs e) |
34 | 189 |
{ |
190 |
isDragging = true; |
|
191 |
OnDragStarted(); |
|
192 |
// media.Pause(); |
|
193 |
} |
|
194 |
protected virtual void OnDragStarted() |
|
195 |
{ |
|
196 |
if (DragStarted != null) |
|
197 |
DragStarted(this, new EventArgs()); |
|
198 |
} |
|
199 |
||
143 | 200 |
private void sliderPosition_DragCompleted(object sender, DragCompletedEventArgs e) |
34 | 201 |
{ |
202 |
finishedDragging = true; |
|
203 |
OnDragCompleted(); |
|
204 |
} |
|
205 |
protected virtual void OnDragCompleted() |
|
206 |
{ |
|
207 |
if (DragCompleted != null) |
|
208 |
DragCompleted(this, new EventArgs()); |
|
209 |
} |
|
210 |
||
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
211 |
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
|
212 |
{ |
143 | 213 |
//startOrEndAnnotation(); |
214 |
} |
|
215 |
||
216 |
public Boolean isAnnotationAccepted(AnnotationViewModel avm) |
|
217 |
{ |
|
218 |
Boolean annotOk = true; |
|
219 |
// We check if the annotation's begin and end timecodes allow a new annotation creation |
|
220 |
if (CuttingVM != null && AnnotWaiting == false) |
|
221 |
{ |
|
222 |
foreach (Annotation a in AnnotList) |
|
223 |
{ |
|
224 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
|
225 |
// Check begin TC |
|
226 |
if (a.TcBegin <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur)) |
|
227 |
{ |
|
228 |
annotOk = false; |
|
229 |
} |
|
230 |
// Check end tc and if the new annotation will not cover any other |
|
231 |
float endTC = avm.TcBegin + avm.Dur; |
|
232 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
|
233 |
if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC)) |
|
234 |
{ |
|
235 |
annotOk = false; |
|
236 |
} |
|
237 |
} |
|
238 |
} |
|
239 |
else |
|
240 |
{ |
|
241 |
annotOk = false; |
|
242 |
} |
|
243 |
return annotOk; |
|
244 |
||
75
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
245 |
} |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
246 |
|
143 | 247 |
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
|
248 |
{ |
143 | 249 |
//Console.WriteLine("addAnnotation = " + avm.TcBegin + ", " + avm.Dur + ", " + avm.GestureType); |
250 |
Boolean annotOk = true; |
|
251 |
// We check if the annotation's begin and end timecodes allow a new annotation creation |
|
252 |
if (CuttingVM != null && AnnotWaiting == false) |
|
253 |
{ |
|
254 |
foreach (Annotation a in AnnotList) |
|
255 |
{ |
|
256 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
|
257 |
// Check begin TC |
|
258 |
if (a.TcBegin <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur)) |
|
259 |
{ |
|
260 |
annotOk = false; |
|
261 |
} |
|
262 |
// Check end tc and if the new annotation will not cover any other |
|
263 |
float endTC = avm.TcBegin + avm.Dur; |
|
264 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
|
265 |
if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC)) |
|
266 |
{ |
|
267 |
annotOk = false; |
|
268 |
} |
|
269 |
} |
|
270 |
// If everything's fine, we create the new one |
|
271 |
if (annotOk == true) |
|
272 |
{ |
|
150
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
273 |
AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType, avm.Color)); |
143 | 274 |
CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
275 |
tv.DataContext = null; |
|
276 |
tv.DataContext = CuttingVM; |
|
277 |
AnnotWaiting = false; |
|
278 |
} |
|
279 |
||
280 |
} |
|
281 |
||
282 |
} |
|
283 |
||
284 |
public void startOrEndAnnotation() |
|
285 |
{ |
|
286 |
Boolean annotOk = true; |
|
287 |
// We open a new annotation |
|
288 |
if (CuttingVM != null && AnnotWaiting == false) |
|
124 | 289 |
{ |
143 | 290 |
AnnotTcBegin = (float)slider.Value / 1000; |
291 |
||
292 |
// First we check if the new annotation will not cover any |
|
293 |
foreach (Annotation a in AnnotList) |
|
294 |
{ |
|
295 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", AnnotTcBegin = " + AnnotTcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
|
296 |
if (a.TcBegin <= AnnotTcBegin && AnnotTcBegin <= (a.TcBegin + a.Dur)) |
|
297 |
{ |
|
298 |
annotOk = false; |
|
299 |
} |
|
300 |
} |
|
301 |
// if not, we mark the beginning |
|
302 |
if (annotOk == true) |
|
303 |
{ |
|
150
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
304 |
AnnotList.Add(new Annotation(AnnotTcBegin, 0, AnnotList.Count.ToString(), IntColor)); |
143 | 305 |
CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
306 |
//Console.WriteLine("BEGIN currentTimecode = " + AnnotTcBegin + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
|
307 |
tv.DataContext = null; |
|
308 |
tv.DataContext = CuttingVM; |
|
309 |
AnnotWaiting = true; |
|
310 |
} |
|
311 |
} |
|
312 |
// We close the current opened annotation... |
|
313 |
else if (CuttingVM != null && AnnotWaiting == true && (((float)slider.Value/1000)>AnnotTcBegin)) |
|
314 |
{ |
|
315 |
// ... by setting setting the good beginning and the good duration |
|
316 |
float currentTC = (float)slider.Value / 1000; |
|
317 |
float currentDuration = currentTC - AnnotTcBegin; |
|
318 |
||
319 |
// First we check if the new annotation will not cover any (AnnotTcBegin was already checked) |
|
320 |
foreach (Annotation a in AnnotList) |
|
321 |
{ |
|
322 |
//Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC); |
|
323 |
if (a.TcBegin <= currentTC && currentTC <= (a.TcBegin + a.Dur) || (AnnotTcBegin < a.TcBegin && (a.TcBegin + a.Dur) < currentTC)) |
|
324 |
{ |
|
325 |
annotOk = false; |
|
326 |
} |
|
327 |
} |
|
328 |
||
329 |
if (annotOk == true) |
|
330 |
{ |
|
331 |
AnnotList.RemoveAt(AnnotList.Count - 1); |
|
150
569925b65604
Annotations are now colored with the same color as the pivot's button
cavaliet
parents:
146
diff
changeset
|
332 |
AnnotList.Add(new Annotation(AnnotTcBegin, currentDuration, AnnotList.Count.ToString(), IntColor)); |
143 | 333 |
CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
334 |
//Console.WriteLine("currentTimecode = " + AnnotTcBegin + ", curDur = " + currentDuration + ", nb = " + AnnotList.Count + ", res = " + (AnnotTcBegin - (AnnotList.Count * AnnotWidth))); |
|
335 |
tv.DataContext = null; |
|
336 |
tv.DataContext = CuttingVM; |
|
337 |
AnnotWaiting = false; |
|
338 |
} |
|
124 | 339 |
} |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
340 |
} |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
341 |
|
143 | 342 |
|
343 |
private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
|
344 |
{ |
|
345 |
FrameworkElement findSource = e.OriginalSource as FrameworkElement; |
|
346 |
SurfaceListBoxItem draggedElement = null; |
|
347 |
||
348 |
// Find the touched SurfaceListBoxItem object. |
|
349 |
while (draggedElement == null && findSource != null) |
|
350 |
{ |
|
351 |
if ((draggedElement = findSource as SurfaceListBoxItem) == null) |
|
352 |
{ |
|
353 |
findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement; |
|
354 |
} |
|
355 |
} |
|
356 |
||
357 |
if (draggedElement == null) |
|
358 |
{ |
|
359 |
return; |
|
360 |
} |
|
361 |
||
362 |
// Create the cursor visual. |
|
363 |
ContentControl cursorVisual = new ContentControl() |
|
364 |
{ |
|
365 |
Content = new TimelineAnnotationView() |
|
366 |
{ |
|
367 |
DataContext = findSource.DataContext |
|
368 |
} |
|
369 |
}; |
|
370 |
||
371 |
// We apply the current scale to the dragged annotation |
|
372 |
((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform; |
|
373 |
||
374 |
// Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
|
375 |
//SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
|
376 |
||
377 |
// Create a list of input devices. Add the contacts that |
|
378 |
// are currently captured within the dragged element and |
|
379 |
// the current contact (if it isn't already in the list). |
|
380 |
List<InputDevice> devices = new List<InputDevice>(); |
|
381 |
devices.Add(e.Contact); |
|
382 |
foreach (Contact contact in draggedElement.ContactsCapturedWithin) |
|
383 |
{ |
|
384 |
if (contact != e.Contact) |
|
385 |
{ |
|
386 |
devices.Add(contact); |
|
387 |
} |
|
388 |
} |
|
389 |
||
390 |
// Get the drag source object |
|
391 |
ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement); |
|
392 |
||
393 |
bool startDragOkay = |
|
394 |
SurfaceDragDrop.BeginDragDrop( |
|
395 |
dragSource, // The SurfaceListBox object that the cursor is dragged out from. |
|
396 |
draggedElement, // The SurfaceListBoxItem object that is dragged from the drag source. |
|
397 |
cursorVisual, // The visual element of the cursor. |
|
398 |
draggedElement.DataContext, // The data associated with the cursor. |
|
399 |
devices, // The input devices that start dragging the cursor. |
|
400 |
DragDropEffects.Move); // The allowed drag-and-drop effects of the operation. |
|
401 |
||
402 |
// If the drag began successfully, set e.Handled to true. |
|
403 |
// Otherwise SurfaceListBoxItem captures the contact |
|
404 |
// and causes the drag operation to fail. |
|
405 |
e.Handled = startDragOkay; |
|
406 |
} |
|
407 |
||
408 |
private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) |
|
409 |
{ |
|
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 |
|
412 |
if (CuttingVM != null) |
|
413 |
{ |
|
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
|
414 |
// 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
|
415 |
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
|
416 |
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
|
417 |
} |
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
|
418 |
} |
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
|
419 |
|
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
|
420 |
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
|
421 |
{ |
146 | 422 |
//Consolenfirm = " + e.Confirmed); |
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
|
423 |
// We check if the annotation is well one of the current annotations |
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
|
424 |
if (CuttingVM != null && canceledAnnotationVM != null && e.Confirmed == true) |
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 |
{ |
143 | 426 |
foreach (Annotation a in AnnotList) |
427 |
{ |
|
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
|
428 |
// 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
|
429 |
if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) |
143 | 430 |
{ |
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
|
431 |
// We found the good annotation so we can remove it |
143 | 432 |
AnnotList.Remove(a); |
433 |
// We redisplay the timeline |
|
434 |
CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
|
435 |
tv.DataContext = null; |
|
436 |
tv.DataContext = CuttingVM; |
|
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
|
437 |
// We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified |
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 |
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
|
439 |
canceledAnnotationVM = null; |
143 | 440 |
return; |
441 |
} |
|
442 |
} |
|
443 |
} |
|
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
|
444 |
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
|
445 |
canceledAnnotationVM = null; |
143 | 446 |
} |
447 |
||
448 |
||
10 | 449 |
} |
450 |
} |