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