| author | totetm <> |
| Fri, 12 Feb 2010 16:22:57 +0100 | |
| changeset 47 | 9b26023b8c83 |
| parent 38 | bd33267300aa |
| permissions | -rw-r--r-- |
| 0 | 1 |
using System; |
2 |
using System.Windows; |
|
3 |
using System.Windows.Controls; |
|
4 |
using System.Windows.Documents; |
|
5 |
using System.Windows.Ink; |
|
6 |
using System.Windows.Input; |
|
7 |
using System.Windows.Media; |
|
8 |
using System.Windows.Media.Animation; |
|
9 |
using System.Windows.Shapes; |
|
10 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
11 |
using Iri.Modernisation.Data.Models; |
|
12 |
using Iri.Modernisation.Controls.ViewModel; |
|
| 20 | 13 |
using System.Collections.ObjectModel; |
| 24 | 14 |
using System.Globalization; |
| 0 | 15 |
namespace Iri.Modernisation.Controls.View |
16 |
{ |
|
17 |
|
|
18 |
public partial class ProductionTimeLine : UserControl |
|
19 |
{ |
|
20 |
public static double ScaleTime |
|
21 |
{ |
|
| 30 | 22 |
get; |
| 28 | 23 |
set; |
| 0 | 24 |
} |
| 35 | 25 |
|
| 0 | 26 |
public ProductionTimeLine() |
27 |
{ |
|
| 28 | 28 |
ScaleTime = 0.0002; |
| 0 | 29 |
// Required to initialize variables |
30 |
InitializeComponent(); |
|
| 20 | 31 |
Commands.ProductionTimeLine.EditorPartSelected.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartSelected_Executed); |
| 19 | 32 |
Commands.ProductionView.VideoRecordUpdated.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(VideoRecordUpdated_Executed); |
| 24 | 33 |
TimeSlider.MouseLeftButtonUp += new MouseButtonEventHandler(TimeSlider_MouseLeftButtonUp); |
| 35 | 34 |
TimeSlider.MouseMove += new MouseEventHandler(TimeSlider_MouseMove); |
35 |
TimeSlider.MouseLeftButtonDown += new MouseButtonEventHandler(TimeSlider_MouseLeftButtonDown); |
|
36 |
TimeSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(TimeSlider_ValueChanged); |
|
| 24 | 37 |
TimeSlider.Maximum = TimeSlider.ActualWidth / ProductionTimeLine.ScaleTime; |
| 38 | 38 |
TimeSlider.ThumbDragStarted += new EventHandler<EventArgs>(TimeSlider_ThumbDragStarted); |
39 |
TimeSlider.ThumbDragCompleted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted); |
|
| 28 | 40 |
ScaleTimeLine.ValueChanged += new RoutedPropertyChangedEventHandler<double>(ScaleTimeLine_ValueChanged); |
| 0 | 41 |
} |
| 38 | 42 |
private bool _saveVideoViewerState { get; set; } |
43 |
void TimeSlider_ThumbDragCompleted(object sender, EventArgs e) |
|
44 |
{ |
|
45 |
if (_saveVideoViewerState) |
|
46 |
{ |
|
47 |
((ProductionTimeLineVM)DataContext).ViewModelVideoViewer.Play(); |
|
48 |
} |
|
49 |
} |
|
50 |
||
51 |
void TimeSlider_ThumbDragStarted(object sender, EventArgs e) |
|
52 |
{ |
|
53 |
_saveVideoViewerState = ((ProductionTimeLineVM)DataContext).ViewModelVideoViewer.IsPLayed; |
|
54 |
((ProductionTimeLineVM)DataContext).ViewModelVideoViewer.Pause(); |
|
55 |
|
|
56 |
} |
|
| 35 | 57 |
bool _mousecapture { get; set; } |
58 |
void TimeSlider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
59 |
{ |
|
60 |
_mousecapture = true; |
|
61 |
} |
|
| 0 | 62 |
|
| 35 | 63 |
|
64 |
||
65 |
void TimeSlider_MouseMove(object sender, MouseEventArgs e) |
|
66 |
{ |
|
67 |
if (_mousecapture) |
|
68 |
((ProductionTimeLineVM)DataContext).ViewModelVideoViewer.Pause(); |
|
69 |
} |
|
70 |
||
71 |
|
|
| 28 | 72 |
void ScaleTimeLine_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
73 |
{ |
|
74 |
ScaleTime = e.NewValue / 3200000; |
|
75 |
UpdateElements(); |
|
76 |
||
77 |
} |
|
78 |
||
| 24 | 79 |
void TimeSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
80 |
{ |
|
| 35 | 81 |
|
| 24 | 82 |
Commands.TimeChange.Execute(TimeSlider.Value,DataContext); |
| 35 | 83 |
ReleaseMouseCapture(); |
84 |
_mousecapture = false; |
|
| 24 | 85 |
} |
86 |
||
87 |
void TimeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
|
88 |
{ |
|
| 35 | 89 |
|
90 |
||
| 24 | 91 |
|
92 |
} |
|
93 |
||
| 20 | 94 |
void EditorPartSelected_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
95 |
{ |
|
96 |
UpdateElements(); |
|
97 |
} |
|
98 |
||
| 19 | 99 |
void VideoRecordUpdated_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
100 |
{ |
|
101 |
UpdateElements(); |
|
102 |
} |
|
| 30 | 103 |
private double _sumOfLengh=0; |
| 19 | 104 |
|
105 |
public void UpdateElements() |
|
106 |
{ |
|
| 24 | 107 |
TimeSlider.Maximum = TimeSlider.ActualWidth / ProductionTimeLine.ScaleTime; |
| 19 | 108 |
if (DataContext != null) |
109 |
{ |
|
| 20 | 110 |
if (((ProductionTimeLineVM)this.DataContext).SelectedChapter != -1) |
| 19 | 111 |
{ |
| 20 | 112 |
if (!((ProductionTimeLineVM)DataContext).IsIndexing) |
| 19 | 113 |
{ |
| 20 | 114 |
VideoTimeStrip.Children.Clear(); |
115 |
int intChapter = 0; |
|
116 |
_sumOfLengh = 0; |
|
117 |
foreach (ObservableCollection<VideoSequence> Ocvs in ((ProductionTimeLineVM)this.DataContext).ListVideoSequences) |
|
| 19 | 118 |
{ |
| 20 | 119 |
|
120 |
foreach (VideoSequence Vs in Ocvs) |
|
| 19 | 121 |
{ |
| 20 | 122 |
CustomableVideoElement _temp = new CustomableVideoElement() |
123 |
{ |
|
124 |
DataContext = new CustomableVideoElementVM(Vs) |
|
125 |
{ |
|
| 27 | 126 |
ChapterColor = FactoryVideoLivre.VideoChapterDescriptions[intChapter].Color |
127 |
} |
|
128 |
||
| 20 | 129 |
}; |
130 |
_temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown); |
|
| 28 | 131 |
//if ((VideoChapterType)intChapter == ((ProductionTimeLineVM)this.DataContext).SelectedBookChapter.Type) |
132 |
//{ |
|
| 20 | 133 |
_temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove); |
| 0 | 134 |
|
| 20 | 135 |
_temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp); |
| 28 | 136 |
//} |
| 20 | 137 |
VideoTimeStrip.Children.Add(_temp);// TODO: Add event handler implementation here. |
138 |
_sumOfLengh += _temp.Width; |
|
139 |
} |
|
140 |
intChapter++; |
|
141 |
} |
|
142 |
} |
|
143 |
else |
|
144 |
{ |
|
145 |
AnnotationTimeStrip.Children.Clear(); |
|
| 27 | 146 |
int intChapter = 0; |
| 20 | 147 |
foreach (ObservableCollection<SegmentIndex> Ocsi in ((ProductionTimeLineVM)this.DataContext).ListIndex) |
148 |
{ |
|
149 |
foreach (SegmentIndex Si in Ocsi) |
|
150 |
{ |
|
151 |
|
|
152 |
// PolemicElementControl an = new PolemicElementControl() { IsEnabled = false }; |
|
| 27 | 153 |
CustomableIndexElement an = new CustomableIndexElement() |
154 |
{ |
|
155 |
DataContext = new CustomableIndexElementVM(Si) |
|
| 20 | 156 |
{ |
| 27 | 157 |
ChapterColor = FactoryVideoLivre.VideoChapterDescriptions[intChapter].Color |
158 |
} |
|
159 |
}; |
|
| 19 | 160 |
|
| 20 | 161 |
//an.DataContext = new PolemicElementVM(Si); |
162 |
||
163 |
an.MouseLeftButtonDown += new MouseButtonEventHandler(an_MouseLeftButtonDown); |
|
| 35 | 164 |
|
| 20 | 165 |
an.MouseMove += new MouseEventHandler(an_MouseMove); |
166 |
an.MouseLeftButtonUp += new MouseButtonEventHandler(an_MouseLeftButtonUp); |
|
167 |
//((ProductionTimeLineVM)DataContext).SelectedBookChapter); |
|
168 |
AnnotationTimeStrip.Children.Add(an); |
|
| 21 | 169 |
|
| 20 | 170 |
|
171 |
} |
|
| 27 | 172 |
intChapter++; |
| 20 | 173 |
|
174 |
} |
|
175 |
|
|
| 19 | 176 |
} |
| 20 | 177 |
|
178 |
||
| 19 | 179 |
} |
180 |
|
|
| 20 | 181 |
|
| 19 | 182 |
} |
183 |
} |
|
| 20 | 184 |
|
185 |
void an_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
186 |
{ |
|
187 |
_isTrimRightCapturated = false; |
|
188 |
_isTrimLeftCapturated = false; |
|
189 |
} |
|
190 |
||
191 |
void an_MouseMove(object sender, MouseEventArgs e) |
|
192 |
{ |
|
193 |
if (((ProductionTimeLineVM)DataContext).IsIndexing) |
|
194 |
{ |
|
195 |
if (e.GetPosition(AnnotationTimeStrip).X <= _sumOfLengh && _isTrimRightCapturated && ((CustomableIndexElement)sender).CaptureMouse()) |
|
196 |
{ |
|
197 |
((CustomableIndexElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableIndexElement)sender)).X; |
|
198 |
_comePoint = e.GetPosition(((CustomableIndexElement)sender)); |
|
199 |
} |
|
200 |
|
|
201 |
} |
|
202 |
} |
|
203 |
private CustomableIndexElement _selectedIndex; |
|
204 |
void an_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
205 |
{ |
|
206 |
_selectedIndex = ((CustomableIndexElement)sender); |
|
207 |
if (e.GetPosition(((CustomableIndexElement)sender)).X >= ((CustomableIndexElement)sender).Width - 5) |
|
208 |
{ |
|
209 |
_comePoint = e.GetPosition(((CustomableIndexElement)sender)); |
|
210 |
_isTrimRightCapturated = true; |
|
211 |
} |
|
| 21 | 212 |
foreach(ObservableCollection<SegmentIndex> Ocsi in ((ProductionTimeLineVM)DataContext).ListIndex) |
213 |
{ |
|
214 |
foreach (SegmentIndex Si in Ocsi ) |
|
215 |
{ |
|
216 |
|
|
217 |
if (((CustomableIndexElementVM)_selectedIndex.DataContext).SegmentIndex == Si) |
|
218 |
{ |
|
219 |
if (Ocsi == ((ProductionTimeLineVM)DataContext).SelectedIndex) |
|
220 |
{ |
|
221 |
Commands.ProductionTimeLine.IndexSelected.Execute(true,Si); |
|
222 |
} |
|
223 |
else |
|
224 |
{ |
|
225 |
||
226 |
Commands.ProductionTimeLine.IndexSelected.Execute(false, Si); |
|
227 |
} |
|
228 |
|
|
229 |
} |
|
230 |
} |
|
231 |
} |
|
232 |
||
233 |
|
|
| 20 | 234 |
|
235 |
} |
|
| 0 | 236 |
private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
237 |
{ |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
21
diff
changeset
|
238 |
AddSequenceButton.Content = ((ProductionTimeLineVM)DataContext).TotalBookDuration; |
| 24 | 239 |
|
240 |
|
|
| 0 | 241 |
} |
242 |
||
243 |
|
|
244 |
||
245 |
private void slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e) |
|
246 |
{ |
|
247 |
AddSequenceButton.Content = e.NewValue; |
|
248 |
// TODO: Add event handler implementation here. |
|
249 |
} |
|
250 |
||
251 |
||
252 |
||
253 |
private Point _comePoint; |
|
254 |
private bool _isTrimRightCapturated = false; |
|
255 |
private bool _isTrimLeftCapturated = false; |
|
256 |
||
257 |
private CustomableVideoElement _selected; |
|
258 |
void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e) |
|
259 |
{ |
|
260 |
||
| 20 | 261 |
if (!((ProductionTimeLineVM)DataContext).IsIndexing) |
| 0 | 262 |
{ |
| 20 | 263 |
if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
264 |
{ |
|
265 |
((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X; |
|
266 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
267 |
} |
|
268 |
else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
|
269 |
{ |
|
270 |
((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X; |
|
271 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
272 |
} |
|
| 0 | 273 |
} |
274 |
|
|
275 |
} |
|
276 |
void CustomableVideoElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
277 |
{ |
|
278 |
_isTrimRightCapturated = false; |
|
279 |
_isTrimLeftCapturated = false; |
|
280 |
} |
|
281 |
||
282 |
void CustomableVideoElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
283 |
{ |
|
| 17 | 284 |
_selected = ((CustomableVideoElement)sender); |
| 0 | 285 |
if (e.GetPosition(((CustomableVideoElement)sender)).X >= ((CustomableVideoElement)sender).Width - 5) |
286 |
{ |
|
287 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
288 |
_isTrimRightCapturated = true; |
|
289 |
} |
|
290 |
if (e.GetPosition(((CustomableVideoElement)sender)).X <= 5) |
|
291 |
{ |
|
292 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
293 |
_isTrimLeftCapturated = true; |
|
294 |
} |
|
295 |
} |
|
296 |
||
297 |
private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
|
298 |
{ |
|
| 20 | 299 |
//VideoTimeStrip.Children.Remove(_selected); |
300 |
Commands.ProductionView.DelVideoSequence.Execute(((CustomableVideoElement)_selected).DataContext); |
|
| 0 | 301 |
} |
| 35 | 302 |
|
| 38 | 303 |
private void TimeSlider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e) |
304 |
{ |
|
305 |
||
306 |
} |
|
307 |
||
| 35 | 308 |
|
| 0 | 309 |
} |
310 |
} |