client/src/Iri.Modernisation.Controls/View/BookTimeLine/BookTimeLine.xaml.cs
changeset 42 594fdedecf7f
parent 41 b51a10574e7f
child 45 de06fa7242ae
equal deleted inserted replaced
41:b51a10574e7f 42:594fdedecf7f
    19     public partial class BookTimeLine : UserControl
    19     public partial class BookTimeLine : UserControl
    20     {
    20     {
    21         public BookTimeLine()
    21         public BookTimeLine()
    22         {
    22         {
    23             InitializeComponent();
    23             InitializeComponent();
    24        
    24           
       
    25             
    25             TimeStripsPanel.SizeChanged += new SizeChangedEventHandler(TimeStripsPanel_SizeChanged);
    26             TimeStripsPanel.SizeChanged += new SizeChangedEventHandler(TimeStripsPanel_SizeChanged);
    26             BookTimeLineSlider.ThumbDragStarted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted);
    27             
    27             BookTimeLineSlider.ThumbDragCompleted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted);
       
    28             BookTimeLineSlider.MouseLeftButtonUp += new MouseButtonEventHandler(BookTimeLineSlider_MouseLeftButtonUp);
    28             BookTimeLineSlider.MouseLeftButtonUp += new MouseButtonEventHandler(BookTimeLineSlider_MouseLeftButtonUp);
    29             //saveAnnotationsButton.Click += new RoutedEventHandler(saveAnnotationsButton_Click);
    29             //saveAnnotationsButton.Click += new RoutedEventHandler(saveAnnotationsButton_Click);
       
    30         
    30             Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(NewAnnotationFinished_Executed);
    31             Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(NewAnnotationFinished_Executed);
       
    32             BookTimeLineSlider.ThumbDragStarted += new EventHandler<EventArgs>(TimeSlider_ThumbDragStarted);
       
    33             BookTimeLineSlider.ThumbDragCompleted += new EventHandler<EventArgs>(TimeSlider_ThumbDragCompleted);
       
    34            
       
    35            
    31         }
    36         }
    32 
    37 
    33         void saveAnnotationsButton_Click(object sender, RoutedEventArgs e)
    38         void saveAnnotationsButton_Click(object sender, RoutedEventArgs e)
    34         {
    39         {
    35             SaveFileDialog mySaveDialog = new SaveFileDialog();
    40             SaveFileDialog mySaveDialog = new SaveFileDialog();
    47         private bool _saveVideoViewerState { get; set; }
    52         private bool _saveVideoViewerState { get; set; }
    48         private void TimeSlider_ThumbDragCompleted(object sender, EventArgs e)
    53         private void TimeSlider_ThumbDragCompleted(object sender, EventArgs e)
    49         {
    54         {
    50             if (_saveVideoViewerState)
    55             if (_saveVideoViewerState)
    51             {
    56             {
       
    57               
    52                 ((BookTimeLineVM)DataContext).ViewModelVideoViewer.Play();
    58                 ((BookTimeLineVM)DataContext).ViewModelVideoViewer.Play();
       
    59                
       
    60 
    53             }
    61             }
    54         }
    62         }
    55 
    63 
    56         private void TimeSlider_ThumbDragStarted(object sender, EventArgs e)
    64         private void TimeSlider_ThumbDragStarted(object sender, EventArgs e)
    57         {
    65         {
    65         }
    73         }
    66 
    74 
    67         private void BookTimeLineSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    75         private void BookTimeLineSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    68         {
    76         {
    69             Commands.TimeChange.Execute(BookTimeLineSlider.Value,DataContext);
    77             Commands.TimeChange.Execute(BookTimeLineSlider.Value,DataContext);
       
    78             
       
    79             
    70         }
    80         }
    71 
    81 
    72         private void TimeStripsPanel_SizeChanged(object sender, SizeChangedEventArgs e)
    82         private void TimeStripsPanel_SizeChanged(object sender, SizeChangedEventArgs e)
    73         {
    83         {
    74             Draw();
    84             Draw();
    94                     pol.Width = (Index.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleTimeLine.Value;
   104                     pol.Width = (Index.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleTimeLine.Value;
    95                     pol.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp);
   105                     pol.MouseLeftButtonUp += new MouseButtonEventHandler(Element_MouseLeftButtonUp);
    96                 }
   106                 }
    97             }
   107             }
    98             int basi = 0;
   108             int basi = 0;
       
   109            
    99             foreach (List<Annotation> LAnnotation in VM.Annotations)
   110             foreach (List<Annotation> LAnnotation in VM.Annotations)
   100             {
   111             {
       
   112                 LAnnotation.Sort((a, b) => TimeSpan.Compare( b.Duration,a.Duration));
   101                 foreach (Annotation Annotation in LAnnotation)
   113                 foreach (Annotation Annotation in LAnnotation)
   102                 {
   114                 {
   103                     PolemicElementControl pol = new PolemicElementControl();
   115                     PolemicElementControl pol = new PolemicElementControl();
   104                     pol.SetValue(Canvas.ZIndexProperty, 10);
   116                     pol.SetValue(Canvas.ZIndexProperty, 10);
   105                     pol.DataContext = new PolemicElementVM(Annotation);
   117                     pol.DataContext = new PolemicElementVM(Annotation);
   116                            )
   128                            )
   117                         {
   129                         {
   118                             int actualTop = (int)Canvas.GetTop(lockedControl);
   130                             int actualTop = (int)Canvas.GetTop(lockedControl);
   119                             if (basi <= actualTop)
   131                             if (basi <= actualTop)
   120                            {
   132                            {
   121                                 basi += 10;
   133                                 basi += 12;
   122                            }
   134                            }
   123                             
   135                             
   124                         }
   136                         }
   125                     }
   137                     }
   126 
   138