client/src/Iri.Modernisation.Controls/ViewModel/ConsultationView/ConsultationViewVM.cs
author totetm <>
Thu, 14 Jan 2010 16:39:50 +0100
changeset 30 644e3cd48034
parent 25 a9c815025a1b
child 35 43bb1b8ed555
permissions -rw-r--r--
Introduce in Web context

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using Iri.Modernisation.Data.Models;
using Iri.Modernisation.Data.LDTClass;
using Iri.Modernisation.BaseMVVM.Commands;
using Iri.Modernisation.BaseMVVM.ViewModel;
using System.Collections.ObjectModel;
namespace Iri.Modernisation.Controls.ViewModel
{
    /// <summary>
    /// ViewModel de ConsultationView
    /// </summary>
    public class ConsultationViewVM : BaseMVVM.ViewModel.ViewModel
    {
        private PolemicElement _selectedElement;
        /// <summary>
        /// PolemicElement sélectionné
        /// </summary>
        public PolemicElement SelectedElement
        {
            get
            {
                return _selectedElement;
            }
            set
            {
                _selectedElement = value;
                OnPropertyChanged("SelectedElement");
            }
        }



        private ObservableCollection<BookTimeLineVM> _selectedVideoBooks;
        /// <summary>
        /// Liste des Livres Sélectionnés
        /// </summary>
        public ObservableCollection<BookTimeLineVM> SelectedVideoBooks
        {
            get
            {

                return _selectedVideoBooks;
            }
            set
            {
                _selectedVideoBooks = value;
                OnPropertyChanged("SelectedVideoBooks");
            }
        }

        private int _selectedVideoBookIndex=-1;
        /// <summary>
        /// Index du livre sélectionné
        /// </summary>
        public int SelectedVideoBookIndex
        {
            get
            {
                return _selectedVideoBookIndex;
            }
            set
            {
                _selectedVideoBookIndex= value;
                OnPropertyChanged("SelectedVideoBookIndex");
                ConsultationBookViewContextMenu.SelectedBookVM = (_selectedVideoBooks[value]);
               
            }
        }

        private ConsultationBookViewVM _consultationBookViewContextMenu;
        /// <summary>
        /// ViewModel de ConsultationBook
        /// </summary>
        public ConsultationBookViewVM ConsultationBookViewContextMenu
        {
            get
            {
                return _consultationBookViewContextMenu;
            }
            set
            {
                _consultationBookViewContextMenu = value;
                OnPropertyChanged(null);
            }
        }

        private void InitializeCommands()
        {
            Commands.ConsultMenu.ClickBook.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(ClickBook_Executed);
            Commands.PolemicElement.SelectPolemicElement.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(SelectPolemicElement_Executed);
       
            Commands.ClickMenu.CreateNewTextualAnnotation.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CreateNewTextualAnnotation_Executed);
        }

        private 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)
           {
               if (BookTLVM.SelectedBook == (VideoBook)e.Parameter)
               {
                   CanAdd = false;
               }
           }
            if(CanAdd)
            {
                SelectedVideoBooks.Add(temp);
            }

        }

      
        private AnnotationMakerVM _annotationMakerVM;
        /// <summary>
        /// ViewModel de AnnotationMaker
        /// </summary>
        public AnnotationMakerVM ViewModelAnnotationMaker
        {
            get
            {
                return _annotationMakerVM;
            }
            set
            {
                _annotationMakerVM = value;
                OnPropertyChanged("ViewModelAnnotationMaker");
            }
        }
        private void CreateNewTextualAnnotation_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
        {
            ViewModelAnnotationMaker.RefElement=SelectedElement;
        }
        public ConsultationViewVM()
        {
            InitializeCommands();
            _consultationBookViewContextMenu = new ConsultationBookViewVM();
            ViewModelAnnotationMaker = new AnnotationMakerVM();
            SelectedVideoBooks = new SLExtensions.Collections.ObjectModel.ObservableCollection<BookTimeLineVM>();
        }

        private void SelectPolemicElement_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
        {
            SelectedElement= (PolemicElement)e.Parameter;
            try
            {
                ConsultationBookViewContextMenu.SelectedIndex = (SegmentIndex)SelectedElement;
            }
            catch
            {
            }
            


        }
    }
}