|
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; |
|
0
|
14 |
namespace Iri.Modernisation.Controls.View |
|
|
15 |
{ |
|
|
16 |
|
|
|
17 |
public partial class ProductionTimeLine : UserControl |
|
|
18 |
{ |
|
|
19 |
public static double ScaleTime |
|
|
20 |
{ |
|
|
21 |
get |
|
|
22 |
{ |
|
|
23 |
return 0.0001; |
|
|
24 |
} |
|
|
25 |
} |
|
|
26 |
public ProductionTimeLine() |
|
|
27 |
{ |
|
|
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); |
|
20
|
32 |
Commands.Action.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Action_Executed); |
|
0
|
33 |
|
|
|
34 |
} |
|
|
35 |
|
|
20
|
36 |
void EditorPartSelected_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
37 |
{ |
|
|
38 |
UpdateElements(); |
|
|
39 |
} |
|
|
40 |
|
|
19
|
41 |
void VideoRecordUpdated_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
42 |
{ |
|
|
43 |
UpdateElements(); |
|
|
44 |
} |
|
|
45 |
|
|
|
46 |
|
|
0
|
47 |
void Action_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
48 |
{ |
|
|
49 |
AddSequenceButton.Content = ((MouseEventArgs)e.Parameter).GetPosition(this).X; |
|
|
50 |
} |
|
20
|
51 |
private double _sumOfLengh=0; |
|
19
|
52 |
public void UpdateElements() |
|
|
53 |
{ |
|
|
54 |
if (DataContext != null) |
|
|
55 |
{ |
|
20
|
56 |
if (((ProductionTimeLineVM)this.DataContext).SelectedChapter != -1) |
|
19
|
57 |
{ |
|
20
|
58 |
if (!((ProductionTimeLineVM)DataContext).IsIndexing) |
|
19
|
59 |
{ |
|
20
|
60 |
VideoTimeStrip.Children.Clear(); |
|
|
61 |
int intChapter = 0; |
|
|
62 |
_sumOfLengh = 0; |
|
|
63 |
foreach (ObservableCollection<VideoSequence> Ocvs in ((ProductionTimeLineVM)this.DataContext).ListVideoSequences) |
|
19
|
64 |
{ |
|
20
|
65 |
|
|
|
66 |
foreach (VideoSequence Vs in Ocvs) |
|
19
|
67 |
{ |
|
20
|
68 |
CustomableVideoElement _temp = new CustomableVideoElement() |
|
|
69 |
{ |
|
|
70 |
DataContext = new CustomableVideoElementVM(Vs) |
|
|
71 |
{ |
|
|
72 |
Chapter = (VideoChapterType)intChapter |
|
|
73 |
}, |
|
|
74 |
}; |
|
|
75 |
_temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown); |
|
|
76 |
if ((VideoChapterType)intChapter == ((ProductionTimeLineVM)this.DataContext).SelectedBookChapter.Type) |
|
|
77 |
{ |
|
|
78 |
_temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove); |
|
0
|
79 |
|
|
20
|
80 |
_temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp); |
|
|
81 |
} |
|
|
82 |
VideoTimeStrip.Children.Add(_temp);// TODO: Add event handler implementation here. |
|
|
83 |
_sumOfLengh += _temp.Width; |
|
|
84 |
} |
|
|
85 |
intChapter++; |
|
|
86 |
} |
|
|
87 |
} |
|
|
88 |
else |
|
|
89 |
{ |
|
|
90 |
AnnotationTimeStrip.Children.Clear(); |
|
|
91 |
|
|
|
92 |
foreach (ObservableCollection<SegmentIndex> Ocsi in ((ProductionTimeLineVM)this.DataContext).ListIndex) |
|
|
93 |
{ |
|
|
94 |
foreach (SegmentIndex Si in Ocsi) |
|
|
95 |
{ |
|
|
96 |
|
|
|
97 |
// PolemicElementControl an = new PolemicElementControl() { IsEnabled = false }; |
|
|
98 |
CustomableIndexElement an = new CustomableIndexElement() |
|
|
99 |
{ |
|
|
100 |
DataContext = new CustomableIndexElementVM(Si) |
|
|
101 |
}; |
|
19
|
102 |
|
|
20
|
103 |
//an.DataContext = new PolemicElementVM(Si); |
|
|
104 |
|
|
|
105 |
an.MouseLeftButtonDown += new MouseButtonEventHandler(an_MouseLeftButtonDown); |
|
|
106 |
an.MouseMove += new MouseEventHandler(an_MouseMove); |
|
|
107 |
an.MouseLeftButtonUp += new MouseButtonEventHandler(an_MouseLeftButtonUp); |
|
|
108 |
//((ProductionTimeLineVM)DataContext).SelectedBookChapter); |
|
|
109 |
AnnotationTimeStrip.Children.Add(an); |
|
21
|
110 |
|
|
20
|
111 |
|
|
|
112 |
} |
|
|
113 |
|
|
|
114 |
} |
|
|
115 |
|
|
19
|
116 |
} |
|
20
|
117 |
|
|
|
118 |
|
|
19
|
119 |
} |
|
|
120 |
|
|
20
|
121 |
|
|
19
|
122 |
} |
|
|
123 |
} |
|
20
|
124 |
|
|
|
125 |
void an_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
|
126 |
{ |
|
|
127 |
_isTrimRightCapturated = false; |
|
|
128 |
_isTrimLeftCapturated = false; |
|
|
129 |
} |
|
|
130 |
|
|
|
131 |
void an_MouseMove(object sender, MouseEventArgs e) |
|
|
132 |
{ |
|
|
133 |
if (((ProductionTimeLineVM)DataContext).IsIndexing) |
|
|
134 |
{ |
|
|
135 |
if (e.GetPosition(AnnotationTimeStrip).X <= _sumOfLengh && _isTrimRightCapturated && ((CustomableIndexElement)sender).CaptureMouse()) |
|
|
136 |
{ |
|
|
137 |
((CustomableIndexElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableIndexElement)sender)).X; |
|
|
138 |
_comePoint = e.GetPosition(((CustomableIndexElement)sender)); |
|
|
139 |
} |
|
|
140 |
|
|
|
141 |
} |
|
|
142 |
} |
|
|
143 |
private CustomableIndexElement _selectedIndex; |
|
|
144 |
void an_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
|
145 |
{ |
|
|
146 |
_selectedIndex = ((CustomableIndexElement)sender); |
|
|
147 |
if (e.GetPosition(((CustomableIndexElement)sender)).X >= ((CustomableIndexElement)sender).Width - 5) |
|
|
148 |
{ |
|
|
149 |
_comePoint = e.GetPosition(((CustomableIndexElement)sender)); |
|
|
150 |
_isTrimRightCapturated = true; |
|
|
151 |
} |
|
21
|
152 |
foreach(ObservableCollection<SegmentIndex> Ocsi in ((ProductionTimeLineVM)DataContext).ListIndex) |
|
|
153 |
{ |
|
|
154 |
foreach (SegmentIndex Si in Ocsi ) |
|
|
155 |
{ |
|
|
156 |
|
|
|
157 |
if (((CustomableIndexElementVM)_selectedIndex.DataContext).SegmentIndex == Si) |
|
|
158 |
{ |
|
|
159 |
if (Ocsi == ((ProductionTimeLineVM)DataContext).SelectedIndex) |
|
|
160 |
{ |
|
|
161 |
Commands.ProductionTimeLine.IndexSelected.Execute(true,Si); |
|
|
162 |
} |
|
|
163 |
else |
|
|
164 |
{ |
|
|
165 |
|
|
|
166 |
Commands.ProductionTimeLine.IndexSelected.Execute(false, Si); |
|
|
167 |
} |
|
|
168 |
|
|
|
169 |
} |
|
|
170 |
} |
|
|
171 |
} |
|
|
172 |
|
|
|
173 |
|
|
20
|
174 |
|
|
|
175 |
} |
|
0
|
176 |
private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
|
|
177 |
{ |
|
|
178 |
Random rndNumbers = new Random(); |
|
18
|
179 |
if (((ProductionTimeLineVM)this.DataContext).SelectedChapter != -1) |
|
17
|
180 |
{ |
|
18
|
181 |
if(!((ProductionTimeLineVM)DataContext).IsIndexing) |
|
|
182 |
{ |
|
0
|
183 |
|
|
18
|
184 |
CustomableVideoElement _temp = new CustomableVideoElement() |
|
0
|
185 |
{ |
|
18
|
186 |
DataContext = new CustomableVideoElementVM(new VideoSequence() |
|
|
187 |
{ |
|
0
|
188 |
|
|
18
|
189 |
RunTime = new TimeSpan(0, rndNumbers.Next(10, 60), 0), |
|
|
190 |
BeginTrim = new TimeSpan(0, 0, 0), |
|
|
191 |
EndTrim = new TimeSpan(0, 0, 0), |
|
17
|
192 |
|
|
18
|
193 |
}) { Chapter = ((ProductionTimeLineVM)this.DataContext).SelectedChapterType}, |
|
|
194 |
// Width = 200 |
|
|
195 |
}; |
|
|
196 |
|
|
|
197 |
_temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove); |
|
|
198 |
_temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown); |
|
|
199 |
_temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp); |
|
|
200 |
|
|
|
201 |
VideoTimeStrip.Children.Add(_temp );// TODO: Add event handler implementation here. |
|
|
202 |
} |
|
|
203 |
else |
|
17
|
204 |
{ |
|
18
|
205 |
VideoChapter vc = ((ProductionTimeLineVM)DataContext).SelectedBookChapter; |
|
20
|
206 |
PolemicElementControl an = new PolemicElementControl() { IsEnabled = false }; |
|
18
|
207 |
an.DataContext = new PolemicElementVM(new SegmentIndex(vc) |
|
|
208 |
{ |
|
|
209 |
TimerIn = TimeSpan.Zero, |
|
|
210 |
Duration = new TimeSpan(0, rndNumbers.Next(10, 60), 0), |
|
|
211 |
Chapter = vc, |
|
20
|
212 |
|
|
18
|
213 |
|
|
|
214 |
}); |
|
20
|
215 |
|
|
18
|
216 |
//((ProductionTimeLineVM)DataContext).SelectedBookChapter); |
|
|
217 |
AnnotationTimeStrip.Children.Add(an); |
|
|
218 |
} |
|
17
|
219 |
} |
|
0
|
220 |
} |
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
private void slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e) |
|
|
225 |
{ |
|
|
226 |
AddSequenceButton.Content = e.NewValue; |
|
|
227 |
// TODO: Add event handler implementation here. |
|
|
228 |
} |
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
private Point _comePoint; |
|
|
233 |
private bool _isTrimRightCapturated = false; |
|
|
234 |
private bool _isTrimLeftCapturated = false; |
|
|
235 |
|
|
|
236 |
private CustomableVideoElement _selected; |
|
|
237 |
void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e) |
|
|
238 |
{ |
|
|
239 |
|
|
20
|
240 |
if (!((ProductionTimeLineVM)DataContext).IsIndexing) |
|
0
|
241 |
{ |
|
20
|
242 |
if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
|
|
243 |
{ |
|
|
244 |
((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X; |
|
|
245 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
246 |
} |
|
|
247 |
else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
|
|
248 |
{ |
|
|
249 |
((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X; |
|
|
250 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
251 |
} |
|
0
|
252 |
} |
|
|
253 |
|
|
|
254 |
} |
|
|
255 |
void CustomableVideoElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
|
256 |
{ |
|
|
257 |
_isTrimRightCapturated = false; |
|
|
258 |
_isTrimLeftCapturated = false; |
|
|
259 |
} |
|
|
260 |
|
|
|
261 |
void CustomableVideoElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
|
262 |
{ |
|
17
|
263 |
_selected = ((CustomableVideoElement)sender); |
|
0
|
264 |
if (e.GetPosition(((CustomableVideoElement)sender)).X >= ((CustomableVideoElement)sender).Width - 5) |
|
|
265 |
{ |
|
|
266 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
267 |
_isTrimRightCapturated = true; |
|
|
268 |
} |
|
|
269 |
if (e.GetPosition(((CustomableVideoElement)sender)).X <= 5) |
|
|
270 |
{ |
|
|
271 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
272 |
_isTrimLeftCapturated = true; |
|
|
273 |
} |
|
|
274 |
} |
|
|
275 |
|
|
|
276 |
private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
|
|
277 |
{ |
|
20
|
278 |
//VideoTimeStrip.Children.Remove(_selected); |
|
|
279 |
Commands.ProductionView.DelVideoSequence.Execute(((CustomableVideoElement)_selected).DataContext); |
|
0
|
280 |
} |
|
|
281 |
} |
|
|
282 |
} |