| author | totetm <> |
| Thu, 14 Jan 2010 16:39:50 +0100 | |
| changeset 30 | 644e3cd48034 |
| parent 28 | 2d4ec5ab2a40 |
| child 35 | 43bb1b8ed555 |
| 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 |
} |
25 |
public ProductionTimeLine() |
|
26 |
{ |
|
| 28 | 27 |
ScaleTime = 0.0002; |
| 0 | 28 |
// Required to initialize variables |
29 |
InitializeComponent(); |
|
| 20 | 30 |
Commands.ProductionTimeLine.EditorPartSelected.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartSelected_Executed); |
| 19 | 31 |
Commands.ProductionView.VideoRecordUpdated.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(VideoRecordUpdated_Executed); |
| 24 | 32 |
TimeSlider.MouseLeftButtonUp += new MouseButtonEventHandler(TimeSlider_MouseLeftButtonUp); |
33 |
//TimeSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(TimeSlider_ValueChanged); |
|
34 |
TimeSlider.Maximum = TimeSlider.ActualWidth / ProductionTimeLine.ScaleTime; |
|
| 28 | 35 |
|
36 |
ScaleTimeLine.ValueChanged += new RoutedPropertyChangedEventHandler<double>(ScaleTimeLine_ValueChanged); |
|
| 0 | 37 |
} |
38 |
||
| 28 | 39 |
void ScaleTimeLine_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
40 |
{ |
|
41 |
ScaleTime = e.NewValue / 3200000; |
|
42 |
UpdateElements(); |
|
43 |
||
44 |
} |
|
45 |
||
| 24 | 46 |
void TimeSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
47 |
{ |
|
48 |
Commands.TimeChange.Execute(TimeSlider.Value,DataContext); |
|
49 |
} |
|
50 |
||
51 |
void TimeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
|
52 |
{ |
|
53 |
DeleteSequenceButton.Content = TimeSpan.FromMilliseconds(TimeSlider.Value); |
|
54 |
|
|
55 |
} |
|
56 |
||
| 20 | 57 |
void EditorPartSelected_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
58 |
{ |
|
59 |
UpdateElements(); |
|
60 |
} |
|
61 |
||
| 19 | 62 |
void VideoRecordUpdated_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
63 |
{ |
|
64 |
UpdateElements(); |
|
65 |
} |
|
| 30 | 66 |
private double _sumOfLengh=0; |
| 19 | 67 |
|
68 |
public void UpdateElements() |
|
69 |
{ |
|
| 24 | 70 |
TimeSlider.Maximum = TimeSlider.ActualWidth / ProductionTimeLine.ScaleTime; |
| 19 | 71 |
if (DataContext != null) |
72 |
{ |
|
| 20 | 73 |
if (((ProductionTimeLineVM)this.DataContext).SelectedChapter != -1) |
| 19 | 74 |
{ |
| 20 | 75 |
if (!((ProductionTimeLineVM)DataContext).IsIndexing) |
| 19 | 76 |
{ |
| 20 | 77 |
VideoTimeStrip.Children.Clear(); |
78 |
int intChapter = 0; |
|
79 |
_sumOfLengh = 0; |
|
80 |
foreach (ObservableCollection<VideoSequence> Ocvs in ((ProductionTimeLineVM)this.DataContext).ListVideoSequences) |
|
| 19 | 81 |
{ |
| 20 | 82 |
|
83 |
foreach (VideoSequence Vs in Ocvs) |
|
| 19 | 84 |
{ |
| 20 | 85 |
CustomableVideoElement _temp = new CustomableVideoElement() |
86 |
{ |
|
87 |
DataContext = new CustomableVideoElementVM(Vs) |
|
88 |
{ |
|
| 27 | 89 |
ChapterColor = FactoryVideoLivre.VideoChapterDescriptions[intChapter].Color |
90 |
} |
|
91 |
||
| 20 | 92 |
}; |
93 |
_temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown); |
|
| 28 | 94 |
//if ((VideoChapterType)intChapter == ((ProductionTimeLineVM)this.DataContext).SelectedBookChapter.Type) |
95 |
//{ |
|
| 20 | 96 |
_temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove); |
| 0 | 97 |
|
| 20 | 98 |
_temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp); |
| 28 | 99 |
//} |
| 20 | 100 |
VideoTimeStrip.Children.Add(_temp);// TODO: Add event handler implementation here. |
101 |
_sumOfLengh += _temp.Width; |
|
102 |
} |
|
103 |
intChapter++; |
|
104 |
} |
|
105 |
} |
|
106 |
else |
|
107 |
{ |
|
108 |
AnnotationTimeStrip.Children.Clear(); |
|
| 27 | 109 |
int intChapter = 0; |
| 20 | 110 |
foreach (ObservableCollection<SegmentIndex> Ocsi in ((ProductionTimeLineVM)this.DataContext).ListIndex) |
111 |
{ |
|
112 |
foreach (SegmentIndex Si in Ocsi) |
|
113 |
{ |
|
114 |
|
|
115 |
// PolemicElementControl an = new PolemicElementControl() { IsEnabled = false }; |
|
| 27 | 116 |
CustomableIndexElement an = new CustomableIndexElement() |
117 |
{ |
|
118 |
DataContext = new CustomableIndexElementVM(Si) |
|
| 20 | 119 |
{ |
| 27 | 120 |
ChapterColor = FactoryVideoLivre.VideoChapterDescriptions[intChapter].Color |
121 |
} |
|
122 |
}; |
|
| 19 | 123 |
|
| 20 | 124 |
//an.DataContext = new PolemicElementVM(Si); |
125 |
||
126 |
an.MouseLeftButtonDown += new MouseButtonEventHandler(an_MouseLeftButtonDown); |
|
127 |
an.MouseMove += new MouseEventHandler(an_MouseMove); |
|
128 |
an.MouseLeftButtonUp += new MouseButtonEventHandler(an_MouseLeftButtonUp); |
|
129 |
//((ProductionTimeLineVM)DataContext).SelectedBookChapter); |
|
130 |
AnnotationTimeStrip.Children.Add(an); |
|
| 21 | 131 |
|
| 20 | 132 |
|
133 |
} |
|
| 27 | 134 |
intChapter++; |
| 20 | 135 |
|
136 |
} |
|
137 |
|
|
| 19 | 138 |
} |
| 20 | 139 |
|
140 |
||
| 19 | 141 |
} |
142 |
|
|
| 20 | 143 |
|
| 19 | 144 |
} |
145 |
} |
|
| 20 | 146 |
|
147 |
void an_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
148 |
{ |
|
149 |
_isTrimRightCapturated = false; |
|
150 |
_isTrimLeftCapturated = false; |
|
151 |
} |
|
152 |
||
153 |
void an_MouseMove(object sender, MouseEventArgs e) |
|
154 |
{ |
|
155 |
if (((ProductionTimeLineVM)DataContext).IsIndexing) |
|
156 |
{ |
|
157 |
if (e.GetPosition(AnnotationTimeStrip).X <= _sumOfLengh && _isTrimRightCapturated && ((CustomableIndexElement)sender).CaptureMouse()) |
|
158 |
{ |
|
159 |
((CustomableIndexElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableIndexElement)sender)).X; |
|
160 |
_comePoint = e.GetPosition(((CustomableIndexElement)sender)); |
|
161 |
} |
|
162 |
|
|
163 |
} |
|
164 |
} |
|
165 |
private CustomableIndexElement _selectedIndex; |
|
166 |
void an_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
167 |
{ |
|
168 |
_selectedIndex = ((CustomableIndexElement)sender); |
|
169 |
if (e.GetPosition(((CustomableIndexElement)sender)).X >= ((CustomableIndexElement)sender).Width - 5) |
|
170 |
{ |
|
171 |
_comePoint = e.GetPosition(((CustomableIndexElement)sender)); |
|
172 |
_isTrimRightCapturated = true; |
|
173 |
} |
|
| 21 | 174 |
foreach(ObservableCollection<SegmentIndex> Ocsi in ((ProductionTimeLineVM)DataContext).ListIndex) |
175 |
{ |
|
176 |
foreach (SegmentIndex Si in Ocsi ) |
|
177 |
{ |
|
178 |
|
|
179 |
if (((CustomableIndexElementVM)_selectedIndex.DataContext).SegmentIndex == Si) |
|
180 |
{ |
|
181 |
if (Ocsi == ((ProductionTimeLineVM)DataContext).SelectedIndex) |
|
182 |
{ |
|
183 |
Commands.ProductionTimeLine.IndexSelected.Execute(true,Si); |
|
184 |
} |
|
185 |
else |
|
186 |
{ |
|
187 |
||
188 |
Commands.ProductionTimeLine.IndexSelected.Execute(false, Si); |
|
189 |
} |
|
190 |
|
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
|
|
| 20 | 196 |
|
197 |
} |
|
| 0 | 198 |
private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
199 |
{ |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
21
diff
changeset
|
200 |
AddSequenceButton.Content = ((ProductionTimeLineVM)DataContext).TotalBookDuration; |
| 24 | 201 |
|
202 |
|
|
| 0 | 203 |
} |
204 |
||
205 |
|
|
206 |
||
207 |
private void slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e) |
|
208 |
{ |
|
209 |
AddSequenceButton.Content = e.NewValue; |
|
210 |
// TODO: Add event handler implementation here. |
|
211 |
} |
|
212 |
||
213 |
||
214 |
||
215 |
private Point _comePoint; |
|
216 |
private bool _isTrimRightCapturated = false; |
|
217 |
private bool _isTrimLeftCapturated = false; |
|
218 |
||
219 |
private CustomableVideoElement _selected; |
|
220 |
void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e) |
|
221 |
{ |
|
222 |
||
| 20 | 223 |
if (!((ProductionTimeLineVM)DataContext).IsIndexing) |
| 0 | 224 |
{ |
| 20 | 225 |
if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
226 |
{ |
|
227 |
((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X; |
|
228 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
229 |
} |
|
230 |
else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
|
231 |
{ |
|
232 |
((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X; |
|
233 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
234 |
} |
|
| 0 | 235 |
} |
236 |
|
|
237 |
} |
|
238 |
void CustomableVideoElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
239 |
{ |
|
240 |
_isTrimRightCapturated = false; |
|
241 |
_isTrimLeftCapturated = false; |
|
242 |
} |
|
243 |
||
244 |
void CustomableVideoElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
245 |
{ |
|
| 17 | 246 |
_selected = ((CustomableVideoElement)sender); |
| 0 | 247 |
if (e.GetPosition(((CustomableVideoElement)sender)).X >= ((CustomableVideoElement)sender).Width - 5) |
248 |
{ |
|
249 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
250 |
_isTrimRightCapturated = true; |
|
251 |
} |
|
252 |
if (e.GetPosition(((CustomableVideoElement)sender)).X <= 5) |
|
253 |
{ |
|
254 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
255 |
_isTrimLeftCapturated = true; |
|
256 |
} |
|
257 |
} |
|
258 |
||
259 |
private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
|
260 |
{ |
|
| 20 | 261 |
//VideoTimeStrip.Children.Remove(_selected); |
262 |
Commands.ProductionView.DelVideoSequence.Execute(((CustomableVideoElement)_selected).DataContext); |
|
| 0 | 263 |
} |
264 |
} |
|
265 |
} |