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; |
|
17 |
|
10
|
18 |
namespace FingersDance.Control.TimeLine |
|
19 |
{ |
|
20 |
public partial class UserControlTimeLine |
34
|
21 |
{ |
|
22 |
|
|
23 |
#region Variables |
|
24 |
private DispatcherTimer timer; |
|
25 |
private bool isDragging = false; |
|
26 |
private bool finishedDragging = false; |
|
27 |
#endregion |
|
28 |
|
|
29 |
public event EventHandler DragStarted; |
|
30 |
public event EventHandler DragCompleted; |
|
31 |
public event EventHandler TimerTick; |
|
32 |
|
|
33 |
#region Properties |
|
34 |
|
|
35 |
public SurfaceSlider Slider |
10
|
36 |
{ |
34
|
37 |
get |
|
38 |
{ |
|
39 |
return slider; |
10
|
40 |
} |
34
|
41 |
set |
|
42 |
{ |
|
43 |
slider = value; |
10
|
44 |
} |
|
45 |
} |
|
46 |
|
34
|
47 |
public bool IsDragging |
|
48 |
{ |
|
49 |
get |
|
50 |
{ |
|
51 |
return isDragging; |
|
52 |
} |
|
53 |
set |
|
54 |
{ |
|
55 |
isDragging = value; |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
public bool FinishedDragging |
|
60 |
{ |
|
61 |
get |
|
62 |
{ |
|
63 |
return finishedDragging; |
|
64 |
} |
|
65 |
set |
|
66 |
{ |
|
67 |
finishedDragging = value; |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
public DispatcherTimer Timer |
|
72 |
{ |
|
73 |
get |
|
74 |
{ |
|
75 |
return timer; |
|
76 |
} |
|
77 |
set |
|
78 |
{ |
|
79 |
timer = value; |
|
80 |
} |
|
81 |
} |
|
82 |
#endregion |
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
10
|
87 |
public UserControlTimeLine() |
|
88 |
{ |
|
89 |
this.InitializeComponent(); |
|
90 |
|
|
91 |
// Insert code required on object creation below this point. |
69
|
92 |
|
10
|
93 |
} |
|
94 |
|
34
|
95 |
public void initslider(double totalmilliseconds) |
|
96 |
{ |
|
97 |
slider.Maximum = totalmilliseconds; |
69
|
98 |
|
|
99 |
|
|
100 |
// TEMP FOR DATA BINDING |
|
101 |
List<Annotation> annotList = new List<Annotation>(); |
|
102 |
annotList.Add(new Annotation(0, 10, "Axe Cam 1")); |
|
103 |
annotList.Add(new Annotation(10, 20, "Mvt Cam 2")); |
|
104 |
annotList.Add(new Annotation(30, 40, "Saut 3")); |
|
105 |
Cutting cut = new Cutting("titre de cutting", annotList); |
|
106 |
CuttingViewModel cutvm = new CuttingViewModel(cut); |
|
107 |
tv.DataContext = cut; |
|
108 |
|
|
109 |
|
34
|
110 |
} |
|
111 |
|
|
112 |
#region Timer |
|
113 |
public void initTimer() |
|
114 |
{ |
|
115 |
timer = new DispatcherTimer(); |
|
116 |
timer.Interval = new TimeSpan(0, 0, 0, 0, 100); |
|
117 |
timer.Tick += new EventHandler(timer_Tick); |
|
118 |
} |
|
119 |
|
|
120 |
public void timerStart() |
|
121 |
{ |
|
122 |
if (timer != null) |
|
123 |
timer.Start(); |
|
124 |
} |
|
125 |
void timer_Tick(object sender, EventArgs e) |
10
|
126 |
{ |
34
|
127 |
OnTimerTick(); |
|
128 |
if (!isDragging) |
|
129 |
{ |
|
130 |
//slider.Value = media.Position.TotalMilliseconds; |
|
131 |
} |
|
132 |
if (finishedDragging) |
|
133 |
{ |
|
134 |
//int SliderValue = (int)slider.Value; |
|
135 |
//TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue); |
|
136 |
// media.Position = ts; |
|
137 |
// media.Play(); |
|
138 |
// isDragging = false; |
|
139 |
//finishedDragging = false; |
|
140 |
} |
|
141 |
} |
|
142 |
protected virtual void OnTimerTick() |
|
143 |
{ |
|
144 |
if (TimerTick != null) |
|
145 |
TimerTick(this, new EventArgs()); |
10
|
146 |
} |
34
|
147 |
|
|
148 |
#endregion |
|
149 |
|
|
150 |
private void sliderPosition_DragStarted( |
|
151 |
object sender, DragStartedEventArgs e) |
|
152 |
{ |
|
153 |
isDragging = true; |
|
154 |
OnDragStarted(); |
|
155 |
// media.Pause(); |
|
156 |
} |
|
157 |
protected virtual void OnDragStarted() |
|
158 |
{ |
|
159 |
if (DragStarted != null) |
|
160 |
DragStarted(this, new EventArgs()); |
|
161 |
} |
|
162 |
|
|
163 |
private void sliderPosition_DragCompleted( |
|
164 |
object sender, DragCompletedEventArgs e) |
|
165 |
{ |
|
166 |
finishedDragging = true; |
|
167 |
OnDragCompleted(); |
|
168 |
} |
|
169 |
protected virtual void OnDragCompleted() |
|
170 |
{ |
|
171 |
if (DragCompleted != null) |
|
172 |
DragCompleted(this, new EventArgs()); |
|
173 |
} |
|
174 |
|
10
|
175 |
} |
|
176 |
} |