| author | totetm <> |
| Fri, 12 Feb 2010 15:57:01 +0100 | |
| changeset 46 | ab3057b82260 |
| parent 45 | de06fa7242ae |
| permissions | -rw-r--r-- |
| 0 | 1 |
using System; |
2 |
using System.Windows.Data; |
|
3 |
using System.Collections.Generic; |
|
4 |
using System.Linq; |
|
5 |
using System.Net; |
|
6 |
using System.Windows; |
|
7 |
using System.Windows.Controls; |
|
8 |
using System.Windows.Documents; |
|
9 |
using System.Windows.Input; |
|
10 |
using System.Windows.Media; |
|
11 |
using System.Windows.Media.Animation; |
|
12 |
using System.Windows.Shapes; |
|
13 |
using Iri.Modernisation.Data.Models; |
|
14 |
using Iri.Modernisation.Controls.ViewModel; |
|
15 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
| 38 | 16 |
using System.IO; |
| 0 | 17 |
namespace Iri.Modernisation.Controls.View |
18 |
{ |
|
19 |
public partial class BookTimeLine : UserControl |
|
20 |
{ |
|
21 |
public BookTimeLine() |
|
22 |
{ |
|
23 |
InitializeComponent(); |
|
| 42 | 24 |
|
25 |
|
|
| 0 | 26 |
TimeStripsPanel.SizeChanged += new SizeChangedEventHandler(TimeStripsPanel_SizeChanged); |
| 42 | 27 |
|
| 38 | 28 |
BookTimeLineSlider.MouseLeftButtonUp += new MouseButtonEventHandler(BookTimeLineSlider_MouseLeftButtonUp); |
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
29 |
//saveAnnotationsButton.Click += new RoutedEventHandler(saveAnnotationsButton_Click); |
| 42 | 30 |
|
| 38 | 31 |
Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(NewAnnotationFinished_Executed); |
| 42 | 32 |
BookTimeLineSlider.ThumbDragStarted += new EventHandler<EventArgs>(TimeSlider_ThumbDragStarted); |
33 |
BookTimeLineSlider.ThumbDragCompleted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted); |
|
34 |
|
|
35 |
|
|
| 24 | 36 |
} |
37 |
||
| 38 | 38 |
void saveAnnotationsButton_Click(object sender, RoutedEventArgs e) |
39 |
{ |
|
40 |
SaveFileDialog mySaveDialog = new SaveFileDialog(); |
|
41 |
mySaveDialog.Filter = "Ldt File (.ldt)|*.ldt|All Files|*.*"; |
|
42 |
bool? ret = mySaveDialog.ShowDialog(); |
|
43 |
if (ret == true) |
|
44 |
{ |
|
45 |
||
46 |
||
47 |
VideoBookUploader.UpdateAnnotation(((BookTimeLineVM)DataContext).SelectedBook, new StreamWriter(mySaveDialog.OpenFile())); |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
} |
|
52 |
private bool _saveVideoViewerState { get; set; } |
|
53 |
private void TimeSlider_ThumbDragCompleted(object sender, EventArgs e) |
|
54 |
{ |
|
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
45
diff
changeset
|
55 |
//Commands.TimeChange.Execute(null, DataContext); |
| 38 | 56 |
if (_saveVideoViewerState) |
57 |
{ |
|
| 42 | 58 |
|
| 38 | 59 |
((BookTimeLineVM)DataContext).ViewModelVideoViewer.Play(); |
| 42 | 60 |
|
61 |
||
| 38 | 62 |
} |
63 |
} |
|
64 |
||
65 |
private void TimeSlider_ThumbDragStarted(object sender, EventArgs e) |
|
66 |
{ |
|
67 |
_saveVideoViewerState = ((BookTimeLineVM)DataContext).ViewModelVideoViewer.IsPLayed; |
|
68 |
((BookTimeLineVM)DataContext).ViewModelVideoViewer.Pause(); |
|
69 |
||
70 |
} |
|
71 |
private void NewAnnotationFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
72 |
{ |
|
73 |
Draw(); |
|
74 |
} |
|
75 |
||
76 |
private void BookTimeLineSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
| 24 | 77 |
{ |
78 |
Commands.TimeChange.Execute(BookTimeLineSlider.Value,DataContext); |
|
| 42 | 79 |
|
80 |
|
|
| 0 | 81 |
} |
| 38 | 82 |
|
83 |
private void TimeStripsPanel_SizeChanged(object sender, SizeChangedEventArgs e) |
|
| 0 | 84 |
{ |
85 |
Draw(); |
|
86 |
} |
|
87 |
||
88 |
|
|
89 |
public void Draw() |
|
90 |
{ |
|
91 |
BookTimeLineVM VM = (BookTimeLineVM)DataContext; |
|
92 |
BookTimeLineElementPanel.Children.Clear(); |
|
| 18 | 93 |
BookTimeLineAnnotationPanel.Children.Clear(); |
| 0 | 94 |
foreach (List<SegmentIndex> LIndex in VM.SegmentIndex) |
95 |
{ |
|
96 |
foreach (SegmentIndex Index in LIndex) |
|
97 |
{ |
|
98 |
|
|
99 |
PolemicElementControl pol = new PolemicElementControl(); |
|
100 |
pol.SetValue(Canvas.ZIndexProperty, 10); |
|
101 |
pol.DataContext = new PolemicElementVM(Index); |
|
102 |
BookTimeLineElementPanel.Children.Add(pol); |
|
| 38 | 103 |
double timeleft = (double)((Index.TimerIn.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleTimeLine.Value); |
104 |
Canvas.SetLeft(pol,timeleft); |
|
105 |
pol.Width = (Index.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleTimeLine.Value; |
|
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
106 |
pol.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp); |
| 0 | 107 |
} |
108 |
} |
|
| 38 | 109 |
int basi = 0; |
|
45
de06fa7242ae
Fixed| agrandir la zonne d'affichage de la time line quand la taille des
totetm <>
parents:
42
diff
changeset
|
110 |
int maxHi = 0; |
| 0 | 111 |
foreach (List<Annotation> LAnnotation in VM.Annotations) |
112 |
{ |
|
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
45
diff
changeset
|
113 |
List<Annotation> tempList = new List<Annotation>(LAnnotation); |
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
45
diff
changeset
|
114 |
tempList.Sort((a, b) => TimeSpan.Compare(b.Duration, a.Duration)); |
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
45
diff
changeset
|
115 |
foreach (Annotation Annotation in tempList) |
| 0 | 116 |
{ |
117 |
PolemicElementControl pol = new PolemicElementControl(); |
|
118 |
pol.SetValue(Canvas.ZIndexProperty, 10); |
|
119 |
pol.DataContext = new PolemicElementVM(Annotation); |
|
| 38 | 120 |
|
121 |
Canvas.SetLeft(pol, (Annotation.TimerIn.TotalMilliseconds / BookTimeLineVM.ratioPixMs)* ScaleTimeLine.Value); |
|
122 |
|
|
123 |
/** It's TETRIS time **/ |
|
124 |
foreach (PolemicElementControl lockedControl in BookTimeLineAnnotationPanel.Children) |
|
125 |
{ |
|
126 |
if ( |
|
127 |
((PolemicElementVM)pol.DataContext).TimerIn >= ((PolemicElementVM)lockedControl.DataContext).TimerIn && ((PolemicElementVM)pol.DataContext).TimerIn <= ((PolemicElementVM)lockedControl.DataContext).TimerOut |
|
128 |
|| ((PolemicElementVM)pol.DataContext).TimerOut >= ((PolemicElementVM)lockedControl.DataContext).TimerIn && ((PolemicElementVM)pol.DataContext).TimerOut <= ((PolemicElementVM)lockedControl.DataContext).TimerOut |
|
129 |
|
|
130 |
) |
|
131 |
{ |
|
132 |
int actualTop = (int)Canvas.GetTop(lockedControl); |
|
133 |
if (basi <= actualTop) |
|
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
45
diff
changeset
|
134 |
{ |
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
45
diff
changeset
|
135 |
basi += 12; |
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
45
diff
changeset
|
136 |
} |
| 38 | 137 |
|
138 |
} |
|
139 |
} |
|
140 |
||
| 0 | 141 |
Canvas.SetTop(pol, basi); |
|
45
de06fa7242ae
Fixed| agrandir la zonne d'affichage de la time line quand la taille des
totetm <>
parents:
42
diff
changeset
|
142 |
if(maxHi<=basi) |
|
de06fa7242ae
Fixed| agrandir la zonne d'affichage de la time line quand la taille des
totetm <>
parents:
42
diff
changeset
|
143 |
{ |
|
de06fa7242ae
Fixed| agrandir la zonne d'affichage de la time line quand la taille des
totetm <>
parents:
42
diff
changeset
|
144 |
maxHi = basi + 24; |
|
de06fa7242ae
Fixed| agrandir la zonne d'affichage de la time line quand la taille des
totetm <>
parents:
42
diff
changeset
|
145 |
} |
| 38 | 146 |
/***********************/ |
147 |
|
|
148 |
|
|
149 |
// pol.Width = (Annotation.Duration.TotalMilliseconds * ScaleTimeLine.Value) / VM.TotalDuration; |
|
150 |
pol.Width = (Annotation.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs)* ScaleTimeLine.Value; |
|
151 |
BookTimeLineAnnotationPanel.Children.Add(pol); |
|
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
152 |
pol.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp); |
| 38 | 153 |
basi = 0; |
| 0 | 154 |
} |
155 |
} |
|
|
45
de06fa7242ae
Fixed| agrandir la zonne d'affichage de la time line quand la taille des
totetm <>
parents:
42
diff
changeset
|
156 |
BookTimeLineAnnotationPanel.Height = maxHi; |
| 0 | 157 |
BookTimeLineElementPanel.UpdateLayout(); |
158 |
} |
|
159 |
||
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
160 |
void Element_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
161 |
{ |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
162 |
PolemicElementVM VMPolemicElement = ((PolemicElementVM)((PolemicElementControl)sender).DataContext); |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
163 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
164 |
Commands.BookTimeLine.LeftClickOnElement.Execute(VMPolemicElement.TimerIn, VMPolemicElement); |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
165 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
166 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
167 |
} |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
168 |
|
| 38 | 169 |
|
| 7 | 170 |
|
| 0 | 171 |
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
} |
|
176 |
||
177 |
} |