| author | Matthieu Totet |
| Mon, 14 Dec 2009 17:02:03 +0100 | |
| changeset 23 | 10acb6a11a73 |
| parent 21 | 253f142174ac |
| child 24 | c031f1132dde |
| 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; |
| 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 |
{ |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
21
diff
changeset
|
178 |
AddSequenceButton.Content = ((ProductionTimeLineVM)DataContext).TotalBookDuration; |
| 0 | 179 |
} |
180 |
||
181 |
|
|
182 |
||
183 |
private void slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e) |
|
184 |
{ |
|
185 |
AddSequenceButton.Content = e.NewValue; |
|
186 |
// TODO: Add event handler implementation here. |
|
187 |
} |
|
188 |
||
189 |
||
190 |
||
191 |
private Point _comePoint; |
|
192 |
private bool _isTrimRightCapturated = false; |
|
193 |
private bool _isTrimLeftCapturated = false; |
|
194 |
||
195 |
private CustomableVideoElement _selected; |
|
196 |
void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e) |
|
197 |
{ |
|
198 |
||
| 20 | 199 |
if (!((ProductionTimeLineVM)DataContext).IsIndexing) |
| 0 | 200 |
{ |
| 20 | 201 |
if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
202 |
{ |
|
203 |
((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X; |
|
204 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
205 |
} |
|
206 |
else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
|
207 |
{ |
|
208 |
((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X; |
|
209 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
210 |
} |
|
| 0 | 211 |
} |
212 |
|
|
213 |
} |
|
214 |
void CustomableVideoElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
215 |
{ |
|
216 |
_isTrimRightCapturated = false; |
|
217 |
_isTrimLeftCapturated = false; |
|
218 |
} |
|
219 |
||
220 |
void CustomableVideoElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
221 |
{ |
|
| 17 | 222 |
_selected = ((CustomableVideoElement)sender); |
| 0 | 223 |
if (e.GetPosition(((CustomableVideoElement)sender)).X >= ((CustomableVideoElement)sender).Width - 5) |
224 |
{ |
|
225 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
226 |
_isTrimRightCapturated = true; |
|
227 |
} |
|
228 |
if (e.GetPosition(((CustomableVideoElement)sender)).X <= 5) |
|
229 |
{ |
|
230 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
231 |
_isTrimLeftCapturated = true; |
|
232 |
} |
|
233 |
} |
|
234 |
||
235 |
private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
|
236 |
{ |
|
| 20 | 237 |
//VideoTimeStrip.Children.Remove(_selected); |
238 |
Commands.ProductionView.DelVideoSequence.Execute(((CustomableVideoElement)_selected).DataContext); |
|
| 0 | 239 |
} |
240 |
} |
|
241 |
} |