client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs
--- a/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs Tue Dec 08 11:39:27 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs Fri Dec 11 10:48:58 2009 +0100
@@ -10,7 +10,7 @@
using Iri.Modernisation.BaseMVVM.Commands;
using Iri.Modernisation.Data.Models;
using Iri.Modernisation.Controls.ViewModel;
-using SLExtensions.Collections.ObjectModel;
+using System.Collections.ObjectModel;
namespace Iri.Modernisation.Controls.View
{
@@ -27,11 +27,17 @@
{
// Required to initialize variables
InitializeComponent();
+ Commands.ProductionTimeLine.EditorPartSelected.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartSelected_Executed);
Commands.ProductionView.VideoRecordUpdated.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(VideoRecordUpdated_Executed);
- Commands.Action.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Action_Executed);
+ Commands.Action.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Action_Executed);
}
+ void EditorPartSelected_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
+ {
+ UpdateElements();
+ }
+
void VideoRecordUpdated_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
{
UpdateElements();
@@ -42,35 +48,108 @@
{
AddSequenceButton.Content = ((MouseEventArgs)e.Parameter).GetPosition(this).X;
}
+ private double _sumOfLengh=0;
public void UpdateElements()
{
if (DataContext != null)
{
- VideoTimeStrip.Children.Clear();
- int intChapter = 0;
- foreach(ObservableCollection<VideoSequence> Ocvs in ((ProductionTimeLineVM)this.DataContext).ListVideoSequences)
+ if (((ProductionTimeLineVM)this.DataContext).SelectedChapter != -1)
{
- foreach (VideoSequence Vs in Ocvs)
+ if (!((ProductionTimeLineVM)DataContext).IsIndexing)
{
- CustomableVideoElement _temp = new CustomableVideoElement()
+ VideoTimeStrip.Children.Clear();
+ int intChapter = 0;
+ _sumOfLengh = 0;
+ foreach (ObservableCollection<VideoSequence> Ocvs in ((ProductionTimeLineVM)this.DataContext).ListVideoSequences)
{
- DataContext = new CustomableVideoElementVM(Vs)
+
+ foreach (VideoSequence Vs in Ocvs)
{
- Chapter = (VideoChapterType)intChapter
- },
- };
- _temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove);
- _temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown);
- _temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp);
+ CustomableVideoElement _temp = new CustomableVideoElement()
+ {
+ DataContext = new CustomableVideoElementVM(Vs)
+ {
+ Chapter = (VideoChapterType)intChapter
+ },
+ };
+ _temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown);
+ if ((VideoChapterType)intChapter == ((ProductionTimeLineVM)this.DataContext).SelectedBookChapter.Type)
+ {
+ _temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove);
- VideoTimeStrip.Children.Add(_temp);// TODO: Add event handler implementation here.
+ _temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp);
+ }
+ VideoTimeStrip.Children.Add(_temp);// TODO: Add event handler implementation here.
+ _sumOfLengh += _temp.Width;
+ }
+ intChapter++;
+ }
+ }
+ else
+ {
+ AnnotationTimeStrip.Children.Clear();
+
+ foreach (ObservableCollection<SegmentIndex> Ocsi in ((ProductionTimeLineVM)this.DataContext).ListIndex)
+ {
+ foreach (SegmentIndex Si in Ocsi)
+ {
+
+ // PolemicElementControl an = new PolemicElementControl() { IsEnabled = false };
+ CustomableIndexElement an = new CustomableIndexElement()
+ {
+ DataContext = new CustomableIndexElementVM(Si)
+ };
+ //an.DataContext = new PolemicElementVM(Si);
+
+ an.MouseLeftButtonDown += new MouseButtonEventHandler(an_MouseLeftButtonDown);
+ an.MouseMove += new MouseEventHandler(an_MouseMove);
+ an.MouseLeftButtonUp += new MouseButtonEventHandler(an_MouseLeftButtonUp);
+ //((ProductionTimeLineVM)DataContext).SelectedBookChapter);
+ AnnotationTimeStrip.Children.Add(an);
+
+ }
+
+ }
+
}
- intChapter++;
+
+
}
+
}
}
+
+ void an_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ _isTrimRightCapturated = false;
+ _isTrimLeftCapturated = false;
+ }
+
+ void an_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (((ProductionTimeLineVM)DataContext).IsIndexing)
+ {
+ if (e.GetPosition(AnnotationTimeStrip).X <= _sumOfLengh && _isTrimRightCapturated && ((CustomableIndexElement)sender).CaptureMouse())
+ {
+ ((CustomableIndexElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableIndexElement)sender)).X;
+ _comePoint = e.GetPosition(((CustomableIndexElement)sender));
+ }
+
+ }
+ }
+ private CustomableIndexElement _selectedIndex;
+ void an_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ _selectedIndex = ((CustomableIndexElement)sender);
+ if (e.GetPosition(((CustomableIndexElement)sender)).X >= ((CustomableIndexElement)sender).Width - 5)
+ {
+ _comePoint = e.GetPosition(((CustomableIndexElement)sender));
+ _isTrimRightCapturated = true;
+ }
+
+ }
private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
Random rndNumbers = new Random();
@@ -101,15 +180,16 @@
else
{
VideoChapter vc = ((ProductionTimeLineVM)DataContext).SelectedBookChapter;
- PolemicElementControl an = new PolemicElementControl();
+ PolemicElementControl an = new PolemicElementControl() { IsEnabled = false };
an.DataContext = new PolemicElementVM(new SegmentIndex(vc)
{
TimerIn = TimeSpan.Zero,
Duration = new TimeSpan(0, rndNumbers.Next(10, 60), 0),
Chapter = vc,
+
});
-
+
//((ProductionTimeLineVM)DataContext).SelectedBookChapter);
AnnotationTimeStrip.Children.Add(an);
}
@@ -134,16 +214,18 @@
void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e)
{
-
- if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse())
+ if (!((ProductionTimeLineVM)DataContext).IsIndexing)
{
- ((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X;
- _comePoint = e.GetPosition(((CustomableVideoElement)sender));
- }
- else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse())
- {
- ((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X;
- _comePoint = e.GetPosition(((CustomableVideoElement)sender));
+ if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse())
+ {
+ ((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X;
+ _comePoint = e.GetPosition(((CustomableVideoElement)sender));
+ }
+ else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse())
+ {
+ ((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X;
+ _comePoint = e.GetPosition(((CustomableVideoElement)sender));
+ }
}
}
@@ -170,7 +252,8 @@
private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
- VideoTimeStrip.Children.Remove(_selected);
+ //VideoTimeStrip.Children.Remove(_selected);
+ Commands.ProductionView.DelVideoSequence.Execute(((CustomableVideoElement)_selected).DataContext);
}
}
}
\ No newline at end of file