client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs
changeset 18 66911d0f0eb6
parent 17 0e4e63f6f567
child 19 7d044e7562ea
--- a/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs	Thu Dec 03 16:05:57 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs	Mon Dec 07 10:36:55 2009 +0100
@@ -39,41 +39,45 @@
         private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
         {
             Random rndNumbers = new Random();
-            if(!((ProductionTimeLineVM)DataContext).IsIndexing)
+            if (((ProductionTimeLineVM)this.DataContext).SelectedChapter != -1)
             {
+                if(!((ProductionTimeLineVM)DataContext).IsIndexing)
+                {
 
-            CustomableVideoElement _temp = new CustomableVideoElement()
-                                     {
-                                         DataContext = new CustomableVideoElementVM(new VideoSequence()
+                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),
+                                                 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()
+                                             }) { 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
                 {
-                    DataContext = new PolemicElementVM(new SegmentIndex(vc))
-                    {
-                        TimerIn = TimeSpan.Zero,
-                        Duration = new TimeSpan(0, rndNumbers.Next(10, 60), 0)
-                    },
-                };
-                    //((ProductionTimeLineVM)DataContext).SelectedBookChapter);
-                AnnotationTimeStrip.Children.Add(an);
+                    VideoChapter vc = ((ProductionTimeLineVM)DataContext).SelectedBookChapter;
+                    PolemicElementControl an = new PolemicElementControl();
+                    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);
+                }
             }
         }