author | cavaliet |
Thu, 17 Sep 2009 17:25:05 +0200 | |
changeset 75 | 99d003723474 |
parent 74 | 7ce946833eae |
child 99 | 5a49507c8159 |
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; |
|
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 |
||
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
33 |
private List<Annotation> annotList = new List<Annotation>(); |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
34 |
private float annotWidth = 40; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
35 |
private CuttingViewModel cutvm; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
36 |
private int numAnnot = 1; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
37 |
|
34 | 38 |
#region Properties |
39 |
||
40 |
public SurfaceSlider Slider |
|
10 | 41 |
{ |
34 | 42 |
get |
43 |
{ |
|
44 |
return slider; |
|
10 | 45 |
} |
34 | 46 |
set |
47 |
{ |
|
48 |
slider = value; |
|
10 | 49 |
} |
50 |
} |
|
51 |
|
|
34 | 52 |
public bool IsDragging |
53 |
{ |
|
54 |
get |
|
55 |
{ |
|
56 |
return isDragging; |
|
57 |
} |
|
58 |
set |
|
59 |
{ |
|
60 |
isDragging = value; |
|
61 |
} |
|
62 |
} |
|
63 |
||
64 |
public bool FinishedDragging |
|
65 |
{ |
|
66 |
get |
|
67 |
{ |
|
68 |
return finishedDragging; |
|
69 |
} |
|
70 |
set |
|
71 |
{ |
|
72 |
finishedDragging = value; |
|
73 |
} |
|
74 |
} |
|
75 |
||
76 |
public DispatcherTimer Timer |
|
77 |
{ |
|
78 |
get |
|
79 |
{ |
|
80 |
return timer; |
|
81 |
} |
|
82 |
set |
|
83 |
{ |
|
84 |
timer = value; |
|
85 |
} |
|
86 |
} |
|
87 |
#endregion |
|
88 |
|
|
89 |
||
90 |
||
91 |
|
|
10 | 92 |
public UserControlTimeLine() |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
93 |
{ |
10 | 94 |
this.InitializeComponent(); |
95 |
||
96 |
// Insert code required on object creation below this point. |
|
69 | 97 |
|
10 | 98 |
} |
99 |
||
34 | 100 |
public void initslider(double totalmilliseconds) |
101 |
{ |
|
102 |
slider.Maximum = totalmilliseconds; |
|
69 | 103 |
|
104 |
||
105 |
// TEMP FOR DATA BINDING |
|
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
106 |
annotList = new List<Annotation>(); |
69 | 107 |
annotList.Add(new Annotation(0, 10, "Axe Cam 1")); |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
108 |
annotList.Add(new Annotation(20 - (1 * annotWidth), 30, "Mvt Cam 2")); |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
109 |
annotList.Add(new Annotation(50 - (2 * annotWidth), 60, "Saut 3")); |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
110 |
annotList.Add(new Annotation(100 - (3 * annotWidth), 20, "Saut 4")); |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
111 |
annotList.Add(new Annotation(120 - (4 * annotWidth), 50, "Saut 5")); |
69 | 112 |
Cutting cut = new Cutting("titre de cutting", annotList); |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
113 |
cutvm = new CuttingViewModel(cut); |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
114 |
tv.DataContext = cutvm; |
69 | 115 |
|
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
116 |
numAnnot = 6; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
117 |
slider_ContactTapGesture(this,null); |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
118 |
/* |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
119 |
cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 - (5 * annotWidth), 10, "6"))); |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
120 |
tv.DataContext = null; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
121 |
tv.DataContext = cutvm; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
122 |
numAnnot = 7; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
123 |
*/ |
34 | 124 |
} |
125 |
||
126 |
#region Timer |
|
127 |
public void initTimer() |
|
128 |
{ |
|
129 |
timer = new DispatcherTimer(); |
|
130 |
timer.Interval = new TimeSpan(0, 0, 0, 0, 100); |
|
131 |
timer.Tick += new EventHandler(timer_Tick); |
|
132 |
} |
|
133 |
||
134 |
public void timerStart() |
|
135 |
{ |
|
136 |
if (timer != null) |
|
137 |
timer.Start(); |
|
138 |
} |
|
139 |
void timer_Tick(object sender, EventArgs e) |
|
10 | 140 |
{ |
34 | 141 |
OnTimerTick(); |
142 |
if (!isDragging) |
|
143 |
{ |
|
144 |
//slider.Value = media.Position.TotalMilliseconds; |
|
145 |
} |
|
146 |
if (finishedDragging) |
|
147 |
{ |
|
148 |
//int SliderValue = (int)slider.Value; |
|
149 |
//TimeSpan ts = new TimeSpan(0, 0, 0, 0, SliderValue); |
|
150 |
// media.Position = ts; |
|
151 |
// media.Play(); |
|
152 |
// isDragging = false; |
|
153 |
//finishedDragging = false; |
|
154 |
} |
|
155 |
} |
|
156 |
protected virtual void OnTimerTick() |
|
157 |
{ |
|
158 |
if (TimerTick != null) |
|
159 |
TimerTick(this, new EventArgs()); |
|
10 | 160 |
} |
34 | 161 |
|
162 |
#endregion |
|
163 |
||
164 |
private void sliderPosition_DragStarted( |
|
165 |
object sender, DragStartedEventArgs e) |
|
166 |
{ |
|
167 |
isDragging = true; |
|
168 |
OnDragStarted(); |
|
169 |
// media.Pause(); |
|
170 |
} |
|
171 |
protected virtual void OnDragStarted() |
|
172 |
{ |
|
173 |
if (DragStarted != null) |
|
174 |
DragStarted(this, new EventArgs()); |
|
175 |
} |
|
176 |
||
177 |
private void sliderPosition_DragCompleted( |
|
178 |
object sender, DragCompletedEventArgs e) |
|
179 |
{ |
|
180 |
finishedDragging = true; |
|
181 |
OnDragCompleted(); |
|
182 |
} |
|
183 |
protected virtual void OnDragCompleted() |
|
184 |
{ |
|
185 |
if (DragCompleted != null) |
|
186 |
DragCompleted(this, new EventArgs()); |
|
187 |
} |
|
188 |
||
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
189 |
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
|
190 |
{ |
75
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
191 |
addAnnotation(); |
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
192 |
} |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
193 |
|
75
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
194 |
public void addAnnotation() |
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
195 |
{ |
99d003723474
data binding second step. we can add annotation by clicking on menu buttons or timeline.
cavaliet
parents:
74
diff
changeset
|
196 |
cutvm.AnnotList.Add(new AnnotationViewModel(new Annotation(180 + (numAnnot - 6) * 20 - ((numAnnot - 1) * annotWidth), 10, numAnnot.ToString()))); |
74
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
197 |
tv.DataContext = null; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
198 |
tv.DataContext = cutvm; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
199 |
numAnnot++; |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
200 |
} |
7ce946833eae
First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents:
69
diff
changeset
|
201 |
|
10 | 202 |
} |
203 |
} |