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