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