11 using System.Windows.Media.Animation; |
11 using System.Windows.Media.Animation; |
12 using System.Windows.Shapes; |
12 using System.Windows.Shapes; |
13 using Iri.Modernisation.Data.Models; |
13 using Iri.Modernisation.Data.Models; |
14 using Iri.Modernisation.Controls.ViewModel; |
14 using Iri.Modernisation.Controls.ViewModel; |
15 using Iri.Modernisation.BaseMVVM.Commands; |
15 using Iri.Modernisation.BaseMVVM.Commands; |
|
16 using System.IO; |
16 namespace Iri.Modernisation.Controls.View |
17 namespace Iri.Modernisation.Controls.View |
17 { |
18 { |
18 public partial class BookTimeLine : UserControl |
19 public partial class BookTimeLine : UserControl |
19 { |
20 { |
20 public BookTimeLine() |
21 public BookTimeLine() |
21 { |
22 { |
22 InitializeComponent(); |
23 InitializeComponent(); |
23 |
24 |
24 TimeStripsPanel.SizeChanged += new SizeChangedEventHandler(TimeStripsPanel_SizeChanged); |
25 TimeStripsPanel.SizeChanged += new SizeChangedEventHandler(TimeStripsPanel_SizeChanged); |
25 BookTimeLineSlider.MouseLeftButtonUp += new MouseButtonEventHandler(BookTimeLineSlider_MouseLeftButtonUp); |
26 BookTimeLineSlider.ThumbDragStarted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted); |
|
27 BookTimeLineSlider.ThumbDragCompleted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted); |
|
28 BookTimeLineSlider.MouseLeftButtonUp += new MouseButtonEventHandler(BookTimeLineSlider_MouseLeftButtonUp); |
|
29 saveAnnotationsButton.Click += new RoutedEventHandler(saveAnnotationsButton_Click); |
|
30 Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(NewAnnotationFinished_Executed); |
26 } |
31 } |
27 |
32 |
28 void BookTimeLineSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
33 void saveAnnotationsButton_Click(object sender, RoutedEventArgs e) |
|
34 { |
|
35 SaveFileDialog mySaveDialog = new SaveFileDialog(); |
|
36 mySaveDialog.Filter = "Ldt File (.ldt)|*.ldt|All Files|*.*"; |
|
37 bool? ret = mySaveDialog.ShowDialog(); |
|
38 if (ret == true) |
|
39 { |
|
40 |
|
41 |
|
42 VideoBookUploader.UpdateAnnotation(((BookTimeLineVM)DataContext).SelectedBook, new StreamWriter(mySaveDialog.OpenFile())); |
|
43 |
|
44 } |
|
45 |
|
46 } |
|
47 private bool _saveVideoViewerState { get; set; } |
|
48 private void TimeSlider_ThumbDragCompleted(object sender, EventArgs e) |
|
49 { |
|
50 if (_saveVideoViewerState) |
|
51 { |
|
52 ((BookTimeLineVM)DataContext).ViewModelVideoViewer.Play(); |
|
53 } |
|
54 } |
|
55 |
|
56 private void TimeSlider_ThumbDragStarted(object sender, EventArgs e) |
|
57 { |
|
58 _saveVideoViewerState = ((BookTimeLineVM)DataContext).ViewModelVideoViewer.IsPLayed; |
|
59 ((BookTimeLineVM)DataContext).ViewModelVideoViewer.Pause(); |
|
60 |
|
61 } |
|
62 private void NewAnnotationFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
63 { |
|
64 Draw(); |
|
65 } |
|
66 |
|
67 private void BookTimeLineSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
29 { |
68 { |
30 Commands.TimeChange.Execute(BookTimeLineSlider.Value,DataContext); |
69 Commands.TimeChange.Execute(BookTimeLineSlider.Value,DataContext); |
31 } |
70 } |
32 |
71 |
33 void TimeStripsPanel_SizeChanged(object sender, SizeChangedEventArgs e) |
72 private void TimeStripsPanel_SizeChanged(object sender, SizeChangedEventArgs e) |
34 { |
73 { |
35 Draw(); |
74 Draw(); |
36 } |
75 } |
37 |
76 |
38 |
77 |
45 { |
84 { |
46 foreach (SegmentIndex Index in LIndex) |
85 foreach (SegmentIndex Index in LIndex) |
47 { |
86 { |
48 |
87 |
49 PolemicElementControl pol = new PolemicElementControl(); |
88 PolemicElementControl pol = new PolemicElementControl(); |
50 |
|
51 pol.SetValue(Canvas.ZIndexProperty, 10); |
89 pol.SetValue(Canvas.ZIndexProperty, 10); |
52 pol.DataContext = new PolemicElementVM(Index); |
90 pol.DataContext = new PolemicElementVM(Index); |
53 BookTimeLineElementPanel.Children.Add(pol); |
91 BookTimeLineElementPanel.Children.Add(pol); |
54 |
92 double timeleft = (double)((Index.TimerIn.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleTimeLine.Value); |
55 Canvas.SetLeft(pol, (Index.TimerIn.TotalMilliseconds * ScaleTimeLine.Value) / VM.TotalDuration); |
93 Canvas.SetLeft(pol,timeleft); |
56 pol.Width = (Index.Duration.TotalMilliseconds * ScaleTimeLine.Value) / VM.TotalDuration; |
94 pol.Width = (Index.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleTimeLine.Value; |
57 } |
95 } |
58 } |
96 } |
59 int basi = 30; |
97 int basi = 0; |
60 foreach (List<Annotation> LAnnotation in VM.Annotations) |
98 foreach (List<Annotation> LAnnotation in VM.Annotations) |
61 { |
99 { |
62 foreach (Annotation Annotation in LAnnotation) |
100 foreach (Annotation Annotation in LAnnotation) |
63 { |
101 { |
64 PolemicElementControl pol = new PolemicElementControl(); |
102 PolemicElementControl pol = new PolemicElementControl(); |
65 pol.SetValue(Canvas.ZIndexProperty, 10); |
103 pol.SetValue(Canvas.ZIndexProperty, 10); |
66 pol.DataContext = new PolemicElementVM(Annotation); |
104 pol.DataContext = new PolemicElementVM(Annotation); |
|
105 |
|
106 Canvas.SetLeft(pol, (Annotation.TimerIn.TotalMilliseconds / BookTimeLineVM.ratioPixMs)* ScaleTimeLine.Value); |
|
107 |
|
108 /** It's TETRIS time **/ |
|
109 foreach (PolemicElementControl lockedControl in BookTimeLineAnnotationPanel.Children) |
|
110 { |
|
111 if ( |
|
112 ((PolemicElementVM)pol.DataContext).TimerIn >= ((PolemicElementVM)lockedControl.DataContext).TimerIn && ((PolemicElementVM)pol.DataContext).TimerIn <= ((PolemicElementVM)lockedControl.DataContext).TimerOut |
|
113 || ((PolemicElementVM)pol.DataContext).TimerOut >= ((PolemicElementVM)lockedControl.DataContext).TimerIn && ((PolemicElementVM)pol.DataContext).TimerOut <= ((PolemicElementVM)lockedControl.DataContext).TimerOut |
|
114 |
|
115 ) |
|
116 { |
|
117 int actualTop = (int)Canvas.GetTop(lockedControl); |
|
118 if (basi <= actualTop) |
|
119 { |
|
120 basi += 10; |
|
121 } |
|
122 |
|
123 } |
|
124 } |
|
125 |
|
126 Canvas.SetTop(pol, basi); |
|
127 /***********************/ |
|
128 |
|
129 |
|
130 // pol.Width = (Annotation.Duration.TotalMilliseconds * ScaleTimeLine.Value) / VM.TotalDuration; |
|
131 pol.Width = (Annotation.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs)* ScaleTimeLine.Value; |
67 BookTimeLineAnnotationPanel.Children.Add(pol); |
132 BookTimeLineAnnotationPanel.Children.Add(pol); |
68 Canvas.SetLeft(pol, (Annotation.TimerIn.TotalMilliseconds * ScaleTimeLine.Value) / VM.TotalDuration); |
133 basi = 0; |
69 Canvas.SetTop(pol, basi); |
|
70 basi += 10; |
|
71 pol.Width = (Annotation.Duration.TotalMilliseconds * ScaleTimeLine.Value) / VM.TotalDuration; |
|
72 } |
134 } |
73 } |
135 } |
74 BookTimeLineElementPanel.UpdateLayout(); |
136 BookTimeLineElementPanel.UpdateLayout(); |
75 } |
137 } |
76 |
138 |
77 private void BookTimeLineSlider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
139 |
78 { |
|
79 MessageBox.Show("Change"); |
|
80 BookTimeLineSlider.Value = (e.GetPosition(BookTimeLineSlider).X) * BookTimeLineSlider.Maximum / BookTimeLineSlider.Width; |
|
81 } |
|
82 |
140 |
83 |
141 |
84 |
142 |
85 |
143 |
86 |
144 |