Update VideoViewer ( Allow Multi-VideoViewer)
authorMatthieu Totet
Mon, 14 Dec 2009 17:02:03 +0100
changeset 23 10acb6a11a73
parent 22 69a2910ec6f9
child 24 c031f1132dde
Update VideoViewer ( Allow Multi-VideoViewer)
client/src/Iri.Modernisation.Controls/View/ProductionEditor/ProductionEditor.xaml
client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml
client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs
client/src/Iri.Modernisation.Controls/View/ProductionView/ProductionView.xaml
client/src/Iri.Modernisation.Controls/View/VideoViewer/VideoViewer.xaml.cs
client/src/Iri.Modernisation.Controls/ViewModel/BookTimeLine/BookTimeLineVM.cs
client/src/Iri.Modernisation.Controls/ViewModel/ConsultationView/ConsultationViewVM.cs
client/src/Iri.Modernisation.Controls/ViewModel/ProductionTimeLine/ProductionTimeLineVM.cs
client/src/Iri.Modernisation.Controls/ViewModel/ProductionView/ProductionViewVM.cs
client/src/Iri.Modernisation.Controls/ViewModel/VideoViewer/VideoViewerVM.cs
--- a/client/src/Iri.Modernisation.Controls/View/ProductionEditor/ProductionEditor.xaml	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ProductionEditor/ProductionEditor.xaml	Mon Dec 14 17:02:03 2009 +0100
@@ -4,10 +4,10 @@
 	xmlns:View="clr-namespace:Iri.Modernisation.Controls.View">
     <StackPanel x:Name="ProductionViewerPanel">
         <StackPanel x:Name="ProductionViewerControlPanel" Height="29" Orientation="Horizontal">
-            <Button x:Name="ProductionViewerDisplayChutierButton"  Width="75" Content="Chutier"/>
-            <Button x:Name="ProductionViewerDisplayWebcamButton"  Width="75" Content="Webcam"/>
+            
+            <ToggleButton x:Name="ProductionViewerDisplayWebcamButton"  Width="75" Content="Webcam"/>
         </StackPanel>
-        <View:VideoViewer Margin="0,0,24,0"  Height="227"/> 
+        <View:VideoViewer x:Name="VideoViewerElement" DataContext="{Binding ViewModelVideoViewer}" Margin="0,0,24,0"  Height="227"/> 
         <StackPanel x:Name="DescriptionSegmentPanel" Height="128">
             <TextBox IsEnabled="{Binding  IsEditableIndex}" x:Name="TitleSegmentLabel" Text="{Binding  SelectedIndexTitle,Mode=TwoWay}" TextWrapping="Wrap" Height="24" Margin="0,0,8,0"/>
             <TextBox  IsEnabled="{Binding  IsEditableIndex}" x:Name="DescriptionSegmentLabel"  Text="{Binding  SelectedIndexDescription,Mode=TwoWay}" TextWrapping="Wrap" Height="64" AcceptsReturn="True" VerticalScrollBarVisibility="Visible"/>
--- a/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml	Mon Dec 14 17:02:03 2009 +0100
@@ -13,22 +13,22 @@
 			<Button x:Name="CutSequenceButton"  Content="Cut" Width="56"/>
 			<Button x:Name="InsertSequenceButton"  Width="58" Content="Ins"/>
 			<Button x:Name="DeleteSequenceButton"  Width="61" Content="Del" Click="DeleteSequenceButton_Click"/>
-			<Button x:Name="AddSequenceButton"  Width="61" Content="Add" Click="AddSequenceButton_Click"/>
+			<Button x:Name="AddSequenceButton"  Width="61" Content="{Binding TotalBookDuration}" Click="AddSequenceButton_Click"/>
 			<Slider x:Name="ScaleTimeLine"  Width="199" Margin="111,0,0,0" Minimum="600" Maximum="10000" Value="600"/>
 		</StackPanel>
-		<ScrollViewer x:Name="TimeLineScroller" Height="154" >
+		<ScrollViewer x:Name="TimeLineScroller" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Visible" Height="154" >
 			<Grid>
 				<Grid.ColumnDefinitions>
 					<ColumnDefinition/>
 				</Grid.ColumnDefinitions>
-				<Slider x:Name="slider" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" SmallChange="0" ValueChanged="slider_ValueChanged"/>
+				<Slider x:Name="TimeSlider" Value="{Binding Position}" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" SmallChange="0" />
 				<StackPanel x:Name="VideoTimeStrip" Margin="0,21,0,0" Orientation="Horizontal" Height="32" VerticalAlignment="Top">
 					<!--<StackPanel Orientation="Horizontal" x:Name="ModenisationVideoTimeStrip"></StackPanel>
 					<StackPanel Orientation="Horizontal" x:Name="ModeniteVideoTimeStrip"></StackPanel>
 					<StackPanel Orientation="Horizontal" x:Name="PostModerniteVideoTimeStrip"></StackPanel>
 					<StackPanel Orientation="Horizontal" x:Name="OuvertureVideoTimeStrip"></StackPanel>-->
 				</StackPanel>
-				<StackPanel x:Name="AnnotationTimeStrip" Margin="0,57,0,67" Orientation="Horizontal" >
+				<StackPanel x:Name="AnnotationTimeStrip" Margin="0,57,0,53" Orientation="Horizontal" d:LayoutOverrides="VerticalAlignment" >
 				
 				</StackPanel>
 			</Grid>
--- a/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs	Mon Dec 14 17:02:03 2009 +0100
@@ -175,48 +175,7 @@
         }
         private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
         {
-            Random rndNumbers = new Random();
-            if (((ProductionTimeLineVM)this.DataContext).SelectedChapter != -1)
-            {
-                if(!((ProductionTimeLineVM)DataContext).IsIndexing)
-                {
-
-                CustomableVideoElement _temp = new CustomableVideoElement()
-                                         {
-                                             DataContext = new CustomableVideoElementVM(new VideoSequence()
-                                             {
-
-                                                 RunTime = new TimeSpan(0, rndNumbers.Next(10, 60), 0),
-                                                 BeginTrim = new TimeSpan(0, 0, 0),
-                                                 EndTrim = new TimeSpan(0, 0, 0),
-
-                                             }) { Chapter = ((ProductionTimeLineVM)this.DataContext).SelectedChapterType},
-                                             // Width = 200
-                                         };
-                
-                _temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove);
-                _temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown);
-                _temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp);
-                
-                   VideoTimeStrip.Children.Add(_temp  );// TODO: Add event handler implementation here.
-                }
-                else
-                {
-                    VideoChapter vc = ((ProductionTimeLineVM)DataContext).SelectedBookChapter;
-                    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);
-                }
-            }
+            AddSequenceButton.Content = ((ProductionTimeLineVM)DataContext).TotalBookDuration;
         }
 
         
--- a/client/src/Iri.Modernisation.Controls/View/ProductionView/ProductionView.xaml	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ProductionView/ProductionView.xaml	Mon Dec 14 17:02:03 2009 +0100
@@ -15,7 +15,7 @@
     	<View:HeaderProduction DataContext="{Binding ViewModelHeaderProduction}" x:Name="HeaderProductionElement" HorizontalAlignment="Left" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment"/>
     	<View:ProductionTimeLine x:Name="ProductionTimeLineElement" Height="176" VerticalAlignment="Bottom" DataContext="{Binding ViewModelProductionTimeLine}"/>
     	<View:ProductionEditor DataContext="{Binding ViewModelProductionEditor}" Margin="272,115,0,0" HorizontalAlignment="Left" Height="381" VerticalAlignment="Top"/>
-    	<View:VideoViewer HorizontalAlignment="Right" Margin="0,115,8,204" Width="404"/>
+    	<View:VideoViewer DataContext="{Binding ViewModelMasterVideoViewer}" HorizontalAlignment="Right" Margin="0,115,8,204" Width="404"/>
     	<StackPanel x:Name="RecordsPanel" HorizontalAlignment="Left" Margin="8,240,0,216" Width="248">
     		<TextBlock Style="{StaticResource CommonTextBlock}" Text="{Binding RecordsLabel, Source={StaticResource LangLabels}}" x:Name="RecordLabel" TextWrapping="Wrap"/>
     		<ListBox SelectedItem="{Binding SelectedVideoSequence,Mode=TwoWay}" x:Name="RecordsList" ItemsSource="{Binding RecordedVideoSequences}" Height="168">
--- a/client/src/Iri.Modernisation.Controls/View/VideoViewer/VideoViewer.xaml.cs	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/VideoViewer/VideoViewer.xaml.cs	Mon Dec 14 17:02:03 2009 +0100
@@ -50,7 +50,10 @@
 
         void GoToTime_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
-            VideoScreen.Position = TimeSpan.FromMilliseconds((double)e.Parameter);
+            if(e.Source == DataContext)
+            {
+               VideoScreen.Position = ((TimeSpan)e.Parameter);
+            }
         }
 
         void VideoPositionTimer_Tick(object sender, EventArgs e)
--- a/client/src/Iri.Modernisation.Controls/ViewModel/BookTimeLine/BookTimeLineVM.cs	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/BookTimeLine/BookTimeLineVM.cs	Mon Dec 14 17:02:03 2009 +0100
@@ -275,13 +275,28 @@
             Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed);
 
         }
-
+        private VideoViewerVM _videoViewerVM;
+        public VideoViewerVM ViewModelVideoViewer
+        {
+            get
+            {
+                return _videoViewerVM;
+            }
+            set
+            {
+                _videoViewerVM = value;
+                OnPropertyChanged("ViewModelVideoViewer");
+            }
+        }
         void TimeChange_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
           //  Position = ((Slider)e.Parameter).Value;
-            //Commands.VideoViewer.Pause.Execute();
-            Commands.GoToTime.Execute(((Slider)e.Parameter).Value);
-            //Commands.VideoViewer.Play.Execute();
+           // Commands.VideoViewer.Pause.Execute();
+
+            ViewModelVideoViewer.GoTo(TimeSpan.FromMilliseconds(((Slider)e.Parameter).Value));
+            //Commands.GoToTime.Execute(((Slider)e.Parameter).Value);
+            
+           // Commands.VideoViewer.Play.Execute();
         }
 
       
--- a/client/src/Iri.Modernisation.Controls/ViewModel/ConsultationView/ConsultationViewVM.cs	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/ConsultationView/ConsultationViewVM.cs	Mon Dec 14 17:02:03 2009 +0100
@@ -89,6 +89,7 @@
         void ClickBook_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
             BookTimeLineVM temp = new BookTimeLineVM((VideoBook)e.Parameter);
+            temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM;
             bool CanAdd = true;
            foreach(BookTimeLineVM BookTLVM in SelectedVideoBooks)
            {
--- a/client/src/Iri.Modernisation.Controls/ViewModel/ProductionTimeLine/ProductionTimeLineVM.cs	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/ProductionTimeLine/ProductionTimeLineVM.cs	Mon Dec 14 17:02:03 2009 +0100
@@ -64,7 +64,21 @@
                 OnPropertyChanged("SelectedVideoSequences");
             }
         }
-    
+        public TimeSpan TotalBookDuration
+        {
+            get
+            {
+                TimeSpan temp = TimeSpan.Zero;
+                foreach (ObservableCollection<VideoSequence> Ocvs in _listVideoSequences)
+                {
+                    foreach (VideoSequence Vs in Ocvs)
+                    {
+                        temp += Vs.Duration;
+                    }
+                }
+                return temp;
+            }
+        }
         public VideoChapter[] Chapters
         {
             get
@@ -97,6 +111,19 @@
         }
 
 
+        private double _position;
+        public double Position
+        {
+            get
+            {
+                return _position;
+            }
+            set
+            {
+                _position = value;
+                OnPropertyChanged("Position");
+            }
+        }
 
         private ObservableCollection<SegmentIndex>[] _listSegmentIndex;
         public ObservableCollection<SegmentIndex>[] ListIndex
@@ -189,6 +216,7 @@
                     TimerOut = dur,
                     Chapter = SelectedBookChapter
                 });
+
             }
  
         }
@@ -196,10 +224,12 @@
         void DelVideoSequence_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
             SelectedVideoSequences.Remove(((CustomableVideoElementVM)e.Parameter).VideoSequence);
+            OnPropertyChanged("TotalBookDuration");
         }
 
         void SelectedVideoSequences_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
         {
+            OnPropertyChanged("TotalBookDuration");
             Commands.ProductionView.VideoRecordUpdated.Execute();
         }
 
@@ -220,5 +250,6 @@
             SelectedChapterType = ((HeaderProductionEventArgs)e.Source).ChapterType ;
             IsIndexing = ((HeaderProductionEventArgs)e.Source).IsIndexPart;
         }
+
     }
 }
--- a/client/src/Iri.Modernisation.Controls/ViewModel/ProductionView/ProductionViewVM.cs	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/ProductionView/ProductionViewVM.cs	Mon Dec 14 17:02:03 2009 +0100
@@ -90,6 +90,20 @@
                 OnPropertyChanged("ViewModelProductionEditor");
             }
         }
+
+        private VideoViewerVM _masterVideoViewerVM;
+        public VideoViewerVM ViewModelMasterVideoViewer
+        {
+            get
+            {
+                return _masterVideoViewerVM;
+            }
+            set
+            {
+                _masterVideoViewerVM = value;
+                OnPropertyChanged("ViewModelMasterVideoViewer");
+            }
+        }
         //SelectedChapter
         public ProductionViewVM()
         {
@@ -97,6 +111,7 @@
             ViewModelHeaderProduction = new HeaderProductionVM();
             ViewModelProductionTimeLine = new ProductionTimeLineVM();
             ViewModelProductionEditor = new ProductionEditorVM();
+            ViewModelMasterVideoViewer = new VideoViewerVM(true, false);
             Commands.ProductionView.ClickAddSelectedRecord.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(ClickAddSelectedRecord_Executed);
             Random rndNumbers = new Random();
             for (int i = 0; i < 10; i++)
@@ -104,15 +119,21 @@
          
                 _recordedVideoSequences.Add(new VideoSequence()
                 {
-                    Path=Application.Current.Host.Source.Host+@"/video.mp4",
+                    Path= Application.Current.Host.Source.Host.ToString()+"/video.mp4",
                     RunTime = new TimeSpan(0, rndNumbers.Next(10, 60), 0),
                     BeginTrim = new TimeSpan(0, 0, 0),
                     EndTrim = new TimeSpan(0, 0, 0),
                 });
             }
+            ViewModelMasterVideoViewer.Tick += new EventHandler<VideoViewerVMEventArgs>(ViewModelMasterVideoViewer_Tick);
            
         }
 
+        void ViewModelMasterVideoViewer_Tick(object sender, VideoViewerVMEventArgs e)
+        {
+            ViewModelProductionTimeLine.Position = e.Position.TotalMilliseconds;
+        }
+
         void ClickAddSelectedRecord_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
             if (ViewModelProductionTimeLine.SelectedChapter != -1)
@@ -124,6 +145,7 @@
                 }
                
             }
+         
            
         }
        
--- a/client/src/Iri.Modernisation.Controls/ViewModel/VideoViewer/VideoViewerVM.cs	Mon Dec 14 11:25:01 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/VideoViewer/VideoViewerVM.cs	Mon Dec 14 17:02:03 2009 +0100
@@ -109,7 +109,11 @@
         {
            
         }
-       
+        public void GoTo(TimeSpan pos)
+        {
+            Position = pos;
+            Commands.GoToTime.Execute(Position,this);
+        }
         public void LaunchTick(TimeSpan Pos)
         {
             if(Tick!=null)
@@ -122,7 +126,7 @@
     }
     public class VideoViewerVMEventArgs : EventArgs
     {
-         public TimeSpan Position { get; set; }
+        public TimeSpan Position { get; set; }
         public VideoViewerVMEventArgs(TimeSpan pos)
         {
             Position = pos;