| author | totetm <> |
| Wed, 10 Feb 2010 14:56:46 +0100 | |
| changeset 41 | b51a10574e7f |
| parent 38 | bd33267300aa |
| child 42 | 594fdedecf7f |
| 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(); |
|
24 |
|
|
25 |
TimeStripsPanel.SizeChanged += new SizeChangedEventHandler(TimeStripsPanel_SizeChanged); |
|
| 38 | 26 |
BookTimeLineSlider.ThumbDragStarted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted); |
27 |
BookTimeLineSlider.ThumbDragCompleted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted); |
|
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); |
| 38 | 30 |
Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(NewAnnotationFinished_Executed); |
| 24 | 31 |
} |
32 |
||
| 38 | 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) |
|
| 24 | 68 |
{ |
69 |
Commands.TimeChange.Execute(BookTimeLineSlider.Value,DataContext); |
|
| 0 | 70 |
} |
| 38 | 71 |
|
72 |
private void TimeStripsPanel_SizeChanged(object sender, SizeChangedEventArgs e) |
|
| 0 | 73 |
{ |
74 |
Draw(); |
|
75 |
} |
|
76 |
||
77 |
|
|
78 |
public void Draw() |
|
79 |
{ |
|
80 |
BookTimeLineVM VM = (BookTimeLineVM)DataContext; |
|
81 |
BookTimeLineElementPanel.Children.Clear(); |
|
| 18 | 82 |
BookTimeLineAnnotationPanel.Children.Clear(); |
| 0 | 83 |
foreach (List<SegmentIndex> LIndex in VM.SegmentIndex) |
84 |
{ |
|
85 |
foreach (SegmentIndex Index in LIndex) |
|
86 |
{ |
|
87 |
|
|
88 |
PolemicElementControl pol = new PolemicElementControl(); |
|
89 |
pol.SetValue(Canvas.ZIndexProperty, 10); |
|
90 |
pol.DataContext = new PolemicElementVM(Index); |
|
91 |
BookTimeLineElementPanel.Children.Add(pol); |
|
| 38 | 92 |
double timeleft = (double)((Index.TimerIn.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleTimeLine.Value); |
93 |
Canvas.SetLeft(pol,timeleft); |
|
94 |
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
|
95 |
pol.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp); |
| 0 | 96 |
} |
97 |
} |
|
| 38 | 98 |
int basi = 0; |
| 0 | 99 |
foreach (List<Annotation> LAnnotation in VM.Annotations) |
100 |
{ |
|
101 |
foreach (Annotation Annotation in LAnnotation) |
|
102 |
{ |
|
103 |
PolemicElementControl pol = new PolemicElementControl(); |
|
104 |
pol.SetValue(Canvas.ZIndexProperty, 10); |
|
105 |
pol.DataContext = new PolemicElementVM(Annotation); |
|
| 38 | 106 |
|
107 |
Canvas.SetLeft(pol, (Annotation.TimerIn.TotalMilliseconds / BookTimeLineVM.ratioPixMs)* ScaleTimeLine.Value); |
|
108 |
|
|
109 |
/** It's TETRIS time **/ |
|
110 |
foreach (PolemicElementControl lockedControl in BookTimeLineAnnotationPanel.Children) |
|
111 |
{ |
|
112 |
if ( |
|
113 |
((PolemicElementVM)pol.DataContext).TimerIn >= ((PolemicElementVM)lockedControl.DataContext).TimerIn && ((PolemicElementVM)pol.DataContext).TimerIn <= ((PolemicElementVM)lockedControl.DataContext).TimerOut |
|
114 |
|| ((PolemicElementVM)pol.DataContext).TimerOut >= ((PolemicElementVM)lockedControl.DataContext).TimerIn && ((PolemicElementVM)pol.DataContext).TimerOut <= ((PolemicElementVM)lockedControl.DataContext).TimerOut |
|
115 |
|
|
116 |
) |
|
117 |
{ |
|
118 |
int actualTop = (int)Canvas.GetTop(lockedControl); |
|
119 |
if (basi <= actualTop) |
|
120 |
{ |
|
121 |
basi += 10; |
|
122 |
} |
|
123 |
|
|
124 |
} |
|
125 |
} |
|
126 |
||
| 0 | 127 |
Canvas.SetTop(pol, basi); |
| 38 | 128 |
/***********************/ |
129 |
|
|
130 |
|
|
131 |
// pol.Width = (Annotation.Duration.TotalMilliseconds * ScaleTimeLine.Value) / VM.TotalDuration; |
|
132 |
pol.Width = (Annotation.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs)* ScaleTimeLine.Value; |
|
133 |
BookTimeLineAnnotationPanel.Children.Add(pol); |
|
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
134 |
pol.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp); |
| 38 | 135 |
basi = 0; |
| 0 | 136 |
} |
137 |
} |
|
138 |
BookTimeLineElementPanel.UpdateLayout(); |
|
139 |
} |
|
140 |
||
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
141 |
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
|
142 |
{ |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
143 |
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
|
144 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
145 |
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
|
146 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
147 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
148 |
} |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
38
diff
changeset
|
149 |
|
| 38 | 150 |
|
| 7 | 151 |
|
| 0 | 152 |
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
} |
|
157 |
||
158 |
} |