|
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; |
|
|
13 |
namespace Iri.Modernisation.Controls.View |
|
|
14 |
{ |
|
|
15 |
|
|
|
16 |
public partial class ProductionTimeLine : UserControl |
|
|
17 |
{ |
|
|
18 |
public static double ScaleTime |
|
|
19 |
{ |
|
|
20 |
get |
|
|
21 |
{ |
|
|
22 |
return 0.0001; |
|
|
23 |
} |
|
|
24 |
} |
|
|
25 |
public ProductionTimeLine() |
|
|
26 |
{ |
|
|
27 |
// Required to initialize variables |
|
|
28 |
InitializeComponent(); |
|
17
|
29 |
|
|
0
|
30 |
Commands.Action.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Action_Executed); |
|
|
31 |
|
|
|
32 |
} |
|
|
33 |
|
|
|
34 |
void Action_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
35 |
{ |
|
|
36 |
AddSequenceButton.Content = ((MouseEventArgs)e.Parameter).GetPosition(this).X; |
|
|
37 |
} |
|
|
38 |
|
|
|
39 |
private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
|
|
40 |
{ |
|
|
41 |
Random rndNumbers = new Random(); |
|
17
|
42 |
if(!((ProductionTimeLineVM)DataContext).IsIndexing) |
|
|
43 |
{ |
|
0
|
44 |
|
|
|
45 |
CustomableVideoElement _temp = new CustomableVideoElement() |
|
|
46 |
{ |
|
|
47 |
DataContext = new CustomableVideoElementVM(new VideoSequence() |
|
|
48 |
{ |
|
|
49 |
|
|
17
|
50 |
RunTime = new TimeSpan(0, rndNumbers.Next(10, 60), 0), |
|
0
|
51 |
BeginTrim = new TimeSpan(0, 0, 0), |
|
17
|
52 |
EndTrim = new TimeSpan(0, 0, 0), |
|
|
53 |
|
|
|
54 |
}) { Chapter = ((ProductionTimeLineVM)this.DataContext).SelectedChapterType}, |
|
|
55 |
// Width = 200 |
|
0
|
56 |
}; |
|
17
|
57 |
|
|
0
|
58 |
_temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove); |
|
|
59 |
_temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown); |
|
|
60 |
_temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp); |
|
17
|
61 |
|
|
|
62 |
VideoTimeStrip.Children.Add(_temp );// TODO: Add event handler implementation here. |
|
|
63 |
} |
|
|
64 |
else |
|
|
65 |
{ |
|
|
66 |
VideoChapter vc = ((ProductionTimeLineVM)DataContext).SelectedBookChapter; |
|
|
67 |
PolemicElementControl an = new PolemicElementControl() |
|
|
68 |
{ |
|
|
69 |
DataContext = new PolemicElementVM(new SegmentIndex(vc)) |
|
|
70 |
{ |
|
|
71 |
TimerIn = TimeSpan.Zero, |
|
|
72 |
Duration = new TimeSpan(0, rndNumbers.Next(10, 60), 0) |
|
|
73 |
}, |
|
|
74 |
}; |
|
|
75 |
//((ProductionTimeLineVM)DataContext).SelectedBookChapter); |
|
|
76 |
AnnotationTimeStrip.Children.Add(an); |
|
|
77 |
} |
|
0
|
78 |
} |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
private void slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e) |
|
|
83 |
{ |
|
|
84 |
AddSequenceButton.Content = e.NewValue; |
|
|
85 |
// TODO: Add event handler implementation here. |
|
|
86 |
} |
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
private Point _comePoint; |
|
|
91 |
private bool _isTrimRightCapturated = false; |
|
|
92 |
private bool _isTrimLeftCapturated = false; |
|
|
93 |
|
|
|
94 |
private CustomableVideoElement _selected; |
|
|
95 |
void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e) |
|
|
96 |
{ |
|
|
97 |
|
|
17
|
98 |
|
|
0
|
99 |
if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
|
|
100 |
{ |
|
|
101 |
((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X; |
|
|
102 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
103 |
} |
|
|
104 |
else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse()) |
|
|
105 |
{ |
|
|
106 |
((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X; |
|
|
107 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
108 |
} |
|
|
109 |
|
|
|
110 |
} |
|
|
111 |
void CustomableVideoElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
|
112 |
{ |
|
|
113 |
_isTrimRightCapturated = false; |
|
|
114 |
_isTrimLeftCapturated = false; |
|
|
115 |
} |
|
|
116 |
|
|
|
117 |
void CustomableVideoElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
|
118 |
{ |
|
17
|
119 |
_selected = ((CustomableVideoElement)sender); |
|
0
|
120 |
if (e.GetPosition(((CustomableVideoElement)sender)).X >= ((CustomableVideoElement)sender).Width - 5) |
|
|
121 |
{ |
|
|
122 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
123 |
_isTrimRightCapturated = true; |
|
|
124 |
} |
|
|
125 |
if (e.GetPosition(((CustomableVideoElement)sender)).X <= 5) |
|
|
126 |
{ |
|
|
127 |
_comePoint = e.GetPosition(((CustomableVideoElement)sender)); |
|
|
128 |
_isTrimLeftCapturated = true; |
|
|
129 |
} |
|
|
130 |
} |
|
|
131 |
|
|
|
132 |
private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e) |
|
|
133 |
{ |
|
17
|
134 |
VideoTimeStrip.Children.Remove(_selected); |
|
0
|
135 |
} |
|
|
136 |
} |
|
|
137 |
} |